Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shareable CCC #1419

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions zkevm-circuits/src/witness/mpt/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -40,7 +40,7 @@ fn to_smt_account(acc: AccountData) -> SMTAccount {
pub struct WitnessGenerator {
trie: ZkTrie,
storages_cache: HashMap<Address, ZkTrie>,
ref_db: Rc<ZkMemoryDb>,
ref_db: Arc<ZkMemoryDb>,
}

impl From<&ZktrieState> for WitnessGenerator {
Expand Down
2 changes: 1 addition & 1 deletion zktrie/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions zktrie/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ pub type ZkTrie = ZktrieT<UpdateDb>;
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<ZkMemoryDb>,
pub zk_db: Arc<ZkMemoryDb>,
/// Trie root
pub trie_root: ZkTrieHash,
addr_cache: HashSet<Address>,
Expand Down Expand Up @@ -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(),
Expand All @@ -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
Expand Down Expand Up @@ -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();
}
Expand All @@ -233,7 +233,7 @@ impl ZktrieState {
}

/// get the inner zk memory db
pub fn into_inner(self) -> Rc<ZkMemoryDb> {
pub fn into_inner(self) -> Arc<ZkMemoryDb> {
self.zk_db
}
}
Loading