@@ -16,13 +16,17 @@ use std::collections::hash_map::Entry;
16
16
17
17
impl From < & AccountData > for state_db:: Account {
18
18
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
+ }
26
30
}
27
31
}
28
32
}
@@ -36,11 +40,12 @@ impl From<&ZktrieState> for StateDB {
36
40
}
37
41
38
42
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
+ }
42
48
}
43
-
44
49
sdb
45
50
}
46
51
}
0 commit comments