From 77ce0d7885da28aa5ca8842fa3a7334c0e9d1619 Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Tue, 27 May 2025 22:54:00 +0000 Subject: [PATCH 1/3] feat(fixtures,specs): Add `postStateHash` on `exclude_full_post_state_in_output` --- src/ethereum_test_fixtures/blockchain.py | 1 + src/ethereum_test_specs/blockchain.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/ethereum_test_fixtures/blockchain.py b/src/ethereum_test_fixtures/blockchain.py index 207082abdbf..ff4e61ef9c1 100644 --- a/src/ethereum_test_fixtures/blockchain.py +++ b/src/ethereum_test_fixtures/blockchain.py @@ -407,6 +407,7 @@ class BlockchainFixtureCommon(BaseFixture): genesis: FixtureHeader = Field(..., alias="genesisBlockHeader") pre: Alloc post_state: Alloc | None = Field(None) + post_state_hash: Hash | None = Field(None) last_block_hash: Hash = Field(..., alias="lastblockhash") # FIXME: lastBlockHash config: FixtureConfig diff --git a/src/ethereum_test_specs/blockchain.py b/src/ethereum_test_specs/blockchain.py index 4ce03b86a4c..fc1a406208a 100644 --- a/src/ethereum_test_specs/blockchain.py +++ b/src/ethereum_test_specs/blockchain.py @@ -656,6 +656,7 @@ def make_fixture( last_block_hash=head, pre=pre, post_state=alloc if not self.exclude_full_post_state_in_output else None, + post_state_hash=alloc.state_root() if self.exclude_full_post_state_in_output else None, config=FixtureConfig( fork=network_info, blob_schedule=FixtureBlobSchedule.from_blob_schedule(fork.blob_schedule()), @@ -754,6 +755,7 @@ def make_hive_fixture( fcu_version=fcu_version, pre=pre, post_state=alloc if not self.exclude_full_post_state_in_output else None, + post_state_hash=alloc.state_root() if self.exclude_full_post_state_in_output else None, sync_payload=sync_payload, last_block_hash=head_hash, config=FixtureConfig( From d1209e5127c7bc0884f9902a00163418eec5bcf0 Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Tue, 27 May 2025 23:04:38 +0000 Subject: [PATCH 2/3] docs: Changelog --- docs/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e25dfdd4f72..4d1e8b5e466 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -31,6 +31,7 @@ Users can select any of the artifacts depending on their testing needs for their - ✨ Don't warn about a "high Transaction gas_limit" for `zkevm` tests ([#1598](https://github.com/ethereum/execution-spec-tests/pull/1598)). - 🐞 `fill` no longer writes generated fixtures into an existing, non-empty output directory; it must now be empty or `--clean` must be used to delete it first ([#1608](https://github.com/ethereum/execution-spec-tests/pull/1608)). - 🐞 zkEVM marked tests have been removed from `tests-deployed` tox environment into its own separate workflow `tests-deployed-zkevm` and are filled by `evmone-t8n` ([#1617](https://github.com/ethereum/execution-spec-tests/pull/1617)). +- ✨ Field `postStateHash` is now added to all `blockchain_test` and `blockchain_test_engine` tests that use `exclude_full_post_state_in_output` in place of `postState`. Fixes `evmone-blockchaintest` test consumption and indirectly fixes coverage runs for these tests ([#1667](https://github.com/ethereum/execution-spec-tests/pull/1667)). #### `consume` From 6888cf7ae89e055599920f306deff8314f087c2a Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Tue, 27 May 2025 23:07:56 +0000 Subject: [PATCH 3/3] feat(fixtures,specs): Check mutually exclusive `postState`/`postStateHash` --- src/ethereum_test_fixtures/blockchain.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ethereum_test_fixtures/blockchain.py b/src/ethereum_test_fixtures/blockchain.py index ff4e61ef9c1..c3d13675d0b 100644 --- a/src/ethereum_test_fixtures/blockchain.py +++ b/src/ethereum_test_fixtures/blockchain.py @@ -411,6 +411,14 @@ class BlockchainFixtureCommon(BaseFixture): last_block_hash: Hash = Field(..., alias="lastblockhash") # FIXME: lastBlockHash config: FixtureConfig + def model_post_init(self, __context): + """Model post init method to check mutually exclusive fields.""" + super().model_post_init(__context) + if self.post_state_hash is None and self.post_state is None: + raise ValueError("Either post_state_hash or post_state must be provided.") + if self.post_state_hash is not None and self.post_state is not None: + raise ValueError("Only one of post_state_hash or post_state must be provided.") + @model_validator(mode="before") @classmethod def config_defaults_for_backwards_compatibility(cls, data: Any) -> Any: