Skip to content

Commit

Permalink
sdb skip empty value
Browse files Browse the repository at this point in the history
  • Loading branch information
noel2004 committed Aug 15, 2023
1 parent b7cf183 commit bc57a83
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions bus-mapping/src/circuit_input_builder/l2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ use std::collections::hash_map::Entry;

impl From<&AccountData> for state_db::Account {
fn from(acc_data: &AccountData) -> Self {
Self {
nonce: acc_data.nonce.into(),
balance: acc_data.balance,
code_hash: acc_data.poseidon_code_hash,
keccak_code_hash: acc_data.keccak_code_hash,
code_size: acc_data.code_size.into(),
storage: Default::default(),
if acc_data.keccak_code_hash.is_zero() {
state_db::Account::zero()
} else {
Self {
nonce: acc_data.nonce.into(),
balance: acc_data.balance,
code_hash: acc_data.poseidon_code_hash,
keccak_code_hash: acc_data.keccak_code_hash,
code_size: acc_data.code_size.into(),
storage: Default::default(),
}
}
}
}
Expand All @@ -36,11 +40,12 @@ impl From<&ZktrieState> for StateDB {
}

for (storage_key, data) in mpt_state.storage() {
//TODO: add an warning on non-existed account?
let (_, acc) = sdb.get_account_mut(&storage_key.0);
acc.storage.insert(storage_key.1, *data.as_ref());
if !data.as_ref().is_zero() {
//TODO: add an warning on non-existed account?
let (_, acc) = sdb.get_account_mut(&storage_key.0);
acc.storage.insert(storage_key.1, *data.as_ref());
}
}

sdb
}
}
Expand Down

0 comments on commit bc57a83

Please sign in to comment.