@@ -184,7 +184,7 @@ impl Cheatcode for getNonce_1Call {
184184impl Cheatcode for loadCall {
185185 fn apply_stateful ( & self , ccx : & mut CheatsCtxt ) -> Result {
186186 let Self { target, slot } = * self ;
187- ensure_not_precompile ! ( & target, ccx ) ;
187+ ccx . ensure_not_precompile ( & target) ? ;
188188 ccx. ecx . journaled_state . load_account ( target) ?;
189189 let mut val = ccx. ecx . journaled_state . sload ( target, slot. into ( ) ) ?;
190190
@@ -530,7 +530,7 @@ impl Cheatcode for dealCall {
530530impl Cheatcode for etchCall {
531531 fn apply_stateful ( & self , ccx : & mut CheatsCtxt ) -> Result {
532532 let Self { target, newRuntimeBytecode } = self ;
533- ensure_not_precompile ! ( target, ccx ) ;
533+ ccx . ensure_not_precompile ( target) ? ;
534534 ccx. ecx . journaled_state . load_account ( * target) ?;
535535 let bytecode = Bytecode :: new_raw_checked ( newRuntimeBytecode. clone ( ) )
536536 . map_err ( |e| fmt_err ! ( "failed to create bytecode: {e}" ) ) ?;
@@ -582,9 +582,8 @@ impl Cheatcode for setNonceUnsafeCall {
582582impl Cheatcode for storeCall {
583583 fn apply_stateful ( & self , ccx : & mut CheatsCtxt ) -> Result {
584584 let Self { target, slot, value } = * self ;
585- ensure_not_precompile ! ( & target, ccx) ;
586- // ensure the account is touched
587- let _ = journaled_account ( ccx. ecx , target) ?;
585+ ccx. ensure_not_precompile ( & target) ?;
586+ ensure_loaded_account ( ccx. ecx , target) ?;
588587 ccx. ecx . journaled_state . sstore ( target, slot. into ( ) , value. into ( ) ) ?;
589588 Ok ( Default :: default ( ) )
590589 }
@@ -1155,9 +1154,14 @@ pub(super) fn journaled_account<'a>(
11551154 ecx : Ecx < ' a , ' _ , ' _ > ,
11561155 addr : Address ,
11571156) -> Result < & ' a mut Account > {
1157+ ensure_loaded_account ( ecx, addr) ?;
1158+ Ok ( ecx. journaled_state . state . get_mut ( & addr) . expect ( "account is loaded" ) )
1159+ }
1160+
1161+ pub ( super ) fn ensure_loaded_account ( ecx : Ecx , addr : Address ) -> Result < ( ) > {
11581162 ecx. journaled_state . load_account ( addr) ?;
11591163 ecx. journaled_state . touch ( addr) ;
1160- Ok ( ecx . journaled_state . state . get_mut ( & addr ) . expect ( "account is loaded" ) )
1164+ Ok ( ( ) )
11611165}
11621166
11631167/// Consumes recorded account accesses and returns them as an abi encoded
0 commit comments