diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d0d3780d..f6e59fb86 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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/anvil-zksync-action@v1.1.0 + 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: @@ -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 @@ -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: | @@ -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: | @@ -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: | @@ -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 @@ -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 @@ -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 diff --git a/README.md b/README.md index 423c693b2..201e17e7c 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/e2e/fixture-projects/node/preprocess.sh b/e2e/fixture-projects/node/preprocess.sh index 9f239e96e..96a280b15 100755 --- a/e2e/fixture-projects/node/preprocess.sh +++ b/e2e/fixture-projects/node/preprocess.sh @@ -12,7 +12,7 @@ cat < "$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", diff --git a/e2e/fixture-projects/node/test.sh b/e2e/fixture-projects/node/test.sh index 3a650cd08..3dffb0c69 100644 --- a/e2e/fixture-projects/node/test.sh +++ b/e2e/fixture-projects/node/test.sh @@ -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." diff --git a/examples/deploy-example/deploy-ZKsync/002_deploy.ts b/examples/deploy-example/deploy-ZKsync/002_deploy.ts index 34bdde6ae..c377cc5de 100644 --- a/examples/deploy-example/deploy-ZKsync/002_deploy.ts +++ b/examples/deploy-example/deploy-ZKsync/002_deploy.ts @@ -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']; - diff --git a/examples/node-example/README.md b/examples/node-example/README.md index 2717a98a7..05d025f6a 100644 --- a/examples/node-example/README.md +++ b/examples/node-example/README.md @@ -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 @@ -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. diff --git a/packages/hardhat-zksync-node/README.md b/packages/hardhat-zksync-node/README.md index f5e7b3eaa..fe311ba79 100644 --- a/packages/hardhat-zksync-node/README.md +++ b/packages/hardhat-zksync-node/README.md @@ -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) @@ -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. | diff --git a/packages/hardhat-zksync-node/package.json b/packages/hardhat-zksync-node/package.json index da255633b..e97d3c4c1 100644 --- a/packages/hardhat-zksync-node/package.json +++ b/packages/hardhat-zksync-node/package.json @@ -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", @@ -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" }, @@ -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", diff --git a/packages/hardhat-zksync-node/src/constants.ts b/packages/hardhat-zksync-node/src/constants.ts index 783a3622f..1201a7ba5 100644 --- a/packages/hardhat-zksync-node/src/constants.ts +++ b/packages/hardhat-zksync-node/src/constants.ts @@ -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'; @@ -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']; @@ -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', diff --git a/packages/hardhat-zksync-node/src/downloader.ts b/packages/hardhat-zksync-node/src/downloader.ts index f392931a9..5a6691286 100644 --- a/packages/hardhat-zksync-node/src/downloader.ts +++ b/packages/hardhat-zksync-node/src/downloader.ts @@ -90,10 +90,10 @@ export class RPCServerDownloader { private async _download(tag: any): Promise { 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}`); } diff --git a/packages/hardhat-zksync-node/src/index.ts b/packages/hardhat-zksync-node/src/index.ts index 1aa882b87..0ce430296 100644 --- a/packages/hardhat-zksync-node/src/index.ts +++ b/packages/hardhat-zksync-node/src/index.ts @@ -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, ) @@ -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, ) diff --git a/packages/hardhat-zksync-node/src/utils.ts b/packages/hardhat-zksync-node/src/utils.ts index 3154169ee..b41ef1f36 100644 --- a/packages/hardhat-zksync-node/src/utils.ts +++ b/packages/hardhat-zksync-node/src/utils.ts @@ -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, @@ -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[] = []; @@ -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 { const compilersCachePath = await getCompilersDir(); const basePath = path.dirname(compilersCachePath); @@ -154,7 +155,7 @@ export async function getRPCServerBinariesDir(): Promise { 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 { const url = `https://github.com/${owner}/${repo}/releases/latest`; const redirectUrlPattern = `https://github.com/${owner}/${repo}/releases/tag/v`; @@ -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 { const platform = getPlatform(); @@ -200,7 +201,9 @@ export async function getNodeUrl(repo: string, release: string): Promise 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 { diff --git a/packages/hardhat-zksync-node/test/tests.ts b/packages/hardhat-zksync-node/test/tests.ts index af45ba62a..dc77320ca 100644 --- a/packages/hardhat-zksync-node/test/tests.ts +++ b/packages/hardhat-zksync-node/test/tests.ts @@ -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); @@ -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; diff --git a/packages/hardhat-zksync-upgradable/src/core/provider.ts b/packages/hardhat-zksync-upgradable/src/core/provider.ts index 64bcfdc8b..8b4bd7184 100644 --- a/packages/hardhat-zksync-upgradable/src/core/provider.ts +++ b/packages/hardhat-zksync-upgradable/src/core/provider.ts @@ -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', }); diff --git a/packages/hardhat-zksync/README.md b/packages/hardhat-zksync/README.md index 3ad73053f..49c735b13 100644 --- a/packages/hardhat-zksync/README.md +++ b/packages/hardhat-zksync/README.md @@ -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. | diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 40bd21d6c..8a9dd6362 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1148,6 +1148,9 @@ importers: proxyquire: specifier: ^2.1.3 version: 2.1.3 + semver: + specifier: ^7.6.2 + version: 7.6.2 sinon: specifier: ^18.0.0 version: 18.0.0 @@ -1176,6 +1179,9 @@ importers: '@types/proxyquire': specifier: ^1.3.31 version: 1.3.31 + '@types/semver': + specifier: ^7.5.8 + version: 7.5.8 '@types/sinon-chai': specifier: ^3.2.10 version: 3.2.12