From 293617ac8b952f2a479a4306e15a8f828757eaad Mon Sep 17 00:00:00 2001 From: Anton Baliasnikov Date: Thu, 16 Jan 2025 11:39:42 +0000 Subject: [PATCH] refactor: move Cargo.toml from root to core workspace (#3456) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ Move `Cargo.toml` from repository root to `core` workspace. ## Why ❔ It is mandatory for proper separation of workspaces and setting up a `release-please` CI that requires all files of a component to be inside the component directory. ## CI failures Currently, the following tests are failing: * `protobuf_compatibility` - the workflow is using base version and will be fixed with the next PRs after merge to `main`. ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`. --- .dockerignore | 4 +- .githooks/pre-commit | 8 +- .github/workflows/cargo-license.yaml | 1 + .github/workflows/ci-core-reusable.yml | 2 +- .github/workflows/ci.yml | 4 +- .github/workflows/protobuf.yaml | 20 +- .github/workflows/vm-perf-comparison.yml | 12 +- .gitignore | 6 - Cargo.toml | 326 ------------------ Cargo.lock => core/Cargo.lock | 0 core/Cargo.toml | 326 ++++++++++++++++++ .../system-constants-generator/src/main.rs | 2 +- deny.toml => core/deny.toml | 0 .../lib/contract_verifier/src/resolver/env.rs | 2 +- core/lib/contracts/src/lib.rs | 2 +- core/lib/utils/src/env.rs | 34 +- core/tests/loadnext/src/fs_utils.rs | 2 +- .../tests/revert-and-restart-en.test.ts | 13 +- core/tests/revert-test/tests/utils.ts | 2 +- docker/contract-verifier/Dockerfile | 4 +- docker/external-node/Dockerfile | 6 +- docker/server-v2/Dockerfile | 8 +- docker/snapshots-creator/Dockerfile | 4 +- docker/verified-sources-fetcher/Dockerfile | 4 +- flake.nix | 12 +- infrastructure/zk/src/server.ts | 8 +- .../crates/bin/prover_cli/src/config/mod.rs | 2 +- prover/crates/bin/prover_cli/src/helper.rs | 2 +- .../src/vk_commitment_helper.rs | 2 +- prover/crates/lib/keystore/src/keystore.rs | 2 +- .../crates/common/src/external_node.rs | 2 +- zkstack_cli/crates/common/src/server.rs | 4 +- .../src/commands/contract_verifier/build.rs | 2 +- .../src/commands/contract_verifier/run.rs | 2 +- .../zkstack/src/commands/dev/commands/fmt.rs | 2 +- .../zkstack/src/commands/dev/commands/lint.rs | 4 +- .../src/commands/dev/commands/snapshot.rs | 2 +- .../commands/dev/commands/test/loadtest.rs | 47 +-- .../src/commands/dev/commands/test/rust.rs | 2 +- .../src/commands/external_node/build.rs | 2 +- .../crates/zkstack/src/commands/server.rs | 2 +- 41 files changed, 452 insertions(+), 439 deletions(-) delete mode 100644 Cargo.toml rename Cargo.lock => core/Cargo.lock (100%) create mode 100644 core/Cargo.toml rename deny.toml => core/deny.toml (100%) diff --git a/.dockerignore b/.dockerignore index 39efdabca19a..9be9fd580858 100644 --- a/.dockerignore +++ b/.dockerignore @@ -20,8 +20,8 @@ keys/setup !prover/ !yarn.lock !package.json -!Cargo.lock -!Cargo.toml +!core/Cargo.lock +!core/Cargo.toml !contracts/ !setup_2\^26.key !setup_2\^24.key diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 1f0c6b945b65..df99db16605f 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -15,8 +15,6 @@ check_fmt () { fi } -check_fmt - -cd prover/ - -check_fmt +( cd core/ && check_fmt ) +( cd prover/ && check_fmt ) +( cd zkstack_cli/ && check_fmt ) diff --git a/.github/workflows/cargo-license.yaml b/.github/workflows/cargo-license.yaml index 72eb8d0d865b..8b0c095c628c 100644 --- a/.github/workflows/cargo-license.yaml +++ b/.github/workflows/cargo-license.yaml @@ -7,5 +7,6 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: EmbarkStudios/cargo-deny-action@8371184bd11e21dcf8ac82ebf8c9c9f74ebf7268 # v2.0.1 with: + manifest-path: "./core/Cargo.toml" command: check command-arguments: "--hide-inclusion-graph" diff --git a/.github/workflows/ci-core-reusable.yml b/.github/workflows/ci-core-reusable.yml index 25a0da838f42..f44b1f54dc02 100644 --- a/.github/workflows/ci-core-reusable.yml +++ b/.github/workflows/ci-core-reusable.yml @@ -79,7 +79,7 @@ jobs: ci_run zkstack dev test rust # Benchmarks are not tested by `cargo nextest` unless specified explicitly, and even then `criterion` harness is incompatible # with how `cargo nextest` runs tests. Thus, we run criterion-based benchmark tests manually. - ci_run cargo test --release -p vm-benchmark --bench oneshot --bench batch + ci_run cargo test --manifest-path ./core/Cargo.toml --release -p vm-benchmark --bench oneshot --bench batch loadtest: runs-on: [ matterlabs-ci-runner-high-performance ] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 899eaea4b445..a0b7ee1bc40e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,8 +57,8 @@ jobs: - '.github/workflows/build-contract-verifier-template.yml' - '.github/workflows/ci-core-reusable.yml' - '.github/workflows/ci-core-lint-reusable.yml' - - 'Cargo.toml' - - 'Cargo.lock' + - './core/Cargo.toml' + - './core/Cargo.lock' - 'zkstack_cli/**' - '!**/*.md' - '!**/*.MD' diff --git a/.github/workflows/protobuf.yaml b/.github/workflows/protobuf.yaml index f0565919ded1..0d7f43f1c2a2 100644 --- a/.github/workflows/protobuf.yaml +++ b/.github/workflows/protobuf.yaml @@ -47,13 +47,13 @@ jobs: git checkout $(git merge-base $BASE $HEAD) --recurse-submodules working-directory: ./before - name: compile before - run: cargo check --all-targets - working-directory: ./before/ + run: cargo check --manifest-path ./core/Cargo.toml --all-targets + working-directory: ./before - name: build before.binpb run: > perl -ne 'print "$1\n" if /PROTOBUF_DESCRIPTOR="(.*)"/' - `find ./before/target/debug/build/*/output` - | xargs cat > ./before.binpb + `find ./before/core/target/debug/build/*/output` + | xargs cat > ./before/.binpb # after - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 @@ -62,12 +62,12 @@ jobs: path: after submodules: recursive - name: compile after - run: cargo check --all-targets + run: cargo check --manifest-path ./core/Cargo.toml --all-targets working-directory: ./after - name: build after.binpb run: > perl -ne 'print "$1\n" if /PROTOBUF_DESCRIPTOR="(.*)"/' - `find ./after/target/debug/build/*/output` + `find ./after/core/target/debug/build/*/output` | xargs cat > ./after.binpb # compare @@ -75,6 +75,8 @@ jobs: with: github_token: ${{ github.token }} - name: buf breaking - run: > - buf breaking './after.binpb' --against './before.binpb' --exclude-path 'zksync/config/experimental.proto' - --config '{"version":"v1","breaking":{"use":["WIRE_JSON","WIRE"]}}' --error-format 'github-actions' + run: | + pwd + ls -la + buf breaking './after.binpb' --against './before.binpb' --exclude-path 'zksync/config/experimental.proto' \ + --config '{"version":"v1","breaking":{"use":["WIRE_JSON","WIRE"]}}' --error-format 'github-actions' diff --git a/.github/workflows/vm-perf-comparison.yml b/.github/workflows/vm-perf-comparison.yml index ac83485a2c12..59e44023243c 100644 --- a/.github/workflows/vm-perf-comparison.yml +++ b/.github/workflows/vm-perf-comparison.yml @@ -53,8 +53,10 @@ jobs: run: | ci_run zkstackup -g --local ci_run zkstack dev contracts - ci_run cargo bench --package vm-benchmark --bench instructions -- --verbose || echo "Instructions benchmark is missing" - ci_run cargo run --package vm-benchmark --release --bin instruction_counts | tee base-opcodes + ci_run cargo bench --manifest-path ./core/Cargo.toml \ + --package vm-benchmark --bench instructions -- --verbose || echo "Instructions benchmark is missing" + ci_run cargo run --manifest-path ./core/Cargo.toml \ + --package vm-benchmark --release --bin instruction_counts | tee base-opcodes - name: checkout PR run: | @@ -69,7 +71,8 @@ jobs: ci_run zkstack dev contracts ci_run cargo bench --package vm-benchmark --bench instructions -- --verbose - ci_run cargo bench --package vm-benchmark --bench instructions -- --print > instructions.log 2>/dev/null + ci_run cargo bench --manifest-path ./core/Cargo.toml \ + --package vm-benchmark --bench instructions -- --print > instructions.log 2>/dev/null # Output all lines from the benchmark result starting from the "## ..." comparison header. # Since the output spans multiple lines, we use a heredoc declaration. EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) @@ -77,7 +80,8 @@ jobs: sed -n '/^## /,$p' instructions.log >> $GITHUB_OUTPUT echo "$EOF" >> $GITHUB_OUTPUT - ci_run cargo run --package vm-benchmark --release --bin instruction_counts -- --diff base-opcodes > opcodes.log + ci_run cargo run --manifest-path ./core/Cargo.toml \ + --package vm-benchmark --release --bin instruction_counts -- --diff base-opcodes > opcodes.log echo "opcodes<<$EOF" >> $GITHUB_OUTPUT sed -n '/^## /,$p' opcodes.log >> $GITHUB_OUTPUT echo "$EOF" >> $GITHUB_OUTPUT diff --git a/.gitignore b/.gitignore index 471a601cc34b..d92880f5ae48 100644 --- a/.gitignore +++ b/.gitignore @@ -26,12 +26,6 @@ zksync_pk.key dist todo -Cargo.lock -!/Cargo.lock -!/infrastructure/zksync-crypto/Cargo.lock -!/prover/Cargo.lock -!/zkstack_cli/Cargo.lock - /etc/env/target/* /etc/env/.current /etc/env/configs/* diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 21a1a342f1ab..000000000000 --- a/Cargo.toml +++ /dev/null @@ -1,326 +0,0 @@ -[workspace] -members = [ - # Binaries - "core/bin/block_reverter", - "core/bin/contract-verifier", - "core/bin/custom_genesis_export", - "core/bin/external_node", - "core/bin/merkle_tree_consistency_checker", - "core/bin/snapshots_creator", - "core/bin/selector_generator", - "core/bin/system-constants-generator", - "core/bin/verified_sources_fetcher", - "core/bin/zksync_server", - "core/bin/genesis_generator", - "core/bin/zksync_tee_prover", - # Node services - "core/node/node_framework", - "core/node/proof_data_handler", - "core/node/block_reverter", - "core/node/commitment_generator", - "core/node/house_keeper", - "core/node/genesis", - "core/node/shared_metrics", - "core/node/db_pruner", - "core/node/fee_model", - "core/node/da_dispatcher", - "core/node/eth_sender", - "core/node/vm_runner", - "core/node/test_utils", - "core/node/state_keeper", - "core/node/reorg_detector", - "core/node/consistency_checker", - "core/node/metadata_calculator", - "core/node/node_sync", - "core/node/node_storage_init", - "core/node/consensus", - "core/node/contract_verification_server", - "core/node/api_server", - "core/node/base_token_adjuster", - "core/node/external_proof_integration_api", - "core/node/logs_bloom_backfill", - "core/node/da_clients", - # Libraries - "core/lib/db_connection", - "core/lib/zksync_core_leftovers", - "core/lib/basic_types", - "core/lib/config", - "core/lib/constants", - "core/lib/contract_verifier", - "core/lib/contracts", - "core/lib/circuit_breaker", - "core/lib/dal", - "core/lib/env_config", - "core/lib/da_client", - "core/lib/eth_client", - "core/lib/eth_signer", - "core/lib/l1_contract_interface", - "core/lib/mempool", - "core/lib/merkle_tree", - "core/lib/mini_merkle_tree", - "core/lib/node_framework_derive", - "core/lib/object_store", - "core/lib/prover_interface", - "core/lib/queued_job_processor", - "core/lib/state", - "core/lib/storage", - "core/lib/tee_verifier", - "core/lib/types", - "core/lib/protobuf_config", - "core/lib/utils", - "core/lib/vlog", - "core/lib/multivm", - "core/lib/vm_interface", - "core/lib/vm_executor", - "core/lib/web3_decl", - "core/lib/snapshots_applier", - "core/lib/crypto_primitives", - "core/lib/external_price_api", - "core/lib/test_contracts", - # Test infrastructure - "core/tests/loadnext", - "core/tests/vm-benchmark", -] -resolver = "2" - -exclude = [] - -# for `perf` profiling -[profile.perf] -inherits = "release" -debug = true - -[workspace.package] -version = "0.1.0" -edition = "2021" -authors = ["The Matter Labs Team "] -homepage = "https://zksync.io/" -repository = "https://github.com/matter-labs/zksync-era" -license = "MIT OR Apache-2.0" -keywords = ["blockchain", "zksync"] -categories = ["cryptography"] - -[workspace.dependencies] -# "External" dependencies -anyhow = "1" -assert_matches = "1.5" -async-trait = "0.1" -async-recursion = "1" -axum = "0.7.5" -backon = "0.4.4" -bigdecimal = "0.4.5" -bincode = "1" -blake2 = "0.10" -bytes = "1" -chrono = "0.4" -clap = "4.2.2" -codegen = "0.2.0" -const-decoder = "0.4.0" -criterion = "0.4.0" -ctrlc = "3.1" -dashmap = "5.5.3" -derive_more = "1.0.0" -envy = "0.4" -ethabi = "18.0.0" -flate2 = "1.0.28" -fraction = "0.15.3" -futures = "0.3" -futures-util = "0.3" -glob = "0.3" -google-cloud-auth = "0.16.0" -google-cloud-storage = "0.20.0" -governor = "0.4.2" -hex = "0.4" -http = "1.1" -http-body-util = "0.1.2" -httpmock = "0.7.0" -hyper = "1.3" -insta = "1.29.0" -itertools = "0.10" -jsonrpsee = { version = "0.23", default-features = false } -leb128 = "0.2.5" -lru = { version = "0.12.1", default-features = false } -mini-moka = "0.10.0" -num = "0.4.0" -num_cpus = "1.13" -num_enum = "0.7.2" -octocrab = "0.41" -once_cell = "1" -opentelemetry = "0.24.0" -opentelemetry_sdk = "0.24.0" -opentelemetry-otlp = "0.17.0" -opentelemetry-semantic-conventions = "0.16.0" -opentelemetry-appender-tracing = "0.5" -pin-project-lite = "0.2.13" -pretty_assertions = "1" -prost = "0.12.6" -rand = "0.8" -rayon = "1.3.1" -regex = "1" -reqwest = "0.12" -rlp = "0.5" -rocksdb = "0.21" -rustc_version = "0.4.0" -rustls = "0.23" -secp256k1 = { version = "0.27.0", features = ["recovery", "global-context"] } -secrecy = "0.8.0" -semver = "1" -sentry = "0.31" -serde = "1" -serde_json = "1" -serde_with = "1" -serde_yaml = "0.9" -sha2 = "0.10.8" -sha3 = "0.10.8" -sqlx = "0.8.1" -static_assertions = "1.1" -structopt = "0.3.20" -strum = "0.26" -tempfile = "3.0.2" -test-casing = "0.1.2" -test-log = "0.2.15" -thiserror = "1" -thread_local = "1.1" -tikv-jemallocator = "0.5" -tiny-keccak = "2" -tokio = "1" -tower = "0.4.13" -tower-http = "0.5.2" -tracing = "0.1" -tracing-subscriber = "0.3" -tracing-opentelemetry = "0.25.0" -time = "0.3.36" # Has to be same as used by `tracing-subscriber` -url = "2" -web3 = "0.19.0" -yab = "0.1.0" - -# Proc-macro -syn = "2.0" -quote = "1.0" -proc-macro2 = "1.0" -trybuild = "1.0" - -# "Internal" dependencies -vise = "0.2.0" -vise-exporter = "0.2.0" -foundry-compilers = { version = "0.11.6", git = "https://github.com/Moonsong-Labs/compilers.git", rev = "7c69695e5c75451f158dd2456bf8c94a7492ea0b" } - -# DA clients' dependencies -# Avail -base58 = "0.2.0" -scale-encode = "0.5.0" -blake2b_simd = "1.0.2" -subxt-metadata = "0.34.0" -parity-scale-codec = { version = "3.6.9", default-features = false } -subxt-signer = { version = "0.34", default-features = false } - -# Celestia -celestia-types = "0.6.1" -bech32 = "0.11.0" -ripemd = "0.1.3" -tonic = { version = "0.11.0", default-features = false } -pbjson-types = "0.6.0" - -# Eigen -tokio-stream = "0.1.16" - -# Here and below: -# We *always* pin the latest version of protocol to disallow accidental changes in the execution logic. -# However, for the historical version of protocol crates, we have lax requirements. Otherwise, -# Bumping a crypto dependency like `boojum` would require us to republish all the historical packages. -circuit_encodings = "=0.150.19" -circuit_sequencer_api = "=0.150.19" -circuit_definitions = "=0.150.19" -crypto_codegen = { package = "zksync_solidity_vk_codegen",version = "=0.30.12" } -kzg = { package = "zksync_kzg", version = "=0.150.19" } -zk_evm = { version = "=0.133.0" } -zk_evm_1_3_1 = { package = "zk_evm", version = "0.131.0-rc.2" } -zk_evm_1_3_3 = { package = "zk_evm", version = "0.133" } -zk_evm_1_4_0 = { package = "zk_evm", version = "0.140" } -zk_evm_1_4_1 = { package = "zk_evm", version = "0.141" } -zk_evm_1_5_0 = { package = "zk_evm", version = "=0.150.19" } -fflonk = "=0.30.12" - -# New VM; pinned to a specific commit because of instability -zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "457d8a7eea9093af9440662e33e598c13ba41633" } - -# Consensus dependencies. -zksync_concurrency = "=0.7.0" -zksync_consensus_bft = "=0.7.0" -zksync_consensus_crypto = "=0.7.0" -zksync_consensus_executor = "=0.7.0" -zksync_consensus_network = "=0.7.0" -zksync_consensus_roles = "=0.7.0" -zksync_consensus_storage = "=0.7.0" -zksync_consensus_utils = "=0.7.0" -zksync_protobuf = "=0.7.0" -zksync_protobuf_build = "=0.7.0" - -# "Local" dependencies -zksync_multivm = { version = "0.1.0", path = "core/lib/multivm" } -zksync_vlog = { version = "0.1.0", path = "core/lib/vlog" } -zksync_vm_interface = { version = "0.1.0", path = "core/lib/vm_interface" } -zksync_vm_executor = { version = "0.1.0", path = "core/lib/vm_executor" } -zksync_basic_types = { version = "0.1.0", path = "core/lib/basic_types" } -zksync_circuit_breaker = { version = "0.1.0", path = "core/lib/circuit_breaker" } -zksync_config = { version = "0.1.0", path = "core/lib/config" } -zksync_contract_verifier_lib = { version = "0.1.0", path = "core/lib/contract_verifier" } -zksync_contracts = { version = "0.1.0", path = "core/lib/contracts" } -zksync_core_leftovers = { version = "0.1.0", path = "core/lib/zksync_core_leftovers" } -zksync_dal = { version = "0.1.0", path = "core/lib/dal" } -zksync_db_connection = { version = "0.1.0", path = "core/lib/db_connection" } -zksync_env_config = { version = "0.1.0", path = "core/lib/env_config" } -zksync_eth_client = { version = "0.1.0", path = "core/lib/eth_client" } -zksync_da_client = { version = "0.1.0", path = "core/lib/da_client" } -zksync_eth_signer = { version = "0.1.0", path = "core/lib/eth_signer" } -zksync_health_check = { version = "0.1.0", path = "core/lib/health_check" } -zksync_l1_contract_interface = { version = "0.1.0", path = "core/lib/l1_contract_interface" } -zksync_mempool = { version = "0.1.0", path = "core/lib/mempool" } -zksync_merkle_tree = { version = "0.1.0", path = "core/lib/merkle_tree" } -zksync_bin_metadata = { version = "0.1.0", path = "core/lib/bin_metadata" } -zksync_mini_merkle_tree = { version = "0.1.0", path = "core/lib/mini_merkle_tree" } -zksync_object_store = { version = "0.1.0", path = "core/lib/object_store" } -zksync_protobuf_config = { version = "0.1.0", path = "core/lib/protobuf_config" } -zksync_prover_interface = { version = "0.1.0", path = "core/lib/prover_interface" } -zksync_queued_job_processor = { version = "0.1.0", path = "core/lib/queued_job_processor" } -zksync_snapshots_applier = { version = "0.1.0", path = "core/lib/snapshots_applier" } -zksync_state = { version = "0.1.0", path = "core/lib/state" } -zksync_storage = { version = "0.1.0", path = "core/lib/storage" } -zksync_system_constants = { version = "0.1.0", path = "core/lib/constants" } -zksync_tee_verifier = { version = "0.1.0", path = "core/lib/tee_verifier" } -zksync_test_contracts = { version = "0.1.0", path = "core/lib/test_contracts" } -zksync_types = { version = "0.1.0", path = "core/lib/types" } -zksync_utils = { version = "0.1.0", path = "core/lib/utils" } -zksync_web3_decl = { version = "0.1.0", path = "core/lib/web3_decl" } -zksync_crypto_primitives = { version = "0.1.0", path = "core/lib/crypto_primitives" } -zksync_external_price_api = { version = "0.1.0", path = "core/lib/external_price_api" } - -# Framework and components -zksync_node_framework = { version = "0.1.0", path = "core/node/node_framework" } -zksync_node_framework_derive = { version = "0.1.0", path = "core/lib/node_framework_derive" } -zksync_eth_watch = { version = "0.1.0", path = "core/node/eth_watch" } -zksync_shared_metrics = { version = "0.1.0", path = "core/node/shared_metrics" } -zksync_proof_data_handler = { version = "0.1.0", path = "core/node/proof_data_handler" } -zksync_block_reverter = { version = "0.1.0", path = "core/node/block_reverter" } -zksync_commitment_generator = { version = "0.1.0", path = "core/node/commitment_generator" } -zksync_house_keeper = { version = "0.1.0", path = "core/node/house_keeper" } -zksync_node_genesis = { version = "0.1.0", path = "core/node/genesis" } -zksync_da_dispatcher = { version = "0.1.0", path = "core/node/da_dispatcher" } -zksync_da_clients = { version = "0.1.0", path = "core/node/da_clients" } -zksync_eth_sender = { version = "0.1.0", path = "core/node/eth_sender" } -zksync_node_db_pruner = { version = "0.1.0", path = "core/node/db_pruner" } -zksync_node_fee_model = { version = "0.1.0", path = "core/node/fee_model" } -zksync_vm_runner = { version = "0.1.0", path = "core/node/vm_runner" } -zksync_external_proof_integration_api = { version = "0.1.0", path = "core/node/external_proof_integration_api" } -zksync_node_test_utils = { version = "0.1.0", path = "core/node/test_utils" } -zksync_state_keeper = { version = "0.1.0", path = "core/node/state_keeper" } -zksync_reorg_detector = { version = "0.1.0", path = "core/node/reorg_detector" } -zksync_consistency_checker = { version = "0.1.0", path = "core/node/consistency_checker" } -zksync_metadata_calculator = { version = "0.1.0", path = "core/node/metadata_calculator" } -zksync_node_sync = { version = "0.1.0", path = "core/node/node_sync" } -zksync_node_storage_init = { version = "0.1.0", path = "core/node/node_storage_init" } -zksync_node_consensus = { version = "0.1.0", path = "core/node/consensus" } -zksync_contract_verification_server = { version = "0.1.0", path = "core/node/contract_verification_server" } -zksync_node_api_server = { version = "0.1.0", path = "core/node/api_server" } -zksync_base_token_adjuster = { version = "0.1.0", path = "core/node/base_token_adjuster" } -zksync_logs_bloom_backfill = { version = "0.1.0", path = "core/node/logs_bloom_backfill" } diff --git a/Cargo.lock b/core/Cargo.lock similarity index 100% rename from Cargo.lock rename to core/Cargo.lock diff --git a/core/Cargo.toml b/core/Cargo.toml new file mode 100644 index 000000000000..1c071c2839fa --- /dev/null +++ b/core/Cargo.toml @@ -0,0 +1,326 @@ +[workspace] +members = [ + # Binaries + "bin/block_reverter", + "bin/contract-verifier", + "bin/custom_genesis_export", + "bin/external_node", + "bin/merkle_tree_consistency_checker", + "bin/snapshots_creator", + "bin/selector_generator", + "bin/system-constants-generator", + "bin/verified_sources_fetcher", + "bin/zksync_server", + "bin/genesis_generator", + "bin/zksync_tee_prover", + # Node services + "node/node_framework", + "node/proof_data_handler", + "node/block_reverter", + "node/commitment_generator", + "node/house_keeper", + "node/genesis", + "node/shared_metrics", + "node/db_pruner", + "node/fee_model", + "node/da_dispatcher", + "node/eth_sender", + "node/vm_runner", + "node/test_utils", + "node/state_keeper", + "node/reorg_detector", + "node/consistency_checker", + "node/metadata_calculator", + "node/node_sync", + "node/node_storage_init", + "node/consensus", + "node/contract_verification_server", + "node/api_server", + "node/base_token_adjuster", + "node/external_proof_integration_api", + "node/logs_bloom_backfill", + "node/da_clients", + # Libraries + "lib/db_connection", + "lib/zksync_core_leftovers", + "lib/basic_types", + "lib/config", + "lib/constants", + "lib/contract_verifier", + "lib/contracts", + "lib/circuit_breaker", + "lib/dal", + "lib/env_config", + "lib/da_client", + "lib/eth_client", + "lib/eth_signer", + "lib/l1_contract_interface", + "lib/mempool", + "lib/merkle_tree", + "lib/mini_merkle_tree", + "lib/node_framework_derive", + "lib/object_store", + "lib/prover_interface", + "lib/queued_job_processor", + "lib/state", + "lib/storage", + "lib/tee_verifier", + "lib/types", + "lib/protobuf_config", + "lib/utils", + "lib/vlog", + "lib/multivm", + "lib/vm_interface", + "lib/vm_executor", + "lib/web3_decl", + "lib/snapshots_applier", + "lib/crypto_primitives", + "lib/external_price_api", + "lib/test_contracts", + # Test infrastructure + "tests/loadnext", + "tests/vm-benchmark", +] +resolver = "2" + +exclude = [] + +# for `perf` profiling +[profile.perf] +inherits = "release" +debug = true + +[workspace.package] +version = "0.1.0" +edition = "2021" +authors = ["The Matter Labs Team "] +homepage = "https://zksync.io/" +repository = "https://github.com/matter-labs/zksync-era" +license = "MIT OR Apache-2.0" +keywords = ["blockchain", "zksync"] +categories = ["cryptography"] + +[workspace.dependencies] +# "External" dependencies +anyhow = "1" +assert_matches = "1.5" +async-trait = "0.1" +async-recursion = "1" +axum = "0.7.5" +backon = "0.4.4" +bigdecimal = "0.4.5" +bincode = "1" +blake2 = "0.10" +bytes = "1" +chrono = "0.4" +clap = "4.2.2" +codegen = "0.2.0" +const-decoder = "0.4.0" +criterion = "0.4.0" +ctrlc = "3.1" +dashmap = "5.5.3" +derive_more = "1.0.0" +envy = "0.4" +ethabi = "18.0.0" +flate2 = "1.0.28" +fraction = "0.15.3" +futures = "0.3" +futures-util = "0.3" +glob = "0.3" +google-cloud-auth = "0.16.0" +google-cloud-storage = "0.20.0" +governor = "0.4.2" +hex = "0.4" +http = "1.1" +http-body-util = "0.1.2" +httpmock = "0.7.0" +hyper = "1.3" +insta = "1.29.0" +itertools = "0.10" +jsonrpsee = { version = "0.23", default-features = false } +leb128 = "0.2.5" +lru = { version = "0.12.1", default-features = false } +mini-moka = "0.10.0" +num = "0.4.0" +num_cpus = "1.13" +num_enum = "0.7.2" +octocrab = "0.41" +once_cell = "1" +opentelemetry = "0.24.0" +opentelemetry_sdk = "0.24.0" +opentelemetry-otlp = "0.17.0" +opentelemetry-semantic-conventions = "0.16.0" +opentelemetry-appender-tracing = "0.5" +pin-project-lite = "0.2.13" +pretty_assertions = "1" +prost = "0.12.6" +rand = "0.8" +rayon = "1.3.1" +regex = "1" +reqwest = "0.12" +rlp = "0.5" +rocksdb = "0.21" +rustc_version = "0.4.0" +rustls = "0.23" +secp256k1 = { version = "0.27.0", features = ["recovery", "global-context"] } +secrecy = "0.8.0" +semver = "1" +sentry = "0.31" +serde = "1" +serde_json = "1" +serde_with = "1" +serde_yaml = "0.9" +sha2 = "0.10.8" +sha3 = "0.10.8" +sqlx = "0.8.1" +static_assertions = "1.1" +structopt = "0.3.20" +strum = "0.26" +tempfile = "3.0.2" +test-casing = "0.1.2" +test-log = "0.2.15" +thiserror = "1" +thread_local = "1.1" +tikv-jemallocator = "0.5" +tiny-keccak = "2" +tokio = "1" +tower = "0.4.13" +tower-http = "0.5.2" +tracing = "0.1" +tracing-subscriber = "0.3" +tracing-opentelemetry = "0.25.0" +time = "0.3.36" # Has to be same as used by `tracing-subscriber` +url = "2" +web3 = "0.19.0" +yab = "0.1.0" + +# Proc-macro +syn = "2.0" +quote = "1.0" +proc-macro2 = "1.0" +trybuild = "1.0" + +# "Internal" dependencies +vise = "0.2.0" +vise-exporter = "0.2.0" +foundry-compilers = { version = "0.11.6", git = "https://github.com/Moonsong-Labs/compilers.git", rev = "7c69695e5c75451f158dd2456bf8c94a7492ea0b" } + +# DA clients' dependencies +# Avail +base58 = "0.2.0" +scale-encode = "0.5.0" +blake2b_simd = "1.0.2" +subxt-metadata = "0.34.0" +parity-scale-codec = { version = "3.6.9", default-features = false } +subxt-signer = { version = "0.34", default-features = false } + +# Celestia +celestia-types = "0.6.1" +bech32 = "0.11.0" +ripemd = "0.1.3" +tonic = { version = "0.11.0", default-features = false } +pbjson-types = "0.6.0" + +# Eigen +tokio-stream = "0.1.16" + +# Here and below: +# We *always* pin the latest version of protocol to disallow accidental changes in the execution logic. +# However, for the historical version of protocol crates, we have lax requirements. Otherwise, +# Bumping a crypto dependency like `boojum` would require us to republish all the historical packages. +circuit_encodings = "=0.150.19" +circuit_sequencer_api = "=0.150.19" +circuit_definitions = "=0.150.19" +crypto_codegen = { package = "zksync_solidity_vk_codegen",version = "=0.30.12" } +kzg = { package = "zksync_kzg", version = "=0.150.19" } +zk_evm = { version = "=0.133.0" } +zk_evm_1_3_1 = { package = "zk_evm", version = "0.131.0-rc.2" } +zk_evm_1_3_3 = { package = "zk_evm", version = "0.133" } +zk_evm_1_4_0 = { package = "zk_evm", version = "0.140" } +zk_evm_1_4_1 = { package = "zk_evm", version = "0.141" } +zk_evm_1_5_0 = { package = "zk_evm", version = "=0.150.19" } +fflonk = "=0.30.12" + +# New VM; pinned to a specific commit because of instability +zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "457d8a7eea9093af9440662e33e598c13ba41633" } + +# Consensus dependencies. +zksync_concurrency = "=0.7.0" +zksync_consensus_bft = "=0.7.0" +zksync_consensus_crypto = "=0.7.0" +zksync_consensus_executor = "=0.7.0" +zksync_consensus_network = "=0.7.0" +zksync_consensus_roles = "=0.7.0" +zksync_consensus_storage = "=0.7.0" +zksync_consensus_utils = "=0.7.0" +zksync_protobuf = "=0.7.0" +zksync_protobuf_build = "=0.7.0" + +# "Local" dependencies +zksync_multivm = { version = "0.1.0", path = "lib/multivm" } +zksync_vlog = { version = "0.1.0", path = "lib/vlog" } +zksync_vm_interface = { version = "0.1.0", path = "lib/vm_interface" } +zksync_vm_executor = { version = "0.1.0", path = "lib/vm_executor" } +zksync_basic_types = { version = "0.1.0", path = "lib/basic_types" } +zksync_circuit_breaker = { version = "0.1.0", path = "lib/circuit_breaker" } +zksync_config = { version = "0.1.0", path = "lib/config" } +zksync_contract_verifier_lib = { version = "0.1.0", path = "lib/contract_verifier" } +zksync_contracts = { version = "0.1.0", path = "lib/contracts" } +zksync_core_leftovers = { version = "0.1.0", path = "lib/zksync_core_leftovers" } +zksync_dal = { version = "0.1.0", path = "lib/dal" } +zksync_db_connection = { version = "0.1.0", path = "lib/db_connection" } +zksync_env_config = { version = "0.1.0", path = "lib/env_config" } +zksync_eth_client = { version = "0.1.0", path = "lib/eth_client" } +zksync_da_client = { version = "0.1.0", path = "lib/da_client" } +zksync_eth_signer = { version = "0.1.0", path = "lib/eth_signer" } +zksync_health_check = { version = "0.1.0", path = "lib/health_check" } +zksync_l1_contract_interface = { version = "0.1.0", path = "lib/l1_contract_interface" } +zksync_mempool = { version = "0.1.0", path = "lib/mempool" } +zksync_merkle_tree = { version = "0.1.0", path = "lib/merkle_tree" } +zksync_bin_metadata = { version = "0.1.0", path = "lib/bin_metadata" } +zksync_mini_merkle_tree = { version = "0.1.0", path = "lib/mini_merkle_tree" } +zksync_object_store = { version = "0.1.0", path = "lib/object_store" } +zksync_protobuf_config = { version = "0.1.0", path = "lib/protobuf_config" } +zksync_prover_interface = { version = "0.1.0", path = "lib/prover_interface" } +zksync_queued_job_processor = { version = "0.1.0", path = "lib/queued_job_processor" } +zksync_snapshots_applier = { version = "0.1.0", path = "lib/snapshots_applier" } +zksync_state = { version = "0.1.0", path = "lib/state" } +zksync_storage = { version = "0.1.0", path = "lib/storage" } +zksync_system_constants = { version = "0.1.0", path = "lib/constants" } +zksync_tee_verifier = { version = "0.1.0", path = "lib/tee_verifier" } +zksync_test_contracts = { version = "0.1.0", path = "lib/test_contracts" } +zksync_types = { version = "0.1.0", path = "lib/types" } +zksync_utils = { version = "0.1.0", path = "lib/utils" } +zksync_web3_decl = { version = "0.1.0", path = "lib/web3_decl" } +zksync_crypto_primitives = { version = "0.1.0", path = "lib/crypto_primitives" } +zksync_external_price_api = { version = "0.1.0", path = "lib/external_price_api" } + +# Framework and components +zksync_node_framework = { version = "0.1.0", path = "node/node_framework" } +zksync_node_framework_derive = { version = "0.1.0", path = "lib/node_framework_derive" } +zksync_eth_watch = { version = "0.1.0", path = "node/eth_watch" } +zksync_shared_metrics = { version = "0.1.0", path = "node/shared_metrics" } +zksync_proof_data_handler = { version = "0.1.0", path = "node/proof_data_handler" } +zksync_block_reverter = { version = "0.1.0", path = "node/block_reverter" } +zksync_commitment_generator = { version = "0.1.0", path = "node/commitment_generator" } +zksync_house_keeper = { version = "0.1.0", path = "node/house_keeper" } +zksync_node_genesis = { version = "0.1.0", path = "node/genesis" } +zksync_da_dispatcher = { version = "0.1.0", path = "node/da_dispatcher" } +zksync_da_clients = { version = "0.1.0", path = "node/da_clients" } +zksync_eth_sender = { version = "0.1.0", path = "node/eth_sender" } +zksync_node_db_pruner = { version = "0.1.0", path = "node/db_pruner" } +zksync_node_fee_model = { version = "0.1.0", path = "node/fee_model" } +zksync_vm_runner = { version = "0.1.0", path = "node/vm_runner" } +zksync_external_proof_integration_api = { version = "0.1.0", path = "node/external_proof_integration_api" } +zksync_node_test_utils = { version = "0.1.0", path = "node/test_utils" } +zksync_state_keeper = { version = "0.1.0", path = "node/state_keeper" } +zksync_reorg_detector = { version = "0.1.0", path = "node/reorg_detector" } +zksync_consistency_checker = { version = "0.1.0", path = "node/consistency_checker" } +zksync_metadata_calculator = { version = "0.1.0", path = "node/metadata_calculator" } +zksync_node_sync = { version = "0.1.0", path = "node/node_sync" } +zksync_node_storage_init = { version = "0.1.0", path = "node/node_storage_init" } +zksync_node_consensus = { version = "0.1.0", path = "node/consensus" } +zksync_contract_verification_server = { version = "0.1.0", path = "node/contract_verification_server" } +zksync_node_api_server = { version = "0.1.0", path = "node/api_server" } +zksync_base_token_adjuster = { version = "0.1.0", path = "node/base_token_adjuster" } +zksync_logs_bloom_backfill = { version = "0.1.0", path = "node/logs_bloom_backfill" } diff --git a/core/bin/system-constants-generator/src/main.rs b/core/bin/system-constants-generator/src/main.rs index cd795f9f5326..69152545bdfe 100644 --- a/core/bin/system-constants-generator/src/main.rs +++ b/core/bin/system-constants-generator/src/main.rs @@ -212,7 +212,7 @@ fn generate_rust_fee_constants(intrinsic_gas_constants: &IntrinsicSystemGasConst } fn save_file(path_in_repo: &str, content: String) { - let zksync_home = Workspace::locate().core(); + let zksync_home = Workspace::locate().root(); let fee_constants_path = zksync_home.join(path_in_repo); fs::write(fee_constants_path, content) diff --git a/deny.toml b/core/deny.toml similarity index 100% rename from deny.toml rename to core/deny.toml diff --git a/core/lib/contract_verifier/src/resolver/env.rs b/core/lib/contract_verifier/src/resolver/env.rs index 798efde64348..75fdf4e7f472 100644 --- a/core/lib/contract_verifier/src/resolver/env.rs +++ b/core/lib/contract_verifier/src/resolver/env.rs @@ -23,7 +23,7 @@ pub(crate) struct EnvCompilerResolver { impl Default for EnvCompilerResolver { fn default() -> Self { Self { - home_dir: Workspace::locate().core(), + home_dir: Workspace::locate().root(), } } } diff --git a/core/lib/contracts/src/lib.rs b/core/lib/contracts/src/lib.rs index 87f102be39d6..e7cf1508f733 100644 --- a/core/lib/contracts/src/lib.rs +++ b/core/lib/contracts/src/lib.rs @@ -82,7 +82,7 @@ const _FAIL_ON_RECEIVE_CONTRACT_FILE: &str = "contracts/l1-contracts/artifacts/contracts/zksync/dev-contracts/FailOnReceive.sol/FailOnReceive.json"; fn home_path() -> PathBuf { - Workspace::locate().core() + Workspace::locate().root() } fn read_file_to_json_value(path: impl AsRef + std::fmt::Debug) -> Option { diff --git a/core/lib/utils/src/env.rs b/core/lib/utils/src/env.rs index 8f4aa1da9400..0da0ddbc9f70 100644 --- a/core/lib/utils/src/env.rs +++ b/core/lib/utils/src/env.rs @@ -11,11 +11,9 @@ static WORKSPACE: OnceCell> = OnceCell::new(); /// Represents Cargo workspaces available in the repository. #[derive(Debug, Clone, Copy)] pub enum Workspace<'a> { - /// Workspace was not found. - /// Assumes that the code is running in a binary. - /// Will use the current directory as a fallback. - None, /// Root folder. + Root, + /// `core` folder. Core(&'a Path), /// `prover` folder. Prover(&'a Path), @@ -42,21 +40,30 @@ impl Workspace<'static> { result.ok() }) .as_deref(); - path.map_or(Self::None, Self::from) + path.map_or(Self::Root, Self::from) } } impl<'a> Workspace<'a> { + const CORE_DIRECTORY_NAME: &'static str = "core"; const PROVER_DIRECTORY_NAME: &'static str = "prover"; const ZKSTACK_CLI_DIRECTORY_NAME: &'static str = "zkstack_cli"; - /// Returns the path of the core workspace. - /// For `Workspace::None`, considers the current directory to represent core workspace. + /// Returns the path of the repository root. + pub fn root(self) -> PathBuf { + match self { + Self::Root => PathBuf::from("."), + Self::Core(path) | Self::Prover(path) | Self::ZkStackCli(path) => { + path.parent().unwrap().into() + } + } + } + + /// Returns the path of the `core` workspace. pub fn core(self) -> PathBuf { match self { - Self::None => PathBuf::from("."), Self::Core(path) => path.into(), - Self::Prover(path) | Self::ZkStackCli(path) => path.parent().unwrap().into(), + _ => self.root().join(Self::CORE_DIRECTORY_NAME), } } @@ -64,7 +71,7 @@ impl<'a> Workspace<'a> { pub fn prover(self) -> PathBuf { match self { Self::Prover(path) => path.into(), - _ => self.core().join(Self::PROVER_DIRECTORY_NAME), + _ => self.root().join(Self::PROVER_DIRECTORY_NAME), } } @@ -72,7 +79,7 @@ impl<'a> Workspace<'a> { pub fn zkstack_cli(self) -> PathBuf { match self { Self::ZkStackCli(path) => path.into(), - _ => self.core().join(Self::ZKSTACK_CLI_DIRECTORY_NAME), + _ => self.root().join(Self::ZKSTACK_CLI_DIRECTORY_NAME), } } } @@ -83,8 +90,10 @@ impl<'a> From<&'a Path> for Workspace<'a> { Self::Prover(path) } else if path.ends_with(Self::ZKSTACK_CLI_DIRECTORY_NAME) { Self::ZkStackCli(path) - } else { + } else if path.ends_with(Self::CORE_DIRECTORY_NAME) { Self::Core(path) + } else { + Self::Root } } } @@ -150,7 +159,6 @@ mod tests { let _pwd_protector = PwdProtector::new(); // Core. - let workspace = Workspace::locate(); assert_matches!(workspace, Workspace::Core(_)); let core_path = workspace.core(); diff --git a/core/tests/loadnext/src/fs_utils.rs b/core/tests/loadnext/src/fs_utils.rs index 0e5107f40861..9f44b1ff4946 100644 --- a/core/tests/loadnext/src/fs_utils.rs +++ b/core/tests/loadnext/src/fs_utils.rs @@ -17,7 +17,7 @@ pub struct Token { } pub fn read_tokens(network: Network) -> anyhow::Result> { - let home = Workspace::locate().core(); + let home = Workspace::locate().root(); let path = home.join(format!("etc/tokens/{network}.json")); let file = File::open(path)?; let reader = BufReader::new(file); diff --git a/core/tests/revert-test/tests/revert-and-restart-en.test.ts b/core/tests/revert-test/tests/revert-and-restart-en.test.ts index ca7f1735b356..a27e3836461a 100644 --- a/core/tests/revert-test/tests/revert-and-restart-en.test.ts +++ b/core/tests/revert-test/tests/revert-and-restart-en.test.ts @@ -54,7 +54,18 @@ function compileBinaries() { console.log('compiling binaries'); run( 'cargo', - ['build', '--release', '--bin', 'zksync_external_node', '--bin', 'zksync_server', '--bin', 'block_reverter'], + [ + 'build', + '--manifest-path', + './core/Cargo.toml', + '--release', + '--bin', + 'zksync_external_node', + '--bin', + 'zksync_server', + '--bin', + 'block_reverter' + ], { cwd: process.env.ZKSYNC_HOME } ); } diff --git a/core/tests/revert-test/tests/utils.ts b/core/tests/revert-test/tests/utils.ts index 8290598a1feb..d2cf9df837ad 100644 --- a/core/tests/revert-test/tests/utils.ts +++ b/core/tests/revert-test/tests/utils.ts @@ -148,7 +148,7 @@ async function runBlockReverter( `; } - const cmd = `cd ${pathToHome} && RUST_LOG=off cargo run --bin block_reverter --release -- ${args.join( + const cmd = `cd ${pathToHome} && RUST_LOG=off cargo run --manifest-path ./core/Cargo.toml --bin block_reverter --release -- ${args.join( ' ' )} ${fileConfigFlags}`; diff --git a/docker/contract-verifier/Dockerfile b/docker/contract-verifier/Dockerfile index d5f3c53db99f..14cae24c0642 100644 --- a/docker/contract-verifier/Dockerfile +++ b/docker/contract-verifier/Dockerfile @@ -17,7 +17,7 @@ ENV RUSTC_WRAPPER=${RUSTC_WRAPPER} WORKDIR /usr/src/zksync COPY . . -RUN cargo build --release --bin zksync_contract_verifier +RUN cargo build --manifest-path ./core/Cargo.toml --release --bin zksync_contract_verifier FROM ghcr.io/matter-labs/zksync-runtime-base:latest @@ -96,7 +96,7 @@ RUN mkdir -p /etc/vyper-bin/0.4.0 \ && mv vyper0.4.0 /etc/vyper-bin/0.4.0/vyper \ && chmod +x /etc/vyper-bin/0.4.0/vyper -COPY --from=builder /usr/src/zksync/target/release/zksync_contract_verifier /usr/bin/ +COPY --from=builder /usr/src/zksync/core/target/release/zksync_contract_verifier /usr/bin/ COPY contracts/system-contracts/zkout/ /contracts/system-contracts/zkout/ # CMD tail -f /dev/null diff --git a/docker/external-node/Dockerfile b/docker/external-node/Dockerfile index 2effe1051b4a..3c968b896e43 100644 --- a/docker/external-node/Dockerfile +++ b/docker/external-node/Dockerfile @@ -15,12 +15,12 @@ ENV RUSTC_WRAPPER=${RUSTC_WRAPPER} WORKDIR /usr/src/zksync COPY . . -RUN cargo build --release --bin zksync_external_node --bin block_reverter +RUN cargo build --manifest-path ./core/Cargo.toml --release --bin zksync_external_node --bin block_reverter FROM ghcr.io/matter-labs/zksync-runtime-base:latest -COPY --from=builder /usr/src/zksync/target/release/zksync_external_node /usr/bin -COPY --from=builder /usr/src/zksync/target/release/block_reverter /usr/bin +COPY --from=builder /usr/src/zksync/core/target/release/zksync_external_node /usr/bin +COPY --from=builder /usr/src/zksync/core/target/release/block_reverter /usr/bin COPY --from=builder /usr/local/cargo/bin/sqlx /usr/bin COPY --from=builder /usr/src/zksync/docker/external-node/entrypoint.sh /usr/bin COPY contracts/system-contracts/zkout/ /contracts/system-contracts/zkout/ diff --git a/docker/server-v2/Dockerfile b/docker/server-v2/Dockerfile index 9557156fa7c4..5855bab8d7ab 100644 --- a/docker/server-v2/Dockerfile +++ b/docker/server-v2/Dockerfile @@ -17,7 +17,7 @@ WORKDIR /usr/src/zksync COPY . . -RUN cargo build --release --features=rocksdb/io-uring --bin zksync_server --bin block_reverter --bin merkle_tree_consistency_checker +RUN cargo build --manifest-path ./core/Cargo.toml --release --features=rocksdb/io-uring --bin zksync_server --bin block_reverter --bin merkle_tree_consistency_checker FROM ghcr.io/matter-labs/zksync-runtime-base:latest @@ -28,9 +28,9 @@ EXPOSE 3000 EXPOSE 3031 EXPOSE 3030 -COPY --from=builder /usr/src/zksync/target/release/zksync_server /usr/bin -COPY --from=builder /usr/src/zksync/target/release/block_reverter /usr/bin -COPY --from=builder /usr/src/zksync/target/release/merkle_tree_consistency_checker /usr/bin +COPY --from=builder /usr/src/zksync/core/target/release/zksync_server /usr/bin +COPY --from=builder /usr/src/zksync/core/target/release/block_reverter /usr/bin +COPY --from=builder /usr/src/zksync/core/target/release/merkle_tree_consistency_checker /usr/bin COPY contracts/system-contracts/zkout/ /contracts/system-contracts/zkout/ COPY contracts/l1-contracts/out/ /contracts/l1-contracts/out/ COPY contracts/l2-contracts/zkout/ /contracts/l2-contracts/zkout/ diff --git a/docker/snapshots-creator/Dockerfile b/docker/snapshots-creator/Dockerfile index 2d3c83064981..753020094df7 100644 --- a/docker/snapshots-creator/Dockerfile +++ b/docker/snapshots-creator/Dockerfile @@ -15,13 +15,13 @@ ENV RUSTC_WRAPPER=${RUSTC_WRAPPER} WORKDIR /usr/src/zksync COPY . . -RUN cargo build --release --bin snapshots_creator +RUN cargo build --manifest-path ./core/Cargo.toml --release --bin snapshots_creator FROM ghcr.io/matter-labs/zksync-runtime-base:latest RUN apt-get update && apt-get install -y liburing-dev && \ rm -rf /var/lib/apt/lists/* -COPY --from=builder /usr/src/zksync/target/release/snapshots_creator /usr/bin +COPY --from=builder /usr/src/zksync/core/target/release/snapshots_creator /usr/bin ENTRYPOINT ["snapshots_creator"] diff --git a/docker/verified-sources-fetcher/Dockerfile b/docker/verified-sources-fetcher/Dockerfile index 87475f3187f3..ebc6619582fd 100644 --- a/docker/verified-sources-fetcher/Dockerfile +++ b/docker/verified-sources-fetcher/Dockerfile @@ -16,7 +16,7 @@ ENV RUSTC_WRAPPER=${RUSTC_WRAPPER} WORKDIR /usr/src/zksync COPY . . -RUN cargo build --release --bin verified_sources_fetcher +RUN cargo build --manifest-path ./core/Cargo.toml --release --bin verified_sources_fetcher FROM ghcr.io/matter-labs/zksync-runtime-base:latest @@ -26,6 +26,6 @@ RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor - RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list RUN apt-get update && apt-get install -y google-cloud-cli && rm -rf /var/lib/apt/lists/* -COPY --from=builder /usr/src/zksync/target/release/verified_sources_fetcher /usr/bin/ +COPY --from=builder /usr/src/zksync/core/target/release/verified_sources_fetcher /usr/bin/ ENTRYPOINT ["verified_sources_fetcher"] diff --git a/flake.nix b/flake.nix index 8c08e880910d..630d719aa4df 100644 --- a/flake.nix +++ b/flake.nix @@ -84,17 +84,7 @@ snappy.dev ]; - src = with pkgs.lib.fileset; toSource { - root = ./.; - fileset = unions [ - ./Cargo.lock - ./Cargo.toml - ./core - ./prover - ./zkstack_cli - ./.github/release-please/manifest.json - ]; - }; + src = ./core/.; env = { OPENSSL_NO_VENDOR = "1"; diff --git a/infrastructure/zk/src/server.ts b/infrastructure/zk/src/server.ts index 8b10559361ae..14a27f6a48be 100644 --- a/infrastructure/zk/src/server.ts +++ b/infrastructure/zk/src/server.ts @@ -17,7 +17,7 @@ export async function server(rebuildTree: boolean, uring: boolean, components?: if (components) { options += ` --components=${components}`; } - await utils.spawn(`cargo run --bin zksync_server --release ${options}`); + await utils.spawn(`cargo run --manifest-path core/Cargo.toml--bin zksync_server --release ${options}`); } export async function externalNode(reinit: boolean = false, args: string[]) { @@ -37,7 +37,9 @@ export async function externalNode(reinit: boolean = false, args: string[]) { clean(path.dirname(process.env.EN_MERKLE_TREE_PATH!)); } - await utils.spawn(`cargo run --release --bin zksync_external_node -- ${args.join(' ')}`); + await utils.spawn( + `cargo run --manifest-path core/Cargo.toml --release --bin zksync_external_node -- ${args.join(' ')}` + ); } async function create_genesis(cmd: string) { @@ -61,7 +63,7 @@ async function create_genesis(cmd: string) { export async function genesisFromSources() { // Note that that all the chains have the same chainId at genesis. It will be changed // via an upgrade transaction during the registration of the chain. - await create_genesis('cargo run --bin zksync_server --release -- --genesis'); + await create_genesis('cargo run --manifest-path core/Cargo.toml --bin zksync_server --release -- --genesis'); } export async function genesisFromBinary() { diff --git a/prover/crates/bin/prover_cli/src/config/mod.rs b/prover/crates/bin/prover_cli/src/config/mod.rs index b3df2e7d2c56..88cf3a55f908 100644 --- a/prover/crates/bin/prover_cli/src/config/mod.rs +++ b/prover/crates/bin/prover_cli/src/config/mod.rs @@ -6,7 +6,7 @@ pub fn get_envfile() -> anyhow::Result { if let Ok(envfile) = std::env::var("PLI__CONFIG") { return Ok(envfile.into()); } - Ok(Workspace::locate().core().join("etc/pliconfig")) + Ok(Workspace::locate().root().join("etc/pliconfig")) } pub fn load_envfile(path: impl AsRef) -> anyhow::Result<()> { diff --git a/prover/crates/bin/prover_cli/src/helper.rs b/prover/crates/bin/prover_cli/src/helper.rs index 7fe0c990e4e0..b793ce5f2be1 100644 --- a/prover/crates/bin/prover_cli/src/helper.rs +++ b/prover/crates/bin/prover_cli/src/helper.rs @@ -24,7 +24,7 @@ fn read_file_to_json_value(path: &PathBuf) -> serde_json::Value { } fn load_contract_if_present(path: &str) -> Contract { - let path = Workspace::locate().core().join(path); + let path = Workspace::locate().root().join(path); path.exists() .then(|| { serde_json::from_value(read_file_to_json_value(&path)["abi"].take()).unwrap_or_else( diff --git a/prover/crates/bin/vk_setup_data_generator_server_fri/src/vk_commitment_helper.rs b/prover/crates/bin/vk_setup_data_generator_server_fri/src/vk_commitment_helper.rs index 2753799dc722..2f5bbf269267 100644 --- a/prover/crates/bin/vk_setup_data_generator_server_fri/src/vk_commitment_helper.rs +++ b/prover/crates/bin/vk_setup_data_generator_server_fri/src/vk_commitment_helper.rs @@ -24,6 +24,6 @@ pub fn read_contract_toml() -> anyhow::Result { pub fn get_contract_toml_path() -> PathBuf { Workspace::locate() - .core() + .root() .join("etc/env/base/contracts.toml") } diff --git a/prover/crates/lib/keystore/src/keystore.rs b/prover/crates/lib/keystore/src/keystore.rs index fb84436916e7..c4ffb32ce73c 100644 --- a/prover/crates/lib/keystore/src/keystore.rs +++ b/prover/crates/lib/keystore/src/keystore.rs @@ -78,7 +78,7 @@ impl Keystore { // - We're running from the core workspace. // - We're running the binary from the docker. let data_dir_path = match Workspace::locate() { - Workspace::None => { + Workspace::Root => { // We're running a binary, likely in a docker. // Keys can be in one of a few paths. // We want to be very conservative here, and checking diff --git a/zkstack_cli/crates/common/src/external_node.rs b/zkstack_cli/crates/common/src/external_node.rs index 8a5cbc3cd14c..7f9031bae4ff 100644 --- a/zkstack_cli/crates/common/src/external_node.rs +++ b/zkstack_cli/crates/common/src/external_node.rs @@ -17,7 +17,7 @@ pub fn run( let cmd = Cmd::new( cmd!( shell, - "cargo run --release --bin zksync_external_node -- + "cargo run --manifest-path ./core/Cargo.toml --release --bin zksync_external_node -- --config-path {config_path} --secrets-path {secrets_path} --external-node-config-path {en_config_path} diff --git a/zkstack_cli/crates/common/src/server.rs b/zkstack_cli/crates/common/src/server.rs index 7f8c2a90e589..0dd93bcd3324 100644 --- a/zkstack_cli/crates/common/src/server.rs +++ b/zkstack_cli/crates/common/src/server.rs @@ -70,7 +70,7 @@ impl Server { let mut cmd = Cmd::new( cmd!( shell, - "cargo run --release --bin zksync_server {uring...} -- + "cargo run --manifest-path ./core/Cargo.toml --release --bin zksync_server {uring...} -- --genesis-path {genesis_path} --wallets-path {wallets_path} --config-path {general_path} @@ -96,7 +96,7 @@ impl Server { /// Builds the server. pub fn build(&self, shell: &Shell) -> anyhow::Result<()> { - let _dir_guard = shell.push_dir(&self.code_path); + let _dir_guard = shell.push_dir(self.code_path.join("core")); Cmd::new(cmd!(shell, "cargo build --release --bin zksync_server")).run()?; Ok(()) } diff --git a/zkstack_cli/crates/zkstack/src/commands/contract_verifier/build.rs b/zkstack_cli/crates/zkstack/src/commands/contract_verifier/build.rs index 384e9a389265..2e4107383d0a 100644 --- a/zkstack_cli/crates/zkstack/src/commands/contract_verifier/build.rs +++ b/zkstack_cli/crates/zkstack/src/commands/contract_verifier/build.rs @@ -13,7 +13,7 @@ pub(crate) async fn build(shell: &Shell) -> anyhow::Result<()> { let chain = ecosystem .load_current_chain() .context(MSG_CHAIN_NOT_FOUND_ERR)?; - let _dir_guard = shell.push_dir(&chain.link_to_code); + let _dir_guard = shell.push_dir(chain.link_to_code.join("core")); logger::info(MSG_BUILDING_CONTRACT_VERIFIER); diff --git a/zkstack_cli/crates/zkstack/src/commands/contract_verifier/run.rs b/zkstack_cli/crates/zkstack/src/commands/contract_verifier/run.rs index fd872aa67248..fe4221e83a46 100644 --- a/zkstack_cli/crates/zkstack/src/commands/contract_verifier/run.rs +++ b/zkstack_cli/crates/zkstack/src/commands/contract_verifier/run.rs @@ -22,7 +22,7 @@ pub(crate) async fn run(shell: &Shell) -> anyhow::Result<()> { let mut cmd = Cmd::new(cmd!( shell, - "cargo run --release --bin zksync_contract_verifier -- --config-path={config_path} --secrets-path={secrets_path}" + "cargo run --manifest-path ./core/Cargo.toml --release --bin zksync_contract_verifier -- --config-path={config_path} --secrets-path={secrets_path}" )); cmd = cmd.with_force_run(); cmd.run().context(MSG_FAILED_TO_RUN_CONTRACT_VERIFIER_ERR) diff --git a/zkstack_cli/crates/zkstack/src/commands/dev/commands/fmt.rs b/zkstack_cli/crates/zkstack/src/commands/dev/commands/fmt.rs index af6985b006d2..82594cccf484 100644 --- a/zkstack_cli/crates/zkstack/src/commands/dev/commands/fmt.rs +++ b/zkstack_cli/crates/zkstack/src/commands/dev/commands/fmt.rs @@ -42,7 +42,7 @@ async fn prettier_contracts(shell: Shell, check: bool) -> anyhow::Result<()> { } async fn rustfmt(shell: Shell, check: bool, link_to_code: PathBuf) -> anyhow::Result<()> { - for dir in [".", "prover", "zkstack_cli"] { + for dir in ["core", "prover", "zkstack_cli"] { let spinner = Spinner::new(&msg_running_rustfmt_for_dir_spinner(dir)); let _dir = shell.push_dir(link_to_code.join(dir)); let mut cmd = cmd!(shell, "cargo fmt -- --config imports_granularity=Crate --config group_imports=StdExternalCrate"); diff --git a/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint.rs b/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint.rs index 6b919b8cdb9d..7ba6fe27481a 100644 --- a/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint.rs +++ b/zkstack_cli/crates/zkstack/src/commands/dev/commands/lint.rs @@ -70,12 +70,12 @@ pub fn run(shell: &Shell, args: LintArgs) -> anyhow::Result<()> { fn lint_rs(shell: &Shell, ecosystem: &EcosystemConfig, check: bool) -> anyhow::Result<()> { let spinner = Spinner::new(&msg_running_linter_for_extension_spinner(&Target::Rs)); - let link_to_code = &ecosystem.link_to_code; + let link_to_core = &ecosystem.link_to_code.join("core"); let lint_to_prover = &ecosystem.link_to_code.join("prover"); let link_to_zkstack = &ecosystem.link_to_code.join("zkstack_cli"); spinner.freeze(); - for path in [link_to_code, lint_to_prover, link_to_zkstack] { + for path in [link_to_core, lint_to_prover, link_to_zkstack] { let _dir_guard = shell.push_dir(path); let mut cmd = cmd!(shell, "cargo clippy"); let mut common_args = vec!["--locked", "--", "-D", "warnings"]; diff --git a/zkstack_cli/crates/zkstack/src/commands/dev/commands/snapshot.rs b/zkstack_cli/crates/zkstack/src/commands/dev/commands/snapshot.rs index dcc41af228be..85aaec103c0b 100644 --- a/zkstack_cli/crates/zkstack/src/commands/dev/commands/snapshot.rs +++ b/zkstack_cli/crates/zkstack/src/commands/dev/commands/snapshot.rs @@ -32,7 +32,7 @@ async fn create(shell: &Shell) -> anyhow::Result<()> { logger::info(MSG_RUNNING_SNAPSHOT_CREATOR); - let mut cmd = Cmd::new(cmd!(shell, "cargo run --bin snapshots_creator --release -- --config-path={config_path} --secrets-path={secrets_path}")) + let mut cmd = Cmd::new(cmd!(shell, "cargo run --manifest-path ./core/Cargo.toml --bin snapshots_creator --release -- --config-path={config_path} --secrets-path={secrets_path}")) .env("RUST_LOG", "snapshots_creator=debug"); cmd = cmd.with_force_run(); diff --git a/zkstack_cli/crates/zkstack/src/commands/dev/commands/test/loadtest.rs b/zkstack_cli/crates/zkstack/src/commands/dev/commands/test/loadtest.rs index 385335890c75..64ea474fa2fa 100644 --- a/zkstack_cli/crates/zkstack/src/commands/dev/commands/test/loadtest.rs +++ b/zkstack_cli/crates/zkstack/src/commands/dev/commands/test/loadtest.rs @@ -17,28 +17,31 @@ pub fn run(shell: &Shell) -> anyhow::Result<()> { .api_config .context("API config is not found")?; - let mut command = cmd!(shell, "cargo run --release --bin loadnext") - .env( - "L2_CHAIN_ID", - chain_config - .get_genesis_config()? - .l2_chain_id - .as_u64() - .to_string(), - ) - .env( - "MAIN_TOKEN", - format!( - "{:?}", - ecosystem_config - .get_erc20_tokens() - .first() - .context("NO Erc20 tokens were deployed")? - .address - ), - ) - .env("L2_RPC_ADDRESS", general_api.web3_json_rpc.http_url) - .env("L2_WS_RPC_ADDRESS", general_api.web3_json_rpc.ws_url); + let mut command = cmd!( + shell, + "cargo run --manifest-path ./core/Cargo.toml --release --bin loadnext" + ) + .env( + "L2_CHAIN_ID", + chain_config + .get_genesis_config()? + .l2_chain_id + .as_u64() + .to_string(), + ) + .env( + "MAIN_TOKEN", + format!( + "{:?}", + ecosystem_config + .get_erc20_tokens() + .first() + .context("NO Erc20 tokens were deployed")? + .address + ), + ) + .env("L2_RPC_ADDRESS", general_api.web3_json_rpc.http_url) + .env("L2_WS_RPC_ADDRESS", general_api.web3_json_rpc.ws_url); if global_config().verbose { command = command.env("RUST_LOG", "loadnext=info") diff --git a/zkstack_cli/crates/zkstack/src/commands/dev/commands/test/rust.rs b/zkstack_cli/crates/zkstack/src/commands/dev/commands/test/rust.rs index c415eb7407d2..dce3cd9022da 100644 --- a/zkstack_cli/crates/zkstack/src/commands/dev/commands/test/rust.rs +++ b/zkstack_cli/crates/zkstack/src/commands/dev/commands/test/rust.rs @@ -59,7 +59,7 @@ pub async fn run(shell: &Shell, args: RustArgs) -> anyhow::Result<()> { reset_test_databases(shell, &link_to_code, dals).await?; - let _dir_guard = shell.push_dir(&link_to_code); + let _dir_guard = shell.push_dir(link_to_code.join("core")); logger::info(MSG_USING_CARGO_NEXTEST); let cmd = cmd!(shell, "cargo nextest run --release"); diff --git a/zkstack_cli/crates/zkstack/src/commands/external_node/build.rs b/zkstack_cli/crates/zkstack/src/commands/external_node/build.rs index 8a4c4befe8db..581f08565162 100644 --- a/zkstack_cli/crates/zkstack/src/commands/external_node/build.rs +++ b/zkstack_cli/crates/zkstack/src/commands/external_node/build.rs @@ -10,7 +10,7 @@ pub(crate) async fn build(shell: &Shell) -> anyhow::Result<()> { let chain = ecosystem .load_current_chain() .context(MSG_CHAIN_NOT_FOUND_ERR)?; - let _dir_guard = shell.push_dir(&chain.link_to_code); + let _dir_guard = shell.push_dir(chain.link_to_code.join("core")); logger::info(MSG_BUILDING_EN); diff --git a/zkstack_cli/crates/zkstack/src/commands/server.rs b/zkstack_cli/crates/zkstack/src/commands/server.rs index 4088a888d534..e1e4ca3ff99d 100644 --- a/zkstack_cli/crates/zkstack/src/commands/server.rs +++ b/zkstack_cli/crates/zkstack/src/commands/server.rs @@ -35,7 +35,7 @@ pub async fn run(shell: &Shell, args: ServerArgs) -> anyhow::Result<()> { } fn build_server(chain_config: &ChainConfig, shell: &Shell) -> anyhow::Result<()> { - let _dir_guard = shell.push_dir(&chain_config.link_to_code); + let _dir_guard = shell.push_dir(chain_config.link_to_code.join("core")); logger::info(MSG_BUILDING_SERVER);