Skip to content

Commit c730e6d

Browse files
committed
fix(bal): Initialize the state tracker before system contract calls
- We were missing system contract calls to beacon roots and history contracts. This change initializes the state tracker before system contract calls and passes the tracker to these calls if post-Amsterdam.
1 parent a5c7b29 commit c730e6d

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/ethereum_spec_tools/evm_tools/t8n/__init__.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -271,20 +271,6 @@ def run_state_test(self) -> Any:
271271
self.result.rejected = self.txs.rejected_txs
272272

273273
def _run_blockchain_test(self, block_env: Any, block_output: Any) -> None:
274-
if self.fork.is_after_fork("ethereum.prague"):
275-
self.fork.process_unchecked_system_transaction(
276-
block_env=block_env,
277-
target_address=self.fork.HISTORY_STORAGE_ADDRESS,
278-
data=block_env.block_hashes[-1], # The parent hash
279-
)
280-
281-
if self.fork.is_after_fork("ethereum.cancun"):
282-
self.fork.process_unchecked_system_transaction(
283-
block_env=block_env,
284-
target_address=self.fork.BEACON_ROOTS_ADDRESS,
285-
data=block_env.parent_beacon_block_root,
286-
)
287-
288274
bal_change_tracker = None
289275
if self.fork.is_after_fork("ethereum.amsterdam"):
290276
bal_change_tracker = StateChangeTracker(
@@ -294,6 +280,26 @@ def _run_blockchain_test(self, block_env: Any, block_output: Any) -> None:
294280
# pre-execution system contracts use index 0
295281
set_transaction_index(bal_change_tracker, 0)
296282

283+
if self.fork.is_after_fork("ethereum.prague"):
284+
process_args = {
285+
"block_env": block_env,
286+
"target_address": self.fork.HISTORY_STORAGE_ADDRESS,
287+
"data": block_env.block_hashes[-1], # The parent hash
288+
}
289+
if self.fork.is_after_fork("ethereum.amsterdam"):
290+
process_args["change_tracker"] = bal_change_tracker
291+
self.fork.process_unchecked_system_transaction(**process_args)
292+
293+
if self.fork.is_after_fork("ethereum.cancun"):
294+
process_args = {
295+
"block_env": block_env,
296+
"target_address": self.fork.BEACON_ROOTS_ADDRESS,
297+
"data": block_env.parent_beacon_block_root,
298+
}
299+
if self.fork.is_after_fork("ethereum.amsterdam"):
300+
process_args["change_tracker"] = bal_change_tracker
301+
self.fork.process_unchecked_system_transaction(**process_args)
302+
297303
for tx_index, (original_idx, tx) in enumerate(zip(
298304
self.txs.successfully_parsed, self.txs.transactions, strict=True,
299305
)):

0 commit comments

Comments
 (0)