@@ -256,8 +256,12 @@ impl Cheatcode for loadCall {
256256 fn apply_stateful ( & self , ccx : & mut CheatsCtxt ) -> Result {
257257 let Self { target, slot } = * self ;
258258 ccx. ensure_not_precompile ( & target) ?;
259- ccx. ecx . journaled_state . load_account ( target) ?;
260- let mut val = ccx. ecx . journaled_state . sload ( target, slot. into ( ) ) ?;
259+
260+ let ( db, journal, _) = ccx. ecx . as_db_env_and_journal ( ) ;
261+ journal. load_account ( db, target) ?;
262+ let mut val = journal
263+ . sload ( db, target, slot. into ( ) , false )
264+ . map_err ( |e| fmt_err ! ( "failed to load storage slot: {:?}" , e) ) ?;
261265
262266 if val. is_cold && val. data . is_zero ( ) {
263267 if ccx. state . has_arbitrary_storage ( & target) {
@@ -611,10 +615,11 @@ impl Cheatcode for etchCall {
611615 fn apply_stateful ( & self , ccx : & mut CheatsCtxt ) -> Result {
612616 let Self { target, newRuntimeBytecode } = self ;
613617 ccx. ensure_not_precompile ( target) ?;
614- ccx. ecx . journaled_state . load_account ( * target) ?;
618+ let ( db, journal, _) = ccx. ecx . as_db_env_and_journal ( ) ;
619+ journal. load_account ( db, * target) ?;
615620 let bytecode = Bytecode :: new_raw_checked ( newRuntimeBytecode. clone ( ) )
616621 . map_err ( |e| fmt_err ! ( "failed to create bytecode: {e}" ) ) ?;
617- ccx . ecx . journaled_state . set_code ( * target, bytecode) ;
622+ journal . set_code ( * target, bytecode) ;
618623 Ok ( Default :: default ( ) )
619624 }
620625}
@@ -664,7 +669,10 @@ impl Cheatcode for storeCall {
664669 let Self { target, slot, value } = * self ;
665670 ccx. ensure_not_precompile ( & target) ?;
666671 ensure_loaded_account ( ccx. ecx , target) ?;
667- ccx. ecx . journaled_state . sstore ( target, slot. into ( ) , value. into ( ) ) ?;
672+ let ( db, journal, _) = ccx. ecx . as_db_env_and_journal ( ) ;
673+ journal
674+ . sstore ( db, target, slot. into ( ) , value. into ( ) , false )
675+ . map_err ( |e| fmt_err ! ( "failed to store storage slot: {:?}" , e) ) ?;
668676 Ok ( Default :: default ( ) )
669677 }
670678}
@@ -970,7 +978,8 @@ impl Cheatcode for getStorageSlotsCall {
970978 if storage_type. encoding == ENCODING_BYTES {
971979 // Try to check if it's a long bytes/string by reading the current storage
972980 // value
973- if let Ok ( value) = ccx. ecx . journaled_state . sload ( * target, slot) {
981+ let ( db, journal, _) = ccx. ecx . as_db_env_and_journal ( ) ;
982+ if let Ok ( value) = journal. sload ( db, * target, slot, false ) {
974983 let value_bytes = value. data . to_be_bytes :: < 32 > ( ) ;
975984 let length_byte = value_bytes[ 31 ] ;
976985 // Check if it's a long bytes/string (LSB is 1)
@@ -1124,7 +1133,8 @@ impl Cheatcode for getEvmVersionCall {
11241133}
11251134
11261135pub ( super ) fn get_nonce ( ccx : & mut CheatsCtxt , address : & Address ) -> Result {
1127- let account = ccx. ecx . journaled_state . load_account ( * address) ?;
1136+ let ( db, journal, _) = ccx. ecx . as_db_env_and_journal ( ) ;
1137+ let account = journal. load_account ( db, * address) ?;
11281138 Ok ( account. info . nonce . abi_encode ( ) )
11291139}
11301140
@@ -1345,8 +1355,9 @@ pub(super) fn journaled_account<'a>(
13451355}
13461356
13471357pub ( super ) fn ensure_loaded_account ( ecx : Ecx , addr : Address ) -> Result < ( ) > {
1348- ecx. journaled_state . load_account ( addr) ?;
1349- ecx. journaled_state . touch ( addr) ;
1358+ let ( db, journal, _) = ecx. as_db_env_and_journal ( ) ;
1359+ journal. load_account ( db, addr) ?;
1360+ journal. touch ( addr) ;
13501361 Ok ( ( ) )
13511362}
13521363
@@ -1573,7 +1584,8 @@ fn get_contract_data<'a>(
15731584 let artifacts = ccx. state . config . available_artifacts . as_ref ( ) ?;
15741585
15751586 // Try to load the account and get its code
1576- let account = ccx. ecx . journaled_state . load_account ( address) . ok ( ) ?;
1587+ let ( db, journal, _) = ccx. ecx . as_db_env_and_journal ( ) ;
1588+ let account = journal. load_account ( db, address) . ok ( ) ?;
15771589 let code = account. info . code . as_ref ( ) ?;
15781590
15791591 // Skip if code is empty
0 commit comments