diff --git a/tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_block_2d_gas_accounting.py b/tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_block_2d_gas_accounting.py index dd18f4b3d47..da1e886537a 100644 --- a/tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_block_2d_gas_accounting.py +++ b/tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_block_2d_gas_accounting.py @@ -483,14 +483,28 @@ def test_multi_block_dimension_flip( ) -@pytest.mark.exception_test +@pytest.mark.parametrize( + "delta", + [ + pytest.param(0, id="exactly_fits"), + pytest.param(1, id="exceeds", marks=pytest.mark.exception_test), + ], +) @pytest.mark.valid_from("EIP8037") -def test_tx_rejected_when_regular_gas_exceeds_block_limit_small( +def test_tx_inclusion_at_regular_gas_block_limit_small( blockchain_test: BlockchainTestFiller, pre: Alloc, fork: Fork, + delta: int, ) -> None: - """Reject a small-gas tx whose regular gas overflows the block.""" + """ + Probe the regular-gas inclusion boundary with a small-gas tx. + + The second tx's ``gas_limit`` is the remaining regular budget + plus ``delta``. The inclusion check uses strict ``>``, so + ``delta=0`` must pass and ``delta=1`` must reject with + ``GAS_ALLOWANCE_EXCEEDED``. Catches an off-by-one ``>=`` bug. + """ gas_limit_cap = fork.transaction_gas_limit_cap() assert gas_limit_cap is not None intrinsic_gas = fork.transaction_intrinsic_cost_calculator()() @@ -504,14 +518,15 @@ def test_tx_rejected_when_regular_gas_exceeds_block_limit_small( sender=pre.fund_eoa(), ) - rejected_gas_limit = intrinsic_gas + 1 - assert rejected_gas_limit < gas_limit_cap - rejected = pre.deploy_contract(code=Op.STOP) - rejected_tx = Transaction( - to=rejected, - gas_limit=rejected_gas_limit, + second_gas_limit = intrinsic_gas + delta + assert second_gas_limit < gas_limit_cap + error = TransactionException.GAS_ALLOWANCE_EXCEEDED if delta else None + second = pre.deploy_contract(code=Op.STOP) + second_tx = Transaction( + to=second, + gas_limit=second_gas_limit, sender=pre.fund_eoa(), - error=TransactionException.GAS_ALLOWANCE_EXCEEDED, + error=error, ) blockchain_test( @@ -519,9 +534,9 @@ def test_tx_rejected_when_regular_gas_exceeds_block_limit_small( pre=pre, blocks=[ Block( - txs=[filler_tx, rejected_tx], + txs=[filler_tx, second_tx], gas_limit=block_gas_limit, - exception=TransactionException.GAS_ALLOWANCE_EXCEEDED, + exception=error, ) ], post={}, diff --git a/tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py b/tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py index 8db97ffb032..3f7152ae731 100644 --- a/tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py +++ b/tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py @@ -1845,15 +1845,16 @@ def test_create_code_deposit_oog_refunds_state_gas( ) @pytest.mark.valid_from("EIP8037") def test_failed_create_tx_refunds_intrinsic_new_account( - blockchain_test: BlockchainTestFiller, + state_test: StateTestFiller, pre: Alloc, fork: Fork, init_code: Bytecode, ) -> None: """ Verify the NEW_ACCOUNT × CPSB portion of intrinsic_state_gas is - refunded on creation-tx revert/halt, so block state-gas excludes - it and header gas_used reflects only the regular component. + refunded on creation-tx revert/halt. Block state-gas excludes it + so header gas_used reflects only the regular component, and the + sender's receipt reflects the same refund via cumulative_gas_used. """ intrinsic_calc = fork.transaction_intrinsic_cost_calculator() create_state_gas = fork.create_state_gas(code_size=0) @@ -1870,23 +1871,23 @@ def test_failed_create_tx_refunds_intrinsic_new_account( regular_consumed = init_code.regular_cost(fork) expected_gas_used = intrinsic_regular + regular_consumed + expected_cumulative = intrinsic_total + regular_consumed - create_state_gas tx = Transaction( to=None, data=init_code, gas_limit=gas_limit, sender=pre.fund_eoa(), + expected_receipt=TransactionReceipt( + cumulative_gas_used=expected_cumulative, + ), ) - blockchain_test( + state_test( pre=pre, - blocks=[ - Block( - txs=[tx], - header_verify=Header(gas_used=expected_gas_used), - ), - ], post={}, + tx=tx, + blockchain_test_header_verify=Header(gas_used=expected_gas_used), )