Skip to content

Commit

Permalink
fix(fw): witness in fixtures from t8n output result.
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-tb committed Aug 6, 2024
1 parent 2b31045 commit 1378e56
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ethereum_test_fixtures/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def from_witness(cls, w: Witness) -> "FixtureWitness":
"""
Returns a FixtureWitness from a Witness.
"""
return cls(**w.model_dump(exclude_none=False))
return cls(**w.model_dump())


class FixtureBlockBase(CamelModel):
Expand Down
21 changes: 17 additions & 4 deletions src/ethereum_test_types/verkle/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
Useful Verkle types for generating Ethereum tests.
"""

from typing import Dict, List
from typing import Any, Dict, List

from pydantic import Field, RootModel, field_validator
from pydantic.functional_serializers import model_serializer

from ethereum_test_base_types import CamelModel, HexNumber, PaddedFixedSizeBytes

Expand Down Expand Up @@ -74,8 +75,20 @@ class SuffixStateDiff(CamelModel):
"""

suffix: int
current_value: Hash | None = Field(default_factory=None)
new_value: Hash | None = Field(default_factory=None)
current_value: Hash | None
new_value: Hash | None

@model_serializer(mode="wrap")
def custom_serializer(self, handler) -> Dict[str, Any]:
"""
Custom serializer to include None (null) values for current/new value.
"""
output = handler(self)
if self.current_value is None:
output["currentValue"] = None
if self.new_value is None:
output["newValue"] = None
return output


class StemStateDiff(CamelModel):
Expand All @@ -86,7 +99,7 @@ class StemStateDiff(CamelModel):
Includes a list of differences for its suffixes.
"""

stem: Hash
stem: Stem
suffix_diffs: List[SuffixStateDiff]


Expand Down
2 changes: 0 additions & 2 deletions src/evm_transition_tool/transition_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ def _evaluate_filesystem(
args.extend(
["--output.vkt", output_paths["vkt"], "--output.witness", output_paths["witness"]]
)
print(output_paths)
if t8n_data.vkt is not None:
args.extend(["--input.vkt", input_paths["vkt"]])

Expand Down Expand Up @@ -379,7 +378,6 @@ def _evaluate_filesystem(
with open(file_path, "r+") as file:
output_contents[key] = json.load(file)
output = TransitionToolOutput(**output_contents)
print(output)
if self.trace:
self.collect_traces(output.result.receipts, temp_dir, debug_output_path)

Expand Down

0 comments on commit 1378e56

Please sign in to comment.