diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 439934b4153..21b0c832e91 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -142,6 +142,7 @@ Users can select any of the artifacts depending on their testing needs for their - โœจ Add a `pytest.mark.with_all_typed_transactions` marker that creates default typed transactions for each `tx_type` supported by the current `fork` ([#1890](https://github.com/ethereum/execution-spec-tests/pull/1890)). - โœจ Add basic support for ``Amsterdam`` fork in order to begin testing Glamsterdam ([#2069](https://github.com/ethereum/execution-spec-tests/pull/2069)). - โœจ [EIP-7928](https://eips.ethereum.org/EIPS/eip-7928): Add initial framework support for `Block Level Access Lists (BAL)` testing for Amsterdam ([#2067](https://github.com/ethereum/execution-spec-tests/pull/2067)). +- ๐Ÿ”€ Restrict extra args from being passed to ``BaseTest`` implementations (e.g. ``BlockchainTest``) ([#2102](https://github.com/ethereum/execution-spec-tests/pull/2102)). ### ๐Ÿงช Test Cases @@ -162,6 +163,7 @@ Users can select any of the artifacts depending on their testing needs for their - ๐Ÿ”€ Adds the max blob transaction limit to the tests including updates to [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) for Osaka ([#1884](https://github.com/ethereum/execution-spec-tests/pull/1884)). - ๐Ÿž Fix issues when filling block rlp size limit tests with ``--generate-pre-alloc-groups`` ([#1989](https://github.com/ethereum/execution-spec-tests/pull/1989)). - โœจ [EIP-7928](https://eips.ethereum.org/EIPS/eip-7928): Add test cases for `Block Level Access Lists (BAL)` to Amsterdam ([#2067](https://github.com/ethereum/execution-spec-tests/pull/2067)). +- ๐Ÿž Fix valid BAL cases to pass the expected block access list via each block, not the blockchain test itself ([2102](https://github.com/ethereum/execution-spec-tests/pull/2102)). ## [v4.5.0](https://github.com/ethereum/execution-spec-tests/releases/tag/v4.5.0) - 2025-05-14 diff --git a/src/ethereum_test_specs/base.py b/src/ethereum_test_specs/base.py index c8c1306bacd..94b8e5d5a29 100644 --- a/src/ethereum_test_specs/base.py +++ b/src/ethereum_test_specs/base.py @@ -9,7 +9,7 @@ from typing import Callable, ClassVar, Dict, Generator, List, Sequence, Type import pytest -from pydantic import BaseModel, Field, PrivateAttr +from pydantic import BaseModel, ConfigDict, Field, PrivateAttr from typing_extensions import Self from ethereum_clis import Result, TransitionTool @@ -61,6 +61,8 @@ class OpMode(StrEnum): class BaseTest(BaseModel): """Represents a base Ethereum test which must return a single test fixture.""" + model_config = ConfigDict(extra="forbid") + tag: str = "" _request: pytest.FixtureRequest | None = PrivateAttr(None) diff --git a/src/ethereum_test_specs/tests/test_expect.py b/src/ethereum_test_specs/tests/test_expect.py index 415c6076e9a..9f2b00acafc 100644 --- a/src/ethereum_test_specs/tests/test_expect.py +++ b/src/ethereum_test_specs/tests/test_expect.py @@ -418,8 +418,6 @@ def test_block_intermediate_state( with pytest.raises(expected_exception) as _: BlockchainTest( genesis_environment=env, - fork=fork, - t8n=default_t8n, pre=pre, post=block_3.expected_post_state, blocks=[block_1, block_2, block_3], @@ -428,8 +426,6 @@ def test_block_intermediate_state( else: BlockchainTest( genesis_environment=env, - fork=fork, - t8n=default_t8n, pre=pre, post=block_3.expected_post_state, blocks=[block_1, block_2, block_3], diff --git a/src/pytest_plugins/filler/tests/test_prealloc_group.py b/src/pytest_plugins/filler/tests/test_prealloc_group.py index 5c1ea0132ed..dfceb93dcc1 100644 --- a/src/pytest_plugins/filler/tests/test_prealloc_group.py +++ b/src/pytest_plugins/filler/tests/test_prealloc_group.py @@ -24,7 +24,10 @@ class MockTest(BaseTest): def __init__(self, pre: Alloc, genesis_environment: Environment, request=None): """Initialize mock test.""" - super().__init__(pre=pre, genesis_environment=genesis_environment) + super().__init__( # type: ignore + pre=pre, + genesis_environment=genesis_environment, + ) self._request = request def generate(self, *args, **kwargs): diff --git a/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py b/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py index f4fa786cc51..c01cdf698d4 100644 --- a/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py +++ b/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py @@ -43,7 +43,16 @@ def test_bal_nonce_changes( value=100, ) - block = Block(txs=[tx]) + block = Block( + txs=[tx], + expected_block_access_list=BlockAccessListExpectation( + account_expectations={ + alice: BalAccountExpectation( + nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)], + ), + } + ), + ) blockchain_test( pre=pre, @@ -52,13 +61,6 @@ def test_bal_nonce_changes( alice: Account(nonce=1), bob: Account(balance=100), }, - expected_block_access_list=BlockAccessListExpectation( - account_expectations={ - alice: BalAccountExpectation( - nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)], - ), - } - ), ) @@ -88,7 +90,6 @@ def test_bal_balance_changes( gas_price=1_000_000_000, ) - block = Block(txs=[tx]) alice_account = pre[alice] assert alice_account is not None, "Alice account should exist" alice_initial_balance = alice_account.balance @@ -96,13 +97,8 @@ def test_bal_balance_changes( # Account for both the value sent and gas cost (gas_price * gas_used) alice_final_balance = alice_initial_balance - 100 - (intrinsic_gas_cost * 1_000_000_000) - blockchain_test( - pre=pre, - blocks=[block], - post={ - alice: Account(nonce=1, balance=alice_final_balance), - bob: Account(balance=100), - }, + block = Block( + txs=[tx], expected_block_access_list=BlockAccessListExpectation( account_expectations={ alice: BalAccountExpectation( @@ -118,6 +114,15 @@ def test_bal_balance_changes( ), ) + blockchain_test( + pre=pre, + blocks=[block], + post={ + alice: Account(nonce=1, balance=alice_final_balance), + bob: Account(balance=100), + }, + ) + @pytest.mark.valid_from("Amsterdam") def test_bal_storage_writes( @@ -139,15 +144,8 @@ def test_bal_storage_writes( gas_limit=100000, ) - block = Block(txs=[tx]) - - blockchain_test( - pre=pre, - blocks=[block], - post={ - alice: Account(nonce=1), - storage_contract: Account(storage={0x01: 0x42}), - }, + block = Block( + txs=[tx], expected_block_access_list=BlockAccessListExpectation( account_expectations={ storage_contract: BalAccountExpectation( @@ -162,6 +160,15 @@ def test_bal_storage_writes( ), ) + blockchain_test( + pre=pre, + blocks=[block], + post={ + alice: Account(nonce=1), + storage_contract: Account(storage={0x01: 0x42}), + }, + ) + @pytest.mark.valid_from("Amsterdam") def test_bal_storage_reads( @@ -181,7 +188,16 @@ def test_bal_storage_reads( gas_limit=100000, ) - block = Block(txs=[tx]) + block = Block( + txs=[tx], + expected_block_access_list=BlockAccessListExpectation( + account_expectations={ + storage_contract: BalAccountExpectation( + storage_reads=[0x01], + ), + } + ), + ) blockchain_test( pre=pre, @@ -190,13 +206,6 @@ def test_bal_storage_reads( alice: Account(nonce=1), storage_contract: Account(storage={0x01: 0x42}), }, - expected_block_access_list=BlockAccessListExpectation( - account_expectations={ - storage_contract: BalAccountExpectation( - storage_reads=[0x01], - ), - } - ), ) @@ -244,21 +253,10 @@ def test_bal_code_changes( gas_limit=500000, ) - block = Block(txs=[tx]) - created_contract = compute_create_address(address=factory_contract, nonce=1) - blockchain_test( - pre=pre, - blocks=[block], - post={ - alice: Account(nonce=1), - factory_contract: Account(nonce=2), # incremented by CREATE to 2 - created_contract: Account( - code=runtime_code_bytes, - storage={}, - ), - }, + block = Block( + txs=[tx], expected_block_access_list=BlockAccessListExpectation( account_expectations={ alice: BalAccountExpectation( @@ -273,3 +271,16 @@ def test_bal_code_changes( } ), ) + + blockchain_test( + pre=pre, + blocks=[block], + post={ + alice: Account(nonce=1), + factory_contract: Account(nonce=2), # incremented by CREATE to 2 + created_contract: Account( + code=runtime_code_bytes, + storage={}, + ), + }, + ) diff --git a/tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py b/tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py index c40337763ab..c20efa7a3ac 100644 --- a/tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py +++ b/tests/osaka/eip7825_transaction_gas_limit_cap/test_tx_gas_limit.py @@ -198,7 +198,7 @@ def test_tx_gas_larger_than_block_gas_limit( exception=TransactionException.GAS_ALLOWANCE_EXCEEDED if exceed_block_gas_limit else None, ) - blockchain_test(env=env, pre=pre, post={}, blocks=[block]) + blockchain_test(pre=pre, post={}, blocks=[block]) @pytest.fixture diff --git a/tests/prague/eip2935_historical_block_hashes_from_state/test_block_hashes.py b/tests/prague/eip2935_historical_block_hashes_from_state/test_block_hashes.py index 7bf5b3faa97..5d9f77b801a 100644 --- a/tests/prague/eip2935_historical_block_hashes_from_state/test_block_hashes.py +++ b/tests/prague/eip2935_historical_block_hashes_from_state/test_block_hashes.py @@ -430,7 +430,6 @@ def test_invalid_history_contract_calls( pre=pre, blocks=blocks, post=post, - reverts=reverts, ) @@ -490,5 +489,4 @@ def test_invalid_history_contract_calls_input_size( pre=pre, blocks=blocks, post=post, - reverts=reverts, ) diff --git a/tests/unscheduled/eip7692_eof_v1/eip6206_jumpf/test_jumpf_execution.py b/tests/unscheduled/eip7692_eof_v1/eip6206_jumpf/test_jumpf_execution.py index 7455ffdd73a..56b2a5fc7c8 100644 --- a/tests/unscheduled/eip7692_eof_v1/eip6206_jumpf/test_jumpf_execution.py +++ b/tests/unscheduled/eip7692_eof_v1/eip6206_jumpf/test_jumpf_execution.py @@ -628,7 +628,6 @@ def test_jumpf_with_inputs_stack_overflow( def test_jumpf_infinite_loop(eof_state_test: EOFStateTestFiller, container: Container): """Tests JUMPF causing an infinite loop.""" eof_state_test( - tx_gas=100_000, container=container, container_post=Account(storage={slot_code_worked: 0}), )