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

feat(toolbox): add zk_toolbox ci #1985

Merged
merged 9 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/ci-zk-toolbox-reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Workflow template for CI jobs for Core Components
on:
workflow_call:

env:
CLICOLOR: 1

jobs:
lint:
name: lint
uses: ./.github/workflows/ci-core-lint-reusable.yml

build:
runs-on: [matterlabs-ci-runner]

steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
submodules: "recursive"
fetch-depth: 0

- name: Setup environment
run: |
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
echo $(pwd)/bin >> $GITHUB_PATH
echo IN_DOCKER=1 >> .env

- name: Start services
run: |
ci_localnet_up

- name: Build
run: |
ci_run bash -c "cd zk_toolbox && cargo build --release"

# Compress with tar to avoid permission loss
# https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
- name: Tar zk_toolbox binaries
run: |
tar -C ./zk_toolbox/target/release -cvf zk_toolbox.tar zk_inception zk_supervisor

- name: Upload zk_toolbox binaries
uses: actions/upload-artifact@v4
with:
name: zk_toolbox
path: zk_toolbox.tar
compression-level: 0

integration_test:
runs-on: [matterlabs-ci-runner]
needs: [build]

steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
submodules: "recursive"
fetch-depth: 0

- name: Download zk_toolbox binaries
uses: actions/download-artifact@v4
with:
name: zk_toolbox
path: .

- name: Extract zk_toolbox binaries
run: |
tar -xvf zk_toolbox.tar -C ./bin

- name: Setup environment
run: |
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
echo $(pwd)/bin >> $GITHUB_PATH
echo IN_DOCKER=1 >> .env

- name: Start services
run: |
ci_localnet_up

- name: Initialize ecosystem
run: |
ci_run zk_inception ecosystem init --deploy-paymaster --deploy-erc20 \
--deploy-ecosystem --l1-rpc-url=http://reth:8545 \
--server-db-url=postgres://postgres:notsecurepassword@postgres:5432 \
--server-db-name=zksync_server_localhost_era \
--prover-db-url=postgres://postgres:notsecurepassword@postgres:5432 \
--prover-db-name=zksync_prover_localhost_era \
--ignore-prerequisites --verbose

- name: Run server
run: |
ci_run zk_inception server --ignore-prerequisites &>server.log &
ci_run sleep 5

- name: Run integration tests
run: |
ci_run zk_supervisor integration-tests --ignore-prerequisites --verbose

- name: Show server.log logs
if: always()
run: ci_run cat server.log || true
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
outputs:
core: ${{ steps.changed-files.outputs.core_any_changed }}
prover: ${{ steps.changed-files.outputs.prover_any_changed }}
zk_toolbox: ${{ steps.changed-files.outputs.zk_toolbox_any_changed }}
docs: ${{ steps.changed-files.outputs.docs_any_changed }}
all: ${{ steps.changed-files.outputs.all_any_changed }}
steps:
Expand Down Expand Up @@ -60,6 +61,10 @@ jobs:
- '!**/*.md'
- '!**/*.MD'
- 'docker-compose.yml'
zk_toolbox:
- 'zk_toolbox/**'
- '!**/*.md'
- '!**/*.MD'
docs:
- '**/*.md'
- '**/*.MD'
Expand Down Expand Up @@ -91,6 +96,12 @@ jobs:
name: CI for Prover Components
uses: ./.github/workflows/ci-prover-reusable.yml

ci-for-zk-toolbox:
needs: changed_files
if: ${{ (needs.changed_files.outputs.zk_toolbox == 'true' || needs.changed_files.outputs.all == 'true') && !contains(github.ref_name, 'release-please--branches') }}
Deniallugo marked this conversation as resolved.
Show resolved Hide resolved
name: CI for zk_toolbox
uses: ./.github/workflows/ci-zk-toolbox-reusable.yml

ci-for-docs:
needs: changed_files
if: needs.changed_files.outputs.docs == 'true'
Expand Down
2 changes: 1 addition & 1 deletion bin/zk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ check_subdirectory
check_yarn_version
if [ -z "$1" ]; then
cd $ZKSYNC_HOME
run_retried yarn install --frozen-lockfile && yarn zk build
run_retried yarn install --frozen-lockfile && yarn utils build && yarn zk build
else
# can't start this with yarn since it has quirks with `--` as an argument
node -- $ZKSYNC_HOME/infrastructure/zk/build/index.js "$@"
Expand Down
2 changes: 1 addition & 1 deletion core/tests/revert-test/tests/revert-and-restart-en.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// NOTE:
// main_contract.getTotalBatchesCommitted actually checks the number of batches committed.
// main_contract.getTotalBatchesExecuted actually checks the number of batches executed.
import * as utils from 'zk/build/utils';
import * as utils from 'utils';
import { Tester } from './tester';
import * as zksync from 'zksync-ethers';
import { BigNumber, ethers } from 'ethers';
Expand Down
2 changes: 1 addition & 1 deletion core/tests/revert-test/tests/revert-and-restart.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as utils from 'zk/build/utils';
import * as utils from 'utils';
import { Tester } from './tester';
import * as zksync from 'zksync-ethers';
import { BigNumber, Contract, ethers } from 'ethers';
Expand Down
8 changes: 6 additions & 2 deletions core/tests/ts-integration/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async function loadTestEnvironmentFromFile(chain: string): Promise<TestEnvironme

let generalConfig = loadConfig(pathToHome, chain, 'general.yaml');
let genesisConfig = loadConfig(pathToHome, chain, 'genesis.yaml');
let secretsConfig = loadConfig(pathToHome, chain, 'secrets.yaml');

const network = ecosystem.l1_network;
let mainWalletPK = getMainWalletPk(pathToHome, network);
Expand All @@ -71,7 +72,7 @@ async function loadTestEnvironmentFromFile(chain: string): Promise<TestEnvironme
const l2Provider = new zksync.Provider(l2NodeUrl);
const baseTokenAddress = await l2Provider.getBaseTokenContractAddress();

const l1NodeUrl = ecosystem.l1_rpc_url;
const l1NodeUrl = secretsConfig.l1.l1_rpc_url;
const wsL2NodeUrl = generalConfig.api.web3_json_rpc.ws_url;

const contractVerificationUrl = generalConfig.contract_verifier.url;
Expand All @@ -80,9 +81,12 @@ async function loadTestEnvironmentFromFile(chain: string): Promise<TestEnvironme
// wBTC is chosen because it has decimals different from ETH (8 instead of 18).
// Using this token will help us to detect decimals-related errors.
// but if it's not available, we'll use the first token from the list.
let token = tokens.tokens['wBTC'];
let token = tokens.tokens['WBTC'];
if (token === undefined) {
token = Object.values(tokens.tokens)[0];
if (token.symbol == 'WETH') {
token = Object.values(tokens.tokens)[1];
}
}
const weth = tokens.tokens['WETH'];
let baseToken;
Expand Down
6 changes: 3 additions & 3 deletions core/tests/ts-integration/tests/fees.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* sure that the test is maintained does not get broken.
*
*/
import * as utils from 'zk/build/utils';
import * as utils from 'utils';
import * as fs from 'fs';
import { TestMaster } from '../src/index';

Expand Down Expand Up @@ -258,10 +258,10 @@ async function updateReport(
const l2EstimatedPriceAsNumber = +ethers.utils.formatEther(estimatedPrice);

const gasReport = `Gas price ${newL1GasPrice / 1000000000} gwei:
L1 cost ${expectedL1Price},
L1 cost ${expectedL1Price},
L2 estimated cost: ${l2EstimatedPriceAsNumber}
Estimated Gain: ${expectedL1Price / l2EstimatedPriceAsNumber}
L2 cost: ${l2PriceAsNumber},
L2 cost: ${l2PriceAsNumber},
Gain: ${expectedL1Price / l2PriceAsNumber}\n`;
console.log(gasReport);

Expand Down
2 changes: 1 addition & 1 deletion core/tests/upgrade-test/tests/upgrade.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as utils from 'zk/build/utils';
import * as utils from 'utils';
import { Tester } from './tester';
import * as zksync from 'zksync-ethers';
import { BigNumber, BigNumberish, ethers } from 'ethers';
Expand Down
1 change: 1 addition & 0 deletions etc/utils/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
13 changes: 13 additions & 0 deletions etc/utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "utils",
"version": "0.1.0",
"license": "MIT",
"main": "build/index.js",
"types": "build/index.d.ts",
"scripts": {
"build": "tsc"
},
"dependencies": {
"chalk": "^4.0.0"
}
}
File renamed without changes.
15 changes: 15 additions & 0 deletions etc/utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "es2019",
"module": "commonjs",
"outDir": "build",
"strict": true,
"esModuleInterop": true,
"noEmitOnError": true,
"skipLibCheck": true,
"declaration": true
},
"files": [
"src/index.ts"
]
}
2 changes: 1 addition & 1 deletion infrastructure/protocol-upgrade/src/crypto/deployer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawn } from 'zk/build/utils';
import { spawn } from 'utils';

export async function deployVerifier(
l1Rpc: string,
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/protocol-upgrade/src/hyperchain-upgrade.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from 'commander';
import { spawn } from 'zk/build/utils';
import { spawn } from 'utils';
import fs from 'fs';
import { ethers } from 'ethers';

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/protocol-upgrade/src/l1upgrade/deployer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawn } from 'zk/build/utils';
import { spawn } from 'utils';

export async function callFacetDeployer(
l1RpcProvider: string,
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/protocol-upgrade/src/l1upgrade/facets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import { Command } from 'commander';
import { spawn } from 'zk/build/utils';
import { spawn } from 'utils';
import { getFacetCutsFileName, getFacetsFileName, getUpgradePath } from '../utils';
import { callFacetDeployer } from './deployer';

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/protocol-upgrade/src/l2upgrade/deployer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawn } from 'zk/build/utils';
import { spawn } from 'utils';

export async function callSystemContractDeployer(
l1RpcProvider: string,
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/protocol-upgrade/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from './utils';
import fs from 'fs';
import { Command } from 'commander';
import { web3Url } from 'zk/build/utils';
import { web3Url } from 'utils';
import * as path from 'path';

const testConfigPath = path.join(process.env.ZKSYNC_HOME as string, `etc/test_config/constant`);
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/zk/src/clean.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Command } from 'commander';
import * as fs from 'fs';
import * as path from 'path';
import { confirmAction } from './utils';
import { confirmAction } from 'utils';
import * as down from './down';

export function clean(path: string) {
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/zk/src/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from 'commander';
import * as utils from './utils';
import * as utils from 'utils';

export async function compileTestContracts() {
await utils.spawn('yarn workspace contracts-test-data build');
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/zk/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import deepExtend from 'deep-extend';
import * as env from './env';
import path from 'path';
import dotenv from 'dotenv';
import { unpackStringSemVer } from './utils';
import { unpackStringSemVer } from 'utils';

function loadConfigFile(configPath: string, stack: string[] = []) {
if (stack.includes(configPath)) {
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/zk/src/contract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from 'commander';
import * as utils from './utils';
import * as utils from 'utils';
import * as env from './env';
import fs from 'fs';

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/zk/src/contract_verifier.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from 'commander';
import * as utils from './utils';
import * as utils from 'utils';

export async function contractVerifier() {
await utils.spawn(`cargo run --bin zksync_contract_verifier --release`);
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/zk/src/database.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from 'commander';
import * as utils from './utils';
import * as utils from 'utils';

export async function reset(opts: DbOpts) {
await utils.confirmAction();
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/zk/src/docker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from 'commander';
import * as utils from './utils';
import * as utils from 'utils';

const IMAGES = [
'server-v2',
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/zk/src/down.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from 'commander';
import * as utils from './utils';
import * as utils from 'utils';
import * as fs from 'fs';

export async function down() {
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/zk/src/env.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Command } from 'commander';
import fs from 'fs';
import dotenv from 'dotenv';
import * as utils from './utils';
import * as utils from 'utils';
import * as config from './config';

export const getAvailableEnvsFromFiles = () => {
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/zk/src/fmt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command } from 'commander';
import { formatSqlxQueries } from './format_sql';
import * as utils from './utils';
import * as utils from 'utils';

const EXTENSIONS = ['ts', 'md', 'js'];
const CONFIG_PATH = 'etc/prettier-config';
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/zk/src/format_sql.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from 'fs';
import * as utils from './utils';
import * as utils from 'utils';
import { format } from 'sql-formatter';

function formatQuery(query: string) {
Expand Down
9 changes: 7 additions & 2 deletions infrastructure/zk/src/hyperchain_wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import fetch from 'node-fetch';
import { up } from './up';
import * as Handlebars from 'handlebars';
import { ProverType, setupProver } from './prover_setup';
import { announced } from './utils';
import { announced } from 'utils';
import { DeploymentMode } from './contract';

const title = chalk.blueBright;
Expand Down Expand Up @@ -49,7 +49,12 @@ export interface BasePromptOptions {
async function initHyperchain(envName: string, runObservability: boolean, validiumMode: boolean) {
await announced('Initializing hyperchain creation', setupConfiguration(envName, runObservability));
let deploymentMode = validiumMode !== undefined ? DeploymentMode.Validium : DeploymentMode.Rollup;
await init.initHyperCmdAction({ skipSetupCompletely: false, bumpChainId: true, runObservability, deploymentMode });
await init.initHyperCmdAction({
skipSetupCompletely: false,
bumpChainId: true,
runObservability,
deploymentMode
});

// TODO: EVM:577 fix hyperchain wizard
env.mergeInitToEnv();
Expand Down
Loading
Loading