Skip to content
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
7 changes: 4 additions & 3 deletions packages/testing/src/execution_testing/cli/extract_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
)
from execution_testing.fixtures.blockchain import FixtureHeader
from execution_testing.fixtures.file import Fixtures
from execution_testing.fixtures.pre_alloc_groups import PreAllocGroup
from execution_testing.fixtures.pre_alloc_groups import PreAllocGroupBuilder
from execution_testing.forks import Fork


Expand Down Expand Up @@ -176,8 +176,9 @@ def from_fixture(cls, fixture_path: Path) -> Self:
pass

try:
# Try to load pre-allocation group
pre_alloc_group = PreAllocGroup.model_validate_json(fixture_bytes)
# Load as builder format and compute genesis on-demand
builder = PreAllocGroupBuilder.model_validate_json(fixture_bytes)
pre_alloc_group = builder.build()
return cls(
header=pre_alloc_group.genesis,
alloc=pre_alloc_group.pre,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Tuple,
)

from pydantic import Field, PrivateAttr, ValidationError
from pydantic import Field, PrivateAttr

from execution_testing.base_types import (
CamelModel,
Expand Down Expand Up @@ -340,21 +340,13 @@ def from_file(cls, file: Path) -> Self:
"""
Load a pre-allocation group from a JSON file.

Handles both builder format (without genesis) and full format (with
genesis). If genesis is missing, computes it from the pre-allocation
state. This ensures state root computation happens exactly once when
loading in Phase 2, not during Phase 1 merging.
Files are stored in builder format (without genesis). Genesis is
computed on-demand when loading, ensuring state root computation
happens exactly once in Phase 2, not during Phase 1 merging.
"""
with open(file) as f:
data = f.read()

# Try loading as full PreAllocGroup first (backwards compatibility)
try:
return cls.model_validate_json(data)
except ValidationError:
pass

# Load as builder format and compute genesis
builder = PreAllocGroupBuilder.model_validate_json(data)
built = builder.build()
# Use cls.model_validate to ensure proper Self return type
Expand Down
Loading