• Stars
    star
    311
  • Rank 133,667 (Top 3 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created about 1 year ago
  • Updated 10 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

In-memory node that can be used for integration testing and debugging.

πŸš€ zkSync Era In-Memory Node πŸš€

This crate provides an in-memory node that supports forking the state from other networks.

The goal of this crate is to offer a fast solution for integration testing, bootloader and system contract testing, and prototyping.

πŸ”— For a detailed walkthrough, refer to the official documentation.

πŸ“Œ Overview

The In-Memory Node is designed for local testing and uses an in-memory database for storing state information. It also employs simplified hashmaps for tracking blocks and transactions. When in fork mode, it fetches missing storage data from a remote source if not available locally. Additionally, it uses the remote server (openchain) to resolve the ABI and topics to human-readable names.

⚠️ Caution

Please note that era-test-node is still in its alpha stage. Some features might not be fully supported yet and may not work as intended. However, it is open-sourced, and contributions are welcome!

πŸ“Š Limitations & Features

🚫 Limitations βœ… Features
No communication between Layer 1 and Layer 2. Can fork the state of mainnet, testnet, or custom network.
No support for accessing historical data. Uses local bootloader and system contracts.
Only one transaction allowed per Layer 1 batch. Operates deterministically in non-fork mode.
Redeploy requires MetaMask cache reset. Supports hardhat's console.log debugging.
Resolves names of ABI functions and Events using openchain.
Can replay existing mainnet or testnet transactions.
Starts up quickly with pre-configured 'rich' accounts.

πŸ›  Prerequisites

  1. Rust: era-test-node is written in Rust. Ensure you have Rust installed on your machine. Download Rust here.

  2. Other Dependencies: This crate relies on rocksDB. If you face any compile errors due to rocksDB, install the necessary dependencies with:

    apt-get install -y cmake pkg-config libssl-dev clang

πŸ“₯ Installation & Setup

  1. Download era-test-node from latest Release

  2. Extract the binary and mark as executable:

    tar xz -f era_test_node.tar.gz -C /usr/local/bin/
    chmod +x /usr/local/bin/era_test_node
  3. Start the node:

    era_test_node run

πŸ§‘β€πŸ’» Running Locally

  1. Compile Rust project and start the node:
    make run

πŸ“„ System Contracts

The system contract within the node can be specified via the --dev-system-contracts option. It can take one of the following options:

  • built-in: Use the compiled built-in contracts
  • built-in-no-verify: Use the compiled built-in contracts, but without signature verification
  • local: Load contracts from ZKSYNC_HOME

πŸ“ƒ Logging

The node may be started in either of debug, info, warn or error logging levels via the --log option:

era_test_node --log=error run

Additionally, the file path can be provided via the --log-file-path option (defaults to ./era_test_node.log):

era_test_node --log=error --log-file-path=run.log run

The logging can be configured during runtime via the config_setLogLevel and config_setLogging methods.

πŸ“ƒ Caching

The node will cache certain network request by default to disk in the .cache directory. Alternatively the caching can be disabled or set to in-memory only via the --cache=none|memory|disk parameter.

era_test_node --cache=none run
era_test_node --cache=memory run

Additionally when using --cache=disk, the cache directory may be specified via --cache-dir and the cache may be reset on startup via --reset-cache parameters.

era_test_node --cache=disk --cache-dir=/tmp/foo --reset-cache run

🌐 Network Details

Note: The existing implementation does not support communication with Layer 1. As a result, an L1 RPC is not available.

🍴 Forking Networks

To fork the mainnet:

era_test_node fork mainnet

Tip: You can also fork the zkSync Sepolia testnet with era_test_node fork sepolia-testnet.

πŸ”„ Replay Remote Transactions Locally

If you wish to replay a remote transaction locally for deep debugging, use the following command:

era_test_node replay_tx <network> <transaction_hash>

πŸ“ž Sending Network Calls

You can send network calls against a running era-test-node. For example, to check the testnet LINK balance or mainnet USDT, use curl or foundry-zksync.

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0x40609141Db628BeEE3BfAB8034Fc2D8278D0Cc78", "data":"0x06fdde03"}, "latest"],"id":1}' http://localhost:8011

πŸ” Seeing more details of the transactions

By default, the tool is just printing the basic information about the executed transactions (like status, gas used etc).

But with --show-calls flag, it can print more detailed call traces, and with --resolve-hashes, it will ask openchain for ABI names.

era_test_node --show-calls=user --resolve-hashes replay_tx sepolia-testnet 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

You can use the following options to get more granular information during transaction processing:

  • --show-storage-logs <SHOW_STORAGE_LOGS>: Show storage log information.
    [default: none]
    [possible values: none, read, paid, write, all]

  • --show-vm-details <SHOW_VM_DETAILS>: Show VM details information.
    [default: none]
    [possible values: none, all]

  • --show-gas-details <SHOW_GAS_DETAILS>: Show Gas details information.
    [default: none]
    [possible values: none, all]

Example:

era_test_node --show-storage-logs=all --show-vm-details=all --show-gas-details=all run

πŸ’° Using Rich Wallets

For testing and development purposes, the era-test-node comes pre-configured with a set of 'rich' wallets. These wallets are loaded with test funds, allowing you to simulate transactions and interactions without the need for real assets.

Here's a list of the available rich wallets:

Account Address Private Key
0x36615Cf349d7F6344891B1e7CA7C72883F5dc049 0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110
0xa61464658AfeAf65CccaaFD3a512b69A83B77618 0xac1e735be8536c6534bb4f17f06f6afc73b2b5ba84ac2cfb12f7461b20c0bbe3
0x0D43eB5B8a47bA8900d84AA36656c92024e9772e 0xd293c684d884d56f8d6abd64fc76757d3664904e309a0645baf8522ab6366d9e
0xA13c10C0D5bd6f79041B9835c63f91de35A15883 0x850683b40d4a740aa6e745f889a6fdc8327be76e122f5aba645a5b02d0248db8
0x8002cD98Cfb563492A6fB3E7C8243b7B9Ad4cc92 0xf12e28c0eb1ef4ff90478f6805b68d63737b7f33abfa091601140805da450d93
0x4F9133D1d3F50011A6859807C837bdCB31Aaab13 0xe667e57a9b8aaa6709e51ff7d093f1c5b73b63f9987e4ab4aa9a5c699e024ee8
0xbd29A1B981925B94eEc5c4F1125AF02a2Ec4d1cA 0x28a574ab2de8a00364d5dd4b07c4f2f574ef7fcc2a86a197f65abaec836d1959
0xedB6F5B4aab3dD95C7806Af42881FF12BE7e9daa 0x74d8b3a188f7260f67698eb44da07397a298df5427df681ef68c45b34b61f998
0xe706e60ab5Dc512C36A4646D719b889F398cbBcB 0xbe79721778b48bcc679b78edac0ce48306a8578186ffcb9f2ee455ae6efeace1
0xE90E12261CCb0F3F7976Ae611A29e84a6A85f424 0x3eb15da85647edd9a1159a4a13b9e7c56877c4eb33f614546d4db06a51868b1c

Feel free to use these wallets in your tests, but remember, they are for development purposes only and should not be used in production or with real assets.

πŸ”§ Supported APIs

See our list of Supported APIs here.

πŸ€– CI/CD Testing with GitHub Actions

A GitHub Action is available for integrating era-test-node into your CI/CD environments. This action offers high configurability and streamlines the process of testing your applications in an automated way.

You can find this GitHub Action in the marketplace here.

πŸ“ Example Usage

Below is an example yaml configuration to use the era-test-node GitHub Action in your workflow:

name: Run Era Test Node Action

on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Run Era Test Node
      uses: dutterbutter/era-test-node-action@latest

🀝 Contributing

We welcome contributions from the community! If you're interested in contributing to the zkSync Era In-Memory Node, please take a look at our CONTRIBUTING.md for guidelines and details on the process.

Thank you for making zkSync Era In-Memory Node better! πŸ™Œ

More Repositories

1

awesome-zero-knowledge-proofs

A curated list of awesome things related to learning Zero-Knowledge Proofs (ZKP).
5,133
star
2

zksync

zkSync: trustless scaling and privacy engine for Ethereum
Rust
4,867
star
3

zksync-era

zkSync era
Rust
3,074
star
4

zksync-web-era-docs

zkSync Era Documentation
JavaScript
986
star
5

zksync-lite-docs

zkSync Lite documentation
Shell
778
star
6

zksync-wallet-vue

zkSync Lite web wallet
Vue
521
star
7

era-contracts

Smart Contract Submodule For zkSync Era
Solidity
471
star
8

l2-intro-pre-ethdenver

Introduction to layer two and zkSync
TypeScript
356
star
9

zinc

The Zinc language public repository
Rust
310
star
10

era-boojum

Boojum, the scariest SNARK implementation.
Rust
299
star
11

foundry-zksync

Fork of Foundry tailored for zkSync environment
Rust
287
star
12

hardhat-zksync

TypeScript
281
star
13

era-sync_vm

Circuit Implementation of zkVM for zkSync Era
Rust
275
star
14

era-system-contracts

Implementation of the system contracts
Solidity
202
star
15

zksync-cli

CLI tool that simplifies ZKsync development
TypeScript
159
star
16

era-tutorial-examples

[DEPRECATED ]Full examples for tutorials in the zkSync Era documentation. Visit: https://github.com/matter-labs/tutorials
TypeScript
130
star
17

zksync-dapp-checkout

zkCheckout β€” trustable permissionless DeFi payment gateway. Fast & cheap transfers / simple & quick withdrawal
Vue
124
star
18

block-explorer

zkSync Era Block Explorer
TypeScript
121
star
19

paymaster-examples

Ready to use paymaster contracts for zkSync Era
TypeScript
105
star
20

era-zk_evm

Out-of-circuit zkEVM implementation
Rust
80
star
21

hodor

Open source implementation of zkSTARKs in pure Rust
Rust
79
star
22

era-bellman-cuda

A library implementing GPU-accelerated cryptographic functionality for the zkSync prover
Cuda
69
star
23

eip1962

EIP1962 implementation effort
Rust
65
star
24

franklin-crypto

Rust
63
star
25

local-setup

zkSync 2.0 setup for local development
Shell
62
star
26

zksync-hardhat-template

[DEPRECATED] Template project for zksync-hardhat
TypeScript
62
star
27

v2-testnet-contracts

Solidity
61
star
28

era-compiler-solidity

Solidity compiler for ZKsync
Rust
61
star
29

era-zkevm_test_harness

Compare in-circuit and out-of-circuit VMs
Rust
59
star
30

era-zkevm_circuits

Rust
58
star
31

era-consensus

Consensus layer implementation for zkSync Era
Rust
56
star
32

zksolc-bin

Releases of the Solidity compiler for ZKsync
54
star
33

zksync-withdrawal-finalizer

zkSync 2.0 Withdrawal Finalizer
Rust
54
star
34

zk_os

OS for next iteration of the world computer
Rust
42
star
35

zksync-link

PayNow - Create payment links, get paid in tokens
Svelte
41
star
36

tutorials

TypeScript
40
star
37

rescue-poseidon

Rescue and Poseidon hash function implementations
Rust
40
star
38

curve-zinc

The Curve Stableswap smart contract implementation in Zinc v0.2.2.
Rust
39
star
39

solidity_plonk_verifier

Solidity verifier for Plonk
Solidity
38
star
40

recursive_aggregation_circuit

Kate commitment based PLONK recursive aggregation circuit
Solidity
38
star
41

era-zkevm_opcode_defs

Definitions of zkEVM opcodes (primary dependency for all other repos)
Rust
37
star
42

era-compiler-vyper

Vyper compiler for ZKsync
Rust
33
star
43

schnorr-musig

Simple Schnorr Multi-Signatures
Rust
28
star
44

zkSync-account-abstraction-template

28
star
45

zksync-contract-templates

Contract Templates for zkSync: solidity, hardhat, vyper
TypeScript
28
star
46

era-shivini

A library implementing GPU-accelerated zkSync prover.
Rust
27
star
47

custom-aa-tutorial

A full example for the tutorial on custom AA
Solidity
27
star
48

zkvyper-bin

Releases of the Vyper compiler for ZKsync
27
star
49

era-compiler-llvm

ZKsync fork of the LLVM framework
C++
26
star
50

cross-chain-tutorial

TypeScript
25
star
51

era-boojum-cuda

A library implementing GPU-accelerated cryptographic functionality for the zkSync prover.
Rust
25
star
52

era-heavy-ops-service

Specialized GPU Prover for zkSync Era
Rust
24
star
53

compiler-solidity

The zkEVM Solidity compiler.
Rust
22
star
54

hackathon-winner-projects

A list of all the projects submitted in all zksync hackathons.
22
star
55

era-boojum-validator-cli

Rust
20
star
56

zksync-web-landing

zkSync.io landing page
CSS
20
star
57

risc_v_simulator

Rust
19
star
58

era-zkevm_tester

Adapter between zk_evm and era-compiler-tester
Rust
19
star
59

custom-paymaster-tutorial

Full example for the custom paymaster tutorial in the documentation
TypeScript
19
star
60

z-prize-msm-gpu

Submission for https://www.zprize.io/prizes/accelerating-msm-operations-on-gpu-fpga
Cuda
19
star
61

era-compiler-llvm-context

Shared front-end code of the ZKsync compilers
Rust
17
star
62

vm2

High performance EraVM for zkSync.
Rust
15
star
63

z-prize-msm-gpu-combined

Combined solution from Matter Labs and Yrrid based on their respective submissions for the Z-Prize category Accelerating MSM Operations on GPU/FPGA
Cuda
15
star
64

era-compiler-tester

Integration testing framework for ZKsync compilers
Rust
14
star
65

era-compiler-tests

Collection of tests for ZKsync compilers
Solidity
13
star
66

eravm-spec

Coq
13
star
67

compiler-llvm

The zkEVM fork of the LLVM framework
12
star
68

era-revm

revm (Rust Ethereum VM) translation for Era / zkEVM
Rust
11
star
69

era-solidity

ZKsync fork of the original Solidity compiler
C++
11
star
70

era-compiler-llvm-builder

ZKsync LLVM framework builder
Rust
10
star
71

ETHLisbon-2022-hackathon

Information about MatterLabs bounty program for ETH Lisbon 2022 hackathon
TypeScript
10
star
72

era-hardhat-with-plugins

A zkSync Hardhat project configured with multiple plugins to improve the developer experience
TypeScript
10
star
73

era-zkEVM-assembly

The zkEVM assembly tools
Rust
10
star
74

zksync-packages-info

Information about the different packages and SDKs by MatterLabs to interact with zkSync Era
Vue
10
star
75

.github

zkSync Frontend Team workflow configuration
10
star
76

zksync-v2-issues

Report issues encountered when using the zkSync 2.0 testnet.
9
star
77

proof_system_info_v1.0

Information about proof system used in zkSync v1.0
8
star
78

aa-signature-checker

TypeScript
8
star
79

era-zk_evm_abstractions

Rust
8
star
80

vise

Tools to define and export metrics in Rust libraries and apps
Rust
8
star
81

zksync-frontend-templates

Frontend Templates for zkSync: vue, react, next, wagmi
TypeScript
8
star
82

l2-intro-ethdenver

Introduction to layer 2 protocols and smart contract examples on zkSync for ETH Denver
Vue
8
star
83

vault-auth-tee

Hashicorp Vault plugin for authenticating Trusted Execution Environments (TEE) like SGX enclaves
Go
8
star
84

nixsgx

Reproducible Nix packages for TEEs
Nix
8
star
85

eip1962_specs

Specification documents for EIP1962
7
star
86

compiler-infra

Docker images with build tools for compiler repos
Dockerfile
7
star
87

demo-circuit

Rust
7
star
88

zkcli-block-explorer

zkSync Block Explorer module for zkcli
TypeScript
7
star
89

zksync-hardhat-vyper-template

[DEPRECATED] Template project for zksync-cli. Includes a Vyper smart contract, tests and script to deploy to zkSync Era
TypeScript
7
star
90

compiler-tests

The compiler tests collection
Solidity
6
star
91

zksync-hardhat-ft-template

Template for a fungible token project on zkSync Era
TypeScript
6
star
92

zksync-dapp-forced-exit

CSS
6
star
93

simple-oracle-benchmarking

Deploy a simplified oracle, track gas usage.
TypeScript
6
star
94

gated-nft-tutorial

TypeScript
5
star
95

teepot

Key Value store in a TEE with Remote Attestation for Authentication
Rust
5
star
96

ansible-en-role

Ansible role for zkSync Era External Node
Jinja
5
star
97

l2-intro-demo

Introduction to layer 2 protocols and smart contract examples on zkSync
TypeScript
5
star
98

multisig

JavaScript
5
star
99

gated-nft-tutorial-starter

TypeScript
5
star
100

greeter-tutorial-starter

Vue
5
star