51
51
/// The [RollupConfig].
52
52
config : & ' a RollupConfig ,
53
53
/// The inner state database component.
54
- state : State < TrieDB < F , H > > ,
54
+ trie_db : TrieDB < F , H > ,
55
55
/// Phantom data for the precompile overrides.
56
56
_phantom : core:: marker:: PhantomData < PO > ,
57
57
}
67
67
StatelessL2BlockExecutorBuilder :: with_config ( config)
68
68
}
69
69
70
- /// Returns a reference to the current [State] database of the executor.
71
- pub fn state_ref ( & self ) -> & State < TrieDB < F , H > > {
72
- & self . state
73
- }
74
-
75
70
/// Executes the given block, returning the resulting state root.
76
71
///
77
72
/// ## Steps
93
88
let initialized_block_env = Self :: prepare_block_env (
94
89
self . revm_spec_id ( payload. timestamp ) ,
95
90
self . config ,
96
- self . state . database . parent_block_header ( ) ,
91
+ self . trie_db . parent_block_header ( ) ,
97
92
& payload,
98
93
) ;
99
94
let initialized_cfg = self . evm_cfg_env ( payload. timestamp ) ;
@@ -110,9 +105,12 @@ where
110
105
tx_len = payload. transactions. len( )
111
106
) ;
112
107
108
+ let mut state =
109
+ State :: builder ( ) . with_database ( & mut self . trie_db ) . with_bundle_update ( ) . build ( ) ;
110
+
113
111
// Apply the pre-block EIP-4788 contract call.
114
112
pre_block_beacon_root_contract_call (
115
- & mut self . state ,
113
+ & mut state,
116
114
self . config ,
117
115
block_number,
118
116
& initialized_cfg,
@@ -121,7 +119,7 @@ where
121
119
) ?;
122
120
123
121
// Ensure that the create2 contract is deployed upon transition to the Canyon hardfork.
124
- ensure_create2_deployer_canyon ( & mut self . state , self . config , payload. timestamp ) ?;
122
+ ensure_create2_deployer_canyon ( & mut state, self . config , payload. timestamp ) ?;
125
123
126
124
let mut cumulative_gas_used = 0u64 ;
127
125
let mut receipts: Vec < OpReceiptEnvelope > = Vec :: with_capacity ( payload. transactions . len ( ) ) ;
@@ -130,7 +128,7 @@ where
130
128
// Construct the block-scoped EVM with the given configuration.
131
129
// The transaction environment is set within the loop for each transaction.
132
130
let mut evm = Evm :: builder ( )
133
- . with_db ( & mut self . state )
131
+ . with_db ( & mut state)
134
132
. with_env_with_handler_cfg ( EnvWithHandlerCfg :: new_with_cfg_env (
135
133
initialized_cfg. clone ( ) ,
136
134
initialized_block_env. clone ( ) ,
@@ -229,13 +227,13 @@ where
229
227
230
228
// Merge all state transitions into the cache state.
231
229
debug ! ( target: "client_executor" , "Merging state transitions" ) ;
232
- self . state . merge_transitions ( BundleRetention :: Reverts ) ;
230
+ state. merge_transitions ( BundleRetention :: Reverts ) ;
233
231
234
232
// Take the bundle state.
235
- let bundle = self . state . take_bundle ( ) ;
233
+ let bundle = state. take_bundle ( ) ;
236
234
237
235
// Recompute the header roots.
238
- let state_root = self . state . database . state_root ( & bundle) ?;
236
+ let state_root = state. database . state_root ( & bundle) ?;
239
237
240
238
let transactions_root = Self :: compute_transactions_root ( payload. transactions . as_slice ( ) ) ;
241
239
let receipts_root = Self :: compute_receipts_root ( & receipts, self . config , payload. timestamp ) ;
@@ -257,7 +255,7 @@ where
257
255
. config
258
256
. is_ecotone_active ( payload. timestamp )
259
257
. then ( || {
260
- let parent_header = self . state . database . parent_block_header ( ) ;
258
+ let parent_header = state. database . parent_block_header ( ) ;
261
259
let excess_blob_gas = if self . config . is_ecotone_active ( parent_header. timestamp ) {
262
260
let parent_excess_blob_gas = parent_header. excess_blob_gas . unwrap_or_default ( ) ;
263
261
let parent_blob_gas_used = parent_header. blob_gas_used . unwrap_or_default ( ) ;
@@ -273,7 +271,7 @@ where
273
271
274
272
// Construct the new header.
275
273
let header = Header {
276
- parent_hash : self . state . database . parent_block_header ( ) . seal ( ) ,
274
+ parent_hash : state. database . parent_block_header ( ) . seal ( ) ,
277
275
ommers_hash : EMPTY_OMMER_ROOT_HASH ,
278
276
beneficiary : payload. fee_recipient ,
279
277
state_root,
@@ -308,9 +306,9 @@ where
308
306
) ;
309
307
310
308
// Update the parent block hash in the state database.
311
- self . state . database . set_parent_block_header ( header) ;
309
+ state. database . set_parent_block_header ( header) ;
312
310
313
- Ok ( self . state . database . parent_block_header ( ) )
311
+ Ok ( state. database . parent_block_header ( ) )
314
312
}
315
313
316
314
/// Computes the current output root of the executor, based on the parent header and the
@@ -331,27 +329,26 @@ where
331
329
address ! ( "4200000000000000000000000000000000000016" ) ;
332
330
333
331
// Fetch the L2 to L1 message passer account from the cache or underlying trie.
334
- let storage_root =
335
- match self . state . database . storage_roots ( ) . get ( & L2_TO_L1_MESSAGE_PASSER_ADDRESS ) {
336
- Some ( storage_root) => storage_root
337
- . blinded_commitment ( )
338
- . ok_or ( anyhow ! ( "Account storage root is unblinded" ) ) ?,
339
- None => {
340
- self . state
341
- . database
342
- . get_trie_account ( & L2_TO_L1_MESSAGE_PASSER_ADDRESS ) ?
343
- . ok_or ( anyhow ! ( "L2 to L1 message passer account not found in trie" ) ) ?
344
- . storage_root
345
- }
346
- } ;
332
+ let storage_root = match self . trie_db . storage_roots ( ) . get ( & L2_TO_L1_MESSAGE_PASSER_ADDRESS )
333
+ {
334
+ Some ( storage_root) => storage_root
335
+ . blinded_commitment ( )
336
+ . ok_or ( anyhow ! ( "Account storage root is unblinded" ) ) ?,
337
+ None => {
338
+ self . trie_db
339
+ . get_trie_account ( & L2_TO_L1_MESSAGE_PASSER_ADDRESS ) ?
340
+ . ok_or ( anyhow ! ( "L2 to L1 message passer account not found in trie" ) ) ?
341
+ . storage_root
342
+ }
343
+ } ;
347
344
348
- let parent_header = self . state . database . parent_block_header ( ) ;
345
+ let parent_header = self . trie_db . parent_block_header ( ) ;
349
346
350
347
info ! (
351
348
target: "client_executor" ,
352
349
"Computing output root | Version: {version} | State root: {state_root} | Storage root: {storage_root} | Block hash: {hash}" ,
353
350
version = OUTPUT_ROOT_VERSION ,
354
- state_root = self . state . database . parent_block_header( ) . state_root,
351
+ state_root = self . trie_db . parent_block_header( ) . state_root,
355
352
hash = parent_header. seal( ) ,
356
353
) ;
357
354
@@ -742,7 +739,7 @@ mod test {
742
739
743
740
assert_eq ! ( produced_header, expected_header) ;
744
741
assert_eq ! (
745
- l2_block_executor. state . database . parent_block_header( ) . seal( ) ,
742
+ l2_block_executor. trie_db . parent_block_header( ) . seal( ) ,
746
743
expected_header. hash_slow( )
747
744
) ;
748
745
}
@@ -800,7 +797,7 @@ mod test {
800
797
801
798
assert_eq ! ( produced_header, expected_header) ;
802
799
assert_eq ! (
803
- l2_block_executor. state . database . parent_block_header( ) . seal( ) ,
800
+ l2_block_executor. trie_db . parent_block_header( ) . seal( ) ,
804
801
expected_header. hash_slow( )
805
802
) ;
806
803
}
@@ -865,7 +862,7 @@ mod test {
865
862
866
863
assert_eq ! ( produced_header, expected_header) ;
867
864
assert_eq ! (
868
- l2_block_executor. state . database . parent_block_header( ) . seal( ) ,
865
+ l2_block_executor. trie_db . parent_block_header( ) . seal( ) ,
869
866
expected_header. hash_slow( )
870
867
) ;
871
868
}
@@ -924,7 +921,7 @@ mod test {
924
921
925
922
assert_eq ! ( produced_header, expected_header) ;
926
923
assert_eq ! (
927
- l2_block_executor. state . database . parent_block_header( ) . seal( ) ,
924
+ l2_block_executor. trie_db . parent_block_header( ) . seal( ) ,
928
925
expected_header. hash_slow( )
929
926
) ;
930
927
}
@@ -992,7 +989,7 @@ mod test {
992
989
993
990
assert_eq ! ( produced_header, expected_header) ;
994
991
assert_eq ! (
995
- l2_block_executor. state . database . parent_block_header( ) . seal( ) ,
992
+ l2_block_executor. trie_db . parent_block_header( ) . seal( ) ,
996
993
expected_header. hash_slow( )
997
994
) ;
998
995
}
@@ -1065,7 +1062,7 @@ mod test {
1065
1062
1066
1063
assert_eq ! ( produced_header, expected_header) ;
1067
1064
assert_eq ! (
1068
- l2_block_executor. state . database . parent_block_header( ) . seal( ) ,
1065
+ l2_block_executor. trie_db . parent_block_header( ) . seal( ) ,
1069
1066
expected_header. hash_slow( )
1070
1067
) ;
1071
1068
}
0 commit comments