From 1378e56575feb4e0171ef086a06d3db743fa6d6a Mon Sep 17 00:00:00 2001 From: Spencer Taylor-Brown Date: Tue, 6 Aug 2024 15:43:41 +0000 Subject: [PATCH] fix(fw): witness in fixtures from t8n output result. --- src/ethereum_test_fixtures/blockchain.py | 2 +- src/ethereum_test_types/verkle/types.py | 21 +++++++++++++++++---- src/evm_transition_tool/transition_tool.py | 2 -- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/ethereum_test_fixtures/blockchain.py b/src/ethereum_test_fixtures/blockchain.py index 5b89d15e49..8007870eba 100644 --- a/src/ethereum_test_fixtures/blockchain.py +++ b/src/ethereum_test_fixtures/blockchain.py @@ -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): diff --git a/src/ethereum_test_types/verkle/types.py b/src/ethereum_test_types/verkle/types.py index 7c0306398b..3b703cebe7 100644 --- a/src/ethereum_test_types/verkle/types.py +++ b/src/ethereum_test_types/verkle/types.py @@ -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 @@ -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): @@ -86,7 +99,7 @@ class StemStateDiff(CamelModel): Includes a list of differences for its suffixes. """ - stem: Hash + stem: Stem suffix_diffs: List[SuffixStateDiff] diff --git a/src/evm_transition_tool/transition_tool.py b/src/evm_transition_tool/transition_tool.py index 67678a09b5..6b4dacfb5f 100644 --- a/src/evm_transition_tool/transition_tool.py +++ b/src/evm_transition_tool/transition_tool.py @@ -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"]]) @@ -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)