Skip to content

Commit

Permalink
fix: update command to include fork-url for anvil-zksync (#307)
Browse files Browse the repository at this point in the history
<!--

Thank you for contributing to the ZKsync Docs!

Before submitting the PR, please make sure you do the following:

- Update your PR title to follow [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/)
- Read the [Contributing
Guide](https://github.com/matter-labs/zksync-docs/blob/main/CONTRIBUTING.md).
- Understand our [Code of
Conduct](https://github.com/matter-labs/zksync-docs/blob/main/CODE_OF_CONDUCT.md)
- Please delete any unused parts of the template when submitting your PR

-->

# Description

<!-- Please describe what are the changes and what they are solving for
in this PR. -->
- update command to include fork-url for anvil-zksync

## Linked Issues

<!-- If you have any issues this PR is related to, link them here. -->
<!--
Check out
https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
on how to automate linking a GitHub Issue to a PR.
-->

## Additional context

Co-authored-by: Igor Aleksanov <[email protected]>
  • Loading branch information
dutterbutter and popzxc authored Jan 20, 2025
1 parent dbd4d87 commit a8181b4
Showing 1 changed file with 96 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,31 +129,29 @@ This will:
To fork the mainnet, use the following command, replacing `[network]` with either `mainnet` or `sepolia-testnet`:
```bash
anvil-zksync fork [network]
anvil-zksync fork --fork-url [network]
```

::drop-panel
::panel{label="Expected output"}

```sh
14:50:12 INFO Creating fork from "https://mainnet.era.zksync.io:443" L1 block: L1BatchNumber(356201) L2 block: 21979120 with timestamp 1703083811, L1 gas price 41757081846 and protocol version: Some(Version18)
14:50:12 INFO Starting network with chain id: L2ChainId(260)
14:50:12 INFO
14:50:12 INFO Rich Accounts
14:50:12 INFO =============
14:50:16 INFO Account #0: 0xBC989fDe9e54cAd2aB4392Af6dF60f04873A033A (1_000_000_000_000 ETH)
14:50:16 INFO Private Key: 0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e
14:50:16 INFO Mnemonic: mass wild lava ripple clog cabbage witness shell unable tribe rubber enter
14:50:16 INFO
14:50:16 INFO Account #1: 0x55bE1B079b53962746B2e86d12f158a41DF294A6 (1_000_000_000_000 ETH)
14:50:16 INFO Private Key: 0x509ca2e9e6acf0ba086477910950125e698d4ea70fa6f63e000c5a22bda9361c
14:50:16 INFO Mnemonic: crumble clutch mammal lecture lazy broken nominee visit gentle gather gym erupt
16:11:26 INFO Fork Details
16:11:26 INFO ========================
16:11:26 INFO Network RPC: https://sepolia.era.zksync.dev:443
16:11:26 INFO Chain ID: 300
16:11:26 INFO L1 Batch #: 4513
16:11:26 INFO L2 Block #: 14945
16:11:26 INFO Block Timestamp: 1703064786
16:11:26 INFO Fork Block Hash: 0xbb7d838d81bffc73c7c6cd29ca6d4a1638f1927775093d477b232231cba861d6
16:11:26 INFO Compute Overhead Part: 0
16:11:26 INFO Pubdata Overhead Part: 1
16:11:26 INFO Batch Overhead L1 Gas: 800000
16:11:26 INFO Max Gas Per Batch: 200000000
16:11:26 INFO Max Pubdata Per Batch: 500000

...

14:50:19 INFO Account #9: 0xe2b8Cb53a43a56d4d2AB6131C81Bd76B86D3AFe5 (1_000_000_000_000 ETH)
14:50:19 INFO Private Key: 0xb0680d66303a0163a19294f1ef8c95cd69a9d7902a4aca99c05f3e134e68a11a
14:50:19 INFO Mnemonic: increase pulp sing wood guilt cement satoshi tiny forum nuclear sudden thank
14:50:19 INFO
14:50:19 INFO ========================================
14:50:19 INFO Node is ready at 127.0.0.1:8011
Expand All @@ -177,15 +175,15 @@ anvil-zksync fork --fork-block-number 7000000 --fork-url mainnet http://172.17.0
If you wish to replay a remote transaction locally for deep debugging, use the following command:

```bash
anvil-zksync replay_tx sepolia-testnet 0x7119045573862797257e4441ff48bf5a3bc4d133a00d167c18dc955eda12cfac
anvil-zksync replay_tx --fork-url sepolia-testnet 0x7119045573862797257e4441ff48bf5a3bc4d133a00d167c18dc955eda12cfac
```

For more detailed transaction information, such as call traces, add the `--show-calls` flag.
If you want to see ABI names, add the `--resolve-hashes` flag:

```bash
anvil-zksync --show-calls=user \
--resolve-hashes replay_tx sepolia-testnet \
anvil-zksync --show-calls=all \
--resolve-hashes=true replay_tx --fork-url sepolia-testnet \
0x7119045573862797257e4441ff48bf5a3bc4d133a00d167c18dc955eda12cfac
```

Expand Down Expand Up @@ -214,58 +212,84 @@ Here's an example of what you should expect to see when `show-calls` and `resolv
::panel{label="Expected output"}

```sh
Creating fork from "%%zk_testnet_rpc_url%%:443" L1 block: L1BatchNumber(4513) L2 block: 14945 with timestamp 1703064786, L1 gas price 61083275326 and protocol version: Some(Version19)
Starting network with chain id: L2ChainId(%%zk_testnet_chain_id%%)
Running 1 transactions (one per batch)

Validating 0x7119045573862797257e4441ff48bf5a3bc4d133a00d167c18dc955eda12cfac
Executing 0x7119045573862797257e4441ff48bf5a3bc4d133a00d167c18dc955eda12cfac
┌─────────────────────────┐
│ TRANSACTION SUMMARY │
└─────────────────────────┘
Transaction: SUCCESS
Initiator: 0x4eaf936c172b5e5511959167e8ab4f7031113ca3
Payer: 0x4eaf936c172b5e5511959167e8ab4f7031113ca3
Gas - Limit: 2_487_330 | Used: 969_330 | Refunded: 1_518_000
Use --show-gas-details flag or call config_setShowGasDetails to display more info

==== Console logs:

==== 22 call traces. Use --show-calls flag or call config_setShowCalls to display more info.
Call(Normal) 0x4eaf936c172b5e5511959167e8ab4f7031113ca3 validateTransaction(bytes32, bytes32, tuple) 1830339
Call(Normal) 0x0000000000000000000000000000000000000001 0x89c19e9b 1766835
Call(Normal) 0x4eaf936c172b5e5511959167e8ab4f7031113ca3 payForTransaction(bytes32, bytes32, tuple) 1789767
Call(Normal) 0x4eaf936c172b5e5511959167e8ab4f7031113ca3 executeTransaction(bytes32, bytes32, tuple) 1671012
Call(Mimic) 0x5d4fb5385ed95b65d1cd6a10ed9549613481ab2f 0x 1443393

==== 4 events
EthToken System Contract
Topics:
Transfer(address,address,uint256)
0x0000000000000000000000004eaf936c172b5e5511959167e8ab4f7031113ca3
0x0000000000000000000000000000000000000000000000000000000000008001
Data (Hex): 0x000000000000000000000000000000000000000000000000000c31dac51a6200

EthToken System Contract
Topics:
Transfer(address,address,uint256)
0x0000000000000000000000000000000000000000000000000000000000008001
0x0000000000000000000000004eaf936c172b5e5511959167e8ab4f7031113ca3
Data (Hex): 0x0000000000000000000000000000000000000000000000000009fc4d1bd4ad00

EthToken System Contract
Topics:
Transfer(address,address,uint256)
0x0000000000000000000000004eaf936c172b5e5511959167e8ab4f7031113ca3
0x0000000000000000000000005d4fb5385ed95b65d1cd6a10ed9549613481ab2f
Data (Hex): 0x0000000000000000000000000000000000000000000000000090f705956a4008

EthToken System Contract
Topics:
Transfer(address,address,uint256)
0x0000000000000000000000000000000000000000000000000000000000008001
0x0000000000000000000000004eaf936c172b5e5511959167e8ab4f7031113ca3
Data (Hex): 0x000000000000000000000000000000000000000000000000000159273ab13800
16:11:18 INFO Validating 0x7119045573862797257e4441ff48bf5a3bc4d133a00d167c18dc955eda12cfac
16:11:18 INFO Executing 0x7119045573862797257e4441ff48bf5a3bc4d133a00d167c18dc955eda12cfac
16:11:21 INFO
16:11:21 INFO ✅ [SUCCESS] Hash: 0x7119045573862797257e4441ff48bf5a3bc4d133a00d167c18dc955eda12cfac
16:11:21 INFO Initiator: 0x4eaf936c172b5e5511959167e8ab4f7031113ca3
16:11:21 INFO Payer: 0x4eaf936c172b5e5511959167e8ab4f7031113ca3
16:11:21 INFO Gas Limit: 2_487_330 | Used: 133_046 | Refunded: 2_354_284
16:11:21 INFO Paid: 0.0000252787 ETH (133046 gas * 0.19000000 gwei)
16:11:21 INFO Refunded: 0.0004473140 ETH
16:11:21 INFO
16:11:21 INFO
16:11:21 INFO [Transaction Execution] (23 calls)
16:11:21 INFO Call(Normal) [4_227_856_164] SystemContext@0x000000000000000000000000000000000000800b::setNewBatch(bytes32,uint128,uint128,uint256) (1_507)
16:11:21 INFO ├─ Call(Normal) [4_161_795_057] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO ├─ Call(Normal) [4_227_852_510] AccountCodeStorage@0x0000000000000000000000000000000000008002::getRawCodeHash(address) (2_226)
16:11:21 INFO ├─ Call(Normal) [4_227_848_478] SystemContext@0x000000000000000000000000000000000000800b::setL2Block(uint128,uint128,bytes32,bool,uint128) (1_849)
16:11:21 INFO │ └─ Call(Normal) [4_161_787_245] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO ├─ Call(Normal) [4_227_844_068] SystemContext@0x000000000000000000000000000000000000800b::baseFee() (243)
16:11:21 INFO ├─ Call(Normal) [4_227_834_870] BootloaderUtilities@0x000000000000000000000000000000000000800c::getTransactionHashes(tuple) (14_751)
16:11:21 INFO │ ├─ Call(Normal) [4_161_774_267] SystemContext@0x000000000000000000000000000000000000800b::chainId() (237)
16:11:21 INFO │ ├─ Call(Normal) [4_161_768_849] Keccak@0x0000000000000000000000000000000000008010::0x02f18201 (159)
16:11:21 INFO │ ├─ Call(Normal) [4_161_768_345] SystemContext@0x000000000000000000000000000000000000800b::chainId() (237)
16:11:21 INFO │ └─ Call(Normal) [4_161_760_659] Keccak@0x0000000000000000000000000000000000008010::0x02f87482 (159)
16:11:21 INFO ├─ Call(Normal) [4_227_819_624] SystemContext@0x000000000000000000000000000000000000800b::appendTransactionToCurrentL2Block(bytes32) (959)
16:11:21 INFO │ └─ Call(Normal) [4_161_759_273] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO ├─ Call(Normal) [4_227_818_364] SystemContext@0x000000000000000000000000000000000000800b::setPubdataInfo(uint256,uint256) (395)
16:11:21 INFO ├─ Call(Normal) [2_424_429] SystemContext@0x000000000000000000000000000000000000800b::setTxOrigin(address) (373)
16:11:21 INFO ├─ Call(Normal) [2_423_736] SystemContext@0x000000000000000000000000000000000000800b::setGasPrice(uint256) (323)
16:11:21 INFO ├─ Call(Normal) [2_417_940] ContractDeployer@0x0000000000000000000000000000000000008006::extendedAccountVersion(address) (3_891)
16:11:21 INFO │ ├─ Call(Normal) [2_379_573] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ └─ Call(Normal) [2_376_864] AccountCodeStorage@0x0000000000000000000000000000000000008002::getRawCodeHash(address) (256)
16:11:21 INFO ├─ Call(Normal) [2_412_774] NonceHolder@0x0000000000000000000000000000000000008003::validateNonceUsage(address, uint256, bool) (5_747)
16:11:21 INFO │ ├─ Call(Normal) [2_374_533] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ ├─ Call(Normal) [2_372_076] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ └─ Call(Normal) [2_371_572] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO ├─ Call(Normal) [2_400_300] initiator@0x4eaf936c172b5e5511959167e8ab4f7031113ca3::validateTransaction(bytes32, bytes32, tuple) (18_748)
16:11:21 INFO │ ├─ Call(Normal) [2_361_996] NonceHolder@0x0000000000000000000000000000000000008003::incrementMinNonceIfEquals(uint256) (4_795)
16:11:21 INFO │ │ ├─ Call(Normal) [2_324_574] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ │ └─ Call(Normal) [2_324_007] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ ├─ Call(Normal) [2_355_570] L2BaseToken@0x000000000000000000000000000000000000800a::balanceOf(uint256) (2_744)
16:11:21 INFO │ │ └─ Call(Normal) [2_318_211] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ └─ Call(Normal) [2_351_664] ECRecover@0x0000000000000000000000000000000000000001::0x89c19e9b (7_224)
16:11:21 INFO ├─ Call(Normal) [2_381_337] NonceHolder@0x0000000000000000000000000000000000008003::validateNonceUsage(address, uint256, bool) (811)
16:11:21 INFO │ └─ Call(Normal) [2_343_600] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO ├─ Call(Normal) [2_379_888] L2BaseToken@0x000000000000000000000000000000000000800a::balanceOf(uint256) (774)
16:11:21 INFO │ └─ Call(Normal) [2_342_151] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO ├─ Call(Normal) [2_378_250] initiator@0x4eaf936c172b5e5511959167e8ab4f7031113ca3::payForTransaction(bytes32, bytes32, tuple) (8_691)
16:11:21 INFO │ └─ Call(Normal) [2_340_360] MsgValueSimulator@0x0000000000000000000000000000000000008009::unknown (7_466)
16:11:21 INFO │ ├─ Call(Normal) [2_303_091] L2BaseToken@0x000000000000000000000000000000000000800a::transferFromTo(address, address, uint256) (6_086)
16:11:21 INFO │ │ ├─ Call(Normal) [2_266_488] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ │ ├─ Call(Normal) [2_265_984] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ │ ├─ Call(Normal) [2_262_078] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ │ └─ Call(Normal) [2_261_385] EventWriter@0x000000000000000000000000000000000000800d::0x00000000 (251)
16:11:21 INFO │ └─ Call(Mimic) [2_296_665] bootloader@0x0000000000000000000000000000000000008001::unknown (23)
16:11:21 INFO ├─ Call(Normal) [2_369_304] L2BaseToken@0x000000000000000000000000000000000000800a::balanceOf(uint256) (774)
16:11:21 INFO │ └─ Call(Normal) [2_331_756] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO ├─ Call(Normal) [2_368_107] L2BaseToken@0x000000000000000000000000000000000000800a::transferFromTo(address, address, uint256) (2_538)
16:11:21 INFO │ ├─ Call(Normal) [2_330_559] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ ├─ Call(Normal) [2_329_992] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ ├─ Call(Normal) [2_329_488] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ └─ Call(Normal) [2_328_858] EventWriter@0x000000000000000000000000000000000000800d::0x00000000 (251)
16:11:21 INFO ├─ Call(Normal) [2_337_678] KnownCodesStorage@0x0000000000000000000000000000000000008004::markFactoryDeps(bool, bytes32[]) (398)
16:11:21 INFO ├─ Call(Normal) [2_335_158] AccountCodeStorage@0x0000000000000000000000000000000000008002::getRawCodeHash(address) (256)
16:11:21 INFO ├─ Call(Normal) [2_334_465] SystemContext@0x000000000000000000000000000000000000800b::setTxOrigin(address) (373)
16:11:21 INFO ├─ Call(Normal) [2_333_268] initiator@0x4eaf936c172b5e5511959167e8ab4f7031113ca3::executeTransaction(bytes32, bytes32, tuple) (10_820)
16:11:21 INFO │ └─ Call(Normal) [2_296_197] MsgValueSimulator@0x0000000000000000000000000000000000008009::unknown (9_511)
16:11:21 INFO │ ├─ Call(Normal) [2_259_621] L2BaseToken@0x000000000000000000000000000000000000800a::transferFromTo(address, address, uint256) (7_972)
16:11:21 INFO │ │ ├─ Call(Normal) [2_223_711] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ │ ├─ Call(Normal) [2_223_207] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ │ ├─ Call(Normal) [2_222_640] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO │ │ └─ Call(Normal) [2_216_718] EventWriter@0x000000000000000000000000000000000000800d::0x00000000 (251)
16:11:21 INFO │ └─ Call(Mimic) [2_251_368] contract@0x5d4fb5385ed95b65d1cd6a10ed9549613481ab2f::unknown (210)
16:11:21 INFO ├─ Call(Normal) [4_227_737_157] SystemContext@0x000000000000000000000000000000000000800b::setTxOrigin(address) (373)
16:11:21 INFO └─ Call(Normal) [4_227_735_456] L2BaseToken@0x000000000000000000000000000000000000800a::transferFromTo(address, address, uint256) (2_538)
16:11:21 INFO ├─ Call(Normal) [4_161_676_491] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO ├─ Call(Normal) [4_161_675_987] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO ├─ Call(Normal) [4_161_675_483] Keccak@0x0000000000000000000000000000000000008010::0x00000000 (159)
16:11:21 INFO └─ Call(Normal) [4_161_674_853] EventWriter@0x000000000000000000000000000000000000800d::0x00000000 (251)
```

::
Expand All @@ -279,7 +303,7 @@ You can send network calls against a running `anvil-zksync`.
Launch the local `anvil-zksync` node:

```bash
anvil-zksync fork sepolia-testnet
anvil-zksync fork --fork-url sepolia-testnet
```

- Use curl to send a network call:
Expand Down

0 comments on commit a8181b4

Please sign in to comment.