From 39b3d26cdfdafe84131cc3a20edd500b425d2e8b Mon Sep 17 00:00:00 2001 From: Antonio Morrone Date: Thu, 14 Sep 2023 12:03:40 +0200 Subject: [PATCH] chore: update tests and docs according to PR suggestions --- .gitignore | 2 +- Cargo.lock | 160 +++++++++++++++++++++++------ docs/development.md | 2 +- infrastructure/zk/src/test/test.ts | 19 ++-- 4 files changed, 140 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index 8878bf804..60f816df8 100644 --- a/.gitignore +++ b/.gitignore @@ -62,4 +62,4 @@ bin/mkcert docker/rskj/data # Files used to generate code-coverage reports -*.profraw \ No newline at end of file +*.profraw diff --git a/Cargo.lock b/Cargo.lock index 87eb2656e..c515e67d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -822,10 +822,10 @@ name = "block_revert" version = "1.0.0" dependencies = [ "anyhow", - "ethabi", + "ethabi 16.0.0", "structopt", "tokio", - "web3", + "web3 0.18.0", "zksync_config", "zksync_eth_client", "zksync_storage", @@ -898,6 +898,12 @@ dependencies = [ "iovec", ] +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + [[package]] name = "bytes" version = "1.1.0" @@ -1498,6 +1504,22 @@ dependencies = [ "serde", ] +[[package]] +name = "ethabi" +version = "14.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01317735d563b3bad2d5f90d2e1799f414165408251abb762510f40e790e69a" +dependencies = [ + "anyhow", + "ethereum-types 0.11.0", + "hex", + "serde", + "serde_json", + "sha3", + "thiserror", + "uint", +] + [[package]] name = "ethabi" version = "16.0.0" @@ -4000,10 +4022,10 @@ name = "remove_proofs" version = "1.0.0" dependencies = [ "anyhow", - "ethabi", + "ethabi 16.0.0", "structopt", "tokio", - "web3", + "web3 0.18.0", "zksync_config", "zksync_eth_client", "zksync_storage", @@ -4060,6 +4082,33 @@ dependencies = [ "sha3", ] +[[package]] +name = "rif_rollup_wallet_generator" +version = "1.0.0" +dependencies = [ + "anyhow", + "async-trait", + "ethabi 14.1.0", + "hex", + "jsonrpc-core 17.1.0", + "num", + "reqwest", + "serde", + "serde_json", + "sha2 0.8.2", + "thiserror", + "tokio", + "web3 0.16.0", + "zksync", + "zksync_config", + "zksync_crypto", + "zksync_eth_client", + "zksync_eth_signer", + "zksync_test_account", + "zksync_types", + "zksync_utils", +] + [[package]] name = "ring" version = "0.16.20" @@ -4615,6 +4664,21 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "soketto" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5c71ed3d54db0a699f4948e1bb3e45b450fa31fe602621dee6680361d569c88" +dependencies = [ + "base64 0.12.3", + "bytes 0.5.6", + "futures 0.3.17", + "httparse", + "log 0.4.14", + "rand 0.7.3", + "sha-1 0.9.8", +] + [[package]] name = "soketto" version = "0.7.1" @@ -5618,6 +5682,40 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web3" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc4c18ae15621f764fab919f7e4a83d87163494cbc3460884debef7c6bc1bc6b" +dependencies = [ + "arrayvec 0.5.2", + "base64 0.13.0", + "bytes 1.1.0", + "derive_more", + "ethabi 14.1.0", + "ethereum-types 0.11.0", + "futures 0.3.17", + "futures-timer", + "headers", + "hex", + "jsonrpc-core 17.1.0", + "log 0.4.14", + "parking_lot 0.11.2", + "pin-project", + "reqwest", + "rlp", + "secp256k1 0.20.3", + "serde", + "serde_json", + "soketto 0.4.2", + "tiny-keccak 2.0.2", + "tokio", + "tokio-stream", + "tokio-util", + "url 2.2.2", + "web3-async-native-tls", +] + [[package]] name = "web3" version = "0.18.0" @@ -5628,7 +5726,7 @@ dependencies = [ "base64 0.13.0", "bytes 1.1.0", "derive_more", - "ethabi", + "ethabi 16.0.0", "ethereum-types 0.12.1", "futures 0.3.17", "futures-timer", @@ -5645,7 +5743,7 @@ dependencies = [ "secp256k1 0.21.3", "serde", "serde_json", - "soketto", + "soketto 0.7.1", "tiny-keccak 2.0.2", "tokio", "tokio-stream", @@ -5840,7 +5938,7 @@ version = "0.3.0" dependencies = [ "anyhow", "async-trait", - "ethabi", + "ethabi 16.0.0", "hex", "jsonrpc-core 17.1.0", "num", @@ -5850,7 +5948,7 @@ dependencies = [ "sha2 0.8.2", "thiserror", "tokio", - "web3", + "web3 0.18.0", "zksync_config", "zksync_crypto", "zksync_eth_client", @@ -5874,7 +5972,7 @@ dependencies = [ "chrono", "criterion", "ctrlc", - "ethabi", + "ethabi 16.0.0", "futures 0.3.17", "hex", "hyper 0.14.14", @@ -5903,7 +6001,7 @@ dependencies = [ "tiny-keccak 1.5.0", "tokio", "vlog", - "web3", + "web3 0.18.0", "zksync_api_client", "zksync_api_types", "zksync_balancer", @@ -5971,7 +6069,7 @@ name = "zksync_basic_types" version = "1.0.0" dependencies = [ "serde", - "web3", + "web3 0.18.0", ] [[package]] @@ -6010,7 +6108,7 @@ dependencies = [ name = "zksync_contracts" version = "1.0.0" dependencies = [ - "ethabi", + "ethabi 16.0.0", "serde_json", ] @@ -6024,7 +6122,7 @@ dependencies = [ "async-trait", "chrono", "ctrlc", - "ethabi", + "ethabi 16.0.0", "futures 0.3.17", "itertools 0.9.0", "metrics", @@ -6036,7 +6134,7 @@ dependencies = [ "tiny-keccak 1.5.0", "tokio", "vlog", - "web3", + "web3 0.18.0", "zksync_api_types", "zksync_balancer", "zksync_config", @@ -6061,7 +6159,7 @@ version = "1.0.0" dependencies = [ "base64 0.13.0", "bincode", - "ethabi", + "ethabi 16.0.0", "fnv", "franklin-crypto", "hex", @@ -6085,7 +6183,7 @@ dependencies = [ "async-trait", "chrono", "db_test_macro", - "ethabi", + "ethabi 16.0.0", "futures 0.3.17", "hex", "jsonrpc-core 18.0.0", @@ -6096,7 +6194,7 @@ dependencies = [ "tiny-keccak 1.5.0", "tokio", "vlog", - "web3", + "web3 0.18.0", "zksync_config", "zksync_contracts", "zksync_crypto", @@ -6111,7 +6209,7 @@ name = "zksync_eth_client" version = "1.0.0" dependencies = [ "anyhow", - "ethabi", + "ethabi 16.0.0", "hex", "metrics", "parity-crypto 0.8.0", @@ -6119,7 +6217,7 @@ dependencies = [ "sha3", "tokio", "vlog", - "web3", + "web3 0.18.0", "zksync_config", "zksync_contracts", "zksync_eth_signer", @@ -6134,7 +6232,7 @@ dependencies = [ "async-trait", "chrono", "ctrlc", - "ethabi", + "ethabi 16.0.0", "futures 0.3.17", "hex", "lazy_static", @@ -6144,7 +6242,7 @@ dependencies = [ "serde_json", "tokio", "vlog", - "web3", + "web3 0.18.0", "zksync_basic_types", "zksync_config", "zksync_contracts", @@ -6175,7 +6273,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "web3", + "web3 0.18.0", "zksync_types", ] @@ -6204,7 +6302,7 @@ dependencies = [ "anyhow", "async-trait", "chrono", - "ethabi", + "ethabi 16.0.0", "futures 0.3.17", "hex", "log 0.4.14", @@ -6212,7 +6310,7 @@ dependencies = [ "num", "tokio", "vlog", - "web3", + "web3 0.18.0", "zksync_api", "zksync_config", "zksync_contracts", @@ -6235,7 +6333,7 @@ dependencies = [ "tokio", "tokio-stream", "vlog", - "web3", + "web3 0.18.0", "zksync_config", "zksync_eth_client", "zksync_utils", @@ -6316,7 +6414,7 @@ dependencies = [ "structopt", "tokio", "vlog", - "web3", + "web3 0.18.0", "zksync_circuit", "zksync_config", "zksync_crypto", @@ -6389,7 +6487,7 @@ dependencies = [ "serde_json", "thiserror", "vlog", - "web3", + "web3 0.18.0", "zksync_crypto", "zksync_types", "zksync_utils", @@ -6441,7 +6539,7 @@ name = "zksync_testkit" version = "1.0.0" dependencies = [ "anyhow", - "ethabi", + "ethabi 16.0.0", "futures 0.3.17", "itertools 0.9.0", "num", @@ -6450,7 +6548,7 @@ dependencies = [ "structopt", "tokio", "vlog", - "web3", + "web3 0.18.0", "zksync_circuit", "zksync_config", "zksync_contracts", @@ -6485,7 +6583,7 @@ dependencies = [ "bigdecimal", "chrono", "criterion", - "ethabi", + "ethabi 16.0.0", "hex", "itertools 0.9.0", "num", @@ -6498,7 +6596,7 @@ dependencies = [ "thiserror", "tiny-keccak 1.5.0", "vlog", - "web3", + "web3 0.18.0", "zksync_basic_types", "zksync_crypto", "zksync_utils", diff --git a/docs/development.md b/docs/development.md index 3d5d6d373..6bc7ffd5b 100644 --- a/docs/development.md +++ b/docs/development.md @@ -190,7 +190,7 @@ cargo install grcov rustup component add llvm-tools-preview ``` -To measure code coverage of unit tests, just set the environment variable `CODE_COVERAGE` to `true`. +To measure code coverage of unit tests, just set the environment variable `CODE_COVERAGE` to `true` or `1`. ```bash CODE_COVERAGE=true zk test prover diff --git a/infrastructure/zk/src/test/test.ts b/infrastructure/zk/src/test/test.ts index 5dfad58b9..59accede9 100644 --- a/infrastructure/zk/src/test/test.ts +++ b/infrastructure/zk/src/test/test.ts @@ -4,10 +4,9 @@ import * as utils from '../utils'; import * as integration from './integration'; export { integration }; -const CODE_COVERAGE_ENABLED = process.env.CODE_COVERAGE; const CODE_COVERAGE_FLAGS = `CARGO_INCREMENTAL=0 RUSTFLAGS='-C instrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw'`; - -const codeCoverageFlags = () => (CODE_COVERAGE_ENABLED ? CODE_COVERAGE_FLAGS : ''); +const IS_CODE_COVERAGE_ENABLED = process.env.CODE_COVERAGE === 'true' || process.env.CODE_COVERAGE === '1'; +const CARGO_FLAGS = IS_CODE_COVERAGE_ENABLED ? CODE_COVERAGE_FLAGS : ''; async function runOnTestDb(reset: boolean, dir: string, command: string) { const databaseUrl = process.env.DATABASE_URL as string; @@ -31,7 +30,7 @@ export async function db(reset: boolean, ...args: string[]) { await runOnTestDb( reset, 'core/lib/storage', - `${codeCoverageFlags()} cargo test --release -p zksync_storage --lib -- --ignored --nocapture --test-threads=1 + `${CARGO_FLAGS} cargo test --release -p zksync_storage --lib -- --ignored --nocapture --test-threads=1 ${args.join(' ')}` ); } @@ -42,7 +41,7 @@ export async function rustApi(reset: boolean, ...args: string[]) { await runOnTestDb( reset, 'core/bin/zksync_api', - `${codeCoverageFlags()} cargo test --release -p zksync_api --lib -- --ignored --nocapture --test-threads=1 api_server + `${CARGO_FLAGS} cargo test --release -p zksync_api --lib -- --ignored --nocapture --test-threads=1 api_server ${args.join(' ')}` ); } @@ -53,17 +52,17 @@ export async function contracts() { export async function circuit(threads: number = 1, testName?: string, ...args: string[]) { await utils.spawn( - `${codeCoverageFlags()} cargo test --no-fail-fast --release -p zksync_circuit ${testName || ''} + `${CARGO_FLAGS} cargo test --no-fail-fast --release -p zksync_circuit ${testName || ''} -- --ignored --test-threads ${threads} ${args.join(' ')}` ); } export async function prover() { - await utils.spawn(`${codeCoverageFlags()} cargo test -p zksync_prover --release`); + await utils.spawn(`${CARGO_FLAGS} cargo test -p zksync_prover --release`); } export async function witness_generator() { - await utils.spawn(`${codeCoverageFlags()} cargo test -p zksync_witness_generator --release`); + await utils.spawn(`${CARGO_FLAGS} cargo test -p zksync_witness_generator --release`); } export async function js() { @@ -72,12 +71,12 @@ export async function js() { async function rustCryptoTests() { process.chdir('sdk/zksync-crypto'); - await utils.spawn(`${codeCoverageFlags()} cargo test --release`); + await utils.spawn(`${CARGO_FLAGS} cargo test --release`); process.chdir(process.env.ZKSYNC_HOME as string); } export async function serverRust() { - await utils.spawn(`${codeCoverageFlags()} cargo test --release`); + await utils.spawn(`${CARGO_FLAGS} cargo test --release`); await db(true); await rustApi(true); await prover();