Skip to content

Commit

Permalink
chore: resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
dutterbutter committed Dec 19, 2024
2 parents fe50c9c + e47e7d5 commit db25f0e
Show file tree
Hide file tree
Showing 21 changed files with 233 additions and 70 deletions.
17 changes: 9 additions & 8 deletions content/00.zksync-era/10.guides/20.zksync-101/00.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ npm install -g zksync-cli

## Setup local node

This series of guides will use an in memory node which allows for quicker testing and debugging processes.
This series of guides will use in memory anvil-zksync node which allows for quicker testing and debugging processes.
A great benefit of using a local node is that you will avoid incurring any actual transaction costs.
ZKsync Era node provides a set of rich wallets that come with more than enough ETH to use for development.

### Run a local in memory node
### Run a local in memory anvil-zksync node

To run a local in memory node on your machine, you will need Docker running.
To run a local in memory anvil-zksync node on your machine, you will need Docker running.
The easiest way to start Docker is to run the Docker Desktop app.

We are going to use the "In memory node" module for our local node setup.
Expand Down Expand Up @@ -79,12 +79,13 @@ We are going to use the "In memory node" module for our local node setup.
zksync-cli dev start
```

The in memory node includes pre-configured rich wallets for use, see [in-memory-node rich wallets](/zksync-era/tooling/local-setup/in-memory-node#pre-configured-rich-wallets).
anvil-zksync node includes pre-configured rich wallets for use, see [anvil-zksync rich wallets](/build/test-and-debug/in-memory-node#pre-configured-rich-wallets).

Your in memory node is accessible at **[http://127.0.0.1:8011](http://127.0.0.1:8011/)**, ready for deployment or testing purposes.
Your anvil-zksync node is accessible at **[http://127.0.0.1:8011](http://127.0.0.1:8011/)**, ready for deployment or testing purposes.
You can use the Docker Desktop app to view logs from the running ZKsync Era node or use the `zksync-cli dev logs` command.
When you are done running your in memory node, you can stop it with `zksync-cli dev stop`.
You can learn more about managing a local node with ZKsync CLI on [Running a node](/zksync-era/tooling/zksync-cli/running-a-node).

When you are done running your anvil-zksync node, you can stop it with `zksync-cli dev stop`.
You can learn more about managing a local node with ZKsync CLI on [Running a node](/build/zksync-cli/running-a-node).

## Create the ZKsync 101 project

Expand All @@ -98,7 +99,7 @@ zksync-cli create zksync-101 --template zksync-101
After you run the `create` command, the CLI will download and install packages for the project.
You should see a success message and instructions to get started with your project.

Since we are using a local in memory node for development, we can use one of the
Since we are using a local in memory anvil-zksync node for development, we can use one of the
rich wallets for transactions and deployments.

Rename the `.env.example` to `.env` which includes the private key for the first rich wallet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ In this section you will learn how to:

:check-icon Craft a smart contract to fund Zeek's latest adventure.

:check-icon Deploy the contract onto your local in memory node.
:check-icon Deploy the contract onto your local in memory anvil-zksync node.

:check-icon Interact with the contract with ZKsync CLI

Expand Down Expand Up @@ -94,7 +94,7 @@ Estimated deployment cost: 0.0065057128 ETH

## Interact with the contract

Now that our contract is deployed to our local in memory node, let's interact with it!
Now that our contract is deployed to our local in memory anvil-zksync node, let's interact with it!
We initially set up the crowdfunding campaign with an amount of `.02 ETH` for the goal.

### Read from the contract using ZKsync CLI
Expand Down Expand Up @@ -191,7 +191,7 @@ to interact with the deployed contract using ZKsync CLI!
- **EVM Compatibility:** ZKsync is EVM compatible and you can write smart contracts in Solidity or Vyper.
- **Custom Compilation:** Contracts deployed to ZKsync are compiled using `zksolc` or `zkvyper` as
they generate a special bytecode for ZKsync's ZKEVM.
- **Development Tools:** In memory node is a quick and easy local node environment to deploy to,
- **Development Tools:** In memory anvil-zksync node is a quick and easy local node environment to deploy to,
saving costs on deployment while developing.
- **ZKsync CLI:** A powerful command line tool to interact with contracts easily.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ numerous similar contracts efficiently.

## Setup the project

Make sure to go through the setup provided in the initial [Getting started](/zksync-era/guides/zksync-101) section.
You will have downloaded the 101 project through ZKsync CLI `create` and started up a local in memory node for development.
Make sure to go through the setup provided in the initial [Getting started](/build/start-coding/zksync-101) section.
You will have downloaded the 101 project through ZKsync CLI `create` and started up a local in memory anvil-zksync node for development.

If you haven't started up your local in memory node or you're not sure, run the following:
If you haven't started up your local in memory anvil-zksync node or you're not sure, run the following:

```bash
zksync-cli dev restart
Expand Down
4 changes: 2 additions & 2 deletions content/00.zksync-era/10.guides/20.zksync-101/30.testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ in the second, work flawlessly.
Make sure to go through the setup provided in the initial [Getting started](/zksync-era/guides/zksync-101) section.
You will have downloaded the 101 project through ZKsync CLI `create`.
Since we are using `hardhat-zksync` for testing, you do not need to have the
in memory node running for this section.
in memory anvil-zksync node running for this section.

If your local in-memory node is running, stop it with the following command:
If your local in-memory anvil-zksync node is running, stop it with the following command:

```bash
zksync-cli dev stop
Expand Down
6 changes: 3 additions & 3 deletions content/00.zksync-era/10.guides/20.zksync-101/40.upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ lead you through the strategies and practices for making the `CrowdfundingCampai

## Setup the project

Make sure to go through the setup provided in the initial [Getting started](/zksync-era/guides/zksync-101) section.
You will have downloaded the 101 project through ZKsync CLI `create` and started up a local in-memory node for development.
Make sure to go through the setup provided in the initial [Getting started](/build/start-coding/zksync-101) section.
You will have downloaded the 101 project through ZKsync CLI `create` and started up a local anvil-zksync node for development.

If you haven't started up your local in-memory node or you're not sure, run the following:
If you haven't started up your local in-memory anvil-zksync node or you're not sure, run the following:

```bash
zksync-cli dev restart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ V2_BeaconCrowdfundingCampaign initialized. Transaction Hash: 0x5f3131c77fcac1939
## Verify upgradeable contracts

::callout{icon="i-heroicons-exclamation-triangle" color="amber"}
Since we are using the in memory node for our smart contracts, we do not have the feature
Since we are using the in memory anvil-zksync node for our smart contracts, we do not have the feature
available to verify the smart contract.

The following explains how you can verify an upgraded smart contract on testnet or mainnet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ V2CrowdfundingCampaign initialized. Transaction Hash: 0x3a7cbf9d584457bc6b452964
## Verify upgradable contracts

::callout{icon="i-heroicons-exclamation-triangle" color="amber"}
Since we are using in memory node for our smart contracts, we do not have the feature
Since we are using in memory anvil-zksync node for our smart contracts, we do not have the feature
available to verify the smart contract.

The following explains how you can verify an upgraded smart contract on testnet or mainnet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ V2_UUPSCrowdfundingCampaign initialized! Transaction Hash: 0xab959f588b64dc6dee1
## Verify upgradable contracts

::callout{icon="i-heroicons-exclamation-triangle" color="amber"}
Since we are using the in memory node for our smart contracts, we do not have the feature
Since we are using the in memory anvil-zksync node for our smart contracts, we do not have the feature
available to verify the smart contract.

The following explains how you can verify an upgraded smart contract on testnet or mainnet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and we'll use [Mocha](https://mochajs.org/) as our test runner.
### Prerequisites

- `zksync-cli` installed from the [zksync-cli section](/build/zksync-cli).
- `anvil-zksync` installed and running. See [In-memory Node](/build/test-and-debug/in-memory-node).
- `anvil-zksync` installed and running. See [anvil-zksync](/build/test-and-debug/in-memory-node).

---
## Environment setup
Expand Down
12 changes: 6 additions & 6 deletions content/00.zksync-era/40.tooling/10.local-setup/00.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@ description: Learn about the recommended paths of testing and debugging your pro
ZKsync Era provides two distinct testing environments for your local development needs:

- Dockerized local setup
- In-Memory Node.
- anvil-zksync (in-memory node implementation for ZKsync).

Each solution boasts unique characteristics tailored to diverse use cases.
This section aims to unpack the intricacies of these tools, aiding you in selecting the setup best suited for your development workflow.

---
## In-Memory node vs Dockerized local setup
## anvil-zksync vs Dockerized local setup

The local testing process revolves around two principal options:

1. **Dockerized local setup**: An extensive ZKsync Era network simulation that comprises a Postgres database,
a local Geth node functioning as Layer 1, and the ZKsync node.
Opt for this setup for comprehensive simulations and testing that require interaction with both L1 and L2.

2. **In-Memory node**: A lightweight, speedy alternative, the in-memory node, supports forking the state from various networks,
2. **anvil-zksync**: A lightweight, speedy alternative, the anvil-zksync node, supports forking the state from various networks,
including the mainnet and testnet. This choice is ideal for swift testing, prototyping, and bootloader and system contract testing.

### When to use each

- Use the **Dockerized local setup** for in-depth simulations and tests that necessitate L1 and L2 interaction.
This detailed setup mirrors how your contracts will function within the mainnet ZKsync Era network.

- Opt for the **In-Memory node** for swift testing, prototyping, or testing new changes via the local bootloader and system contracts.
- Opt for the **anvil-zksync** for swift testing, prototyping, or testing new changes via the local bootloader and system contracts.
This setup facilitates forking the state from the mainnet or testnet, suitable for replaying transactions
or observing the impact of modifications on existing contracts.

### Feature comparison

The following table highlights the key characteristics of each testing environment for a quick comparison:

| Feature | In-memory node | Dockerized local setup |
| Feature | anvil-zksync | Dockerized local setup |
| --------------------------------------- | ------------------- | ---------------------- |
| Quick startup | Yes | No |
| Supports forking state | Yes | No |
Expand All @@ -51,5 +51,5 @@ The following table highlights the key characteristics of each testing environme
| Websocket support | No | Yes |

Whether you're testing new contracts, debugging transactions, or prototyping, ZKsync Era provides robust options for local testing.
Both the Dockerized local setup and the In-Memory Node offer feature-rich and quick setup options, each with their distinct strengths and limitations.
Both the Dockerized local setup and the anvil-zksync offer feature-rich and quick setup options, each with their distinct strengths and limitations.
Choose the most appropriate setup based on your specific needs, and happy testing!
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: In-Memory Node
title: anvil-zksync
description: Learn how to setup a local in-memory anvil-zksync.
---

Expand All @@ -12,18 +12,18 @@ some features might not be fully supported yet and may not work as fully intende
It is [open-sourced](%%zk_git_repo_era-test-node%%) and contributions are welcomed.
::

## Understand the In-Memory Node
## Understand anvil-zksync

The In-Memory Node uses an in-memory database for storing state information and simplified hashmaps for tracking blocks and transactions.
anvil-zksync uses an in-memory database for storing state information and simplified hashmaps for tracking blocks and transactions.
In fork mode, it retrieves missing storage data from a remote source when not available locally.
Moreover it also uses the remote server (openchain) to resolve the ABI and topics to human readable names.

You can visit the `anvil-zksync` repository [to learn more](%%zk_git_repo_era-test-node%%).

## Run actions with `zksync-cli`

You can setup the In-Memory Node quickly with `zksync-cli dev start`.
If you don't have `zksync-cli` setup, see the [Overview](/zksync-era/tooling/zksync-cli) guide.
You can setup `anvil-zksync` quickly with `zksync-cli dev start`.
If you don't have `zksync-cli` setup, see the [Overview](/build/zksync-cli) guide.

Note: at the moment this method won't allow you to use additional features like forking networks or replaying transactions.

Expand Down Expand Up @@ -56,7 +56,7 @@ The expected output will be as follows:
testing
18:02:50 INFO Version: 0.1.0-alpha.34
18:02:50 INFO Repository: https://github.com/matter-labs/era-test-node
18:02:50 INFO Repository: https://github.com/matter-labs/anvil-zksync
18:02:50 INFO Rich Accounts
Expand All @@ -80,7 +80,7 @@ testing
```
::callout{icon="i-heroicons-information-circle-16-solid" color="amber"}
When utilizing `anvil-zksync` with MetaMask, it's essential to note that any restart of the in-memory node
When utilizing `anvil-zksync` with MetaMask, it's essential to note that any restart of the node
will necessitate a reset of MetaMask's cached account data (nonce, etc).
In the MetaMask app, navigate to 'Settings', then 'Advanced', and finally, select 'Clear activity tab data'.
::
Expand All @@ -101,7 +101,7 @@ As a result, an L1 RPC is not available.
### Pre-configured rich wallets
In-Memory node includes pre-configured "rich" accounts for testing:
anvil-zksync includes pre-configured "rich" accounts for testing:
:display-partial{path="_partials/_rich-wallets"}
Expand Down Expand Up @@ -276,7 +276,7 @@ Here's an example of what you should expect to see when `show-calls` and `resolv

You can send network calls against a running `anvil-zksync`.

Launch the local in-memory node:
Launch the local in-memory anvil-zksync node:

```bash
anvil-zksync fork sepolia-testnet
Expand Down Expand Up @@ -370,7 +370,7 @@ forge create contracts/Greeter.sol:Greeter \
---
## Test bootloader and system contracts
In-memory node allows testing of the currently compiled bootloader and system contracts.
anvil-zksync allows testing of the currently compiled bootloader and system contracts.
This makes it possible to examine the effects of changes on already deployed contracts.
::callout{icon="i-heroicons-information-circle-16-solid" color="amber"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The following are examples of configuration for your GitHub Action.
### Quickstart

```yaml
name: Run Era Test Node Action
name: Run anvil-zksync Action

on:
push:
Expand All @@ -62,7 +62,7 @@ jobs:
With configuration options:
```yaml
name: Run Era Test Node Action
name: Run anvil-zksync Action

on:
push:
Expand All @@ -76,7 +76,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Run Era Test Node
- name: Run anvil-zksync
uses: dutterbutter/anvil-zksync-action@v1
with:
mode: "run"
Expand All @@ -93,7 +93,7 @@ jobs:
With upload log file to artifacts:
```yaml
name: Run Era Test Node Action
name: Run anvil-zksync Action

on:
pull_request:
Expand All @@ -111,7 +111,7 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v3

- name: Run Era Test Node
- name: Run anvil-zksync
uses: dutterbutter/anvil-zksync-action@v1
with:
mode: "fork"
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
With Fork:
```yaml
name: Run Era Test Node Action
name: Run anvil-zksync Action

on:
push:
Expand All @@ -158,7 +158,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Run Era Test Node
- name: Run anvil-zksync
uses: dutterbutter/anvil-zksync-action@v1
with:
mode: "fork"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,26 +189,26 @@ See differences with EVM opcodes in [EVM instructions](/zksync-protocol/differen

ZKSync provides different EraVM node implementations to test smart contracts locally:

- In-Memory Node: fast L2 node with non-persistent state.
- anvil-zksync (in-memory node implementation for ZKsync): fast L2 node with non-persistent state.
- Dockerized setup: L1 and L2 nodes with persistent state but slower performance.

Unless your project contains L1-L2 features, testing with the In-Memory Node is recommended, which is included in the `@matterlabs/hardhat-zksync` plugin.
Unless your project contains L1-L2 features, testing with the anvil-zksync is recommended, which is included in the `@matterlabs/hardhat-zksync` plugin.

::callout{icon="i-heroicons-exclamation-triangle" color="amber"}
In version `1.0.12`, `hardhat-network-helpers` introduced support for both In-Memory Node and Dockerized setups, allowing methods
In version `1.0.12`, `hardhat-network-helpers` introduced support for both in-memory anvil-zksync node and Dockerized setups, allowing methods
such as `loadFixture` to be utilized in test files.
::

You can read more about each node in the [Testing section of the docs](/zksync-era/tooling/local-setup).

### Running unit tests on In-Memory Node
### Running unit tests on anvil-zksync node

To run tests using In-Memory Node, follow these steps:
To run tests using anvil-zksync node, follow these steps:

1. Add the `zksync:true` flag to the `hardhat` network in the `hardhat.config.ts` file to override Hardhat's default node with ZKsync In-Memory Node.
1. Add the `zksync:true` flag to the `hardhat` network in the `hardhat.config.ts` file to override Hardhat's default node with anvil-zksync node.
1. Run the test task with `npx hardhat test --network hardhat` (or make `hardhat` the default network).
You can find more info about testing with the In-Memory-Node in [Hardhat-ZKsync node](/zksync-era/tooling/hardhat/plugins/hardhat-zksync-node#running-hardhats-test-task-with-hardhat-zksync-node).
You can find more info about testing with the `anvil-zksync` in [Hardhat-ZKsync node](/build/tooling/hardhat/plugins/hardhat-zksync-node#running-hardhats-test-task-with-hardhat-zksync-node).
### Running tests on Dockerized setup
Expand Down
Loading

0 comments on commit db25f0e

Please sign in to comment.