Giter Club home page Giter Club logo

scroll-prover's Introduction

📜 scroll-prover 📜

Unit Test issues

Usage

Latest Release

v0.10.3 is used in Scroll Mainnet currently. Branch main HEAD is used for development.

Prerequisite

Install Solidity compiler solc of version 0.8.19 via svm-rs:

cargo install svm-rs
svm install 0.8.19

Download all setup params, degree 20, 24 and 26 are used in config. Could only download params of degree 26, but it may affect performance (when downsizing params).

make download-setup -e degree=20
make download-setup -e degree=24
make download-setup -e degree=26

Or specify other degree and target directory to download.

# As default `degree=26` and `params_dir=./integration/params`.
make download-setup -e degree=DEGREE params_dir=PARAMS_DIR

Testing

make test-chunk-prove and make test-e2e-prove are the main testing entries for multi-level circuit constraint system of scroll-prover. Developers could understand how the system works by reading the codes of these tests.

And there are other tests:

  • make test-inner-prove could be used to test the first-level circuit.
  • make test-batch-prove could be used to test the final two levels.

Binaries

Could use the following command to run binaries locally.

Run zkevm prover to generate chunk proof (work directory is ./integration)

# Params file should be located in `./integration/params`.
cargo run --release --bin trace_prover -- --params=params --trace=tests/extra_traces/batch_34700/chunk_1236462/block_4176564.json

Verifier Contract

Both YUL and bytecode of verifier contract could be generated when running aggregation tests (make test-e2e-prove). After running aggregation tests, a new folder is created in integration folder of scroll-prover and named like integration/outputs/e2e_tests_*. It contains below files:

  • Chunk protocol: chunk_chunk_0.protocol
  • Chunk VK: vk_chunk_0.vkey
  • Batch VK: vk_batch_agg.vkey
  • Verifier YUL source code: evm_verifier.yul
  • Verifier bytecode: evm_verifier.bin

The YUL source code is generated by params, VK and num instance of proof, could reference gen_evm_verifier function in snark-verifier.

The verifier bytecode is compiled from YUL source code, it invokes Solidity compiler (0.8.19 as mentioned above) command line with specified parameters, could reference compile_yul function in snark-verifier.

License

Licensed under either of

at your option.

scroll-prover's People

Contributors

29988122 avatar controlcpluscontrolv avatar haoyuathz avatar icemelon avatar kunxian-xia avatar lawliet-chan avatar lispc avatar mask-pp avatar noel2004 avatar omahs avatar scroll-dev avatar silathdiir avatar tranhoaison avatar zhenfeizhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scroll-prover's Issues

thread 'test_chunk_prove_verify' panicked at 'called `Result::unwrap()` on an `Err` value

I am running make test-chunk-prove and running into this error during the tests:

thread 'test_chunk_prove_verify' panicked at 'called Result::unwrap()on anErr value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /home/ubuntu/.cargo/git/checkouts/snark-verifier-cd02c9c9f799657f/bc1d39a/snark-verifier/src/loader/evm/util.rs:115:10

Please let me know if there are any other logs or artifacts I can include that would help to debug.

Here is the full stack trace:

Context "Range" used 1 advice columns and 9169285 total advice cells in phase 0
Special lookup advice cells: optimal columns: 1, total 1002822 cells used in phase 0.
Fixed columns: 1, Total fixed cells: 300577
computing length 37 fixed base msm
computing length 38 MSM
computing length 1 MSM
computing length 1 MSM
Context "Range" used 1 advice columns and 9169285 total advice cells in phase 0
Special lookup advice cells: optimal columns: 1, total 1002822 cells used in phase 0.
Fixed columns: 1, Total fixed cells: 300577
thread 'test_chunk_prove_verify' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /home/ubuntu/.cargo/git/checkouts/snark-verifier-cd02c9c9f799657f/bc1d39a/snark-verifier/src/loader/evm/util.rs:115:10
stack backtrace:
   0: rust_begin_unwind
             at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/core/src/panicking.rs:64:14
   2: core::result::unwrap_failed
             at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/core/src/result.rs:1791:5
   3: snark_verifier::loader::evm::util::compile_yul
   4: snark_verifier_sdk::evm_api::gen_evm_verifier
   5: prover::common::verifier::evm::<impl prover::common::verifier::Verifier<C>>::evm_verify
   6: integration::test_util::proof::gen_and_verify_normal_and_evm_proofs
   7: integration::test_util::proof::gen_and_verify_chunk_proofs
   8: core::ops::function::FnOnce::call_once
   9: core::ops::function::FnOnce::call_once
             at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    test_chunk_prove_verify

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 5289.95s

Run tests error: (signal: 11, SIGSEGV: invalid memory reference)

RUN : cargo test --features
prove_verify --release

error:
[2023-05-17T17:12:31Z DEBUG zkevm_circuits::rlp_circuit] rlp circuit assign 7th tx at offset:7901, tx hash 0x0644db0ab25173d6fea411f2f6e0fea73efb45e96811761bf6d3659ce64aab69
[2023-05-17T17:12:38Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region row_count "mpt table": 1000000
[2023-05-17T17:12:38Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "mpt table", idx 26341 start 281
[2023-05-17T17:12:57Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region row_count "zktrie main": 1000001
[2023-05-17T17:12:57Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "zktrie main", idx 26342 start 0
[2023-05-17T18:16:17Z INFO zkevm::prover] Create super proof of block 0x97ec…3b72 ... block 0x97ec…3b72 Successfully!
[2023-05-17T18:16:17Z DEBUG zkevm::prover] super circuit: proof [50, 239, 42, 165, 77, 103, 7, 223, 247, 194, 253, 61, 3, 134, 66], instance len 187
[2023-05-17T18:16:18Z DEBUG zkevm::prover] n_instances [[[[[0x00000000000000000000000000000000499a9246c0bca9c77571c81f56b6a723, 0x00000000000000000000000000000000a137dd5b0d8f50308a4ea3609d20602a], []]]]]
error: test failed, to rerun pass -p zkevm --test aggregation_tests

Caused by:
process didn't exit successfully: /root/src/target/release/deps/aggregation_tests-b47800ff1f35758f (signal: 11, SIGSEGV: invalid memory reference)

missing field `coinbase` `startL1QueueIndex`

When I use the latest code to run chunk_tests, it failed. How to get the correct traces file to solve this error?

`test test_chunk_prove_verify ... FAILED

failures:

---- test_chunk_prove_verify stdout ----
thread 'test_chunk_prove_verify' panicked at 'unable to load BlockTrace from "./tests/traces/erc20/10_transfer.json", Error("missing field coinbase", line: 69137, column: 1), Error("missing field startL1QueueIndex", line: 69136, column: 3)', prover/src/utils.rs:87:17
stack backtrace:
0: rust_begin_unwind
at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/core/src/panicking.rs:64:14
2: prover::utils::get_block_trace_from_file
3: <alloc::vec::Vec as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
4: prover::test_util::load_block_traces_for_test
5: core::ops::function::FnOnce::call_once
6: core::ops::function::FnOnce::call_once
at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

failures:
test_chunk_prove_verify

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s

error: test failed, to rerun pass `-p prover --test chunk_tests``

ERROR zkevm_circuits::witness::mpt - roots non consistent

Hi Scroll team,

An error raised when I was testing scroll-zkevm. It looks like an internal error. Could you please take a look?

My code and the errors are pasted below:

The error:

2023-06-11T00:42:05.556480238+00:00 ERROR zkevm_circuits::witness::mpt - roots non consistent (0x4c24b736c6ad0723c18abc19427cdc3f04c587144ace83fa8f4b4fdc235854a,0x14d0144696eef8219c87d939389abfba43b018cf6dc63e28b6b17505ef54594f) vs (0x4c24b736c6ad0723c18abc19427cdc3f04c587144ace83fa8f4b4fdc235854a,0x28595a20069852e700e8fd2554d136c1cb3e087a60018a27b719c88b6ad8f6eb)

Note: there's a segmentation fault in the end. prover.create_target_circuit_proof_batch() does not return.

The log file:

2023-06-10T21:00:51.201968704+00:00 INFO zkevm::utils - git version prealpha-v2.0-25-g1f24911-modified
2023-06-10T21:00:51.202490876+00:00 INFO zkevm::utils - load_or_create_params /home/ubuntu/scroll-zkevm/param/params25
2023-06-10T21:00:51.202604204+00:00 INFO zkevm::utils - start creating params with degree 25
2023-06-11T00:06:03.628418193+00:00 INFO zkevm::utils - create params successfully!
2023-06-11T00:37:32.127070146+00:00 INFO zkevm::prover::util - loaded parameters for degrees 20 and 25
2023-06-11T00:37:32.127300581+00:00 INFO zkevm::prover::util - params g2 (Fq2 { c0: 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed, c1: 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2 }, Fq2 { c0: 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa, c1: 0x090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b }) s_g2 (Fq2 { c0: 0x097aa085249a574ff7d1aaa2b498623f2923d159833cfde765a657aff8e0b527, c1: 0x2c358c680be102b15427cd4f58158ea3267a938ac04e1de564fd577bb7258960 }, Fq2 { c0: 0x1899775af20ee6b6b62d0b1c9dd6ad2e954af70764a84584c7cec5e522339fd9, c1: 0x0f77730977b52fe9c4d6cee4c281a3ace737795a9788d0ac3d9f3a9692708c75 })
2023-06-11T00:37:32.146821161+00:00 INFO zkevm::circuit::builder - check capacity of block traces, num_block 1, num_tx 1, tx total len 68
2023-06-11T00:37:38.172389249+00:00 INFO bus_mapping::circuit_input_builder - handling block Some(5), tx num 1
2023-06-11T00:37:38.172574898+00:00 INFO bus_mapping::circuit_input_builder - handling 0th tx(inner idx: 0): 0x1803da2b53edba96f1122f6a1c7edb58b47489956f4f5e96028369f71b30a91d rwc 1, to: Some(0x03f8133dd5ed58838b20af1296f62f44e69baa48), input_len 68
2023-06-11T00:37:38.177600653+00:00 WARN bus_mapping::evm::opcodes - geth error OutOfGas(SloadSstore) occurred in  SSTORE at pc 0x000b16
2023-06-11T00:37:38.178022338+00:00 INFO bus_mapping::circuit_input_builder - handling block done, total gas 49854
2023-06-11T00:37:46.652621750+00:00 ERROR zkevm_circuits::witness::mpt - roots non consistent (0x4c24b736c6ad0723c18abc19427cdc3f04c587144ace83fa8f4b4fdc235854a,0x14d0144696eef8219c87d939389abfba43b018cf6dc63e28b6b17505ef54594f) vs (0x4c24b736c6ad0723c18abc19427cdc3f04c587144ace83fa8f4b4fdc235854a,0x28595a20069852e700e8fd2554d136c1cb3e087a60018a27b719c88b6ad8f6eb)
2023-06-11T00:37:46.652851744+00:00 INFO mpt_zktrie::state::witness - account data {
    0x5300000000000000000000000000000000000002: AccountData {
        nonce: 0,
        balance: 0,
        keccak_code_hash: 0x0fabb5b0f58ec2922e2969f4dadb6d1395b49ecd40feff93e01212ae848355d4,
        poseidon_code_hash: 0x10e77cae1c507f967948c6cd114e74ed65f662e365c7d6993e97f78ce8982528,
        code_size: 2164,
        storage_root: 0x256484a85a716c24ed051180b7f705d3f8a890641a8df27c18d0e6ec3a024473,
    },
    0x03f8133dd5ed58838b20af1296f62f44e69baa48: AccountData {
        nonce: 1,
        balance: 0,
        keccak_code_hash: 0x16fc66d15010e6213d2a009f57ed8e847717ea0b83eeb37cd322e9ad1b018a3e,
        poseidon_code_hash: 0x0d85b09a93d5ed99a87d27dcf6d50e4459d16bb694e70f89eefcb745ea1c85e7,
        code_size: 4507,
        storage_root: 0x1b725ef9a53b6069ef6daeb73a063cf042a7c995dc1771f3908f0d7ce19f32a6,
    },
    0x1c5a77d9fa7ef466951b2f01f724bca3a5820b63: AccountData {
        nonce: 5,
        balance: 904625697166532776746648320380374280103671755200316706558261057343822587536,
        keccak_code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
        poseidon_code_hash: 0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864,
        code_size: 0,
        storage_root: 0x0000000000000000000000000000000000000000000000000000000000000000,
    },
    0x5300000000000000000000000000000000000005: AccountData {
        nonce: 0,
        balance: 1317718015514992,
        keccak_code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
        poseidon_code_hash: 0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864,
        code_size: 0,
        storage_root: 0x0000000000000000000000000000000000000000000000000000000000000000,
    },
    0x5300000000000000000000000000000000000000: AccountData {
        nonce: 0,
        balance: 0,
        keccak_code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
        poseidon_code_hash: 0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864,
        code_size: 0,
        storage_root: 0x0000000000000000000000000000000000000000000000000000000000000000,
    },
}
2023-06-11T00:41:57.060325708+00:00 INFO bus_mapping::circuit_input_builder - handling block Some(5), tx num 1
2023-06-11T00:41:57.060533364+00:00 INFO bus_mapping::circuit_input_builder - handling 0th tx(inner idx: 0): 0x1803da2b53edba96f1122f6a1c7edb58b47489956f4f5e96028369f71b30a91d rwc 1, to: Some(0x03f8133dd5ed58838b20af1296f62f44e69baa48), input_len 68
2023-06-11T00:41:57.064486391+00:00 WARN bus_mapping::evm::opcodes - geth error OutOfGas(SloadSstore) occurred in  SSTORE at pc 0x000b16
2023-06-11T00:41:57.064757045+00:00 INFO bus_mapping::circuit_input_builder - handling block done, total gas 49854
2023-06-11T00:42:05.556480238+00:00 ERROR zkevm_circuits::witness::mpt - roots non consistent (0x4c24b736c6ad0723c18abc19427cdc3f04c587144ace83fa8f4b4fdc235854a,0x14d0144696eef8219c87d939389abfba43b018cf6dc63e28b6b17505ef54594f) vs (0x4c24b736c6ad0723c18abc19427cdc3f04c587144ace83fa8f4b4fdc235854a,0x28595a20069852e700e8fd2554d136c1cb3e087a60018a27b719c88b6ad8f6eb)
2023-06-11T00:42:05.556712654+00:00 INFO mpt_zktrie::state::witness - account data {
    0x5300000000000000000000000000000000000000: AccountData {
        nonce: 0,
        balance: 0,
        keccak_code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
        poseidon_code_hash: 0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864,
        code_size: 0,
        storage_root: 0x0000000000000000000000000000000000000000000000000000000000000000,
    },
    0x5300000000000000000000000000000000000005: AccountData {
        nonce: 0,
        balance: 1317718015514992,
        keccak_code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
        poseidon_code_hash: 0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864,
        code_size: 0,
        storage_root: 0x0000000000000000000000000000000000000000000000000000000000000000,
    },
    0x03f8133dd5ed58838b20af1296f62f44e69baa48: AccountData {
        nonce: 1,
        balance: 0,
        keccak_code_hash: 0x16fc66d15010e6213d2a009f57ed8e847717ea0b83eeb37cd322e9ad1b018a3e,
        poseidon_code_hash: 0x0d85b09a93d5ed99a87d27dcf6d50e4459d16bb694e70f89eefcb745ea1c85e7,
        code_size: 4507,
        storage_root: 0x1b725ef9a53b6069ef6daeb73a063cf042a7c995dc1771f3908f0d7ce19f32a6,
    },
    0x5300000000000000000000000000000000000002: AccountData {
        nonce: 0,
        balance: 0,
        keccak_code_hash: 0x0fabb5b0f58ec2922e2969f4dadb6d1395b49ecd40feff93e01212ae848355d4,
        poseidon_code_hash: 0x10e77cae1c507f967948c6cd114e74ed65f662e365c7d6993e97f78ce8982528,
        code_size: 2164,
        storage_root: 0x256484a85a716c24ed051180b7f705d3f8a890641a8df27c18d0e6ec3a024473,
    },
    0x1c5a77d9fa7ef466951b2f01f724bca3a5820b63: AccountData {
        nonce: 5,
        balance: 904625697166532776746648320380374280103671755200316706558261057343822587536,
        keccak_code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
        poseidon_code_hash: 0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864,
        code_size: 0,
        storage_root: 0x0000000000000000000000000000000000000000000000000000000000000000,
    },
}
2023-06-11T00:42:05.560718561+00:00 INFO zkevm::prover::inner_circuit - proving batch of len 1, batch metric BatchMetric { num_block: 1, num_tx: 1, num_step: 298 }
2023-06-11T00:45:41.431136025+00:00 INFO zkevm_circuits::tx_circuit - TxCircuit::new(max_txs = 32, max_calldata = 400000, chain_id = 53077)
2023-06-11T00:45:49.985448538+00:00 INFO zkevm::prover::inner_circuit - Create super proof of block 0x9adb…b929 ... block 0x9adb…b929, batch len 1
2023-06-11T00:45:51.993973205+00:00 INFO zkevm_circuits::tx_circuit - TxCircuit::new(max_txs = 32, max_calldata = 400000, chain_id = 534353)
2023-06-11T00:45:53.178631865+00:00 INFO zkevm_circuits::tx_circuit - after value_is_zero, meta.degree: 9
2023-06-11T00:45:53.656106861+00:00 INFO zkevm_circuits::tx_circuit - after end, meta.degree: 9
2023-06-11T00:49:10.506689326+00:00 INFO zkevm_circuits::keccak_circuit::keccak_packed_multi - multi_keccak assign with capacity: Some(1744)

My code:
demo --trace /home/ubuntu/scroll-zkevm/zkevm/tests/traces/erc20/erc20_1_transfer.json

use clap::Parser;
use log::info;
use std::collections::HashMap;
use std::fs;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use std::time::Instant;
use std::env;
use zkevm::{
    circuit::{SuperCircuit, AGG_DEGREE},
    prover::Prover,
    utils::{get_block_trace_from_file, init_env_and_log, load_or_create_params},
};

#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct Args {
    /// Get params and write into file.
    #[clap(short, long = "params")]
    params_path: Option<String>,
    /// Get BlockTrace from file or dir.
    #[clap(short, long = "trace")]
    trace_path: Option<String>,
}

fn main() {
    let args = Args::parse();
    env::set_var("RUST_BACKTRACE", "1");
    let param_path = "/home/ubuntu/scroll-zkevm/param";
    init_env_and_log("prove");

    //
    // 1. instantiation the parameters and the prover
    //

    println!("Started!");

    let args = Args::parse();
    let agg_params = load_or_create_params(param_path, *AGG_DEGREE)
        .expect("failed to load or create params");

    let mut prover = Prover::from_params(agg_params);
    
    println!("Prover built");

    //
    // 2. read inner circuit proofs (a.k.a. SNARKs) from previous dumped file or
    //    convert block traces into proofs
    //

    // 2.1. Read traces from a directory or a file.
    let mut path_traces = HashMap::new();
    let trace_path = PathBuf::from(&args.trace_path.unwrap());
    if trace_path.is_dir() {
        for entry in fs::read_dir(trace_path).unwrap() {
            let path = entry.unwrap().path();
            if path.is_file() && path.to_str().unwrap().ends_with(".json") {
                let block_trace = get_block_trace_from_file(path.to_str().unwrap());
                path_traces.insert(path.file_stem().unwrap().to_os_string(), block_trace);
            }
        }
    } else {
        let block_trace = get_block_trace_from_file(trace_path.to_str().unwrap());
        path_traces.insert(trace_path.file_stem().unwrap().to_os_string(), block_trace);
    }
    let traces = path_traces.values().cloned().collect::<Vec<types::eth::BlockTrace>>();

    println!("Traces readen");

    // 2.2. Generate super circuit proof and dump it to output folder.
    let outer_now = Instant::now();
    let inner_proof_file_path = "/home/ubuntu/scroll-zkevm/output/super_proof.json";
    let proof = prover
                .create_target_circuit_proof_batch::<SuperCircuit>(&traces)
                .expect("Cannot generate evm_proof");

    println!("Proof generated!");

    // Dump inner circuit proof.
    proof.dump_to_file(&inner_proof_file_path)
        .expect("Cannot dump evm_proof");

    println!("finish generating all, elapsed: {:?}", outer_now.elapsed());
}

`CHAIN_ID env var is wrong` when running `make test-chunk-prove`

I am trying to run make test-chunk-prove but getting this error: CHAIN_ID env var is wrong. chain id in trace 534351, CHAIN_ID 53077

The full trace is:

running 1 test
2023-10-03T13:51:27.882740624+00:00 INFO prover::utils - git version 7ddaf92
2023-10-03T13:51:27.882767635+00:00 INFO prover::utils - short git version 7ddaf92
2023-10-03T13:51:27.882777676+00:00 INFO chunk_tests - Initialized ENV and created output-dir chunk_tests_output_multi_20231003_135127
2023-10-03T13:51:27.882851200+00:00 INFO integration::test_util - using mode "default", testing with "./tests/extra_traces/new.json"
2023-10-03T13:51:27.882903014+00:00 INFO integration::test_util - test cases traces: ["./tests/extra_traces/new.json"]
2023-10-03T13:51:27.886142221+00:00 INFO chunk_tests - Loaded chunk trace
2023-10-03T13:51:27.886170983+00:00 INFO prover::zkevm::circuit::l2_builder - check capacity of block traces, num_block 1, num_tx 1, tx total len 36
test test_chunk_prove_verify ... FAILED

failures:

---- test_chunk_prove_verify stdout ----
thread 'test_chunk_prove_verify' panicked at 'called `Result::unwrap()` on an `Err` value: CHAIN_ID env var is wrong. chain id in trace 534351, CHAIN_ID 53077

thread "test_agg_prove_verify" panicked at "called Option::unwrap()" on a "None" value

when I run "make test-agg-prove", I get this error so the test failed. What should I do to solve this problem?

test test_agg_prove_verify ... FAILED

failures:

---- test_agg_prove_verify stdout ----
thread 'test_agg_prove_verify' panicked at 'called `Option::unwrap()` on a `None` value', /root/.cargo/git/checkouts/snark-verifier-cd02c9c9f799657f/514f457/snark-verifier-sdk/src/evm_api.rs:198:20
stack backtrace:
   0: rust_begin_unwind
             at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/core/src/panicking.rs:64:14
   2: core::panicking::panic
             at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/core/src/panicking.rs:111:5
   3: snark_verifier_sdk::evm_api::verify_evm_proof
   4: core::ops::function::FnOnce::call_once
   5: core::ops::function::FnOnce::call_once
             at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    test_agg_prove_verify

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 953.87s

error: test failed, to rerun pass `-p prover --test aggregation_tests`
Makefile:45: recipe for target 'test-agg-prove' failed
make: *** [test-agg-prove] Error 101

feat: add API to check circuit capacity

Problem:
currently we use some heuristic mechansim in l2geth to prevent big batch overflowing circuit, like block_num_limit, total_gas_limit, etc. But it is not the final/correct solution. Circuit have much more limitation factors than these relatively simpler metrics, for example, sum(calldata), sum(keccak_len), sum(code_copy_len), etc all have some limitations. It is not wise to reimplement these fast changing rules again in golang, instead circuits should provide a simple stable capacity check interface to be used by sequencer(rust->CGO->golang).

p-code in infra side:

Solution1(stateless):

let mut blocks = Vec::new();
while true {
  let mut cur_blocks = blocks.clone();
  cur_blocks.push(fetch_new_block());
  if CapacityChecker::check(cur_blocks) {
    // circuit can process this batch, continue try
    blocks = cur_blocks;
    continue;
  } else {
    //  circuit cannot process the batch with last block, need to exclude the last block
    break;
  }
}
prover.prove_batch(blocks)

Solution2(stateful):
More efficient, need some extra work in circuit side, i prefer this way.

let mut checker = CapacityChecker::new();
while true {
   if checker.try_add_block(fetch_new_block()) {
     continue;
   } else {
     // checker cannot process the last block, and **will not add it to its internal queue**.
      break;
   }
}
prover.prove_batch(checker.get_batch());

Problems:

what if circuit cannot even process one block / one tx?

tx level: must implement some limitation(max tx len, max keccak len etc..) in l2geth to prevent these txs..so even worse case single evil attack tx cannot overflow circuit.

block level: (A) always make one l2block == one tx to simplify these checks.. or (B) allow l2block containing multi txs, but add a "fallback" mechanism in l2geth, reorg blocks and split big block into smaller blocks..

recently tried scroll bridge

Hi,

I recently tried scroll bridge. when I gave .01 ETH transfer it's sending .016 ETH. Please check the below image

image

The technical details of how Scroll-prover works?

  1. Zero-knowledge proofs: Scroll-prover utilizes techniques from cryptography called "zero-knowledge proofs" to verify the validity of transactions. These proofs ensure that transactions executed on Scroll were valid without revealing their actual data. Essentially, the prover convinces the verifier (a smart contract on the Ethereum mainnet) that everything happened correctly without divulging sensitive information.

  2. zkEVM circuits: To achieve this, Scroll-prover translates transactions into special mathematical structures called "circuits." These circuits encode the logic and rules that govern the transactions, essentially mimicking the Ethereum Virtual Machine (EVM) execution.

  3. Proving process:

Circuit generation: Once translated, Scroll-prover generates "witness data" which acts as proof that the circuit executed correctly. This data includes intermediate states, memory details, and other information specific to the transactions.
Proving: The prover then performs complex cryptographic computations on the witness data to generate a concise "proof" – a short string of data that mathematically convinces the verifier of the circuit's validity.
Verification: The proof is sent to the mainnet, where the verifier executes the circuit itself (without the original witness data) and compares the outcome with the provided proof. If they match, the transactions are deemed valid and accepted on the mainnet.
4. Optimizations: Scroll-prover employs various optimizations to improve efficiency and scalability:

Batching: Proofs are aggregated for multiple transactions, reducing gas costs and communication overhead.
Hardware acceleration: Specialized hardware like GPUs or FPGAs can accelerate proof generation, further increasing speed.
Circuit delegation: Complex circuits can be broken down into smaller, more manageable ones, improving efficiency.
Further exploration:

If you're interested in diving deeper, here are some resources:

Scroll Technical Blog: https://scroll.mirror.xyz/
Scroll Prover Github Repository: https://github.com/scroll-tech/scroll-prover
Zero-knowledge Proofs Explained: https://www.technologyreview.com/

what hardware configuration is needed to run scroll-prover?

i've watched Ye's speech about Scroll architecture, and now i wanna run scroll-prover, so i am curious that what hardware configuration is needed? Is it really need 500+ DRAM and 8+ GB GPU memory? And what hardware configuration is when dev team testing this repo (circuit, prover, verifier, etc.) ?

Error 101 when running `make test-chunk-prove`

make test-chunk-prove runs for 10-20 minutes before it terminates, complaining that process didn't exit successfully: "/data/scroll-prover/target/release/deps/chunk_tests-2cc1811299f948cd test_chunk_prove_verify" (signal: 9, SIGKILL: kill)

In case it helps, the message prior to the error message is printed out a few minutes before, and it hadn't printed anything out for a while.

Here are more details of the trace:

...
2023-10-05T00:15:36.290214221+00:00 INFO halo2_proofs::circuit::floor_planner::single_pass - region state circuit (synthesize_sub) part2_16 2nd pass synthesis took 57.795971ms
2023-10-05T00:15:36.290310397+00:00 INFO halo2_proofs::circuit::floor_planner::single_pass - region state circuit (synthesize_sub) part2_24 2nd pass synthesis took 57.877096ms
2023-10-05T00:15:36.291487719+00:00 INFO halo2_proofs::circuit::floor_planner::single_pass - region state circuit (synthesize_sub) part2_0 2nd pass synthesis took 60.293544ms
2023-10-05T00:15:36.292047993+00:00 INFO halo2_proofs::circuit::floor_planner::single_pass - Merge 32 subCS back took 13.82µs
2023-10-05T00:15:36.292106747+00:00 INFO halo2_proofs::circuit::floor_planner::single_pass - 32 sub_regions of state circuit (synthesize_sub) part2 2nd pass synthesis took 60.996997ms
error: test failed, to rerun pass `-p integration --test chunk_tests`

Caused by:
  process didn't exit successfully: `/data/scroll-prover/target/release/deps/chunk_tests-2cc1811299f948cd test_chunk_prove_verify` (signal: 9, SIGKILL: kill)
make: *** [Makefile:42: test-chunk-prove] Error 101

Transaction speed

Scroll 📜 need to improve transaction speed that's all I wanna say god bless this project and move to the moon

Uniswap pool creation bug

The token selection process on Uniswap testing the Scroll Alpha Testnet is not functioning correctly, which impedes the ability of developers to create functional liquidity pools.

Liquidity Pool on Uniswap

When trying to Add a Pool on Uniswap testing the Scroll Alpha Testnet
The Selecting of the Pair is not working as it is selecting only one token rather than the Usual two tokens
Could be because of a Bug or Congestion

New to scroll prover?

Scroll Prover is likely a component or software tool associated with the Scroll network, specifically designed for generating and verifying proofs within the zero-knowledge rollup mechanism.

Here's how the Scroll Prover might function within the context of the Scroll network:

Proof Generation: The Scroll Prover is responsible for creating zero-knowledge proofs that encapsulate batches of transactions. These proofs demonstrate that the transactions are valid without revealing any sensitive information about the transactions themselves. This process is crucial for ensuring the integrity and security of the off-chain transactions before they are committed to the Ethereum mainnet.

Validation: After generating the proofs, the Scroll Prover submits them to the Ethereum mainnet periodically. Validators on the Ethereum mainnet then verify the correctness of the proofs. This verification process ensures that the transactions processed off-chain comply with the rules of the Ethereum network and are valid according to the consensus protocol.

Efficiency and Scalability: By utilizing the Scroll Prover to generate and validate proofs off-chain, the Scroll network achieves significant improvements in efficiency and scalability compared to processing every transaction directly on the Ethereum mainnet. The use of zero-knowledge proofs allows for the aggregation of multiple transactions into a single proof, reducing the computational overhead and gas costs associated with on-chain transactions.

Overall, the Scroll Prover plays a critical role in enabling the functionality and performance of the Scroll network as a Layer 2 solution built on Ethereum, facilitating secure and efficient off-chain transaction processing through the use of zero-knowledge proofs.

inconsistency between state rebuilding

VS https://github.com/scroll-tech/zkevm-circuits/blob/3a48411dec61360e7a441bdf5abbf4b052f2d7ad/bus-mapping/src/circuit_input_builder/access.rs#L114

  1. if tx.to == null, trace the newly created contract. accountCreated? but be careful with this problem scroll-tech/go-ethereum#137
  2. DELEGATECALL / STATICCALL, need caller state?
  3. history block hashes is empty now. (upstream is also "TODO" ... , at least we should provide 1 prev block hash for pseudo randomness)
  4. some edge case handling codes may be missing here. Eg: 'create' fails?

more accurate row usage estimation in capacity checker

currently the algorithm is for each tx, we build an witness block, then calculate row usage of each subcircuit of this tx, then add the usage vector and find max inside the acc vector.

This algorithm will count some data redundantly. For example, if 2 tx shares same bytecode, then the len of bytecode circuit is counted twice. Overestimated.

We may impl a function "acc_witness_block += tx_witness_block"? Inside this function we do some basic de-duplicate and make more accurate estimation.

Pricinple: row estimation should be fast, a bit over estimation is allowd. Under estimation is seen as bug and should be avoided.

Things to know about scroll-prover

Zero-Knowledge Proofs:

Implement advanced zero-knowledge proofs for enhanced privacy and security.
Consider incorporating zk-SNARKs (Zero-Knowledge Succinct Non-Interactive Arguments of Knowledge) or zk-STARKs (Zero-Knowledge Scalable Transparent Arguments of Knowledge) to allow for efficient and trustless verification of transactions.
Gas Efficiency:

Focus on optimizing gas consumption by utilizing efficient algorithms and data structures.
Explore methods to reduce transaction costs and make the Scroll-Prover network more economical for users.
Cross-Layer Compatibility:

Ensure seamless interoperability with other Layer 2 solutions and standard Ethereum contracts.
Provide tools and resources for developers to easily integrate Scroll-Prover into their existing projects.
Smart Contract Compatibility:

Develop tools and documentation to support the easy deployment and execution of smart contracts on Scroll-Prover.
Enable developers to migrate their contracts from the Ethereum mainnet to Scroll-Prover with minimal friction.
Developer SDKs:

Create robust software development kits (SDKs) for various programming languages to encourage wider adoption among developers.
Include comprehensive documentation and tutorials to assist developers in building on the Scroll-Prover network.
Community Engagement:

Foster an active and supportive community through forums, social media, and developer meetups.
Encourage community-driven development and contributions to enhance the network's features and security.
Ecosystem Incentives:

Establish a reward system or grants to incentivize developers, validators, and users to actively participate in the Scroll-Prover ecosystem.
Consider introducing a native token to facilitate network governance and incentivize stakeholders.
Security Audits:

Conduct regular security audits to identify and address potential vulnerabilities.
Collaborate with reputable auditing firms to ensure the robustness of the Scroll-Prover protocol and smart contracts.
Scalability Solutions:

Explore additional scalability solutions, such as state channels or sidechains, to further enhance the throughput of the Scroll-Prover network.
User-Friendly Interfaces:

Develop user-friendly interfaces for both developers and end-users to interact with Scroll-Prover.
Prioritize an intuitive design that simplifies the user experience and encourages broader adoption.
By focusing on these aspects, Scroll-Prover can aim to provide a secure, scalable, and user-friendly Layer 2 solution for the Ethereum network.

ERROR MASSAGE

First open https://scroll.io/alpha/bridge and try to make a transaction the screen looks like the picture. Then I did it again and the error message disappeared and I made a successful transaction. Then when you want to do another transaction, the error message appears again. I'm using a Windows OS on Laptop

aaa

error[E0554]: `#![feature]` may not be used on the stable release channel

I'm running make test-chunk-prove and getting this error:

  Compiling halo2-gate-generator v0.1.0 (https://github.com/scroll-tech/halo2gategen.git#35b137de)
   Compiling halo2wrong v0.1.0 (https://github.com/scroll-tech/halo2wrong.git?branch=halo2-ecc-snark-verifier-0323#939d679c)
   Compiling misc-precompiled-circuit v0.1.0 (https://github.com/scroll-tech/misc-precompiled-circuit.git?tag=v0.1.0#f647341f)
error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /home/ec2-user/.cargo/git/checkouts/halo2-lib-f617e885ffdce2b3/7058817/halo2-base/src/lib.rs:1:1
  |
1 | #![feature(stmt_expr_attributes)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /home/ec2-user/.cargo/git/checkouts/halo2-lib-f617e885ffdce2b3/7058817/halo2-base/src/lib.rs:2:1
  |
2 | #![feature(trait_alias)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /home/ec2-user/.cargo/git/checkouts/poseidon-circuit-4ba4b0c72487e98b/69524f4/src/lib.rs:4:12
  |
4 | #![feature(slice_group_by)]
  |            ^^^^^^^^^^^^^^

release plans

scroll-dev-0804

  1. fix statedb/codedb building in common-rs. #36
  2. upgrade zkevm-circuits: (1) more error case handling by dream like invalid jump (2) some recent fixes like selfdestruct (3) logging improvements (eg: change logging level of witness assignment progress from debug to info)
  3. upgrade rust version. Same with zkevm-circuits
  4. MOCK_PROVE set to true by default?
  5. (optional) upgrade aggregator : (1) reduce gas to 1M (2) deterministic solidity verifier
  6. (optional, minor) change load_or_create_params to load_params to prevent incorrect params

run make test-agg fail

I read the code in snark-verifier-cd02c9c9f799657f/a3d0a5a/snark-verifier-sdk/src/evm.rs:188:24 but have no idea what cause the failures.

[2023-06-02T02:51:42.502Z INFO  aggregation_tests] got super circuit proof
[2023-06-02T03:14:27.575Z INFO  aggregation_tests] finished aggregation generation
[2023-06-02T03:14:27.643Z INFO  aggregation_tests] finished byte code generation
test test_aggregation_api ... FAILED
failures:

---- test_aggregation_api stdout ----
Context "Range" used 33 advice columns and 17076467 total advice cells in phase 0
Special lookup advice cells: optimal columns: 0, total 0 cells used in phase 0.
Fixed columns: 1, Total fixed cells: 8031
Context "Range" used 33 advice columns and 17076467 total advice cells in phase 0
Special lookup advice cells: optimal columns: 6, total 2817792 cells used in phase 0.
Context "Range" used 1 advice columns and 12384 total advice cells in phase 1
Special lookup advice cells: optimal columns: 0, total 0 cells used in phase 1.
Fixed columns: 1, Total fixed cells: 8031
Context "Range" used 33 advice columns and 17076467 total advice cells in phase 0
Special lookup advice cells: optimal columns: 0, total 0 cells used in phase 0.
Fixed columns: 1, Total fixed cells: 8031
Context "Range" used 33 advice columns and 17076467 total advice cells in phase 0
Special lookup advice cells: optimal columns: 6, total 2817792 cells used in phase 0.
Context "Range" used 1 advice columns and 12384 total advice cells in phase 1
Special lookup advice cells: optimal columns: 0, total 0 cells used in phase 1.
Fixed columns: 1, Total fixed cells: 8031
Context "Range" used 33 advice columns and 17076467 total advice cells in phase 0
Special lookup advice cells: optimal columns: 0, total 0 cells used in phase 0.
Fixed columns: 1, Total fixed cells: 8031
Context "Range" used 33 advice columns and 17076467 total advice cells in phase 0
Special lookup advice cells: optimal columns: 6, total 2817792 cells used in phase 0.
Context "Range" used 1 advice columns and 12384 total advice cells in phase 1
Special lookup advice cells: optimal columns: 0, total 0 cells used in phase 1.
Fixed columns: 1, Total fixed cells: 8031
Context "Range" used 33 advice columns and 17076467 total advice cells in phase 0
Special lookup advice cells: optimal columns: 0, total 0 cells used in phase 0.
Fixed columns: 1, Total fixed cells: 8031
Context "Range" used 33 advice columns and 17076467 total advice cells in phase 0
Special lookup advice cells: optimal columns: 6, total 2817792 cells used in phase 0.
Context "Range" used 1 advice columns and 12384 total advice cells in phase 1
Special lookup advice cells: optimal columns: 0, total 0 cells used in phase 1.
Fixed columns: 1, Total fixed cells: 8031
computing length 206 fixed base msm
computing length 1723 MSM
computing length 206 fixed base msm
computing length 1723 MSM
computing length 206 fixed base msm
computing length 1723 MSM
thread 'test_aggregation_api' panicked at 'called `Option::unwrap()` on a `None` value', /home/dev/.cargo/git/checkouts/snark-verifier-cd02c9c9f799657f/a3d0a5a/snark-verifier-sdk/src/evm.rs:188:24
stack backtrace:
   0: rust_begin_unwind
             at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/core/src/panicking.rs:64:14
   2: core::panicking::panic
             at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/core/src/panicking.rs:111:5
   3: snark_verifier_sdk::evm::evm_verify
   4: zkevm::verifier::EvmVerifier::verify
   5: core::ops::function::FnOnce::call_once
   6: core::ops::function::FnOnce::call_once
             at /rustc/dfe3fe710181738a2cb3060c23ec5efb3c68ca09/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    test_aggregation_api

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 5976.53s

error: test failed, to rerun pass `-p zkevm --test aggregation_tests`

test: add more traces

  • bridge traces #46 (comment)
  • failed
    • out of gas constant
    • out of gas dynamic
    • revert
    • invalid opcode
    • balance not enough (balance < call.value)
  • self destruct
  • native transfer
    • A transfer to B twice, B is a new address

Scroll Bridge

The bridging process from L1 to L2 and back is still very slow. Txn pending for over 10 mins.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.