diff --git a/.github/configs/eels_resolutions.json b/.github/configs/eels_resolutions.json index aedebb763f5..44833d9a06a 100644 --- a/.github/configs/eels_resolutions.json +++ b/.github/configs/eels_resolutions.json @@ -52,6 +52,6 @@ "Amsterdam": { "git_url": "https://github.com/fselmo/execution-specs.git", "branch": "feat/amsterdam-fork-and-block-access-lists", - "commit": "a5c7b29a658320c2432de78883d350e9f4444d14" + "commit": "39e0b59613be4100d2efc86702ff594c54e5bd81" } } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0778f582d03..14c9dda37ba 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -239,6 +239,7 @@ Users can select any of the artifacts depending on their benchmarking or testing - 🔀 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 issues with `Block Level Access Lists (BAL)` tests for Amsterdam ([#2121](https://github.com/ethereum/execution-spec-tests/pull/2121)). ## [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/blockchain.py b/src/ethereum_test_specs/blockchain.py index 7ee7507ff3c..2848a40f387 100644 --- a/src/ethereum_test_specs/blockchain.py +++ b/src/ethereum_test_specs/blockchain.py @@ -660,7 +660,7 @@ def generate_block_data( and not block.skip_exception_verification and not ( block.expected_block_access_list is not None - and block.expected_block_access_list.modifier is not None + and block.expected_block_access_list._modifier is not None ) ): # Only verify block level exception if: diff --git a/src/ethereum_test_types/block_access_list/__init__.py b/src/ethereum_test_types/block_access_list/__init__.py index fac6f906c2c..753aaa44e77 100644 --- a/src/ethereum_test_types/block_access_list/__init__.py +++ b/src/ethereum_test_types/block_access_list/__init__.py @@ -9,7 +9,7 @@ from typing import Any, Callable, ClassVar, Dict, List import ethereum_rlp as eth_rlp -from pydantic import Field +from pydantic import Field, PrivateAttr from ethereum_test_base_types import ( Address, @@ -197,15 +197,13 @@ class BlockAccessListExpectation(CamelModel): """ + model_config = CamelModel.model_config | {"extra": "forbid"} + account_expectations: Dict[Address, BalAccountExpectation | None] = Field( default_factory=dict, description="Expected account changes or exclusions to verify" ) - modifier: Callable[["BlockAccessList"], "BlockAccessList"] | None = Field( - None, - exclude=True, - description="Optional modifier to modify the BAL for invalid tests", - ) + _modifier: Callable[["BlockAccessList"], "BlockAccessList"] | None = PrivateAttr(default=None) def modify( self, *modifiers: Callable[["BlockAccessList"], "BlockAccessList"] @@ -228,7 +226,7 @@ def modify( """ new_instance = self.model_copy(deep=True) - new_instance.modifier = compose(*modifiers) + new_instance._modifier = compose(*modifiers) return new_instance def to_fixture_bal(self, t8n_bal: "BlockAccessList") -> "BlockAccessList": @@ -249,8 +247,8 @@ def to_fixture_bal(self, t8n_bal: "BlockAccessList") -> "BlockAccessList": self.verify_against(t8n_bal) # Apply modifier if present (for invalid tests) - if self.modifier: - return self.modifier(t8n_bal) + if self._modifier: + return self._modifier(t8n_bal) return t8n_bal diff --git a/src/pytest_plugins/eels_resolutions.json b/src/pytest_plugins/eels_resolutions.json index a5aae290805..2b1a9c5f9db 100644 --- a/src/pytest_plugins/eels_resolutions.json +++ b/src/pytest_plugins/eels_resolutions.json @@ -55,6 +55,6 @@ "Amsterdam": { "git_url": "https://github.com/fselmo/execution-specs.git", "branch": "feat/amsterdam-fork-and-block-access-lists", - "commit": "a5c7b29a658320c2432de78883d350e9f4444d14" + "commit": "39e0b59613be4100d2efc86702ff594c54e5bd81" } } diff --git a/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py b/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py index c557e711c2c..f86b7af4014 100644 --- a/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py +++ b/tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py @@ -20,6 +20,7 @@ ) from ethereum_test_types.block_access_list import ( BalAccountChange, + BalAccountExpectation, BalBalanceChange, BalNonceChange, BalStorageChange, @@ -73,12 +74,11 @@ def test_bal_invalid_missing_nonce( txs=[tx], exception=BlockException.INCORRECT_BLOCK_FORMAT, expected_block_access_list=BlockAccessListExpectation( - account_changes=[ - BalAccountChange( - address=sender, + account_expectations={ + sender: BalAccountExpectation( nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)], ), - ] + } ).modify(remove_nonces(sender)), ) ], @@ -113,12 +113,11 @@ def test_bal_invalid_nonce_value( txs=[tx], exception=BlockException.INCORRECT_BLOCK_FORMAT, expected_block_access_list=BlockAccessListExpectation( - account_changes=[ - BalAccountChange( - address=sender, + account_expectations={ + sender: BalAccountExpectation( nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)], ), - ] + } ).modify(modify_nonce(sender, tx_index=1, nonce=42)), ) ], @@ -158,9 +157,8 @@ def test_bal_invalid_storage_value( txs=[tx], exception=BlockException.INCORRECT_BLOCK_FORMAT, expected_block_access_list=BlockAccessListExpectation( - account_changes=[ - BalAccountChange( - address=contract, + account_expectations={ + contract: BalAccountExpectation( storage_changes=[ BalStorageSlot( slot=0x01, @@ -176,7 +174,7 @@ def test_bal_invalid_storage_value( ), ], ), - ] + } ).modify( # Corrupt storage value for slot 0x02 modify_storage(contract, tx_index=1, slot=0x02, value=0xFF) @@ -223,23 +221,20 @@ def test_bal_invalid_tx_order( txs=[tx1, tx2], exception=BlockException.INCORRECT_BLOCK_FORMAT, expected_block_access_list=BlockAccessListExpectation( - account_changes=[ - BalAccountChange( - address=sender1, + account_expectations={ + sender1: BalAccountExpectation( nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)], ), - BalAccountChange( - address=sender2, + sender2: BalAccountExpectation( nonce_changes=[BalNonceChange(tx_index=2, post_nonce=1)], ), - BalAccountChange( - address=receiver, + receiver: BalAccountExpectation( balance_changes=[ BalBalanceChange(tx_index=1, post_balance=10**15), BalBalanceChange(tx_index=2, post_balance=3 * 10**15), ], ), - ] + } ).modify(swap_tx_indices(1, 2)), ) ], @@ -276,12 +271,11 @@ def test_bal_invalid_account( txs=[tx], exception=BlockException.INCORRECT_BLOCK_FORMAT, expected_block_access_list=BlockAccessListExpectation( - account_changes=[ - BalAccountChange( - address=sender, + account_expectations={ + sender: BalAccountExpectation( nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)], ), - ] + } ).modify( append_account( BalAccountChange( @@ -323,16 +317,14 @@ def test_bal_invalid_duplicate_account( txs=[tx], exception=BlockException.INCORRECT_BLOCK_FORMAT, expected_block_access_list=BlockAccessListExpectation( - account_changes=[ - BalAccountChange( - address=sender, + account_expectations={ + sender: BalAccountExpectation( nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)], ), - BalAccountChange( - address=receiver, + receiver: BalAccountExpectation( balance_changes=[BalBalanceChange(tx_index=1, post_balance=10**15)], ), - ] + } ).modify(duplicate_account(sender)), ) ], @@ -367,16 +359,14 @@ def test_bal_invalid_account_order( txs=[tx], exception=BlockException.INCORRECT_BLOCK_FORMAT, expected_block_access_list=BlockAccessListExpectation( - account_changes=[ - BalAccountChange( - address=sender, + account_expectations={ + sender: BalAccountExpectation( nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)], ), - BalAccountChange( - address=receiver, + receiver: BalAccountExpectation( balance_changes=[BalBalanceChange(tx_index=1, post_balance=10**15)], ), - ] + } ).modify(reverse_accounts()), ) ], @@ -424,16 +414,14 @@ def test_bal_invalid_complex_corruption( txs=[tx1, tx2], exception=BlockException.INCORRECT_BLOCK_FORMAT, expected_block_access_list=BlockAccessListExpectation( - account_changes=[ - BalAccountChange( - address=sender, + account_expectations={ + sender: BalAccountExpectation( nonce_changes=[ BalNonceChange(tx_index=1, post_nonce=1), BalNonceChange(tx_index=2, post_nonce=2), ], ), - BalAccountChange( - address=contract, + contract: BalAccountExpectation( storage_changes=[ BalStorageSlot( slot=0x01, @@ -445,11 +433,10 @@ def test_bal_invalid_complex_corruption( ), ], ), - BalAccountChange( - address=receiver, + receiver: BalAccountExpectation( balance_changes=[BalBalanceChange(tx_index=2, post_balance=10**15)], ), - ] + } ).modify( remove_nonces(sender), modify_storage(contract, tx_index=1, slot=0x01, value=0xFF), @@ -489,16 +476,14 @@ def test_bal_invalid_missing_account( txs=[tx], exception=BlockException.INCORRECT_BLOCK_FORMAT, expected_block_access_list=BlockAccessListExpectation( - account_changes=[ - BalAccountChange( - address=sender, + account_expectations={ + sender: BalAccountExpectation( nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)], ), - BalAccountChange( - address=receiver, + receiver: BalAccountExpectation( balance_changes=[BalBalanceChange(tx_index=1, post_balance=10**15)], ), - ] + } ).modify(remove_accounts(receiver)), ) ], @@ -533,12 +518,11 @@ def test_bal_invalid_balance_value( txs=[tx], exception=BlockException.INCORRECT_BLOCK_FORMAT, expected_block_access_list=BlockAccessListExpectation( - account_changes=[ - BalAccountChange( - address=receiver, + account_expectations={ + receiver: BalAccountExpectation( balance_changes=[BalBalanceChange(tx_index=1, post_balance=10**15)], ), - ] + } ).modify(modify_balance(receiver, tx_index=1, balance=999999)), ) ],