@@ -244,15 +244,24 @@ def run_state_test(self) -> Any:
244
244
if len (self .txs .transactions ) > 0 :
245
245
tx = self .txs .transactions [0 ]
246
246
try :
247
- self .fork .process_transaction (
248
- block_env = block_env ,
249
- block_output = block_output ,
250
- tx = tx ,
251
- index = Uint (0 ),
252
- change_tracker = StateChangeTracker (
253
- block_output .block_access_list_builder
254
- ),
255
- )
247
+ # Only pass change_tracker for Amsterdam and later
248
+ if self .fork .is_after_fork ("ethereum.amsterdam" ):
249
+ self .fork .process_transaction (
250
+ block_env = block_env ,
251
+ block_output = block_output ,
252
+ tx = tx ,
253
+ index = Uint (0 ),
254
+ change_tracker = StateChangeTracker (
255
+ block_output .block_access_list_builder
256
+ ),
257
+ )
258
+ else :
259
+ self .fork .process_transaction (
260
+ block_env = block_env ,
261
+ block_output = block_output ,
262
+ tx = tx ,
263
+ index = Uint (0 ),
264
+ )
256
265
except EthereumException as e :
257
266
self .txs .rejected_txs [0 ] = f"Failed transaction: { e !r} "
258
267
self .restore_state ()
@@ -276,12 +285,12 @@ def _run_blockchain_test(self, block_env: Any, block_output: Any) -> None:
276
285
data = block_env .parent_beacon_block_root ,
277
286
)
278
287
279
- bal_change_tracker = StateChangeTracker (
280
- block_output .block_access_list_builder
281
- )
282
-
283
- # EIP-7928: Set transaction index for block access lists
288
+ bal_change_tracker = None
284
289
if self .fork .is_after_fork ("ethereum.amsterdam" ):
290
+ bal_change_tracker = StateChangeTracker (
291
+ block_output .block_access_list_builder
292
+ )
293
+ # EIP-7928: Set transaction index for block access lists
285
294
# pre-execution system contracts use index 0
286
295
set_transaction_index (bal_change_tracker , 0 )
287
296
@@ -290,21 +299,26 @@ def _run_blockchain_test(self, block_env: Any, block_output: Any) -> None:
290
299
)):
291
300
self .backup_state ()
292
301
try :
293
- # use 1...n for transaction indices
302
+ process_tx_args = [
303
+ block_env ,
304
+ block_output ,
305
+ tx ,
306
+ Uint (original_idx ),
307
+ ]
308
+
294
309
if self .fork .is_after_fork ("ethereum.amsterdam" ):
295
- set_transaction_index (bal_change_tracker , tx_index + 1 )
310
+ process_tx_args . append (bal_change_tracker )
296
311
297
- self .fork .process_transaction (
298
- block_env ,
299
- block_output ,
300
- tx ,
301
- Uint (original_idx ),
302
- bal_change_tracker ,
303
- )
304
- finalize_transaction_changes (
305
- bal_change_tracker ,
306
- block_env .state ,
307
- )
312
+ assert bal_change_tracker is not None
313
+ # use 1...n for transaction indices
314
+ set_transaction_index (bal_change_tracker , tx_index + 1 )
315
+ self .fork .process_transaction (* process_tx_args )
316
+ finalize_transaction_changes (
317
+ bal_change_tracker ,
318
+ block_env .state ,
319
+ )
320
+ else :
321
+ self .fork .process_transaction (* process_tx_args )
308
322
309
323
except EthereumException as e :
310
324
self .txs .rejected_txs [
@@ -324,19 +338,27 @@ def _run_blockchain_test(self, block_env: Any, block_output: Any) -> None:
324
338
)
325
339
326
340
if self .fork .is_after_fork ("ethereum.shanghai" ):
327
- self .fork .process_withdrawals (
328
- block_env ,
329
- block_output ,
330
- self .env .withdrawals ,
331
- bal_change_tracker ,
332
- )
341
+ process_withdrawal_args = [
342
+ block_env , block_output , self .env .withdrawals
343
+ ]
344
+
345
+ if self .fork .is_after_fork ("ethereum.amsterdam" ):
346
+ assert bal_change_tracker is not None
347
+ process_withdrawal_args .append (bal_change_tracker )
348
+
349
+ self .fork .process_withdrawals (* process_withdrawal_args )
333
350
334
351
if self .fork .is_after_fork ("ethereum.prague" ):
335
- self .fork .process_general_purpose_requests (
336
- block_env , block_output , bal_change_tracker
337
- )
352
+ process_general_purpose_args = [block_env , block_output ]
353
+
354
+ if self .fork .is_after_fork ("ethereum.amsterdam" ):
355
+ assert bal_change_tracker is not None
356
+ process_general_purpose_args .append (bal_change_tracker )
357
+
358
+ self .fork .process_general_purpose_requests (* process_general_purpose_args )
338
359
339
360
if self .fork .is_after_fork ("ethereum.amsterdam" ):
361
+ assert bal_change_tracker is not None
340
362
num_transactions = len (
341
363
[tx for tx in self .txs .successfully_parsed if tx ]
342
364
)
0 commit comments