Skip to content

Commit d712d0e

Browse files
Merge pull request #40 from vyperlang/fix/anvil-zksync
fix: updated era_test_node to anvil-zksync
2 parents 2e6a0e7 + edc1a08 commit d712d0e

13 files changed

+102
-61
lines changed

.github/workflows/test.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ jobs:
2626
pip install -r dev-requirements.txt
2727
pip install .
2828
29-
echo "Installing zkvyper and era_test_node"
30-
# Install zkvyper and era_test_node from binary repositories
29+
echo "Installing zkvyper and anvil-zksync"
30+
# Install zkvyper and anvil-zksync from binary repositories
3131
curl --location https://raw.githubusercontent.com/matter-labs/zkvyper-bin/v1.5.7/linux-amd64/zkvyper-linux-amd64-musl-v1.5.7 \
3232
--silent --output /usr/local/bin/zkvyper && \
3333
chmod +x /usr/local/bin/zkvyper && \
3434
zkvyper --version
35-
curl --location https://github.com/matter-labs/era-test-node/releases/download/v0.1.0-alpha.32/era_test_node-v0.1.0-alpha.32-x86_64-unknown-linux-gnu.tar.gz \
35+
curl --location https://github.com/matter-labs/anvil-zksync/releases/download/v0.1.0-alpha.35/era_test_node-v0.1.0-alpha.35-x86_64-unknown-linux-gnu.tar.gz \
3636
--silent --output era_test_node.tar.gz && \
3737
tar --extract --file=era_test_node.tar.gz && \
38-
mv era_test_node /usr/local/bin/era_test_node && \
39-
era_test_node --version && \
38+
mv era_test_node /usr/local/bin/anvil-zksync && \
39+
anvil-zksync --version && \
4040
rm era_test_node.tar.gz
4141
4242
- run: make coverage lint

README.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# titanoboa-zksync
22
A Zksync plugin for the Titanoboa Vyper interpreter
33

4-
54
## Installation
65

76
First install the following dependencies, depending on your system:
@@ -24,15 +23,15 @@ Then, make sure this is available in your system PATH.
2423

2524
#### ZkSync Node
2625

27-
If you want to test with forks or a local test node, you will need to install the ZkSync [era-test-node](https://github.com/matter-labs/era-test-node/releases).
26+
If you want to test with forks or a local test node, you will need to install the ZkSync [anvil-zksyncs](https://github.com/matter-labs/anvil-zksync/releases).
2827

29-
1. Download `era-test-node` from latest [Release](https://github.com/matter-labs/era-test-node/releases/latest)
28+
1. Download and install `anvil-zksync`
3029

31-
2. Extract the binary and mark as executable:
32-
```bash
33-
tar xz -f era_test_node.tar.gz -C /usr/local/bin/
34-
chmod +x /usr/local/bin/era_test_node
35-
```
30+
```bash
31+
curl --proto '=https' -sSf https://raw.githubusercontent.com/matter-labs/anvil-zksync/main/scripts/install.sh > install.sh
32+
chmod +x install.sh
33+
sudo ./install.sh
34+
```
3635

3736
Then, make sure this is available in your system PATH.
3837

boa_zksync/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from boa_zksync.contract import ZksyncContract
66
from boa_zksync.environment import ZksyncEnv
7-
from boa_zksync.node import EraTestNode
7+
from boa_zksync.node import AnvilZKsync
88
from boa_zksync.verifiers import ZksyncExplorer
99

1010

@@ -15,7 +15,7 @@ def set_zksync_env(url, explorer_url=None, nickname=None):
1515

1616
def set_zksync_test_env(node_args=(), nickname=None):
1717
return boa.set_env(
18-
ZksyncEnv(rpc=EraTestNode(node_args=node_args), nickname=nickname)
18+
ZksyncEnv(rpc=AnvilZKsync(node_args=node_args), nickname=nickname)
1919
)
2020

2121

boa_zksync/browser.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from boa.rpc import EthereumRPC
66

77
from boa_zksync.environment import ZksyncEnv
8-
from boa_zksync.util import install_era_test_node, install_zkvyper_compiler
8+
from boa_zksync.util import install_anvil_zksync, install_zkvyper_compiler
99

1010

1111
class ZksyncBrowserEnv(ZksyncEnv):
@@ -34,10 +34,10 @@ def set_chain_id(self, chain_id: int | str):
3434
def fork_rpc(
3535
self, rpc: EthereumRPC, reset_traces=True, block_identifier="safe", **kwargs
3636
):
37-
if colab_eval_js and not which("era_test_node"):
37+
if colab_eval_js and not which("anvil-zksync"):
3838
logging.warning(
39-
"Automatically installing era-test-node in the Colab environment."
39+
"Automatically installing anvil-zksync in the Colab environment."
4040
)
41-
install_era_test_node()
41+
install_anvil_zksync()
4242

4343
return super().fork_rpc(rpc, reset_traces, block_identifier, **kwargs)

boa_zksync/compiler_utils.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ def get_compiler_output(output):
8080
# from the compiler. Assuming key names could change and also assuming that the
8181
# number of keys could change, this method breaks if any of that happens:
8282

83-
excluded_keys = {"version", "zk_version", "__VYPER_MINIMAL_PROXY_CONTRACT", "extra_data"}
83+
excluded_keys = {
84+
"version",
85+
"zk_version",
86+
"__VYPER_MINIMAL_PROXY_CONTRACT",
87+
"extra_data",
88+
}
8489
contract_keys = set(output.keys()) - excluded_keys
8590

8691
if len(contract_keys) != 1:

boa_zksync/environment.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from requests import HTTPError
1818

1919
from boa_zksync.deployer import ZksyncDeployer
20-
from boa_zksync.node import EraTestNode
20+
from boa_zksync.node import AnvilZKsync
2121
from boa_zksync.types import (
2222
CONTRACT_DEPLOYER_ADDRESS,
2323
DEFAULT_SALT,
@@ -66,7 +66,7 @@ def _reset_fork(self, block_identifier="latest"):
6666
self._vm = None
6767
if (
6868
block_identifier == "latest"
69-
and isinstance(self._rpc, EraTestNode)
69+
and isinstance(self._rpc, AnvilZKsync)
7070
and (inner_rpc := self._rpc.inner_rpc)
7171
):
7272
del self._rpc # close the old rpc
@@ -93,7 +93,7 @@ def fork_rpc(
9393
if reset_traces:
9494
self.sha3_trace: dict = {}
9595
self.sstore_trace: dict = {}
96-
self._rpc = EraTestNode(rpc, block_identifier, **kwargs)
96+
self._rpc = AnvilZKsync(rpc, block_identifier, **kwargs)
9797

9898
def register_contract(self, address, obj):
9999
addr = Address(address)

boa_zksync/node.py

+28-24
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,48 @@
88
from boa_zksync.util import find_free_port, stop_subprocess, wait_url
99

1010

11-
class EraTestNode(EthereumRPC):
12-
# list of public+private keys for test accounts in the era_test_node
11+
class AnvilZKsync(EthereumRPC):
12+
# list of public+private keys for test accounts in the anvil-zksync
1313
TEST_ACCOUNTS = [
1414
(
15-
"0xBC989fDe9e54cAd2aB4392Af6dF60f04873A033A",
16-
"0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e",
15+
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
16+
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
1717
),
1818
(
19-
"0x55bE1B079b53962746B2e86d12f158a41DF294A6",
20-
"0x509ca2e9e6acf0ba086477910950125e698d4ea70fa6f63e000c5a22bda9361c",
19+
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
20+
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
2121
),
2222
(
23-
"0xCE9e6063674DC585F6F3c7eaBe82B9936143Ba6C",
24-
"0x71781d3a358e7a65150e894264ccc594993fbc0ea12d69508a340bc1d4f5bfbc",
23+
"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
24+
"0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a",
2525
),
2626
(
27-
"0xd986b0cB0D1Ad4CCCF0C4947554003fC0Be548E9",
28-
"0x379d31d4a7031ead87397f332aab69ef5cd843ba3898249ca1046633c0c7eefe",
27+
"0x90F79bf6EB2c4f870365E785982E1f101E93b906",
28+
"0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6",
2929
),
3030
(
31-
"0x87d6ab9fE5Adef46228fB490810f0F5CB16D6d04",
32-
"0x105de4e75fe465d075e1daae5647a02e3aad54b8d23cf1f70ba382b9f9bee839",
31+
"0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65",
32+
"0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a",
3333
),
3434
(
35-
"0x78cAD996530109838eb016619f5931a03250489A",
36-
"0x7becc4a46e0c3b512d380ca73a4c868f790d1055a7698f38fb3ca2b2ac97efbb",
35+
"0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
36+
"0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba",
3737
),
3838
(
39-
"0xc981b213603171963F81C687B9fC880d33CaeD16",
40-
"0xe0415469c10f3b1142ce0262497fe5c7a0795f0cbfd466a6bfa31968d0f70841",
39+
"0x976EA74026E726554dB657fA54763abd0C3a0aa9",
40+
"0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e",
4141
),
4242
(
43-
"0x42F3dc38Da81e984B92A95CBdAAA5fA2bd5cb1Ba",
44-
"0x4d91647d0a8429ac4433c83254fb9625332693c848e578062fe96362f32bfe91",
43+
"0x14dC79964da2C08b23698B3D3cc7Ca32193d9955",
44+
"0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356",
4545
),
4646
(
47-
"0x64F47EeD3dC749d13e49291d46Ea8378755fB6DF",
48-
"0x41c9f9518aa07b50cb1c0cc160d45547f57638dd824a8d85b5eb3bf99ed2bdeb",
47+
"0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f",
48+
"0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97",
4949
),
5050
(
51-
"0xe2b8Cb53a43a56d4d2AB6131C81Bd76B86D3AFe5",
52-
"0xb0680d66303a0163a19294f1ef8c95cd69a9d7902a4aca99c05f3e134e68a11a",
51+
"0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
52+
"0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6",
5353
),
5454
]
5555

@@ -67,8 +67,12 @@ def __init__(
6767
if isinstance(block_identifier, int)
6868
else []
6969
)
70-
command = ["fork", inner_rpc._rpc_url] + fork_at if inner_rpc else ["run"]
71-
args = ["era_test_node"] + list(node_args) + ["--port", f"{port}"] + command
70+
command = (
71+
["fork", "--fork-url", inner_rpc._rpc_url] + fork_at
72+
if inner_rpc
73+
else ["run"]
74+
)
75+
args = ["anvil-zksync"] + list(node_args) + ["--port", f"{port}"] + command
7276
self._test_node = Popen(args, stdout=sys.stdout, stderr=sys.stderr)
7377

7478
super().__init__(f"http://localhost:{port}")

boa_zksync/types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def to_deployment(
203203
):
204204
contract_name = getattr(contract, "contract_name", None)
205205
if (filename := getattr(contract, "filename", None)) is not None:
206-
filename = str(filename) # can be Path sometimes
206+
filename = str(filename) # can be Path sometimes
207207
try:
208208
source_bundle = get_verification_bundle(contract)
209209
except Exception as e:

boa_zksync/util.py

+29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import socket
3+
import warnings
34
from datetime import datetime, timedelta
45
from subprocess import Popen, TimeoutExpired
56
from time import sleep
@@ -57,6 +58,27 @@ def install_zkvyper_compiler(
5758
assert os.system("zkvyper --version") == 0 # check if it works
5859

5960

61+
def install_anvil_zksync(
62+
source="https://github.com/matter-labs/anvil-zksync/releases/download/v0.1.0-alpha.35/era_test_node-v0.1.0-alpha.35-x86_64-unknown-linux-gnu.tar.gz", # noqa: E501
63+
destination="/usr/local/bin/anvil-zksync",
64+
):
65+
"""
66+
Downloads the anvil-zksync binary from the given source URL and installs it to
67+
the destination directory.
68+
69+
This is a very basic implementation - usually users want to install the binary
70+
manually, but in the Colab environment, we can automate this process.
71+
"""
72+
response = requests.get(source)
73+
with open("era_test_node.tar.gz", "wb") as f:
74+
f.write(response.content)
75+
76+
os.system("tar --extract --file=era_test_node.tar.gz")
77+
os.system(f"mv era_test_node {destination}")
78+
os.system(f"{destination} --version")
79+
os.system("rm era_test_node.tar.gz")
80+
81+
6082
def install_era_test_node(
6183
source="https://github.com/matter-labs/era-test-node/releases/download/v0.1.0-alpha.32/era_test_node-v0.1.0-alpha.32-x86_64-unknown-linux-gnu.tar.gz", # noqa: E501
6284
destination="/usr/local/bin/era_test_node",
@@ -68,6 +90,13 @@ def install_era_test_node(
6890
This is a very basic implementation - usually users want to install the binary
6991
manually, but in the Colab environment, we can automate this process.
7092
"""
93+
warnings.warn(
94+
"""This feature is deprecated and will be removed in a future release.
95+
era_test_node has since been renamed to anvil-zksync.""",
96+
DeprecationWarning,
97+
stacklevel=2,
98+
)
99+
71100
response = requests.get(source)
72101
with open("era_test_node.tar.gz", "wb") as f:
73102
f.write(response.content)

pyproject.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "titanoboa-zksync"
3-
version = "0.2.8"
3+
version = "0.2.9"
44
description = "A Zksync plugin for the Titanoboa Vyper interpreter"
55
license = { file = "LICENSE" }
66
readme = "README.md"
@@ -48,4 +48,9 @@ dev-dependencies = [
4848
"nest-asyncio>=1.6.0",
4949
"pytest-xdist>=3.6.1",
5050
"pytest>=8.3.3",
51+
"mypy>=1.13.0",
52+
"pip>=24.3.1",
53+
"black>=24.10.0",
54+
"flake8>=7.1.1",
55+
"isort>=5.13.2",
5156
]

tests/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from eth_account import Account
77

88
import boa_zksync
9-
from boa_zksync import EraTestNode
9+
from boa_zksync import AnvilZKsync
1010
from boa_zksync.deployer import ZksyncDeployer
1111

1212
STARTING_SUPPLY = 100
@@ -58,7 +58,7 @@ def zksync_sepolia_env():
5858
@pytest.fixture(scope="module")
5959
def account():
6060
# default rich account from era_test_node
61-
_public_key, private_key = EraTestNode.TEST_ACCOUNTS[0]
61+
_public_key, private_key = AnvilZKsync.TEST_ACCOUNTS[0]
6262
return Account.from_key(private_key)
6363

6464

tests/test_boa_loads.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -131,24 +131,23 @@ def get_name_of(addr: HasName) -> String[32]:
131131
f"{caller_contract.address}> (file "
132132
"<unknown>).get_name_of(address) -> ['string'])",
133133
" <Unknown contract 0x0000000000000000000000000000000000008009>",
134-
" <Unknown contract 0x0000000000000000000000000000000000008002>",
134+
" <Unknown contract 0x000000000000000000000000000000000000800b>",
135135
" Test an error(<CallerContract interface at "
136136
f"{caller_contract.address}> (file <unknown>).get_name_of(address) -> "
137137
"['string'])",
138138
]
139139
)
140140
assert isinstance(call_trace, TraceFrame)
141141
assert str(call_trace).split("\n") == [
142-
f'[E] [24505] CallerContract.get_name_of(addr = "{called_addr}") <0x>',
143-
" [E] [23574] Unknown contract 0x0000000000000000000000000000000000008002.0x4de2e468",
144-
" [566] Unknown contract 0x000000000000000000000000000000000000800B.0x29f172ad",
142+
f'[E] [21325] CallerContract.get_name_of(addr = "{called_addr}") <0x>',
143+
" [E] [19164] Unknown contract 0x000000000000000000000000000000000000800B.0x29f172ad",
145144
" [1909] Unknown contract 0x000000000000000000000000000000000000800B.0x06bed036",
146145
" [159] Unknown contract 0x0000000000000000000000000000000000008010.0x00000000",
147-
" [449] Unknown contract 0x000000000000000000000000000000000000800B.0xa225efcb",
146+
" [395] Unknown contract 0x000000000000000000000000000000000000800B.0xa225efcb",
148147
" [2226] Unknown contract 0x0000000000000000000000000000000000008002.0x4de2e468",
149-
" [427] Unknown contract 0x000000000000000000000000000000000000800B.0xa851ae78",
148+
" [373] Unknown contract 0x000000000000000000000000000000000000800B.0xa851ae78",
150149
" [398] Unknown contract 0x0000000000000000000000000000000000008004.0xe516761e",
151-
" [E] [2548] Unknown contract 0x0000000000000000000000000000000000008009.0xb47fade1",
150+
" [E] [2554] Unknown contract 0x0000000000000000000000000000000000008009.0xb47fade1",
152151
f' [E] [1365] CallerContract.get_name_of(addr = "{called_addr}") <0x>',
153152
" [E] [397] CalledContract.name() <0x>",
154153
]
@@ -198,7 +197,7 @@ def transfer(_to : address, _value : uint256) -> bool:
198197
contract = boa.loads(code, 100)
199198
assert [str(e) for e in contract.get_logs()] == [
200199
"Transfer(sender=0x0000000000000000000000000000000000000000, "
201-
"receiver=0xBC989fDe9e54cAd2aB4392Af6dF60f04873A033A, value=100)"
200+
"receiver=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, value=100)"
202201
]
203202

204203
to = boa.env.generate_address()

tests/test_sepolia.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from boa.rpc import EthereumRPC
44

55
import boa_zksync
6-
from boa_zksync import EraTestNode
6+
from boa_zksync import AnvilZKsync
77
from boa_zksync.environment import ZERO_ADDRESS
88

99

@@ -37,7 +37,7 @@ def set_implementation(_implementation: address):
3737

3838

3939
def test_fork_rpc(zksync_sepolia_fork):
40-
assert isinstance(boa.env._rpc, EraTestNode)
40+
assert isinstance(boa.env._rpc, AnvilZKsync)
4141
assert isinstance(boa.env._rpc.inner_rpc, EthereumRPC)
4242

4343

0 commit comments

Comments
 (0)