Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update naming from era_test_node to anvil-zksync #1567

Merged
merged 10 commits into from
Dec 10, 2024
38 changes: 20 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ jobs:

- uses: actions/checkout@v3

- name: Run Era Test Node
uses: dutterbutter/era-test-node-action@latest
- name: Run anvil-zksync
uses: dutterbutter/[email protected]
with:
logFilePath: "anvil_zksync.log"

- name: Run fixture-projects script
run: |
cd e2e
chmod +x run-fixture-projects.sh
./run-fixture-projects.sh
cd e2e
chmod +x run-fixture-projects.sh
./run-fixture-projects.sh
shell: bash

examples:
Expand All @@ -108,8 +110,8 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Run Era Test Node
uses: dutterbutter/era-test-node-action@latest
- name: Run anvil-zksync
uses: dutterbutter/anvil-zksync-action@v1.1.0

- uses: pnpm/action-setup@v3

Expand Down Expand Up @@ -145,9 +147,9 @@ jobs:

- name: Test node example
run: |
cd examples/node-example
pnpm hardhat compile
pnpm hardhat test
cd examples/node-example
pnpm hardhat compile
pnpm hardhat test

- name: Test noninline libraries example
run: |
Expand Down Expand Up @@ -178,7 +180,7 @@ jobs:
pnpm hardhat run scripts/deploy-box-uups-factory.ts
pnpm hardhat run scripts/upgrade-box-uups-factory.ts
pnpm hardhat run scripts/upgrade-box-beacon-factory.ts
pnpm hardhat run scripts/upgrade-box-factory.ts
pnpm hardhat run scripts/upgrade-box-factory.ts

- name: Test upgradable example
run: |
Expand All @@ -189,7 +191,7 @@ jobs:
pnpm hardhat run scripts/deploy-box-uups.ts
pnpm hardhat run scripts/upgrade-box-beacon.ts
pnpm hardhat run scripts/upgrade-box-uups.ts
pnpm hardhat run scripts/upgrade-box.ts
pnpm hardhat run scripts/upgrade-box.ts

- name: Test zksync-ethers example
run: |
Expand All @@ -208,8 +210,8 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Run Era Test Node
uses: dutterbutter/era-test-node-action@latest
- name: Run anvil-zksync
uses: dutterbutter/anvil-zksync-action@v1.1.0

- uses: pnpm/action-setup@v3

Expand Down Expand Up @@ -295,8 +297,8 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Run Era Test Node
uses: dutterbutter/era-test-node-action@latest
- name: Run anvil-zksync
uses: dutterbutter/anvil-zksync-action@v1.1.0

- uses: pnpm/action-setup@v3

Expand Down Expand Up @@ -328,8 +330,8 @@ jobs:

- uses: actions/checkout@v3

- name: Run Era Test Node
uses: dutterbutter/era-test-node-action@latest
- name: Run anvil-zksync
uses: dutterbutter/anvil-zksync-action@v1.1.0

- uses: pnpm/action-setup@v3

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Here is an overview of the plugins currently available:
| hardhat-zksync-vyper | Streamlines the compilation of Vyper contracts for deployment on the ZKsync network. |
| hardhat-zksync | Offers a suite of ZKsync-related Hardhat plugins in one package, enhancing accessibility and efficiency. |
| hardhat-zksync-upgradeable | Enables easier deployment and upgrading of smart contracts on the ZKsync network, improving contract lifecycle management. |
| hardhat-zksync-node | Convenient plugin to run the ZKsync era-test-node locally. |
| hardhat-zksync-node | Convenient plugin to run the anvil-zksync locally. |
| hardhat-zksync-ethers | A zksync-ethers SDK wrapper providing additional methods for accelerated development on ZKsync. |

You can find more detailed explanations on how to use hardhat ZKsync plugins on our [documentation page](https://docs.zksync.io/build/tooling/hardhat/getting-started) where each plugin has its own section:
Expand Down
2 changes: 1 addition & 1 deletion e2e/fixture-projects/node/preprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cat <<EOF > "$SCRIPT_DIR/package.json"
{
"name": "@matterlabs/hardhat-zksync-node",
"version": "1.0.3",
"description": "Hardhat plugin to run ZKsync era-test-node locally",
"description": "Hardhat plugin to run anvil-zksync locally",
"repository": "github:matter-labs/hardhat-zksync",
"homepage": "https://github.com/matter-labs/hardhat-zksync/tree/main/packages/hardhat-zksync-node",
"author": "Matter Labs",
Expand Down
2 changes: 1 addition & 1 deletion e2e/fixture-projects/node/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sleep 10

LOG_FILE="./era_test_node.log"

if grep -q "Listening on 127.0.0.1:8012" "$LOG_FILE"; then
if grep -q "Listening on 0.0.0.0:8012" "$LOG_FILE"; then
echo "ZKsync node started successfully."
else
echo "Failed to start ZKsync node. Exiting with code 1."
Expand Down
7 changes: 3 additions & 4 deletions examples/deploy-example/deploy-ZKsync/002_deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ const deployScript = async function (hre: HardhatRuntimeEnvironment) {
// This contract has no constructor arguments.
const factoryContract = await hre.deployer.deploy(artifact, [], 'create2', {
customData: {
salt: '0x7935910912126667836566922594852029127629416664760357073852948630'
}
salt: '0x7935910912126667836566922594852029127629416664760357073852948630',
},
});

// Show the contract info.
const contractAddress = await factoryContract.getAddress();
console.info(chalk.green(`${artifact.contractName} was deployed to ${contractAddress}!`));
}
};

export default deployScript;

deployScript.tags = ['first'];

4 changes: 2 additions & 2 deletions examples/node-example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ZKsync Era node environment example

This project demonstrates how to run [era-test-node](https://docs.zksync.io/build/test-and-debug/in-memory-node) locally using the zksync's `hardhat-zksync-node` Hardhat plugin for testing purposes.
This project demonstrates how to run [anvil-zksync](https://docs.zksync.io/build/test-and-debug/in-memory-node) locally using the zksync's `hardhat-zksync-node` Hardhat plugin for testing purposes.

## Prerequisites

Expand Down Expand Up @@ -50,4 +50,4 @@ yarn hardhat test

- `yarn hardhat compile`: compiles all the contracts in the `contracts` folder.
- `yarn hardhat deploy-zksync`: runs all the deploy scripts in the `deploy` folder.
- `yarn hardhat test`: runs all the tests against the era-test-node instance instantiated in a separate process.
- `yarn hardhat test`: runs all the tests against the anvil-zksync instance instantiated in a separate process.
4 changes: 2 additions & 2 deletions packages/hardhat-zksync-node/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# hardhat-zksync-node 🚀

ZKsync Era [Hardhat](https://hardhat.org/) plugin to run the ZKsync era-test-node locally.
ZKsync Era [Hardhat](https://hardhat.org/) plugin to run anvil-zksync locally.

![Era Logo](https://github.com/matter-labs/era-contracts/raw/main/eraLogo.svg)

Expand Down Expand Up @@ -35,7 +35,7 @@ This command runs a local ZKsync In-memory node by initiating a JSON-RPC server.
|-------------------------------------|----------------------------------------------------------------------------------------------------------------------|
| --port | Port on which the server should listen. Defaults to 8011. |
| --log | Log filter level. Accepted values are: error, warn, info, and debug. Defaults to info. |
| --log-file-path | Path to the file where logs should be written. Defaults to era_test_node.log |
| --log-file-path | Path to the file where logs should be written. Defaults to anvil-zksync.log |
| --cache | Type of cache to use. Accepted values are: none, disk, and memory. Defaults to disk. |
| --cache-dir | Directory location for the disk cache. Defaults to .cache |
| --reset-cache | Flag to reset the local disk cache. |
Expand Down
4 changes: 3 additions & 1 deletion packages/hardhat-zksync-node/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@matterlabs/hardhat-zksync-node",
"version": "1.2.0",
"description": "Hardhat plugin to run ZKsync era-test-node locally",
"description": "Hardhat plugin to run anvil-zksync locally",
"repository": "github:matter-labs/hardhat-zksync",
"homepage": "https://github.com/matter-labs/hardhat-zksync/tree/main/packages/hardhat-zksync-node",
"author": "Matter Labs",
Expand Down Expand Up @@ -42,6 +42,7 @@
"undici": "^6.18.2",
"sinon-chai": "^3.7.0",
"sinon": "^18.0.0",
"semver": "^7.6.2",
"source-map-support": "^0.5.21",
"debug": "^4.3.5"
},
Expand All @@ -50,6 +51,7 @@
"@types/fs-extra": "^11.0.4",
"@types/mocha": "^10.0.6",
"@types/node": "^18.11.17",
"@types/semver": "^7.5.8",
"@types/proxyquire": "^1.3.31",
"@types/sinon-chai": "^3.2.10",
"@typescript-eslint/eslint-plugin": "^7.12.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/hardhat-zksync-node/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const PLUGIN_NAME = '@matterlabs/hardhat-zksync-node';

export const ZKNODE_BIN_OWNER = 'matter-labs';
export const ZKNODE_BIN_REPOSITORY_NAME = 'era-test-node';
export const ZKNODE_BIN_REPOSITORY = 'https://github.com/matter-labs/era-test-node';
export const ZKNODE_BIN_REPOSITORY_NAME = 'anvil-zksync';
export const ZKNODE_BIN_REPOSITORY = 'https://github.com/matter-labs/anvil-zksync';
// User agent of MacOSX Chrome 120.0.0.0
export const USER_AGENT =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
Expand All @@ -16,7 +16,7 @@ export const PROCESS_TERMINATION_SIGNALS = ['SIGINT', 'SIGTERM', 'SIGKILL'];

export const ALLOWED_LOG_VALUES = ['error', 'warn', 'info', 'debug'];
export const ALLOWED_CACHE_VALUES = ['none', 'disk', 'memory'];
export const ALLOWED_FORK_VALUES = ['testnet', 'mainnet'];
export const ALLOWED_FORK_VALUES = ['sepolia-testnet', 'mainnet'];
export const ALLOWED_SHOW_CALLS_VALUES = ['none', 'user', 'system', 'all'];
export const ALLOWED_SHOW_STORAGE_LOGS_VALUES = ['none', 'read', 'write', 'all'];
export const ALLOWED_SHOW_VM_DETAILS_VALUES = ['none', 'all'];
Expand All @@ -38,7 +38,7 @@ export const MAX_PORT_ATTEMPTS = 10;
export const PORT_CHECK_DELAY = 500;
export const RPC_ENDPOINT_PATH = 'eth_chainId';

export const ZKSYNC_ERA_TEST_NODE_NETWORK_NAME = 'zkSyncEraTestNode';
export const ZKSYNC_ERA_TEST_NODE_NETWORK_NAME = 'AnvilZKsync';
export const BASE_URL = `http://127.0.0.1`;
export const NETWORK_ACCOUNTS = {
REMOTE: 'remote',
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat-zksync-node/src/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export class RPCServerDownloader {
private async _download(tag: any): Promise<void> {
const url: any = await getNodeUrl(ZKNODE_BIN_REPOSITORY, tag);
try {
console.info(chalk.yellow(`Downloading era-test-node binary, release: ${tag}`));
console.info(chalk.yellow(`Downloading anvil-zksync binary, release: ${tag}`));
await download(url, await this._createBinaryPath(tag), PLUGIN_NAME, tag, 30000);
await this._postProcessDownload(tag);
console.info(chalk.green('era-test-node binary downloaded successfully'));
console.info(chalk.green('anvil-zksync binary downloaded successfully'));
} catch (error: any) {
throw new ZkSyncNodePluginError(`Error downloading binary from URL ${url}: ${error.message}`);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat-zksync-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ task(TASK_NODE, 'Start a ZKSync Node')
.addOptionalParam('log', 'Log filter level (error, warn, info, debug) - default: info', undefined, types.string)
.addOptionalParam(
'logFilePath',
'Path to the file where logs should be written - default: `era_test_node.log`',
'Path to the file where logs should be written - default: `anvil-zksync.log`',
undefined,
types.string,
)
Expand Down Expand Up @@ -155,7 +155,7 @@ task(TASK_NODE_ZKSYNC, 'Starts a JSON-RPC server for ZKsync node')
.addOptionalParam('log', 'Log filter level (error, warn, info, debug) - default: info', undefined, types.string)
.addOptionalParam(
'logFilePath',
'Path to the file where logs should be written - default: `era_test_node.log`',
'Path to the file where logs should be written - default: `anvil-zksync.log`',
undefined,
types.string,
)
Expand Down
13 changes: 8 additions & 5 deletions packages/hardhat-zksync-node/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { Dispatcher } from 'undici';
import { getCompilersDir } from 'hardhat/internal/util/global-dir';
import { createProvider } from 'hardhat/internal/core/providers/construction';
import { HardhatConfig } from 'hardhat/types';
import semver from 'semver';

import {
ALLOWED_CACHE_VALUES,
Expand All @@ -34,7 +35,7 @@ import { CommandArguments } from './types';
import { RPCServerDownloader } from './downloader';
import { JsonRpcServer } from './server';

// Generates command arguments for running the era-test-node binary
// Generates command arguments for running the anvil-zksync binary
export function constructCommandArgs(args: CommandArguments): string[] {
const commandArgs: string[] = [];

Expand Down Expand Up @@ -145,7 +146,7 @@ function getArch() {
return process.arch === 'arm64' ? 'aarch64' : arch;
}

// Returns the path to the directory where the era-test-node binary is/will be located
// Returns the path to the directory where the anvil-zksync binary is/will be located
export async function getRPCServerBinariesDir(): Promise<string> {
const compilersCachePath = await getCompilersDir();
const basePath = path.dirname(compilersCachePath);
Expand All @@ -154,7 +155,7 @@ export async function getRPCServerBinariesDir(): Promise<string> {
return rpcServerBinariesPath;
}

// Get latest release from GitHub of the era-test-node binary
// Get latest release from GitHub of the anvil-zksync binary
export async function getLatestRelease(owner: string, repo: string, userAgent: string, timeout: number): Promise<any> {
const url = `https://github.com/${owner}/${repo}/releases/latest`;
const redirectUrlPattern = `https://github.com/${owner}/${repo}/releases/tag/v`;
Expand Down Expand Up @@ -191,7 +192,7 @@ export async function getLatestRelease(owner: string, repo: string, userAgent: s
}
}

// Get the asset to download from the latest release of the era-test-node binary
// Get the asset to download from the latest release of the anvil-zksync binary
export async function getNodeUrl(repo: string, release: string): Promise<string> {
const platform = getPlatform();

Expand All @@ -200,7 +201,9 @@ export async function getNodeUrl(repo: string, release: string): Promise<string>
throw new ZkSyncNodePluginError(`Unsupported platform: ${platform}`);
}

return `${repo}/releases/download/v${release}/era_test_node-v${release}-${getArch()}-${platform}.tar.gz`;
return semver.gte(release, '0.1.0')
? `${repo}/releases/download/v${release}/anvil-zksync-v${release}-${getArch()}-${platform}.tar.gz`
: `${repo}/releases/download/v${release}/era_test_node-v${release}-${getArch()}-${platform}.tar.gz`;
}

function isTarGzFile(filePath: string): boolean {
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat-zksync-node/test/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ describe('node-zksync plugin', async function () {
it('should return the node URL for the given repo and release', async function () {
const repo = 'example/repo';
const release = '1.0.0';
const expectedUrl = `${repo}/releases/download/v${release}/era_test_node-v${release}-amd64-linux.tar.gz`;
const expectedUrl = `${repo}/releases/download/v${release}/anvil-zksync-v${release}-amd64-linux.tar.gz`;

const url = await utils.getNodeUrl(repo, release);

Expand Down Expand Up @@ -346,7 +346,7 @@ describe('node-zksync plugin', async function () {
const mockRelease = '1.0.0';

const mockUrl =
'https://github.com/matter-labs/era-test-node/releases/download/v0.1.0/era_test_node-v0.1.0-aarch64-apple-darwin.tar.gz';
'https://github.com/matter-labs/anvil-zksync/releases/download/v0.1.0/era_test_node-v0.1.0-aarch64-apple-darwin.tar.gz';

let downloadStub: sinon.SinonStub;
let existsSyncStub: sinon.SinonStub;
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat-zksync-upgradable/src/core/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export const networkNames: { [chainId in number]?: string } = Object.freeze({
280: 'ZKsync-testnet-goerli',
270: 'ZKsync-local-setup',
300: 'ZKsync-testnet-sepolia',
260: 'ZKsync-era-test-node',
260: 'ZKsync-anvil',
});
2 changes: 1 addition & 1 deletion packages/hardhat-zksync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Here is an overview of the plugins currently available in this package when inst
| hardhat-zksync-deploy | Facilitates the deployment of contracts on ZKsync, utilizing artifacts from hardhat-zksync-solc. |
| hardhat-zksync-verify | Automates the process of verifying smart contracts on the ZKsync network, enhancing transparency and trust. |
| hardhat-zksync-upgradeable | Enables easier deployment and upgrading of smart contracts on the ZKsync network, improving contract lifecycle management. |
| hardhat-zksync-node | Convenient plugin to run the ZKsync era-test-node locally. |
| hardhat-zksync-node | Convenient plugin to run anvil-zksync locally. |
| hardhat-zksync-ethers | A zksync-ethers SDK wrapper providing additional methods for accelerated development on ZKsync. |


Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading