Skip to content

Commit bc57a83

Browse files
committed
sdb skip empty value
1 parent b7cf183 commit bc57a83

File tree

1 file changed

+16
-11
lines changed
  • bus-mapping/src/circuit_input_builder

1 file changed

+16
-11
lines changed

bus-mapping/src/circuit_input_builder/l2.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ use std::collections::hash_map::Entry;
1616

1717
impl From<&AccountData> for state_db::Account {
1818
fn from(acc_data: &AccountData) -> Self {
19-
Self {
20-
nonce: acc_data.nonce.into(),
21-
balance: acc_data.balance,
22-
code_hash: acc_data.poseidon_code_hash,
23-
keccak_code_hash: acc_data.keccak_code_hash,
24-
code_size: acc_data.code_size.into(),
25-
storage: Default::default(),
19+
if acc_data.keccak_code_hash.is_zero() {
20+
state_db::Account::zero()
21+
} else {
22+
Self {
23+
nonce: acc_data.nonce.into(),
24+
balance: acc_data.balance,
25+
code_hash: acc_data.poseidon_code_hash,
26+
keccak_code_hash: acc_data.keccak_code_hash,
27+
code_size: acc_data.code_size.into(),
28+
storage: Default::default(),
29+
}
2630
}
2731
}
2832
}
@@ -36,11 +40,12 @@ impl From<&ZktrieState> for StateDB {
3640
}
3741

3842
for (storage_key, data) in mpt_state.storage() {
39-
//TODO: add an warning on non-existed account?
40-
let (_, acc) = sdb.get_account_mut(&storage_key.0);
41-
acc.storage.insert(storage_key.1, *data.as_ref());
43+
if !data.as_ref().is_zero() {
44+
//TODO: add an warning on non-existed account?
45+
let (_, acc) = sdb.get_account_mut(&storage_key.0);
46+
acc.storage.insert(storage_key.1, *data.as_ref());
47+
}
4248
}
43-
4449
sdb
4550
}
4651
}

0 commit comments

Comments
 (0)