From cfe87fc8b5cb48ad542e0d8e6f69863e6abbdb6d Mon Sep 17 00:00:00 2001 From: roshan <19766713+rpalakkal@users.noreply.github.com> Date: Mon, 6 May 2024 14:13:46 -0400 Subject: [PATCH] chore: make poseidon hasher thread safe --- halo2-base/src/poseidon/hasher/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/halo2-base/src/poseidon/hasher/mod.rs b/halo2-base/src/poseidon/hasher/mod.rs index 68cf64c6..b477edcf 100644 --- a/halo2-base/src/poseidon/hasher/mod.rs +++ b/halo2-base/src/poseidon/hasher/mod.rs @@ -10,7 +10,7 @@ use crate::{ use getset::{CopyGetters, Getters}; use num_bigint::BigUint; -use std::{cell::OnceCell, mem}; +use std::{mem, sync::OnceLock}; #[cfg(test)] mod tests; @@ -28,7 +28,7 @@ pub struct PoseidonHasher { /// Spec, contains round constants and optimized matrices. #[getset(get = "pub")] spec: OptimizedPoseidonSpec, - consts: OnceCell>, + consts: OnceLock>, } #[derive(Clone, Debug, Getters)] struct PoseidonHasherConsts { @@ -123,7 +123,7 @@ pub struct PoseidonCompactOutput { impl PoseidonHasher { /// Create a poseidon hasher from an existing spec. pub fn new(spec: OptimizedPoseidonSpec) -> Self { - Self { spec, consts: OnceCell::new() } + Self { spec, consts: OnceLock::new() } } /// Initialize necessary consts of hasher. Must be called before any computation. pub fn initialize_consts(&mut self, ctx: &mut Context, gate: &impl GateInstructions) {