diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3872f92ac..a3608580d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,6 +1,6 @@ * @muursh @Nashtare /evm_arithmetization/ @wborgeaud @muursh @Nashtare @LindaGuiga -/zero_bin/ @muursh @Nashtare @atanmarko +/zero/ @muursh @Nashtare @atanmarko /smt_trie/ @0xaatif @muursh @Nashtare /mpt_trie/ @0xaatif @Nashtare @muursh /trace_decoder/ @0xaatif @muursh @Nashtare diff --git a/.github/labeler.yml b/.github/labeler.yml index 72647b77b..d64cda1ec 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -18,10 +18,10 @@ - changed-files: - any-glob-to-any-file: proof_gen/** -# Add 'crate: zero_bin' label to any changes within 'zero_bin' folder. +# Add 'crate: zero_bin' label to any changes within 'zero' folder. 'crate: zero_bin': - changed-files: - - any-glob-to-any-file: zero_bin/** + - any-glob-to-any-file: zero/** # Add 'specs' label to any changes within 'docs' or `book` folder. 'specs': diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f34dd53f..066789eea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,13 +140,7 @@ jobs: - name: Test in zero_bin subdirectory run: | - cargo test --manifest-path zero_bin/common/Cargo.toml - cargo test --manifest-path zero_bin/leader/Cargo.toml - cargo test --manifest-path zero_bin/ops/Cargo.toml - cargo test --manifest-path zero_bin/prover/Cargo.toml - cargo test --manifest-path zero_bin/rpc/Cargo.toml - cargo test --manifest-path zero_bin/verifier/Cargo.toml - cargo test --manifest-path zero_bin/worker/Cargo.toml + cargo test --manifest-path zero/Cargo.toml env: RUSTFLAGS: -Copt-level=3 -Cdebug-assertions -Coverflow-checks=y -Cdebuginfo=0 @@ -188,9 +182,7 @@ jobs: uses: actions/checkout@v3 - name: Run the script - run: | - pushd zero_bin/tools - ./prove_stdio.sh artifacts/witness_b19807080.json + run: ./scripts/prove_stdio.sh artifacts/witness_b19807080.json simple_proof_witness_only: name: Execute bash script to generate the proof witness for a small block. @@ -201,9 +193,7 @@ jobs: uses: actions/checkout@v3 - name: Run the script - run: | - pushd zero_bin/tools - ./prove_stdio.sh artifacts/witness_b19807080.json test_only + run: ./scripts/prove_stdio.sh artifacts/witness_b19807080.json test_only multi_blocks_proof_regular: name: Execute bash script to generate and verify a proof for multiple blocks using parallel proving. @@ -214,9 +204,7 @@ jobs: uses: actions/checkout@v3 - name: Run the script - run: | - pushd zero_bin/tools - ./prove_stdio.sh artifacts/witness_b3_b6.json + run: ./scripts/prove_stdio.sh artifacts/witness_b3_b6.json lints: name: Rustdoc, Formatting and Clippy @@ -244,7 +232,7 @@ jobs: run: cargo clippy --all-targets -- -D warnings -A incomplete-features - name: Run cargo clippy (with `cdk_erigon` flag) - run: cargo clippy --all-targets --no-default-features --features cdk_erigon -- -D warnings -A incomplete-features + run: cargo clippy --package zero --all-targets --no-default-features --features cdk_erigon -- -D warnings -A incomplete-features - name: Rustdoc run: cargo doc --all diff --git a/.github/workflows/jerigon-native.yml b/.github/workflows/jerigon-native.yml index 6c5967278..7c79454a1 100644 --- a/.github/workflows/jerigon-native.yml +++ b/.github/workflows/jerigon-native.yml @@ -74,17 +74,15 @@ jobs: - name: Run prove blocks with native tracer in test_only mode run: | ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)" - cd zero_bin/tools ulimit -n 8192 - OUTPUT_TO_TERMINAL=true ./prove_rpc.sh 0x1 0xf $ETH_RPC_URL native true 3000 100 test_only + OUTPUT_TO_TERMINAL=true ./scripts/prove_rpc.sh 0x1 0xf $ETH_RPC_URL native true 3000 100 test_only echo "Proving blocks in test_only mode finished" - name: Run prove blocks with native tracer in real mode run: | ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)" - cd zero_bin/tools rm -rf proofs/* circuits/* ./proofs.json test.out verify.out leader.out - OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./prove_rpc.sh 0x4 0x7 $ETH_RPC_URL native true 3000 100 + OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./scripts/prove_rpc.sh 0x4 0x7 $ETH_RPC_URL native true 3000 100 echo "Proving blocks in real mode finished" - name: Shut down network diff --git a/.github/workflows/jerigon-zero.yml b/.github/workflows/jerigon-zero.yml index a7e6fcb3e..ca14085dc 100644 --- a/.github/workflows/jerigon-zero.yml +++ b/.github/workflows/jerigon-zero.yml @@ -75,18 +75,16 @@ jobs: - name: Run prove blocks with zero tracer in test_only mode run: | ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)" - cd zero_bin/tools ulimit -n 8192 - OUTPUT_TO_TERMINAL=true ./prove_rpc.sh 0x1 0xf $ETH_RPC_URL jerigon true 3000 100 test_only + OUTPUT_TO_TERMINAL=true ./scripts/prove_rpc.sh 0x1 0xf $ETH_RPC_URL jerigon true 3000 100 test_only echo "Proving blocks in test_only mode finished" - name: Run prove blocks with zero tracer in real mode run: | ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)" - cd zero_bin/tools rm -rf proofs/* circuits/* ./proofs.json test.out verify.out leader.out - OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./prove_rpc.sh 0x2 0x5 $ETH_RPC_URL jerigon true 3000 100 + OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./scripts/prove_rpc.sh 0x2 0x5 $ETH_RPC_URL jerigon true 3000 100 echo "Proving blocks in real mode finished" - name: Shut down network diff --git a/.gitignore b/.gitignore index f035f7002..0016ff3b4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,25 @@ -/**/target +# Alphabetically, by-category + +# Build artifacts +################# /target -**/*.rs.bk -*.iml -.idea/ -.vscode + +# Editors +######### +/.idea/ +/.vscode +/*.iml + +# Misc +###### /**/*.ignoreme -**/output.log +/**/*.ipynb +/**/*.log +/**/*.out +# Hardcoded in https://github.com/0xPolygonZero/zk_evm/blob/v0.6.0/zero_bin/common/src/debug_utils.rs#L9 +/debug + +# Proof artifacts +################# +/proofs +/**/*.zkproof diff --git a/Cargo.lock b/Cargo.lock index 1791c16ed..16fda46f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2850,34 +2850,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -[[package]] -name = "leader" -version = "0.1.0" -dependencies = [ - "alloy", - "anyhow", - "axum", - "cargo_metadata", - "clap", - "evm_arithmetization", - "futures", - "ops", - "paladin-core", - "proof_gen", - "prover", - "rpc", - "serde", - "serde_json", - "serde_path_to_error", - "tokio", - "toml", - "tracing", - "tracing-subscriber", - "vergen", - "zero_bin_common", - "zk_evm_common", -] - [[package]] name = "libc" version = "0.2.158" @@ -3293,20 +3265,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "ops" -version = "0.1.0" -dependencies = [ - "evm_arithmetization", - "keccak-hash 0.10.0", - "paladin-core", - "proof_gen", - "serde", - "tracing", - "zero_bin_common", - "zk_evm_common", -] - [[package]] name = "option-ext" version = "0.2.0" @@ -3880,31 +3838,6 @@ dependencies = [ "unarray", ] -[[package]] -name = "prover" -version = "0.1.0" -dependencies = [ - "alloy", - "anyhow", - "clap", - "evm_arithmetization", - "futures", - "num-traits", - "ops", - "paladin-core", - "plonky2", - "plonky2_maybe_rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proof_gen", - "ruint", - "serde", - "serde_json", - "tokio", - "trace_decoder", - "tracing", - "zero_bin_common", - "zk_evm_common", -] - [[package]] name = "quick-error" version = "1.2.3" @@ -4163,37 +4096,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "rpc" -version = "0.1.0" -dependencies = [ - "alloy", - "alloy-compat", - "anyhow", - "cargo_metadata", - "clap", - "compat", - "evm_arithmetization", - "futures", - "hex", - "itertools 0.13.0", - "mpt_trie", - "primitive-types 0.12.2", - "proof_gen", - "prover", - "serde", - "serde_json", - "tokio", - "tower 0.4.13", - "trace_decoder", - "tracing", - "tracing-subscriber", - "url", - "vergen", - "zero_bin_common", - "zk_evm_common", -] - [[package]] name = "ruint" version = "1.12.3" @@ -5165,7 +5067,6 @@ dependencies = [ "plonky2_maybe_rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions", "pretty_env_logger", - "prover", "rlp", "serde", "serde_json", @@ -5176,6 +5077,7 @@ dependencies = [ "thiserror", "u4", "winnow", + "zero", "zk_evm_common", ] @@ -5410,24 +5312,6 @@ dependencies = [ "rustversion", ] -[[package]] -name = "verifier" -version = "0.1.0" -dependencies = [ - "anyhow", - "cargo_metadata", - "clap", - "dotenvy", - "proof_gen", - "serde_json", - "serde_path_to_error", - "tracing", - "tracing-subscriber", - "vergen", - "zero_bin_common", - "zk_evm_common", -] - [[package]] name = "version_check" version = "0.9.5" @@ -5779,23 +5663,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "worker" -version = "0.1.0" -dependencies = [ - "anyhow", - "cargo_metadata", - "clap", - "dotenvy", - "jemallocator", - "ops", - "paladin-core", - "tokio", - "tracing-subscriber", - "vergen", - "zero_bin_common", -] - [[package]] name = "wyz" version = "0.5.1" @@ -5846,29 +5713,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] -name = "zero_bin_common" +name = "zero" version = "0.1.0" dependencies = [ "alloy", + "alloy-compat", "anyhow", "async-stream", + "axum", "cargo_metadata", "clap", + "compat", "directories", "dotenvy", "evm_arithmetization", "futures", + "hex", + "itertools 0.13.0", + "jemallocator", + "keccak-hash 0.10.0", "lru", + "mpt_trie", + "num-traits", "once_cell", + "paladin-core", "plonky2", + "plonky2_maybe_rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.12.2", "proof_gen", + "ruint", "serde", "serde_json", "serde_path_to_error", "thiserror", "tokio", + "toml", + "tower 0.4.13", + "trace_decoder", "tracing", "tracing-subscriber", + "url", "vergen", "zk_evm_common", ] diff --git a/Cargo.toml b/Cargo.toml index 9628a345c..5bbffbb10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,13 +8,7 @@ members = [ "proof_gen", "smt_trie", "trace_decoder", - "zero_bin/common", - "zero_bin/leader", - "zero_bin/ops", - "zero_bin/prover", - "zero_bin/rpc", - "zero_bin/verifier", - "zero_bin/worker", + "zero", ] resolver = "2" @@ -118,12 +112,7 @@ smt_trie = { path = "smt_trie", version = "0.1.1" } trace_decoder = { path = "trace_decoder", version = "0.6.0", default-features = false } zk_evm_common = { path = "common", version = "0.1.0" } zk_evm_proc_macro = { path = "proc_macro", version = "0.1.0" } - -# zero-bin related dependencies -ops = { path = "zero_bin/ops", default-features = false } -prover = { path = "zero_bin/prover", default-features = false } -rpc = { path = "zero_bin/rpc", default-features = false } -zero_bin_common = { path = "zero_bin/common", default-features = false } +zero = { path = "zero", default-features = false } # plonky2-related dependencies plonky2 = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "dc77c77f2b06500e16ad4d7f1c2b057903602eed" } diff --git a/zero_bin/tools/artifacts/witness_b19807080.json b/artifacts/witness_b19807080.json similarity index 100% rename from zero_bin/tools/artifacts/witness_b19807080.json rename to artifacts/witness_b19807080.json diff --git a/zero_bin/tools/artifacts/witness_b3_b6.json b/artifacts/witness_b3_b6.json similarity index 100% rename from zero_bin/tools/artifacts/witness_b3_b6.json rename to artifacts/witness_b3_b6.json diff --git a/proof_gen/src/lib.rs b/proof_gen/src/lib.rs index f1e48a109..bdfa7943e 100644 --- a/proof_gen/src/lib.rs +++ b/proof_gen/src/lib.rs @@ -145,5 +145,4 @@ pub mod verifier_state; // Re-exports -pub use prover_state::ProverState; pub use verifier_state::VerifierState; diff --git a/zero_bin/tools/prove_rpc.sh b/scripts/prove_rpc.sh similarity index 86% rename from zero_bin/tools/prove_rpc.sh rename to scripts/prove_rpc.sh index 1c7420491..736b9a943 100755 --- a/zero_bin/tools/prove_rpc.sh +++ b/scripts/prove_rpc.sh @@ -33,10 +33,9 @@ if ! [[ $8 == "test_only" ]]; then export MEMORY_AFTER_CIRCUIT_SIZE="7..23" fi -# Force the working directory to always be the `tools/` directory. -TOOLS_DIR=$(dirname $(realpath "$0")) +REPO_ROOT=$(git rev-parse --show-toplevel) -PROOF_OUTPUT_DIR="${TOOLS_DIR}/proofs" +PROOF_OUTPUT_DIR="${REPO_ROOT}/proofs" OUT_LOG_PATH="${PROOF_OUTPUT_DIR}/b$1_$2.log" ALWAYS_WRITE_LOGS=0 # Change this to `1` if you always want logs to be written. TOT_BLOCKS=$(($2-$1+1)) @@ -110,7 +109,7 @@ fi if [[ $8 == "test_only" ]]; then # test only run echo "Proving blocks ${BLOCK_INTERVAL} in a test_only mode now... (Total: ${TOT_BLOCKS})" - command='cargo r --release --bin leader -- --test-only --runtime in-memory --load-strategy on-demand --proof-output-dir $PROOF_OUTPUT_DIR --block-batch-size $BLOCK_BATCH_SIZE rpc --rpc-type "$NODE_RPC_TYPE" --rpc-url "$NODE_RPC_URL" --block-interval $BLOCK_INTERVAL $PREV_PROOF_EXTRA_ARG --backoff "$BACKOFF" --max-retries "$RETRIES" ' + command='cargo r --release --package zero --bin leader -- --test-only --runtime in-memory --load-strategy on-demand --proof-output-dir $PROOF_OUTPUT_DIR --block-batch-size $BLOCK_BATCH_SIZE rpc --rpc-type "$NODE_RPC_TYPE" --rpc-url "$NODE_RPC_URL" --block-interval $BLOCK_INTERVAL $PREV_PROOF_EXTRA_ARG --backoff "$BACKOFF" --max-retries "$RETRIES" ' if [ "$OUTPUT_TO_TERMINAL" = true ]; then eval $command retVal=$? @@ -133,7 +132,7 @@ if [[ $8 == "test_only" ]]; then else # normal run echo "Proving blocks ${BLOCK_INTERVAL} now... (Total: ${TOT_BLOCKS})" - command='cargo r --release --bin leader -- --runtime in-memory --load-strategy on-demand --proof-output-dir $PROOF_OUTPUT_DIR --block-batch-size $BLOCK_BATCH_SIZE rpc --rpc-type "$NODE_RPC_TYPE" --rpc-url "$3" --block-interval $BLOCK_INTERVAL $PREV_PROOF_EXTRA_ARG --backoff "$BACKOFF" --max-retries "$RETRIES" ' + command='cargo r --release --package zero --bin leader -- --runtime in-memory --load-strategy on-demand --proof-output-dir $PROOF_OUTPUT_DIR --block-batch-size $BLOCK_BATCH_SIZE rpc --rpc-type "$NODE_RPC_TYPE" --rpc-url "$3" --block-interval $BLOCK_INTERVAL $PREV_PROOF_EXTRA_ARG --backoff "$BACKOFF" --max-retries "$RETRIES" ' if [ "$OUTPUT_TO_TERMINAL" = true ]; then eval $command echo -e "Proof generation finished with result: $?" @@ -161,7 +160,7 @@ if [ "$RUN_VERIFICATION" = true ]; then proof_file_name=$PROOF_OUTPUT_DIR/b$END_BLOCK.zkproof echo "Verifying the proof of the latest block in the interval:" $proof_file_name - cargo r --release --bin verifier -- -f $proof_file_name > $PROOF_OUTPUT_DIR/verify.out 2>&1 + cargo r --release --package zero --bin verifier -- -f $proof_file_name > $PROOF_OUTPUT_DIR/verify.out 2>&1 if grep -q 'All proofs verified successfully!' $PROOF_OUTPUT_DIR/verify.out; then echo "$proof_file_name verified successfully!"; diff --git a/zero_bin/tools/prove_stdio.sh b/scripts/prove_stdio.sh similarity index 89% rename from zero_bin/tools/prove_stdio.sh rename to scripts/prove_stdio.sh index 815a7048d..f54969930 100755 --- a/zero_bin/tools/prove_stdio.sh +++ b/scripts/prove_stdio.sh @@ -18,15 +18,15 @@ else fi # Force the working directory to always be the `tools/` directory. -TOOLS_DIR=$(dirname $(realpath "$0")) -PROOF_OUTPUT_DIR="${TOOLS_DIR}/proofs" +REPO_ROOT=$(git rev-parse --show-toplevel) +PROOF_OUTPUT_DIR="${REPO_ROOT}/proofs" BLOCK_BATCH_SIZE="${BLOCK_BATCH_SIZE:-8}" echo "Block batch size: $BLOCK_BATCH_SIZE" -OUTPUT_LOG="${TOOLS_DIR}/output.log" +OUTPUT_LOG="${REPO_ROOT}/output.log" PROOFS_FILE_LIST="${PROOF_OUTPUT_DIR}/proof_files.json" -TEST_OUT_PATH="${TOOLS_DIR}/test.out" +TEST_OUT_PATH="${REPO_ROOT}/test.out" # Configured Rayon and Tokio with rough defaults export RAYON_NUM_THREADS=$num_procs @@ -95,7 +95,7 @@ fi # proof. This is useful for quickly testing decoding and all of the # other non-proving code. if [[ $TEST_ONLY == "test_only" ]]; then - cargo run --quiet --release --bin leader -- --test-only --runtime in-memory --load-strategy on-demand --block-batch-size $BLOCK_BATCH_SIZE --proof-output-dir $PROOF_OUTPUT_DIR stdio < $INPUT_FILE &> $TEST_OUT_PATH + cargo run --quiet --release --package zero --bin leader -- --test-only --runtime in-memory --load-strategy on-demand --block-batch-size $BLOCK_BATCH_SIZE --proof-output-dir $PROOF_OUTPUT_DIR stdio < $INPUT_FILE &> $TEST_OUT_PATH if grep -q 'All proof witnesses have been generated successfully.' $TEST_OUT_PATH; then echo -e "\n\nSuccess - Note this was just a test, not a proof" rm $TEST_OUT_PATH @@ -110,7 +110,7 @@ cargo build --release --jobs "$num_procs" start_time=$(date +%s%N) -"${TOOLS_DIR}/../../target/release/leader" --runtime in-memory --load-strategy on-demand --block-batch-size $BLOCK_BATCH_SIZE \ +"${REPO_ROOT}/target/release/leader" --runtime in-memory --load-strategy on-demand --block-batch-size $BLOCK_BATCH_SIZE \ --proof-output-dir $PROOF_OUTPUT_DIR stdio < $INPUT_FILE &> $OUTPUT_LOG end_time=$(date +%s%N) @@ -125,7 +125,7 @@ cat $PROOFS_FILE_LIST | while read proof_file; do echo "Verifying proof file $proof_file" verify_file=$PROOF_OUTPUT_DIR/verify_$(basename $proof_file).out - "${TOOLS_DIR}/../../target/release/verifier" -f $proof_file | tee $verify_file + "${REPO_ROOT}/target/release/verifier" -f $proof_file | tee $verify_file if grep -q 'All proofs verified successfully!' $verify_file; then echo "Proof verification for file $proof_file successful"; rm $verify_file # we keep the generated proof for potential reuse diff --git a/trace_decoder/Cargo.toml b/trace_decoder/Cargo.toml index 262185c7a..7b9aa83e2 100644 --- a/trace_decoder/Cargo.toml +++ b/trace_decoder/Cargo.toml @@ -54,26 +54,16 @@ glob = "0.3.1" libtest-mimic = "0.7.3" plonky2_maybe_rayon = { workspace = true } pretty_assertions = "1.4.0" +zero = { workspace = true, features = ["eth_mainnet"] } pretty_env_logger = { workspace = true } -prover = { workspace = true } serde_json = { workspace = true } serde_path_to_error = { workspace = true } - [features] default = ["eth_mainnet"] -eth_mainnet = [ - "evm_arithmetization/eth_mainnet", - "prover/eth_mainnet", -] -cdk_erigon = [ - "evm_arithmetization/cdk_erigon", - "prover/cdk_erigon", -] -polygon_pos = [ - "evm_arithmetization/polygon_pos", - "prover/polygon_pos", -] +eth_mainnet = ["evm_arithmetization/eth_mainnet"] +cdk_erigon = ["evm_arithmetization/cdk_erigon"] +polygon_pos = ["evm_arithmetization/polygon_pos"] [[bench]] name = "block_processing" diff --git a/trace_decoder/src/lib.rs b/trace_decoder/src/lib.rs index fba82d8f7..8c54eea8e 100644 --- a/trace_decoder/src/lib.rs +++ b/trace_decoder/src/lib.rs @@ -41,8 +41,6 @@ #![warn(missing_debug_implementations)] #![warn(missing_docs)] -zk_evm_common::check_chain_features!(); - /// Over RPC, ethereum nodes expose their tries as a series of binary /// [`wire::Instruction`]s in a node-dependant format. /// diff --git a/trace_decoder/tests/common/mod.rs b/trace_decoder/tests/common/mod.rs index 51c74f75c..0183c785a 100644 --- a/trace_decoder/tests/common/mod.rs +++ b/trace_decoder/tests/common/mod.rs @@ -3,9 +3,9 @@ use std::{fs::File, path::Path}; use alloy::rpc::types::Header; use anyhow::{ensure, Context as _}; use camino::Utf8Path; -use prover::BlockProverInput; use serde::de::DeserializeOwned; use trace_decoder::{BlockTrace, OtherBlockData}; +use zero::prover::BlockProverInput; pub fn cases() -> anyhow::Result> { print!("loading test vectors..."); diff --git a/zero_bin/common/Cargo.toml b/zero/Cargo.toml similarity index 52% rename from zero_bin/common/Cargo.toml rename to zero/Cargo.toml index 1b69be922..109cb1f28 100644 --- a/zero_bin/common/Cargo.toml +++ b/zero/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "zero_bin_common" -authors = ["Polygon Zero "] +name = "zero" +authors = ["Polygon Zero"] version = "0.1.0" edition.workspace = true license.workspace = true @@ -9,32 +9,51 @@ keywords.workspace = true categories.workspace = true [dependencies] +__compat_primitive_types = { workspace = true } alloy = { workspace = true } +alloy-compat = "0.1.0" anyhow = { workspace = true } async-stream = { workspace = true } +axum = { workspace = true } cargo_metadata = { workspace = true } -clap = { workspace = true } +clap = { workspace = true, features = ["derive", "string"] } +directories = "5.0.1" dotenvy = { workspace = true } futures = { workspace = true } +hex = { workspace = true } +itertools = { workspace = true } +keccak-hash = { workspace = true } lru = { workspace = true } +num-traits = { workspace = true } once_cell = { workspace = true } +paladin-core = { workspace = true } plonky2 = { workspace = true } +plonky2_maybe_rayon = { workspace = true } +ruint = { workspace = true, features = ["num-traits", "primitive-types"] } serde = { workspace = true } serde_json = { workspace = true } serde_path_to_error = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true } +toml = { workspace = true } +tower = { workspace = true, features = ["retry"] } tracing = { workspace = true } tracing-subscriber = { workspace = true } +url = { workspace = true } vergen = { workspace = true } -directories = "5.0.1" - # Local dependencies +compat = { workspace = true } evm_arithmetization = { workspace = true } +mpt_trie = { workspace = true } proof_gen = { workspace = true } +trace_decoder = { workspace = true } zk_evm_common = { workspace = true } +[target.'cfg(not(target_env = "msvc"))'.dependencies] +jemallocator = "0.5.4" + + [build-dependencies] anyhow = { workspace = true } cargo_metadata = { workspace = true } @@ -43,18 +62,9 @@ vergen = { workspace = true } [features] default = ["eth_mainnet"] -eth_mainnet = [ - "evm_arithmetization/eth_mainnet", - "proof_gen/eth_mainnet", -] -cdk_erigon = [ - "evm_arithmetization/cdk_erigon", - "proof_gen/cdk_erigon", -] -polygon_pos = [ - "evm_arithmetization/polygon_pos", - "proof_gen/polygon_pos", -] +eth_mainnet = ["evm_arithmetization/eth_mainnet", "proof_gen/eth_mainnet"] +cdk_erigon = ["evm_arithmetization/cdk_erigon", "proof_gen/cdk_erigon"] +polygon_pos = ["evm_arithmetization/polygon_pos", "proof_gen/polygon_pos"] [lints] workspace = true diff --git a/zero_bin/README.md b/zero/README.md similarity index 98% rename from zero_bin/README.md rename to zero/README.md index b6221a724..dda10a95b 100644 --- a/zero_bin/README.md +++ b/zero/README.md @@ -339,7 +339,7 @@ docker run --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management Start worker process(es). The default paladin runtime is AMQP, so no additional flags are required to enable it. ```bash -RUST_LOG=debug cargo r --release --bin worker +RUST_LOG=debug cargo r --release --package zk_evm_common --bin worker ``` ##### Start leader @@ -466,7 +466,7 @@ When needed (e.g. some block with corner-case discovered), additional input witn 1. Run the `rpc` tool to fetch the block (or multiple blocks) witness: ```sh -cargo run --bin rpc fetch --rpc-url --start-block --end-block > ./b_.json +cargo run --package zero --bin rpc fetch --rpc-url --start-block --end-block > ./b_.json ``` 2. Download the header file for the block (or range of blocks), making the json array of headers: diff --git a/zero_bin/common/build.rs b/zero/build.rs similarity index 100% rename from zero_bin/common/build.rs rename to zero/build.rs diff --git a/zero_bin/leader/src/main.rs b/zero/src/bin/leader.rs similarity index 89% rename from zero_bin/leader/src/main.rs rename to zero/src/bin/leader.rs index 61ffb98ce..e01465c29 100644 --- a/zero_bin/leader/src/main.rs +++ b/zero/src/bin/leader.rs @@ -7,29 +7,30 @@ use anyhow::Result; use clap::Parser; use cli::Command; use client::RpcParams; -use ops::register; use paladin::runtime::Runtime; -use prover::ProverConfig; use tracing::info; -use zero_bin_common::env::load_dotenvy_vars_if_present; -use zero_bin_common::fs::get_previous_proof; -use zero_bin_common::{ +use zero::env::load_dotenvy_vars_if_present; +use zero::prover::ProverConfig; +use zero::{ block_interval::BlockInterval, prover_state::persistence::set_circuit_cache_dir_env_if_not_set, }; -use zero_bin_common::{prover_state::persistence::CIRCUIT_VERSION, version}; +use zero::{fs::get_previous_proof, ops::register}; +use zero::{prover_state::persistence::CIRCUIT_VERSION, version}; +use self::leader::*; use crate::client::{client_main, LeaderConfig}; - -mod cli; -mod client; -mod http; -mod stdio; +mod leader { + pub mod cli; + pub mod client; + pub mod http; + pub mod stdio; +} #[tokio::main] async fn main() -> Result<()> { load_dotenvy_vars_if_present(); set_circuit_cache_dir_env_if_not_set()?; - zero_bin_common::tracing::init(); + zero::tracing::init(); let args: Vec = env::args().collect(); @@ -45,7 +46,7 @@ async fn main() -> Result<()> { let args = cli::Cli::parse(); if let Command::Clean = args.command { - return zero_bin_common::prover_state::persistence::delete_all(); + return zero::prover_state::persistence::delete_all(); } let runtime = Arc::new(Runtime::from_config(&args.paladin, register()).await?); diff --git a/zero_bin/leader/src/cli.rs b/zero/src/bin/leader/cli.rs similarity index 95% rename from zero_bin/leader/src/cli.rs rename to zero/src/bin/leader/cli.rs index 9cc2de300..ee45c946f 100644 --- a/zero_bin/leader/src/cli.rs +++ b/zero/src/bin/leader/cli.rs @@ -2,9 +2,9 @@ use std::path::PathBuf; use alloy::transports::http::reqwest::Url; use clap::{Parser, Subcommand, ValueHint}; -use prover::cli::CliProverConfig; -use rpc::RpcType; -use zero_bin_common::prover_state::cli::CliProverStateConfig; +use zero::prover::cli::CliProverConfig; +use zero::prover_state::cli::CliProverStateConfig; +use zero::rpc::RpcType; /// zero-bin leader config #[derive(Parser)] diff --git a/zero_bin/leader/src/client.rs b/zero/src/bin/leader/client.rs similarity index 88% rename from zero_bin/leader/src/client.rs rename to zero/src/bin/leader/client.rs index a0f38727d..6825b6683 100644 --- a/zero_bin/leader/src/client.rs +++ b/zero/src/bin/leader/client.rs @@ -5,12 +5,13 @@ use alloy::transports::http::reqwest::Url; use anyhow::{anyhow, Result}; use paladin::runtime::Runtime; use proof_gen::proof_types::GeneratedBlockProof; -use prover::{BlockProverInput, ProverConfig}; -use rpc::{retry::build_http_retry_provider, RpcType}; use tokio::sync::mpsc; use tracing::info; -use zero_bin_common::block_interval::{BlockInterval, BlockIntervalStream}; -use zero_bin_common::pre_checks::check_previous_proof_and_checkpoint; +use zero::block_interval::{BlockInterval, BlockIntervalStream}; +use zero::pre_checks::check_previous_proof_and_checkpoint; +use zero::prover::{self, BlockProverInput, ProverConfig}; +use zero::rpc; +use zero::rpc::{retry::build_http_retry_provider, RpcType}; #[derive(Debug)] pub struct RpcParams { @@ -37,7 +38,7 @@ pub(crate) async fn client_main( ) -> Result<()> { use futures::StreamExt; - let cached_provider = Arc::new(zero_bin_common::provider::CachedProvider::new( + let cached_provider = Arc::new(zero::provider::CachedProvider::new( build_http_retry_provider( rpc_params.rpc_url.clone(), rpc_params.backoff, @@ -53,8 +54,7 @@ pub(crate) async fn client_main( // Create a channel for block prover input and use it to send prover input to // the proving task. The second element of the tuple is a flag indicating // whether the block is the last one in the interval. - let (block_tx, block_rx) = - mpsc::channel::<(BlockProverInput, bool)>(zero_bin_common::BLOCK_CHANNEL_SIZE); + let (block_tx, block_rx) = mpsc::channel::<(BlockProverInput, bool)>(zero::BLOCK_CHANNEL_SIZE); let test_only = leader_config.prover_config.test_only; // Run proving task diff --git a/zero_bin/leader/src/http.rs b/zero/src/bin/leader/http.rs similarity index 98% rename from zero_bin/leader/src/http.rs rename to zero/src/bin/leader/http.rs index 14fa965a4..3ebcbdaec 100644 --- a/zero_bin/leader/src/http.rs +++ b/zero/src/bin/leader/http.rs @@ -5,10 +5,10 @@ use anyhow::{bail, Result}; use axum::{http::StatusCode, routing::post, Json, Router}; use paladin::runtime::Runtime; use proof_gen::proof_types::GeneratedBlockProof; -use prover::{BlockProverInput, ProverConfig}; use serde::{Deserialize, Serialize}; use serde_json::to_writer; use tracing::{debug, error, info}; +use zero::prover::{BlockProverInput, ProverConfig}; /// The main function for the HTTP mode. pub(crate) async fn http_main( diff --git a/zero_bin/leader/src/stdio.rs b/zero/src/bin/leader/stdio.rs similarity index 91% rename from zero_bin/leader/src/stdio.rs rename to zero/src/bin/leader/stdio.rs index 71db3c6ae..2bef3ceff 100644 --- a/zero_bin/leader/src/stdio.rs +++ b/zero/src/bin/leader/stdio.rs @@ -4,9 +4,9 @@ use std::sync::Arc; use anyhow::{anyhow, Result}; use paladin::runtime::Runtime; use proof_gen::proof_types::GeneratedBlockProof; -use prover::{BlockProverInput, ProverConfig}; use tokio::sync::mpsc; use tracing::info; +use zero::prover::{self, BlockProverInput, ProverConfig}; /// The main function for the stdio mode. pub(crate) async fn stdio_main( @@ -22,8 +22,7 @@ pub(crate) async fn stdio_main( .into_iter() .collect::>(); - let (block_tx, block_rx) = - mpsc::channel::<(BlockProverInput, bool)>(zero_bin_common::BLOCK_CHANNEL_SIZE); + let (block_tx, block_rx) = mpsc::channel::<(BlockProverInput, bool)>(zero::BLOCK_CHANNEL_SIZE); let runtime_ = runtime.clone(); let prover_config_ = prover_config.clone(); diff --git a/zero_bin/rpc/src/main.rs b/zero/src/bin/rpc.rs similarity index 96% rename from zero_bin/rpc/src/main.rs rename to zero/src/bin/rpc.rs index 308ea8cd0..5f9d9c276 100644 --- a/zero_bin/rpc/src/main.rs +++ b/zero/src/bin/rpc.rs @@ -9,14 +9,15 @@ use alloy::transports::Transport; use anyhow::anyhow; use clap::{Args, Parser, Subcommand, ValueHint}; use futures::StreamExt; -use prover::BlockProverInput; -use rpc::{retry::build_http_retry_provider, RpcType}; use tracing_subscriber::{prelude::*, EnvFilter}; use url::Url; -use zero_bin_common::block_interval::BlockIntervalStream; -use zero_bin_common::provider::CachedProvider; -use zero_bin_common::version; -use zero_bin_common::{block_interval::BlockInterval, prover_state::persistence::CIRCUIT_VERSION}; +use zero::block_interval::BlockIntervalStream; +use zero::prover::BlockProverInput; +use zero::provider::CachedProvider; +use zero::{block_interval::BlockInterval, prover_state::persistence::CIRCUIT_VERSION}; +use zero::{rpc, version}; + +use self::rpc::{retry::build_http_retry_provider, RpcType}; #[derive(Clone, Debug, Copy)] struct FetchParams { diff --git a/zero_bin/verifier/src/main.rs b/zero/src/bin/verifier.rs similarity index 94% rename from zero_bin/verifier/src/main.rs rename to zero/src/bin/verifier.rs index aa97d6087..a7d80197a 100644 --- a/zero_bin/verifier/src/main.rs +++ b/zero/src/bin/verifier.rs @@ -9,13 +9,16 @@ use dotenvy::dotenv; use proof_gen::proof_types::GeneratedBlockProof; use serde_json::Deserializer; use tracing::info; -use zero_bin_common::{ +use zero::{ prover_state::persistence::{set_circuit_cache_dir_env_if_not_set, CIRCUIT_VERSION}, version, }; -mod cli; -mod init; +use self::verifier::*; +mod verifier { + pub mod cli; + pub mod init; +} fn main() -> Result<()> { dotenv().ok(); diff --git a/zero_bin/verifier/src/cli.rs b/zero/src/bin/verifier/cli.rs similarity index 87% rename from zero_bin/verifier/src/cli.rs rename to zero/src/bin/verifier/cli.rs index 76306ec41..157674130 100644 --- a/zero_bin/verifier/src/cli.rs +++ b/zero/src/bin/verifier/cli.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use clap::{Parser, ValueHint}; -use zero_bin_common::prover_state::cli::CliProverStateConfig; +use zero::prover_state::cli::CliProverStateConfig; #[derive(Parser)] pub(crate) struct Cli { diff --git a/zero_bin/verifier/src/init.rs b/zero/src/bin/verifier/init.rs similarity index 100% rename from zero_bin/verifier/src/init.rs rename to zero/src/bin/verifier/init.rs diff --git a/zero_bin/worker/src/main.rs b/zero/src/bin/worker.rs similarity index 92% rename from zero_bin/worker/src/main.rs rename to zero/src/bin/worker.rs index 3ea4c7cae..1d941341f 100644 --- a/zero_bin/worker/src/main.rs +++ b/zero/src/bin/worker.rs @@ -3,13 +3,12 @@ use std::env; use anyhow::Result; use clap::Parser; use dotenvy::dotenv; -use ops::register; use paladin::runtime::WorkerRuntime; -use zero_bin_common::prover_state::{ +use zero::prover_state::{ cli::CliProverStateConfig, persistence::{set_circuit_cache_dir_env_if_not_set, CIRCUIT_VERSION}, }; -use zero_bin_common::{tracing, version}; +use zero::{ops::register, tracing, version}; // TODO: https://github.com/0xPolygonZero/zk_evm/issues/302 // this should probably be removed. diff --git a/zero_bin/common/src/block_interval.rs b/zero/src/block_interval.rs similarity index 99% rename from zero_bin/common/src/block_interval.rs rename to zero/src/block_interval.rs index a659976a3..e424076e0 100644 --- a/zero_bin/common/src/block_interval.rs +++ b/zero/src/block_interval.rs @@ -43,7 +43,7 @@ impl BlockInterval { /// /// ```rust /// # use alloy::rpc::types::eth::BlockId; - /// # use zero_bin_common::block_interval::BlockInterval; + /// # use zero::block_interval::BlockInterval; /// assert_eq!(BlockInterval::new("0..10").unwrap(), BlockInterval::Range(0..10)); /// assert_eq!(BlockInterval::new("0..=10").unwrap(), BlockInterval::Range(0..11)); /// assert_eq!(BlockInterval::new("32141").unwrap(), BlockInterval::SingleBlockId(BlockId::Number(32141.into()))); diff --git a/zero_bin/common/src/debug_utils.rs b/zero/src/debug_utils.rs similarity index 100% rename from zero_bin/common/src/debug_utils.rs rename to zero/src/debug_utils.rs diff --git a/zero_bin/common/src/env.rs b/zero/src/env.rs similarity index 100% rename from zero_bin/common/src/env.rs rename to zero/src/env.rs diff --git a/zero_bin/common/src/fs.rs b/zero/src/fs.rs similarity index 100% rename from zero_bin/common/src/fs.rs rename to zero/src/fs.rs diff --git a/zero_bin/common/src/lib.rs b/zero/src/lib.rs similarity index 92% rename from zero_bin/common/src/lib.rs rename to zero/src/lib.rs index 890558de6..3dc34d421 100644 --- a/zero_bin/common/src/lib.rs +++ b/zero/src/lib.rs @@ -4,10 +4,13 @@ pub mod block_interval; pub mod debug_utils; pub mod env; pub mod fs; +pub mod ops; pub mod parsing; pub mod pre_checks; +pub mod prover; pub mod prover_state; pub mod provider; +pub mod rpc; pub mod tracing; pub mod version; diff --git a/zero_bin/ops/src/lib.rs b/zero/src/ops.rs similarity index 98% rename from zero_bin/ops/src/lib.rs rename to zero/src/ops.rs index 3a6d3854c..a697d9416 100644 --- a/zero_bin/ops/src/lib.rs +++ b/zero/src/ops.rs @@ -19,7 +19,8 @@ use proof_gen::{ use serde::{Deserialize, Serialize}; use tracing::error; use tracing::{event, info_span, Level}; -use zero_bin_common::{debug_utils::save_inputs_to_disk, prover_state::p_state}; + +use crate::{debug_utils::save_inputs_to_disk, prover_state::p_state}; registry!(); @@ -40,7 +41,7 @@ impl Operation for SegmentProof { let segment_index = all_data.1.segment_index(); let _span = SegmentProofSpan::new(&input, all_data.1.segment_index()); let proof = if self.save_inputs_on_error { - zero_bin_common::prover_state::p_manager() + crate::prover_state::p_manager() .generate_segment_proof(all_data) .map_err(|err| { if let Err(write_err) = save_inputs_to_disk( @@ -59,7 +60,7 @@ impl Operation for SegmentProof { FatalError::from_anyhow(err, FatalStrategy::Terminate) })? } else { - zero_bin_common::prover_state::p_manager() + crate::prover_state::p_manager() .generate_segment_proof(all_data) .map_err(|err| FatalError::from_anyhow(err, FatalStrategy::Terminate))? }; diff --git a/zero_bin/common/src/parsing.rs b/zero/src/parsing.rs similarity index 100% rename from zero_bin/common/src/parsing.rs rename to zero/src/parsing.rs diff --git a/zero_bin/common/src/pre_checks.rs b/zero/src/pre_checks.rs similarity index 100% rename from zero_bin/common/src/pre_checks.rs rename to zero/src/pre_checks.rs diff --git a/zero_bin/prover/src/lib.rs b/zero/src/prover.rs similarity index 99% rename from zero_bin/prover/src/lib.rs rename to zero/src/prover.rs index 29bf42127..3916f98d2 100644 --- a/zero_bin/prover/src/lib.rs +++ b/zero/src/prover.rs @@ -18,7 +18,9 @@ use tokio::sync::mpsc::Receiver; use tokio::sync::{oneshot, Semaphore}; use trace_decoder::{BlockTrace, OtherBlockData}; use tracing::{error, info}; -use zero_bin_common::fs::generate_block_proof_file_name; + +use crate::fs::generate_block_proof_file_name; +use crate::ops; // All proving tasks are executed concurrently, which can cause issues for large // block intervals, where distant future blocks may be proven first. diff --git a/zero_bin/prover/src/cli.rs b/zero/src/prover/cli.rs similarity index 97% rename from zero_bin/prover/src/cli.rs rename to zero/src/prover/cli.rs index 694194ad9..e55141b7a 100644 --- a/zero_bin/prover/src/cli.rs +++ b/zero/src/prover/cli.rs @@ -45,7 +45,7 @@ pub struct CliProverConfig { block_batch_size: usize, } -impl From for crate::ProverConfig { +impl From for super::ProverConfig { fn from(cli: CliProverConfig) -> Self { Self { batch_size: cli.batch_size, diff --git a/zero_bin/common/src/prover_state/circuit.rs b/zero/src/prover_state/circuit.rs similarity index 100% rename from zero_bin/common/src/prover_state/circuit.rs rename to zero/src/prover_state/circuit.rs diff --git a/zero_bin/common/src/prover_state/cli.rs b/zero/src/prover_state/cli.rs similarity index 100% rename from zero_bin/common/src/prover_state/cli.rs rename to zero/src/prover_state/cli.rs diff --git a/zero_bin/common/src/prover_state/mod.rs b/zero/src/prover_state/mod.rs similarity index 100% rename from zero_bin/common/src/prover_state/mod.rs rename to zero/src/prover_state/mod.rs diff --git a/zero_bin/common/src/prover_state/persistence.rs b/zero/src/prover_state/persistence.rs similarity index 100% rename from zero_bin/common/src/prover_state/persistence.rs rename to zero/src/prover_state/persistence.rs diff --git a/zero_bin/common/src/provider.rs b/zero/src/provider.rs similarity index 100% rename from zero_bin/common/src/provider.rs rename to zero/src/provider.rs diff --git a/zero_bin/rpc/src/jerigon.rs b/zero/src/rpc/jerigon.rs similarity index 96% rename from zero_bin/rpc/src/jerigon.rs rename to zero/src/rpc/jerigon.rs index 00d56cf48..df00bc605 100644 --- a/zero_bin/rpc/src/jerigon.rs +++ b/zero/src/rpc/jerigon.rs @@ -1,12 +1,12 @@ use alloy::{providers::Provider, rpc::types::eth::BlockId, transports::Transport}; use anyhow::Context as _; -use prover::BlockProverInput; use serde::Deserialize; use serde_json::json; use trace_decoder::{BlockTrace, BlockTraceTriePreImages, CombinedPreImages, TxnInfo}; -use zero_bin_common::provider::CachedProvider; use super::fetch_other_block_data; +use crate::prover::BlockProverInput; +use crate::provider::CachedProvider; /// Transaction traces retrieved from Erigon zeroTracer. #[derive(Debug, Deserialize)] diff --git a/zero_bin/rpc/src/lib.rs b/zero/src/rpc/mod.rs similarity index 99% rename from zero_bin/rpc/src/lib.rs rename to zero/src/rpc/mod.rs index 87a581a14..cf8ec09cf 100644 --- a/zero_bin/rpc/src/lib.rs +++ b/zero/src/rpc/mod.rs @@ -15,16 +15,17 @@ use compat::Compat; use evm_arithmetization::proof::{consolidate_hashes, BlockHashes, BlockMetadata}; use futures::{StreamExt as _, TryStreamExt as _}; use proof_gen::types::{Field, Hasher}; -use prover::BlockProverInput; use serde_json::json; use trace_decoder::{BlockLevelData, OtherBlockData}; use tracing::warn; +use crate::prover::BlockProverInput; + pub mod jerigon; pub mod native; pub mod retry; -use zero_bin_common::provider::CachedProvider; +use crate::provider::CachedProvider; pub(crate) type PreviousBlockHashes = [FixedBytes<32>; 256]; diff --git a/zero_bin/rpc/src/native/mod.rs b/zero/src/rpc/native/mod.rs similarity index 90% rename from zero_bin/rpc/src/native/mod.rs rename to zero/src/rpc/native/mod.rs index 2e9527274..5b4ed5dd9 100644 --- a/zero_bin/rpc/src/native/mod.rs +++ b/zero/src/rpc/native/mod.rs @@ -8,9 +8,10 @@ use alloy::{ transports::Transport, }; use futures::try_join; -use prover::BlockProverInput; use trace_decoder::BlockTrace; -use zero_bin_common::provider::CachedProvider; + +use crate::prover::BlockProverInput; +use crate::provider::CachedProvider; mod state; mod txn; @@ -29,7 +30,7 @@ where { let (block_trace, other_data) = try_join!( process_block_trace(provider.clone(), block_number), - crate::fetch_other_block_data(provider.clone(), block_number, checkpoint_block_number) + crate::rpc::fetch_other_block_data(provider.clone(), block_number, checkpoint_block_number) )?; Ok(BlockProverInput { diff --git a/zero_bin/rpc/src/native/state.rs b/zero/src/rpc/native/state.rs similarity index 99% rename from zero_bin/rpc/src/native/state.rs rename to zero/src/rpc/native/state.rs index a61f73e01..579c3f5a6 100644 --- a/zero_bin/rpc/src/native/state.rs +++ b/zero/src/rpc/native/state.rs @@ -16,7 +16,8 @@ use trace_decoder::{ BlockTraceTriePreImages, SeparateStorageTriesPreImage, SeparateTriePreImage, SeparateTriePreImages, TxnInfo, }; -use zero_bin_common::provider::CachedProvider; + +use crate::provider::CachedProvider; /// Processes the state witness for the given block. pub async fn process_state_witness( diff --git a/zero_bin/rpc/src/native/txn.rs b/zero/src/rpc/native/txn.rs similarity index 99% rename from zero_bin/rpc/src/native/txn.rs rename to zero/src/rpc/native/txn.rs index 5e3be656a..79de06d79 100644 --- a/zero_bin/rpc/src/native/txn.rs +++ b/zero/src/rpc/native/txn.rs @@ -20,11 +20,11 @@ use alloy::{ transports::Transport, }; use anyhow::Context as _; +use compat::Compat; use futures::stream::{FuturesOrdered, TryStreamExt}; use trace_decoder::{ContractCodeUsage, TxnInfo, TxnMeta, TxnTrace}; use super::CodeDb; -use crate::Compat; /// Processes the transactions in the given block and updates the code db. pub(super) async fn process_transactions( diff --git a/zero_bin/rpc/src/retry.rs b/zero/src/rpc/retry.rs similarity index 100% rename from zero_bin/rpc/src/retry.rs rename to zero/src/rpc/retry.rs diff --git a/zero_bin/common/src/tracing.rs b/zero/src/tracing.rs similarity index 100% rename from zero_bin/common/src/tracing.rs rename to zero/src/tracing.rs diff --git a/zero_bin/common/src/version.rs b/zero/src/version.rs similarity index 100% rename from zero_bin/common/src/version.rs rename to zero/src/version.rs diff --git a/zero_bin/.gitignore b/zero_bin/.gitignore deleted file mode 100644 index ab214fd70..000000000 --- a/zero_bin/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -# Default extension for generated block proofs -*.zkproof - -# Folder containing all the locally generated circuit data -circuits/ - -# Folders containing logs from the utility scripts in tools/ -debug/ -proofs/ - -# Files generated from the tools script tests -test.out -proofs.json -verify.out -leader.out diff --git a/zero_bin/leader/Cargo.toml b/zero_bin/leader/Cargo.toml deleted file mode 100644 index 27d22a347..000000000 --- a/zero_bin/leader/Cargo.toml +++ /dev/null @@ -1,69 +0,0 @@ -[package] -name = "leader" -authors = ["Polygon Zero "] -version = "0.1.0" -edition.workspace = true -license.workspace = true -repository.workspace = true -keywords.workspace = true -categories.workspace = true -build = "../common/build.rs" - -[dependencies] -alloy = { workspace = true } -anyhow = { workspace = true } -axum = { workspace = true } -clap = { workspace = true } -futures = { workspace = true } -paladin-core = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -serde_path_to_error = { workspace = true } -tokio = { workspace = true } -toml = { workspace = true } -tracing = { workspace = true } -tracing-subscriber = { workspace = true } - -# Local dependencies -evm_arithmetization = { workspace = true } -ops = { workspace = true } -proof_gen = { workspace = true } -prover = { workspace = true } -rpc = { workspace = true } -zero_bin_common = { workspace = true } -zk_evm_common = { workspace = true } - -[features] -default = ["eth_mainnet"] -eth_mainnet = [ - "evm_arithmetization/eth_mainnet", - "ops/eth_mainnet", - "proof_gen/eth_mainnet", - "prover/eth_mainnet", - "rpc/eth_mainnet", - "zero_bin_common/eth_mainnet", -] -cdk_erigon = [ - "evm_arithmetization/cdk_erigon", - "ops/cdk_erigon", - "proof_gen/cdk_erigon", - "prover/cdk_erigon", - "rpc/cdk_erigon", - "zero_bin_common/cdk_erigon", -] -polygon_pos = [ - "evm_arithmetization/polygon_pos", - "ops/polygon_pos", - "proof_gen/polygon_pos", - "prover/polygon_pos", - "rpc/polygon_pos", - "zero_bin_common/polygon_pos", -] - -[build-dependencies] -cargo_metadata = { workspace = true } -vergen = { workspace = true } -anyhow = { workspace = true } - -[lints] -workspace = true diff --git a/zero_bin/ops/Cargo.toml b/zero_bin/ops/Cargo.toml deleted file mode 100644 index 4e49a3ae6..000000000 --- a/zero_bin/ops/Cargo.toml +++ /dev/null @@ -1,39 +0,0 @@ -[package] -name = "ops" -version = "0.1.0" -authors = ["Polygon Zero "] -edition.workspace = true -license.workspace = true -repository.workspace = true -keywords.workspace = true -categories.workspace = true - -[dependencies] -keccak-hash = { workspace = true } -paladin-core = { workspace = true } -serde = { workspace = true } -tracing = { workspace = true } - -# Local dependencies -evm_arithmetization = { workspace = true } -proof_gen = { workspace = true } -zero_bin_common = { workspace = true } -zk_evm_common = { workspace = true } - -[features] -default = ["eth_mainnet"] -eth_mainnet = [ - "evm_arithmetization/eth_mainnet", - "proof_gen/eth_mainnet", - "zero_bin_common/eth_mainnet", -] -cdk_erigon = [ - "evm_arithmetization/cdk_erigon", - "proof_gen/cdk_erigon", - "zero_bin_common/cdk_erigon", -] -polygon_pos = [ - "evm_arithmetization/polygon_pos", - "proof_gen/polygon_pos", - "zero_bin_common/polygon_pos", -] diff --git a/zero_bin/prover/Cargo.toml b/zero_bin/prover/Cargo.toml deleted file mode 100644 index a2ad4ccb4..000000000 --- a/zero_bin/prover/Cargo.toml +++ /dev/null @@ -1,60 +0,0 @@ -[package] -name = "prover" -authors = ["Polygon Zero "] -version = "0.1.0" -edition.workspace = true -license.workspace = true -repository.workspace = true -keywords.workspace = true -categories.workspace = true - -[dependencies] -alloy = { workspace = true } -anyhow = { workspace = true } -clap = { workspace = true, features = ["derive", "string"] } -futures = { workspace = true } -num-traits = { workspace = true } -ops = { workspace = true } -paladin-core = { workspace = true } -plonky2 = { workspace = true } -plonky2_maybe_rayon = { workspace = true } -ruint = { workspace = true, features = ["num-traits", "primitive-types"] } -serde = { workspace = true } -serde_json = { workspace = true } -tokio = { workspace = true } -tracing = { workspace = true } - -# Local dependencies -evm_arithmetization = { workspace = true } -proof_gen = { workspace = true } -trace_decoder = { workspace = true } -zero_bin_common = { workspace = true } -zk_evm_common = { workspace = true } - - -[features] -default = ["eth_mainnet"] -eth_mainnet = [ - "evm_arithmetization/eth_mainnet", - "ops/eth_mainnet", - "proof_gen/eth_mainnet", - "trace_decoder/eth_mainnet", - "zero_bin_common/eth_mainnet", -] -cdk_erigon = [ - "evm_arithmetization/cdk_erigon", - "ops/cdk_erigon", - "proof_gen/cdk_erigon", - "trace_decoder/cdk_erigon", - "zero_bin_common/cdk_erigon", -] -polygon_pos = [ - "evm_arithmetization/polygon_pos", - "ops/polygon_pos", - "proof_gen/polygon_pos", - "trace_decoder/polygon_pos", - "zero_bin_common/polygon_pos", -] - -[lints] -workspace = true diff --git a/zero_bin/rpc/Cargo.toml b/zero_bin/rpc/Cargo.toml deleted file mode 100644 index c694335d4..000000000 --- a/zero_bin/rpc/Cargo.toml +++ /dev/null @@ -1,65 +0,0 @@ -[package] -name = "rpc" -authors = ["Polygon Zero "] -version = "0.1.0" -edition.workspace = true -license.workspace = true -repository.workspace = true -keywords.workspace = true -categories.workspace = true -build = "../common/build.rs" - -[dependencies] -__compat_primitive_types = { workspace = true } -alloy = { workspace = true } -alloy-compat = "0.1.0" -anyhow = { workspace = true } -clap = { workspace = true } -futures = { workspace = true } -hex = { workspace = true } -itertools = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -tokio = { workspace = true } -tower = { workspace = true, features = ["retry"] } -tracing = { workspace = true } -tracing-subscriber = { workspace = true } -url = { workspace = true } - -# Local dependencies -compat = { workspace = true } -evm_arithmetization = { workspace = true } -mpt_trie = { workspace = true } -proof_gen = { workspace = true } -prover = { workspace = true } -trace_decoder = { workspace = true } -zero_bin_common = { workspace = true } -zk_evm_common = { workspace = true } - -[build-dependencies] -anyhow = { workspace = true } -cargo_metadata = { workspace = true } -vergen = { workspace = true } - -[features] -default = ["eth_mainnet"] -eth_mainnet = [ - "evm_arithmetization/eth_mainnet", - "proof_gen/eth_mainnet", - "prover/eth_mainnet", - "trace_decoder/eth_mainnet", - "zero_bin_common/eth_mainnet", -] -cdk_erigon = [ - "evm_arithmetization/cdk_erigon", - "proof_gen/cdk_erigon", - "prover/cdk_erigon", - "trace_decoder/cdk_erigon", - "zero_bin_common/cdk_erigon", -] -polygon_pos = [ - "evm_arithmetization/polygon_pos", - "prover/polygon_pos", - "trace_decoder/polygon_pos", - "zero_bin_common/polygon_pos", -] diff --git a/zero_bin/verifier/Cargo.toml b/zero_bin/verifier/Cargo.toml deleted file mode 100644 index ff0458197..000000000 --- a/zero_bin/verifier/Cargo.toml +++ /dev/null @@ -1,41 +0,0 @@ -[package] -name = "verifier" -authors = ["Polygon Zero "] -version = "0.1.0" -edition = "2021" -build = "../common/build.rs" - -[dependencies] -anyhow = { workspace = true } -clap = { workspace = true } -dotenvy = { workspace = true } -serde_json = { workspace = true } -serde_path_to_error = { workspace = true } -tracing = { workspace = true } -tracing-subscriber = { workspace = true } - -# Local dependencies -proof_gen = { workspace = true } -zero_bin_common = { workspace = true } -zk_evm_common = { workspace = true } - -[build-dependencies] -anyhow = { workspace = true } -cargo_metadata = { workspace = true } -vergen = { workspace = true } - - -[features] -default = ["eth_mainnet"] -eth_mainnet = [ - "proof_gen/eth_mainnet", - "zero_bin_common/eth_mainnet", -] -cdk_erigon = [ - "proof_gen/cdk_erigon", - "zero_bin_common/cdk_erigon", -] -polygon_pos = [ - "proof_gen/polygon_pos", - "zero_bin_common/polygon_pos", -] diff --git a/zero_bin/worker/Cargo.toml b/zero_bin/worker/Cargo.toml deleted file mode 100644 index ffb762627..000000000 --- a/zero_bin/worker/Cargo.toml +++ /dev/null @@ -1,45 +0,0 @@ -[package] -name = "worker" -authors = ["Polygon Zero "] -version = "0.1.0" -edition.workspace = true -license.workspace = true -repository.workspace = true -keywords.workspace = true -categories.workspace = true -build = "../common/build.rs" - -[dependencies] -paladin-core = { workspace = true } -anyhow = { workspace = true } -dotenvy = { workspace = true } -tracing-subscriber = { workspace = true } -clap = { workspace = true } -tokio = { workspace = true } - -# Local dependencies -ops = { workspace = true } -zero_bin_common = { workspace = true } - -[target.'cfg(not(target_env = "msvc"))'.dependencies] -jemallocator = "0.5.4" - -[build-dependencies] -cargo_metadata = { workspace = true } -vergen = { workspace = true } -anyhow = { workspace = true } - -[features] -default = ["eth_mainnet"] -eth_mainnet = [ - "ops/eth_mainnet", - "zero_bin_common/eth_mainnet", -] -cdk_erigon = [ - "ops/cdk_erigon", - "zero_bin_common/cdk_erigon", -] -polygon_pos = [ - "ops/polygon_pos", - "zero_bin_common/polygon_pos", -]