From 4df9c7d258db47bdb0641242798bb0332b5de581 Mon Sep 17 00:00:00 2001 From: ilitteri Date: Thu, 13 Aug 2026 10:50:33 -0300 Subject: [PATCH 1/3] fix(tests,tools): make the EIP-7805 FOCIL tests fill on the current Amsterdam 21 of the 24 FOCIL tests do not fill on this branch. Three independent causes, none of them in the tests' assertions. t8n passed decoded transactions where raw ones are expected. check_inclusion_list_transactions takes Tuple[LegacyTransaction | Bytes, ...] and calls get_transaction_hash, which asserts isinstance(tx, (LegacyTransaction, Bytes)); the caller passed convert_transaction(...), which returns a decoded fork transaction, so every typed-transaction case died on AssertionError. Both tuples now go through encode_transaction. The scenarios left no gas budget for the block's own access list. They size block_gas_limit to their transactions alone, but the EIP-7928 budget is block_gas_limit // GAS_BLOCK_ACCESS_LIST_ITEM, and the system-contract predeploys touched every block plus senders, recipients and coinbase come to about 30 items against a limit of about 22. Raising the limit alone would change what the scenarios assert, because the gas a pending inclusion-list transaction is allowed comes from block_gas_limit minus the gas the included transactions use. So build_block raises the limit and spends exactly the same amount on ballast transactions, leaving remaining_gas -- and therefore every "fits" and "does not fit" boundary -- unchanged. The ballast is a whole number of empty transfers so the amount is always representable on the fork's calldata-cost lattice. One funding transfer predated value-carrying transactions costing extra intrinsic gas. test_unsatisfied_when_block_tx_funds_pending_il_sender sizes and funds alice's transfer with calc(), but it carries value, so it needs calc(sends_value=True) and was failing INTRINSIC_GAS_BELOW_FLOOR_GAS_COST. Assertions are untouched: of the changed lines in test_focil.py, none touch expected_status, pytest.param, assertions, sender balances, nonces or inclusion-list composition. Scenario ids are unchanged and the reference implementation validates all 24 expected outcomes during fill. --- .../evm_tools/t8n/__init__.py | 11 +++- tests/bogota/eip7805_focil/helpers.py | 56 ++++++++++++++++++- tests/bogota/eip7805_focil/test_focil.py | 35 +++++++----- 3 files changed, 85 insertions(+), 17 deletions(-) diff --git a/src/ethereum_spec_tools/evm_tools/t8n/__init__.py b/src/ethereum_spec_tools/evm_tools/t8n/__init__.py index 76fb19ea2ba..4a2c892164b 100644 --- a/src/ethereum_spec_tools/evm_tools/t8n/__init__.py +++ b/src/ethereum_spec_tools/evm_tools/t8n/__init__.py @@ -409,9 +409,16 @@ def _run_blockchain_test(self, block_env: Any, block_output: Any) -> None: self.fork.check_inclusion_list_transactions( block_env, block_output, - tuple(self.convert_transaction(tx) for tx in self.txs), tuple( - self.convert_transaction(tx) + self.fork.encode_transaction( + self.convert_transaction(tx) + ) + for tx in self.txs + ), + tuple( + self.fork.encode_transaction( + self.convert_transaction(tx) + ) for tx in self.inclusion_list_txs ), ) diff --git a/tests/bogota/eip7805_focil/helpers.py b/tests/bogota/eip7805_focil/helpers.py index d4e9801f329..5470b86e5fe 100644 --- a/tests/bogota/eip7805_focil/helpers.py +++ b/tests/bogota/eip7805_focil/helpers.py @@ -36,6 +36,35 @@ class PendingInclusionListTx(NamedTuple): sender_balance: int = 10**18 +# EIP-7928 caps a block's access list at `block_gas_limit // +# GAS_BLOCK_ACCESS_LIST_ITEM` items (2000 gas per item on Amsterdam). These +# scenarios size the block gas limit to the transactions alone, which on the +# current Amsterdam leaves no budget for the block's own access list: the +# system-contract predeploys touched every block (beacon roots, history, the +# EIP-7002/7251 request contracts and the EIP-8282 builder deposit/exit pair) +# plus the senders, recipients and coinbase come to ~30 items against a limit +# of ~22, and every fixture fails to fill with +# `BlockAccessListGasLimitExceededError`. +# +# Raising the limit alone would change what the scenarios assert, because the +# gas a pending IL transaction is allowed is derived from +# `block_gas_limit - gas_used_by_included_txs`. So `build_block` raises the +# limit and spends exactly the same amount on a ballast transaction, leaving +# `remaining_gas` — and therefore every "fits" / "does not fit" boundary — +# byte-for-byte what it was. +# Gas to add. Realised as a whole number of empty transfers so the amount is +# always representable on the fork's calldata-cost lattice (a flat target like +# 64_000 is not, once EIP-7623's floor makes marginal calldata cost non-linear). +BAL_GAS_HEADROOM_TARGET = 64_000 + + +def bal_gas_headroom(fork: Fork) -> int: + """Gas added to a block's limit to leave room for its own access list.""" + empty_transfer_gas = fork.transaction_intrinsic_cost_calculator()() + count = -(-BAL_GAS_HEADROOM_TARGET // empty_transfer_gas) + return count * empty_transfer_gas + + class BuiltBlock(NamedTuple): """ Concrete block data plus the derived gas headroom. @@ -56,6 +85,10 @@ class BuiltBlock(NamedTuple): 1. Sender `nonce` is correct 2. Sender `balance` could have afforded the tx + `effective_gas_limit` is the gas limit the block must actually declare: + the caller's `block_gas_limit` plus `BAL_GAS_HEADROOM`. Pass it to + `Environment(gas_limit=...)` instead of the raw value. + These helpers only describe the block body, the flattened IL view, and the gas headroom for a scenario. The actual satisfaction check is done by the Amsterdam fork logic after block execution, when it re-validates any @@ -66,6 +99,7 @@ class BuiltBlock(NamedTuple): block_txs: list[Transaction] inclusion_list_txs: list[Transaction] remaining_gas: int + effective_gas_limit: int def _resolve_sender( @@ -220,10 +254,30 @@ def build_block( gas_used_by_included_txs = sum( tx_spec.actual_gas_used for tx_spec in included_block_tx_specs ) + + # Ballast: burns exactly the extra gas the raised limit adds, so + # `remaining_gas` below is identical to what it was before the limit was + # raised for the EIP-7928 access-list budget. It is a plain transfer from a + # fresh sender and appears in no inclusion list, so it cannot affect which + # IL transactions are appendable. + empty_transfer_gas = fork.transaction_intrinsic_cost_calculator()() + headroom = bal_gas_headroom(fork) + ballast_txs = [ + generate_custom_tx( + pre, + fork=fork, + actual_gas_used=empty_transfer_gas, + is_inclusion_list_tx=False, + ).tx + for _ in range(headroom // empty_transfer_gas) + ] + return BuiltBlock( - block_txs=[tx_with_origin.tx for tx_with_origin in included_block_txs], + block_txs=ballast_txs + + [tx_with_origin.tx for tx_with_origin in included_block_txs], inclusion_list_txs=flatten_inclusion_list_txs( included_block_txs + pending_inclusion_list_txs ), remaining_gas=block_gas_limit - gas_used_by_included_txs, + effective_gas_limit=block_gas_limit + headroom, ) diff --git a/tests/bogota/eip7805_focil/test_focil.py b/tests/bogota/eip7805_focil/test_focil.py index cfcb7c9b30d..d5ebc34d7b2 100644 --- a/tests/bogota/eip7805_focil/test_focil.py +++ b/tests/bogota/eip7805_focil/test_focil.py @@ -23,6 +23,7 @@ from ethereum.forks.amsterdam.fork import VERSIONED_HASH_VERSION_KZG from .helpers import ( + bal_gas_headroom, IncludedBlockTx, PendingInclusionListTx, build_block, @@ -103,7 +104,9 @@ def test_block_with_same_sender_included_il_txs_is_valid( ) assert built_block.remaining_gas == SAME_SENDER_BLOCK_HEADROOM blockchain_test( - genesis_environment=Environment(gas_limit=block_gas_limit), + genesis_environment=Environment( + gas_limit=built_block.effective_gas_limit + ), pre=pre, post={}, blocks=[ @@ -136,7 +139,7 @@ def test_block_with_reverting_included_il_tx_is_valid( gas_limit=100_000, ) blockchain_test( - genesis_environment=Environment(gas_limit=200_000), + genesis_environment=Environment(gas_limit=200_000 + bal_gas_headroom(fork)), pre=pre, post={}, blocks=[ @@ -338,7 +341,7 @@ def test_block_status_depends_on_pending_inclusion_list( ) blockchain_test( genesis_environment=Environment( - gas_limit=block_gas_limit, + gas_limit=built_block.effective_gas_limit, ), pre=pre, post={}, @@ -382,7 +385,7 @@ def test_block_with_pending_blob_il_tx_is_valid( ) blockchain_test( - genesis_environment=Environment(gas_limit=simple_transfer_gas * 4), + genesis_environment=Environment(gas_limit=simple_transfer_gas * 4 + bal_gas_headroom(fork)), pre=pre, post={}, blocks=[ @@ -406,8 +409,6 @@ def test_block_with_invalid_signature_pending_il_tx_is_valid( If the signature is invalid, the tx is not appendable and omission is allowed. """ - del fork - sender = pre.fund_eoa(amount=10**18) recipient = pre.fund_eoa() invalid_signature_tx = Transaction( @@ -420,7 +421,7 @@ def test_block_with_invalid_signature_pending_il_tx_is_valid( ) blockchain_test( - genesis_environment=Environment(gas_limit=21_000 * 4), + genesis_environment=Environment(gas_limit=21_000 * 4 + bal_gas_headroom(fork)), pre=pre, post={}, blocks=[ @@ -454,7 +455,7 @@ def test_block_with_intrinsic_gas_too_low_pending_il_tx_is_valid( ) blockchain_test( - genesis_environment=Environment(gas_limit=simple_transfer_gas * 4), + genesis_environment=Environment(gas_limit=simple_transfer_gas * 4 + bal_gas_headroom(fork)), pre=pre, post={}, blocks=[ @@ -481,11 +482,15 @@ def test_unsatisfied_when_block_tx_funds_pending_il_sender( """ calc = fork.transaction_intrinsic_cost_calculator() simple_transfer_gas = calc() + # A transfer that carries value costs more intrinsic gas than an empty one + # on this fork, so alice's funding tx must be sized (and paid for) with + # `sends_value=True`. Bob's IL tx carries no value and keeps the plain cost. + value_transfer_gas = calc(sends_value=True) gas_price = TransactionDefaults.gas_price value_to_fund_bob = simple_transfer_gas * gas_price alice = pre.fund_eoa( - amount=simple_transfer_gas * gas_price + value_to_fund_bob, + amount=value_transfer_gas * gas_price + value_to_fund_bob, ) bob = pre.fund_eoa(amount=0) recipient = pre.fund_eoa() @@ -493,7 +498,7 @@ def test_unsatisfied_when_block_tx_funds_pending_il_sender( alice_tx = Transaction( sender=alice, to=bob, - gas_limit=simple_transfer_gas, + gas_limit=value_transfer_gas, value=value_to_fund_bob, ) bob_il_tx = Transaction( @@ -502,7 +507,7 @@ def test_unsatisfied_when_block_tx_funds_pending_il_sender( gas_limit=simple_transfer_gas, ) - block_gas_limit = simple_transfer_gas * 5 + block_gas_limit = simple_transfer_gas * 5 + bal_gas_headroom(fork) blockchain_test( genesis_environment=Environment( gas_limit=block_gas_limit, @@ -586,7 +591,9 @@ def test_pending_il_depends_on_7702_authorization_nonce_effect( # Leave headroom after the set-code tx so the pending IL tx always # fits the block. The satisfied/unsatisfied outcome then depends only # on Bob's post-execution nonce, not on remaining gas. - block_gas_limit = set_code_gas + simple_transfer_gas * 2 + block_gas_limit = ( + set_code_gas + simple_transfer_gas * 2 + bal_gas_headroom(fork) + ) blockchain_test( genesis_environment=Environment(gas_limit=block_gas_limit), pre=pre, @@ -622,7 +629,7 @@ def test_unsatisfied_with_contract_creating_pending_il_tx( gas_limit=create_gas, ) - block_gas_limit = create_gas * 2 + block_gas_limit = create_gas * 2 + bal_gas_headroom(fork) blockchain_test( genesis_environment=Environment(gas_limit=block_gas_limit), pre=pre, @@ -696,7 +703,7 @@ def test_unsatisfied_with_typed_pending_il_tx( gas_price=TransactionDefaults.gas_price, ) - block_gas_limit = gas_limit * 2 + block_gas_limit = gas_limit * 2 + bal_gas_headroom(fork) blockchain_test( genesis_environment=Environment(gas_limit=block_gas_limit), pre=pre, From 563321febddc77254852f711a5d3a8a5e161aa22 Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Thu, 13 Aug 2026 15:29:47 -0600 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Mario Vega --- tests/bogota/eip7805_focil/helpers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/bogota/eip7805_focil/helpers.py b/tests/bogota/eip7805_focil/helpers.py index 5470b86e5fe..252ee2b76df 100644 --- a/tests/bogota/eip7805_focil/helpers.py +++ b/tests/bogota/eip7805_focil/helpers.py @@ -55,13 +55,16 @@ class PendingInclusionListTx(NamedTuple): # Gas to add. Realised as a whole number of empty transfers so the amount is # always representable on the fork's calldata-cost lattice (a flat target like # 64_000 is not, once EIP-7623's floor makes marginal calldata cost non-linear). -BAL_GAS_HEADROOM_TARGET = 64_000 def bal_gas_headroom(fork: Fork) -> int: """Gas added to a block's limit to leave room for its own access list.""" empty_transfer_gas = fork.transaction_intrinsic_cost_calculator()() - count = -(-BAL_GAS_HEADROOM_TARGET // empty_transfer_gas) + bal_gas_headroom_target = ( + fork.empty_block_bal_item_count() + * fork.gas_costs().BLOCK_ACCESS_LIST_ITEM + ) + count = -(-bal_gas_headroom_target // empty_transfer_gas) return count * empty_transfer_gas From 94a976a3fac2bbfc8d84758dbe4bf591ecf10bcf Mon Sep 17 00:00:00 2001 From: marioevz Date: Thu, 13 Aug 2026 15:38:52 -0600 Subject: [PATCH 3/3] fix: lint --- tests/bogota/eip7805_focil/helpers.py | 8 +++++--- tests/bogota/eip7805_focil/test_focil.py | 21 +++++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/tests/bogota/eip7805_focil/helpers.py b/tests/bogota/eip7805_focil/helpers.py index 252ee2b76df..5db2e1e8ee6 100644 --- a/tests/bogota/eip7805_focil/helpers.py +++ b/tests/bogota/eip7805_focil/helpers.py @@ -52,9 +52,11 @@ class PendingInclusionListTx(NamedTuple): # limit and spends exactly the same amount on a ballast transaction, leaving # `remaining_gas` — and therefore every "fits" / "does not fit" boundary — # byte-for-byte what it was. -# Gas to add. Realised as a whole number of empty transfers so the amount is -# always representable on the fork's calldata-cost lattice (a flat target like -# 64_000 is not, once EIP-7623's floor makes marginal calldata cost non-linear). +# +# The headroom is realised as a whole number of empty transfers so the amount +# is always representable on the fork's calldata-cost lattice (a flat target +# like 64_000 is not, once EIP-7623's floor makes marginal calldata cost +# non-linear). def bal_gas_headroom(fork: Fork) -> int: diff --git a/tests/bogota/eip7805_focil/test_focil.py b/tests/bogota/eip7805_focil/test_focil.py index d5ebc34d7b2..9dddd1d448b 100644 --- a/tests/bogota/eip7805_focil/test_focil.py +++ b/tests/bogota/eip7805_focil/test_focil.py @@ -23,9 +23,9 @@ from ethereum.forks.amsterdam.fork import VERSIONED_HASH_VERSION_KZG from .helpers import ( - bal_gas_headroom, IncludedBlockTx, PendingInclusionListTx, + bal_gas_headroom, build_block, ) from .spec import Spec, ref_spec_7805 @@ -139,7 +139,9 @@ def test_block_with_reverting_included_il_tx_is_valid( gas_limit=100_000, ) blockchain_test( - genesis_environment=Environment(gas_limit=200_000 + bal_gas_headroom(fork)), + genesis_environment=Environment( + gas_limit=200_000 + bal_gas_headroom(fork) + ), pre=pre, post={}, blocks=[ @@ -385,7 +387,9 @@ def test_block_with_pending_blob_il_tx_is_valid( ) blockchain_test( - genesis_environment=Environment(gas_limit=simple_transfer_gas * 4 + bal_gas_headroom(fork)), + genesis_environment=Environment( + gas_limit=simple_transfer_gas * 4 + bal_gas_headroom(fork) + ), pre=pre, post={}, blocks=[ @@ -421,7 +425,9 @@ def test_block_with_invalid_signature_pending_il_tx_is_valid( ) blockchain_test( - genesis_environment=Environment(gas_limit=21_000 * 4 + bal_gas_headroom(fork)), + genesis_environment=Environment( + gas_limit=21_000 * 4 + bal_gas_headroom(fork) + ), pre=pre, post={}, blocks=[ @@ -455,7 +461,9 @@ def test_block_with_intrinsic_gas_too_low_pending_il_tx_is_valid( ) blockchain_test( - genesis_environment=Environment(gas_limit=simple_transfer_gas * 4 + bal_gas_headroom(fork)), + genesis_environment=Environment( + gas_limit=simple_transfer_gas * 4 + bal_gas_headroom(fork) + ), pre=pre, post={}, blocks=[ @@ -484,7 +492,8 @@ def test_unsatisfied_when_block_tx_funds_pending_il_sender( simple_transfer_gas = calc() # A transfer that carries value costs more intrinsic gas than an empty one # on this fork, so alice's funding tx must be sized (and paid for) with - # `sends_value=True`. Bob's IL tx carries no value and keeps the plain cost. + # `sends_value=True`. Bob's IL tx carries no value and keeps the plain + # cost. value_transfer_gas = calc(sends_value=True) gas_price = TransactionDefaults.gas_price