Skip to content

Commit

Permalink
fix: issue where could not handle missing memory (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Nov 1, 2022
1 parent ae4e67f commit 714918c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions evm_trace/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {}


Expand All @@ -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"] = []
Expand Down
5 changes: 5 additions & 0 deletions tests/test_trace_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
(
Expand Down

0 comments on commit 714918c

Please sign in to comment.