diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 35270f8ed1..76ddb5c590 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -40,6 +40,7 @@ Test fixtures for use by clients are available for each release on the [Github r - ✨ Add "description" and "url" fields containing test case documentation and a source code permalink to fixtures during `fill` and use them in `consume`-generated Hive test reports ([#579](https://github.com/ethereum/execution-spec-tests/pull/579)). - ✨ Add git workflow evmone coverage script for any new lines mentioned in converted_ethereum_tests.txt ([#503](https://github.com/ethereum/execution-spec-tests/pull/503)). - ✨ Add a new covariant marker `with_all_contract_creating_tx_types` that allows automatic parametrization of a test with all contract-creating transaction types at the current executing fork ([#602](https://github.com/ethereum/execution-spec-tests/pull/602)). +- ✨ Enable loading of [ethereum/tests/BlockchainTests](https://github.com/ethereum/tests/tree/develop/BlockchainTests) ([#596](https://github.com/ethereum/execution-spec-tests/pull/596)). ### 🔧 EVM Tools diff --git a/src/cli/gen_index.py b/src/cli/gen_index.py index 639befe0ab..eb461db4af 100644 --- a/src/cli/gen_index.py +++ b/src/cli/gen_index.py @@ -25,6 +25,18 @@ from .hasher import HashableItem +# TODO: remove when these tests are ported or fixed within ethereum/tests. +fixtures_to_skip = set( + [ + # These fixtures have invalid fields that we can't load into our pydantic models (bigint). + "BlockchainTests/GeneralStateTests/stTransactionTest/ValueOverflowParis.json", + "BlockchainTests/InvalidBlocks/bc4895-withdrawals/withdrawalsAmountBounds.json", + "BlockchainTests/InvalidBlocks/bc4895-withdrawals/withdrawalsIndexBounds.json", + "BlockchainTests/InvalidBlocks/bc4895-withdrawals/withdrawalsValidatorIndexBounds.json", + "BlockchainTests/InvalidBlocks/bc4895-withdrawals/withdrawalsAddressBounds.json", + ] +) + def count_json_files_exclude_index(start_path: Path) -> int: """ @@ -47,6 +59,8 @@ def infer_fixture_format_from_path(file: Path) -> FixtureFormats: return FixtureFormats.BLOCKCHAIN_TEST_HIVE if "blockchain_tests" in file.parts: return FixtureFormats.BLOCKCHAIN_TEST + if "BlockchainTests" in file.parts: # ethereum/tests + return FixtureFormats.BLOCKCHAIN_TEST if "state_tests" in file.parts: return FixtureFormats.STATE_TEST return FixtureFormats.UNSET_TEST_FORMAT @@ -167,6 +181,9 @@ def generate_fixtures_index( continue if "blockchain_tests_hive" in file.parts: continue + if any(fixture in str(file) for fixture in fixtures_to_skip): + rich.print(f"Skipping '{file}'") + continue try: fixture_format = None diff --git a/src/cli/hasher.py b/src/cli/hasher.py index e724d57fc5..341606c15b 100644 --- a/src/cli/hasher.py +++ b/src/cli/hasher.py @@ -79,13 +79,16 @@ def from_json_file(cls, *, file_path: Path, parents: List[str]) -> "HashableItem raise TypeError(f"Expected dict, got {type(item)} for {key}") if "_info" not in item: raise KeyError(f"Expected '_info' in {key}") - if "hash" not in item["_info"]: - raise KeyError(f"Expected 'hash' in {key}") - if not isinstance(item["_info"]["hash"], str): - raise TypeError( - f"Expected hash to be a string in {key}, got {type(item['_info']['hash'])}" - ) - item_hash_bytes = bytes.fromhex(item["_info"]["hash"][2:]) + + # EEST uses 'hash'; ethereum/tests use 'generatedTestHash' + hash_value = item["_info"].get("hash") or item["_info"].get("generatedTestHash") + if hash_value is None: + raise KeyError(f"Expected 'hash' or 'generatedTestHash' in {key}") + + if not isinstance(hash_value, str): + raise TypeError(f"Expected hash to be a string in {key}, got {type(hash_value)}") + + item_hash_bytes = bytes.fromhex(hash_value[2:]) items[key] = cls( type=HashableItemType.TEST, root=item_hash_bytes, diff --git a/src/ethereum_test_tools/spec/blockchain/types.py b/src/ethereum_test_tools/spec/blockchain/types.py index 9b00d6f5c5..41dda76238 100644 --- a/src/ethereum_test_tools/spec/blockchain/types.py +++ b/src/ethereum_test_tools/spec/blockchain/types.py @@ -3,7 +3,17 @@ """ from functools import cached_property -from typing import Annotated, Any, ClassVar, Dict, List, Literal, get_args, get_type_hints +from typing import ( + Annotated, + Any, + ClassVar, + Dict, + List, + Literal, + Optional, + get_args, + get_type_hints, +) from ethereum import rlp as eth_rlp from ethereum.base_types import Uint @@ -636,7 +646,7 @@ class FixtureCommon(BaseFixture): fork: str = Field(..., alias="network") genesis: FixtureHeader = Field(..., alias="genesisBlockHeader") pre: Alloc - post_state: Alloc + post_state: Optional[Alloc] = Field(None) def get_fork(self) -> str: """ diff --git a/whitelist.txt b/whitelist.txt index 48880d34e3..17c804ed50 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -19,6 +19,7 @@ basename bb besu bidict +bigint big0 big1 blobgasfee