Skip to content

Commit

Permalink
Fix deployment issue for production RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Aug 20, 2024
1 parent 9013e66 commit aa89289
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
6 changes: 5 additions & 1 deletion boa_zksync/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def from_debug_trace(cls, output: dict):
"""
Finds the actual transaction computation, since zksync has system
contract calls in the trace.
Note: The output has more data when running via the era test node.
"""
to, sender = output["to"], output["from"]

Expand All @@ -270,7 +271,10 @@ def _find(calls: list[dict]):
if trace["to"] == to and trace["from"] == sender:
return cls.from_call_trace(trace)

return _find(output["calls"])
if result := _find(output["calls"]):
return result
# in production mode the result is not always nested
return cls.from_call_trace(output)

@property
def is_success(self) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[project]
name = "titanoboa-zksync"
version = "0.1.1"
version = "0.1.2"
description = "A Zksync plugin for the Titanoboa Vyper interpreter"
license = { file = "LICENSE" }
readme = "README.md"
keywords = ["ethereum", "evm", "smart contract", "development", "vyper", "zksync"]
classifiers = ["Topic :: Software Development"]

# Requirements
dependencies = ["titanoboa>=0.1,<0.2"]
dependencies = ["titanoboa==0.1.10"]

[project.optional-dependencies]
forking-recommended = ["ujson"]
Expand Down
50 changes: 50 additions & 0 deletions tests/test_computation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import boa

from boa_zksync.types import ZksyncComputation

_required_fields = {"gas": "0x0", "value": "0x0", "input": "0x00", "gasUsed": "0x0"}


def test_from_debug_trace_nested():
sender = boa.env.generate_address()
to = boa.env.generate_address()
result = boa.env.generate_address().canonical_address
output = {
"from": sender,
"to": to,
"output": boa.env.generate_address(),
"calls": [{
"from": boa.env.generate_address(),
"to": boa.env.generate_address(),
"output": boa.env.generate_address(),
"calls": [],
**_required_fields,
}, {
"from": sender,
"to": to,
"output": "0x" +result.hex(),
"calls": [],
**_required_fields,
}, {
"from": boa.env.generate_address(),
"to": boa.env.generate_address(),
"output": boa.env.generate_address(),
"calls": [],
**_required_fields,
}]
}
assert ZksyncComputation.from_debug_trace(output).output == result


def test_from_debug_trace_production_mode():
# in production the real transaction output is directly in the result
# when running via the era test node, more contracts are actually included
result = boa.env.generate_address().canonical_address
output = {
"from": boa.env.generate_address(),
"to": boa.env.generate_address(),
"output": "0x" +result.hex(),
"calls": [],
**_required_fields,
}
assert ZksyncComputation.from_debug_trace(output).output == result
1 change: 1 addition & 0 deletions tests/test_fork.py → tests/test_sepolia.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from boa_zksync import EraTestNode
from boa_zksync.environment import ZERO_ADDRESS
from boa_zksync.types import ZksyncComputation


def test_dummy_contract(zksync_sepolia_fork):
Expand Down

0 comments on commit aa89289

Please sign in to comment.