diff --git a/Cargo.lock b/Cargo.lock index a2bcbfc150..d7b4de30fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5560,7 +5560,7 @@ dependencies = [ [[package]] name = "zktrie" version = "0.3.0" -source = "git+https://github.com/scroll-tech/zktrie.git?branch=v0.9#460b8c22af65b7809164548cba1e0253b6db5a70" +source = "git+https://github.com/scroll-tech/zktrie.git?branch=omerfirmak/send-sync-shared-db#566d4cc29d35744de1d1ab204a6ac95bceb15bbc" dependencies = [ "gobuild", "zktrie_rust", @@ -5569,10 +5569,11 @@ dependencies = [ [[package]] name = "zktrie_rust" version = "0.3.0" -source = "git+https://github.com/scroll-tech/zktrie.git?branch=v0.9#460b8c22af65b7809164548cba1e0253b6db5a70" +source = "git+https://github.com/scroll-tech/zktrie.git?branch=omerfirmak/send-sync-shared-db#566d4cc29d35744de1d1ab204a6ac95bceb15bbc" dependencies = [ "hex", "lazy_static", + "log", "num", "num-derive", "num-traits", diff --git a/zkevm-circuits/src/witness/mpt/witness.rs b/zkevm-circuits/src/witness/mpt/witness.rs index 7054997c6e..1793ceeb9c 100644 --- a/zkevm-circuits/src/witness/mpt/witness.rs +++ b/zkevm-circuits/src/witness/mpt/witness.rs @@ -11,7 +11,7 @@ use mpt_zktrie::{ extend_address_to_h256, state::StorageData, AccountData, BytesArray, CanRead, TrieProof, ZkMemoryDb, ZkTrie, ZkTrieNode, ZktrieState, SECURE_HASH_DOMAIN, }; -use std::{collections::HashMap, rc::Rc}; +use std::{collections::HashMap, sync::Arc}; use num_bigint::BigUint; use std::{ @@ -40,7 +40,7 @@ fn to_smt_account(acc: AccountData) -> SMTAccount { pub struct WitnessGenerator { trie: ZkTrie, storages_cache: HashMap, - ref_db: Rc, + ref_db: Arc, } impl From<&ZktrieState> for WitnessGenerator { diff --git a/zktrie/Cargo.toml b/zktrie/Cargo.toml index 33cc999f4c..64d0e39429 100644 --- a/zktrie/Cargo.toml +++ b/zktrie/Cargo.toml @@ -8,7 +8,7 @@ license.workspace = true [dependencies] halo2curves.workspace = true -zktrie = { git = "https://github.com/scroll-tech/zktrie.git", branch = "v0.9", features= ["rs_zktrie"] } +zktrie = { git = "https://github.com/scroll-tech/zktrie.git", branch = "omerfirmak/send-sync-shared-db", features= ["rs_zktrie"] } poseidon-base.workspace = true eth-types = { path = "../eth-types" } num-bigint.workspace = true diff --git a/zktrie/src/state.rs b/zktrie/src/state.rs index 9c0139f155..228bd15afa 100644 --- a/zktrie/src/state.rs +++ b/zktrie/src/state.rs @@ -10,13 +10,13 @@ pub type ZkTrie = ZktrieT; pub mod builder; pub use builder::{AccountData, StorageData}; -use std::{fmt, rc::Rc}; +use std::{fmt, sync::Arc}; /// represent a storage state being applied in specified block #[derive(Clone)] pub struct ZktrieState { /// The underlying db - pub zk_db: Rc, + pub zk_db: Arc, /// Trie root pub trie_root: ZkTrieHash, addr_cache: HashSet
, @@ -52,7 +52,7 @@ impl ZktrieState { builder::init_hash_scheme(); Self { - zk_db: Rc::new(ZkMemoryDb::new()), + zk_db: Arc::new(ZkMemoryDb::new()), trie_root: state_root.0, addr_cache: HashSet::new(), storage_cache: HashSet::new(), @@ -61,7 +61,7 @@ impl ZktrieState { /// expose writable db, has to be used when no trie is created pub fn expose_db(&mut self) -> &mut ZkMemoryDb { - Rc::get_mut(&mut self.zk_db).expect("no extra reference") + Arc::get_mut(&mut self.zk_db).expect("no extra reference") } /// apply the updates in Zktries into underlying db @@ -206,7 +206,7 @@ impl ZktrieState { .flat_map(|(_, _, bytes)| bytes), ) .chain(additional_proofs); - let zk_db = Rc::get_mut(&mut self.zk_db).expect("no extra reference"); + let zk_db = Arc::get_mut(&mut self.zk_db).expect("no extra reference"); for bytes in proofs { zk_db.add_node_data(bytes).unwrap(); } @@ -233,7 +233,7 @@ impl ZktrieState { } /// get the inner zk memory db - pub fn into_inner(self) -> Rc { + pub fn into_inner(self) -> Arc { self.zk_db } }