Skip to content

Commit

Permalink
Update EIP-2935
Browse files Browse the repository at this point in the history
  • Loading branch information
gurukamath committed Sep 9, 2024
1 parent a6f5eae commit 6544a4e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
23 changes: 15 additions & 8 deletions src/ethereum/prague/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
increment_nonce,
process_withdrawal,
set_account_balance,
set_storage,
state_root,
)
from .transactions import (
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down
29 changes: 18 additions & 11 deletions src/ethereum_spec_tools/evm_tools/t8n/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions tests/prague/test_state_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
)
Expand Down

0 comments on commit 6544a4e

Please sign in to comment.