Skip to content

feat(fixtures,specs): Add postStateHash on exclude_full_post_state_in_output #1667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
9 changes: 9 additions & 0 deletions src/ethereum_test_fixtures/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions src/ethereum_test_specs/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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(
Expand Down
Loading