@@ -184,7 +184,7 @@ impl Cheatcode for getNonce_1Call {
184
184
impl Cheatcode for loadCall {
185
185
fn apply_stateful ( & self , ccx : & mut CheatsCtxt ) -> Result {
186
186
let Self { target, slot } = * self ;
187
- ensure_not_precompile ! ( & target, ccx ) ;
187
+ ccx . ensure_not_precompile ( & target) ? ;
188
188
ccx. ecx . journaled_state . load_account ( target) ?;
189
189
let mut val = ccx. ecx . journaled_state . sload ( target, slot. into ( ) ) ?;
190
190
@@ -530,7 +530,7 @@ impl Cheatcode for dealCall {
530
530
impl Cheatcode for etchCall {
531
531
fn apply_stateful ( & self , ccx : & mut CheatsCtxt ) -> Result {
532
532
let Self { target, newRuntimeBytecode } = self ;
533
- ensure_not_precompile ! ( target, ccx ) ;
533
+ ccx . ensure_not_precompile ( target) ? ;
534
534
ccx. ecx . journaled_state . load_account ( * target) ?;
535
535
let bytecode = Bytecode :: new_raw_checked ( newRuntimeBytecode. clone ( ) )
536
536
. map_err ( |e| fmt_err ! ( "failed to create bytecode: {e}" ) ) ?;
@@ -582,9 +582,8 @@ impl Cheatcode for setNonceUnsafeCall {
582
582
impl Cheatcode for storeCall {
583
583
fn apply_stateful ( & self , ccx : & mut CheatsCtxt ) -> Result {
584
584
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) ?;
588
587
ccx. ecx . journaled_state . sstore ( target, slot. into ( ) , value. into ( ) ) ?;
589
588
Ok ( Default :: default ( ) )
590
589
}
@@ -1155,9 +1154,14 @@ pub(super) fn journaled_account<'a>(
1155
1154
ecx : Ecx < ' a , ' _ , ' _ > ,
1156
1155
addr : Address ,
1157
1156
) -> 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 < ( ) > {
1158
1162
ecx. journaled_state . load_account ( addr) ?;
1159
1163
ecx. journaled_state . touch ( addr) ;
1160
- Ok ( ecx . journaled_state . state . get_mut ( & addr ) . expect ( "account is loaded" ) )
1164
+ Ok ( ( ) )
1161
1165
}
1162
1166
1163
1167
/// Consumes recorded account accesses and returns them as an abi encoded
0 commit comments