@@ -28,8 +28,6 @@ pub fn optimism_handle_register<DB: Database, EXT>(handler: &mut EvmHandler<'_,
28
28
handler. validation. tx_against_state = Arc :: new( validate_tx_against_state:: <SPEC , EXT , DB >) ;
29
29
// Load additional precompiles for the given chain spec.
30
30
handler. pre_execution. load_precompiles = Arc :: new( load_precompiles:: <SPEC , EXT , DB >) ;
31
- // load l1 data
32
- handler. pre_execution. load_accounts = Arc :: new( load_accounts:: <SPEC , EXT , DB >) ;
33
31
// An estimated batch cost is charged from the caller and added to L1 Fee Vault.
34
32
handler. pre_execution. deduct_caller = Arc :: new( deduct_caller:: <SPEC , EXT , DB >) ;
35
33
// Refund is calculated differently then mainnet.
@@ -70,13 +68,22 @@ pub fn validate_env<SPEC: Spec, DB: Database>(env: &Env) -> Result<(), EVMError<
70
68
pub fn validate_tx_against_state < SPEC : Spec , EXT , DB : Database > (
71
69
context : & mut Context < EXT , DB > ,
72
70
) -> Result < ( ) , EVMError < DB :: Error > > {
73
- let env @ Env { cfg, tx, .. } = context. evm . inner . env . as_ref ( ) ;
74
-
75
71
// No validation is needed for deposit transactions, as they are pre-verified on L1.
76
- if tx. optimism . source_hash . is_some ( ) {
72
+ if context . evm . inner . env . tx . optimism . source_hash . is_some ( ) {
77
73
return Ok ( ( ) ) ;
78
74
}
79
75
76
+ // storage l1 block info for later use. l1_block_info is cleared after execution.
77
+ if context. evm . inner . l1_block_info . is_none ( ) {
78
+ // the L1-cost fee is only computed for Optimism non-deposit transactions.
79
+ let l1_block_info =
80
+ crate :: optimism:: L1BlockInfo :: try_fetch ( & mut context. evm . inner . db , SPEC :: SPEC_ID )
81
+ . map_err ( EVMError :: Database ) ?;
82
+ context. evm . inner . l1_block_info = Some ( l1_block_info) ;
83
+ }
84
+
85
+ let env @ Env { cfg, tx, .. } = context. evm . inner . env . as_ref ( ) ;
86
+
80
87
// load acc
81
88
let tx_caller = tx. caller ;
82
89
let account = context
@@ -312,25 +319,6 @@ pub fn load_precompiles<SPEC: Spec, EXT, DB: Database>() -> ContextPrecompiles<D
312
319
}
313
320
}
314
321
315
- /// Load account (make them warm) and l1 data from database.
316
- #[ inline]
317
- pub fn load_accounts < SPEC : Spec , EXT , DB : Database > (
318
- context : & mut Context < EXT , DB > ,
319
- ) -> Result < ( ) , EVMError < DB :: Error > > {
320
- // the L1-cost fee is only computed for Optimism non-deposit transactions.
321
-
322
- if context. evm . inner . env . tx . optimism . source_hash . is_none ( ) {
323
- let l1_block_info =
324
- crate :: optimism:: L1BlockInfo :: try_fetch ( & mut context. evm . inner . db , SPEC :: SPEC_ID )
325
- . map_err ( EVMError :: Database ) ?;
326
-
327
- // storage l1 block info for later use.
328
- context. evm . inner . l1_block_info = Some ( l1_block_info) ;
329
- }
330
-
331
- mainnet:: load_accounts :: < SPEC , EXT , DB > ( context)
332
- }
333
-
334
322
/// Deduct max balance from caller
335
323
#[ inline]
336
324
pub fn deduct_caller < SPEC : Spec , EXT , DB : Database > (
@@ -559,9 +547,7 @@ pub fn end<SPEC: Spec, EXT, DB: Database>(
559
547
pub fn clear < EXT , DB : Database > ( context : & mut Context < EXT , DB > ) {
560
548
// clear error and journaled state.
561
549
mainnet:: clear ( context) ;
562
- if let Some ( l1_block) = & mut context. evm . inner . l1_block_info {
563
- l1_block. clear_tx_l1_cost ( ) ;
564
- }
550
+ context. evm . inner . l1_block_info = None ;
565
551
}
566
552
567
553
#[ cfg( test) ]
0 commit comments