diff --git a/evm_trace/base.py b/evm_trace/base.py index 60382b0..0af1158 100644 --- a/evm_trace/base.py +++ b/evm_trace/base.py @@ -15,8 +15,8 @@ class TraceFrame(BaseModel): gas: int gas_cost: int = Field(alias="gasCost") depth: int - stack: List[HexBytes] - memory: List[HexBytes] + stack: List[HexBytes] = [] + memory: List[HexBytes] = [] storage: Dict[HexBytes, HexBytes] = {} @@ -25,8 +25,8 @@ class CallTreeNode(BaseModel): address: HexBytes = HexBytes("") value: int = 0 depth: int = 0 - gas_limit: Optional[int] - gas_cost: Optional[int] # calculated from call starting and return + gas_limit: Optional[int] = None + gas_cost: Optional[int] = None # calculated from call starting and return calldata: HexBytes = HexBytes("") returndata: HexBytes = HexBytes("") calls: List["CallTreeNode"] = [] diff --git a/tests/test_trace_frame.py b/tests/test_trace_frame.py index cd22699..68c6c4f 100644 --- a/tests/test_trace_frame.py +++ b/tests/test_trace_frame.py @@ -9,6 +9,11 @@ def test_trace_frame_validation_passes(trace_frame_data): assert frame +def test_trace_no_memory(): + raw_frame = {"pc": 0, "op": "PUSH1", "gas": 4732305, "gasCost": 3, "depth": 1, "stack": []} + assert TraceFrame(**raw_frame) + + @pytest.mark.parametrize( "test_data", (