diff --git a/src/ethereum/prague/fork.py b/src/ethereum/prague/fork.py index 71f02cc0e2..be7472bf03 100644 --- a/src/ethereum/prague/fork.py +++ b/src/ethereum/prague/fork.py @@ -41,7 +41,6 @@ increment_nonce, process_withdrawal, set_account_balance, - set_storage, state_root, ) from .transactions import ( @@ -204,13 +203,6 @@ def state_transition(chain: BlockChain, block: Block) -> None: if block.ommers != (): raise InvalidBlock - set_storage( - chain.state, - HISTORY_STORAGE_ADDRESS, - ((block.header.number - 1) % HISTORY_SERVE_WINDOW).to_be_bytes32(), - U256.from_be_bytes(block.header.parent_hash), - ) - apply_body_output = apply_body( chain.state, get_last_256_block_hashes(chain), @@ -728,6 +720,21 @@ def apply_body( excess_blob_gas, ) + process_system_transaction( + HISTORY_STORAGE_ADDRESS, + block_hashes[-1], # The parent hash + block_hashes, + coinbase, + block_number, + base_fee_per_gas, + block_gas_limit, + block_time, + prev_randao, + state, + chain_id, + excess_blob_gas, + ) + for i, tx in enumerate(map(decode_transaction, transactions)): trie_set( transactions_trie, rlp.encode(Uint(i)), encode_transaction(tx) diff --git a/src/ethereum_spec_tools/evm_tools/t8n/__init__.py b/src/ethereum_spec_tools/evm_tools/t8n/__init__.py index da13689085..5ac44d9b84 100644 --- a/src/ethereum_spec_tools/evm_tools/t8n/__init__.py +++ b/src/ethereum_spec_tools/evm_tools/t8n/__init__.py @@ -316,20 +316,27 @@ def apply_body(self) -> None: receipts_trie = self.fork.Trie(secured=False, default=None) block_logs = () blob_gas_used = Uint(0) - if self.fork.is_after_fork("ethereum.prague"): + if ( + self.fork.is_after_fork("ethereum.prague") + and not self.options.state_test + ): requests_trie = self.fork.Trie(secured=False, default=None) requests_from_execution: Tuple[Bytes, ...] = () - if not self.options.state_test: - self.fork.set_storage( - self.alloc.state, - self.fork.HISTORY_STORAGE_ADDRESS, - ( - (self.env.block_number - 1) - % self.fork.HISTORY_SERVE_WINDOW - ).to_be_bytes32(), - U256.from_be_bytes(self.env.parent_hash), - ) + self.fork.process_system_transaction( + self.fork.HISTORY_SERVE_WINDOW, + self.env.parent_hash, + self.env.block_hashes, + self.env.coinbase, + self.env.block_number, + self.env.base_fee_per_gas, + self.env.block_gas_limit, + self.env.block_timestamp, + self.env.prev_randao, + self.alloc.state, + self.chain_id, + self.env.excess_blob_gas, + ) if ( self.fork.is_after_fork("ethereum.cancun") diff --git a/tests/prague/test_state_transition.py b/tests/prague/test_state_transition.py index ce51c13099..ef4f1bcd98 100644 --- a/tests/prague/test_state_transition.py +++ b/tests/prague/test_state_transition.py @@ -105,6 +105,7 @@ "tests/fixtures/latest_fork_tests/blockchain_tests/prague/eip7251_consolidations", "tests/fixtures/latest_fork_tests/blockchain_tests/prague/eip7685_general_purpose_el_requests", "tests/fixtures/latest_fork_tests/blockchain_tests/prague/eip2537_bls_12_381_precompiles", + "tests/fixtures/latest_fork_tests/blockchain_tests/prague/eip2935_historical_block_hashes_from_state", # TODO: Current test fixtures don't support EOF along with other # EIPs. This will be fixed in the future. )