Skip to content

Commit

Permalink
Merge pull request #10 from DanielSchiavini/fix/deployment-rpc
Browse files Browse the repository at this point in the history
fix: deployment issue for production RPC
  • Loading branch information
DanielSchiavini authored Aug 20, 2024
2 parents 9013e66 + 89415b4 commit 5da3a09
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 5 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
54 changes: 54 additions & 0 deletions tests/test_computation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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
3 changes: 1 addition & 2 deletions tests/test_get_compiler_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def test_get_compiler_output_unexpected_key():
output_dict = {"blabla": 123, "zk_versions": 456, "version": 789}

with pytest.raises(
ValueError,
match="Expected exactly one contract key, found blabla, zk_versions",
ValueError, match="Expected exactly one contract key, found blabla, zk_versions"
):
get_compiler_output(output_dict)
File renamed without changes.

0 comments on commit 5da3a09

Please sign in to comment.