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` diff --git a/src/ethereum_test_fixtures/blockchain.py b/src/ethereum_test_fixtures/blockchain.py index 207082abdbf..c3d13675d0b 100644 --- a/src/ethereum_test_fixtures/blockchain.py +++ b/src/ethereum_test_fixtures/blockchain.py @@ -407,9 +407,18 @@ 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 + 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: 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(