Skip to content

Commit

Permalink
switch to latest develop + new mpt circuit (#151)
Browse files Browse the repository at this point in the history
* build but fail to mock prove

* upgrade traces

* update

* upgrade snark verifier

* it works

* update deps

* misc fix
  • Loading branch information
lispc committed Jun 27, 2023
1 parent 203b834 commit 0ca5710
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 73 deletions.
72 changes: 34 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ poseidon = { git = "https://github.com/scroll-tech/poseidon.git", branch = "scro
[patch."https://github.com/privacy-scaling-explorations/halo2wrong.git"]
halo2wrong = { git = "https://github.com/scroll-tech/halo2wrong.git", branch = "halo2-ecc-snark-verifier-0323" }
maingate = { git = "https://github.com/scroll-tech/halo2wrong", branch = "halo2-ecc-snark-verifier-0323" }
[patch."https://github.com/axiom-crypto/halo2-lib.git"]
halo2-base = { git = "https://github.com/scroll-tech/halo2-lib", branch = "halo2-ecc-snark-verifier-0323" }
halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", branch = "halo2-ecc-snark-verifier-0323" }
[patch."https://github.com/privacy-scaling-explorations/halo2curves.git"]
halo2curves = { git = "https://github.com/scroll-tech/halo2curves.git", branch = "0.3.1-derive-serde" }

Expand Down
2 changes: 1 addition & 1 deletion prover/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Cargo.lock
test_params*
test_seed

output_*
*output_*
6 changes: 3 additions & 3 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.gi

bus-mapping = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "develop" }
eth-types = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "develop" }
zkevm-circuits = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "develop", default-features = false, features = ["test","scroll","poseidon-codehash-lookup"] }
zkevm-circuits = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "develop", default-features = false, features = ["test","scroll","scroll-trace"] }
mpt-zktrie = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "develop" }
mock = { git = "https://github.com/scroll-tech/zkevm-circuits", branch = "develop" }

snark-verifier = { git = "https://github.com/scroll-tech/snark-verifier", branch = "halo2-ecc-snark-verifier-0323" }
snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "halo2-ecc-snark-verifier-0323" }
snark-verifier = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop" }
snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop" }

rand = "0.8"
rand_xorshift = "0.3"
Expand Down
16 changes: 8 additions & 8 deletions prover/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ pub fn load_batch_traces(batch_dir: &str) -> (Vec<String>, Vec<types::eth::Block
pub fn parse_trace_path_from_mode(mode: &str) -> &'static str {
let trace_path = match mode {
"empty" => "./tests/traces/empty.json",
"greeter" => "./tests/traces/greeter_setValue.json",
"single" => "./tests/traces/erc20/erc20_1_transfer.json",
"multiple" => "./tests/traces/erc20/erc20_10_transfer.json",
"native" => "./tests/traces/native_transfer.json",
"dao" => "./tests/traces/dao/dao_dao-Propose.json",
"nft" => "./tests/traces/nft/nft_mint.json",
"sushi" => "./tests/traces/sushi/sushi_chef-withdraw.json",
_ => "./tests/traces/erc20/erc20_10_transfer.json",
"greeter" => "./tests/traces/greeter/setValue.json",
"single" => "./tests/traces/erc20/1_transfer.json",
"multiple" => "./tests/traces/erc20/10_transfer.json",
"native" => "./tests/traces/native/transfer.json",
"dao" => "./tests/traces/dao/dao-propose.json",
"nft" => "./tests/traces/nft/mint.json",
"sushi" => "./tests/traces/sushi/chef-withdraw.json",
_ => "./tests/traces/erc20/10_transfer.json",
};
log::info!("using mode {:?}, testing with {:?}", mode, trace_path);
trace_path
Expand Down
5 changes: 3 additions & 2 deletions prover/src/zkevm/circuit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,10 @@ pub fn block_traces_to_witness_block_with_updated_state(
max_keccak_rows: MAX_KECCAK_ROWS,
max_exp_steps: MAX_EXP_STEPS,
max_mpt_rows: MAX_MPT_ROWS,
max_rlp_rows: MAX_CALLDATA,
};
let mut builder_block = circuit_input_builder::Block::from_headers(&[], circuit_params);
builder_block.chain_id = chain_id;
builder_block.chain_id = chain_id.as_u64();
builder_block.prev_state_root = U256::from(zktrie_state.root());
let mut builder = CircuitInputBuilder::new(state_db.clone(), code_db, &builder_block);
for (idx, block_trace) in block_traces.iter().enumerate() {
Expand All @@ -228,7 +229,7 @@ pub fn block_traces_to_witness_block_with_updated_state(
geth_trace.push(result.into());
}
// TODO: Get the history_hashes.
let mut header = BlockHead::new(chain_id, Vec::new(), &eth_block)?;
let mut header = BlockHead::new(chain_id.as_u64(), Vec::new(), &eth_block)?;
// override zeroed minder field with additional "coinbase" field in blocktrace
if let Some(address) = block_trace.coinbase.address {
header.coinbase = address;
Expand Down
4 changes: 1 addition & 3 deletions prover/src/zkevm/prover/evm.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use super::Prover;
use halo2_proofs::halo2curves::bn256::G1Affine;
use halo2_proofs::plonk::VerifyingKey;
use snark_verifier_sdk::evm::gen_evm_verifier_shplonk;
use snark_verifier_sdk::halo2::aggregation::AggregationCircuit;
use snark_verifier_sdk::CircuitExt;
use snark_verifier_sdk::{gen_evm_verifier_shplonk, AggregationCircuit, CircuitExt};
use std::path::Path;

impl Prover {
Expand Down
2 changes: 1 addition & 1 deletion prover/src/zkevm/prover/inner_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use halo2_proofs::halo2curves::bn256::Fr;
use log::info;
use rand::{Rng, SeedableRng};
use rand_xorshift::XorShiftRng;
use snark_verifier_sdk::halo2::gen_snark_shplonk;
use snark_verifier_sdk::gen_snark_shplonk;
use types::eth::BlockTrace;

impl Prover {
Expand Down
4 changes: 1 addition & 3 deletions prover/src/zkevm/prover/outer_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ use super::{AggCircuitProof, Prover, TargetCircuitProof};
use crate::io::{serialize_fr_tensor, serialize_vk};
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use snark_verifier_sdk::evm::gen_evm_proof_shplonk;
use snark_verifier_sdk::halo2::aggregation::AggregationCircuit;
use snark_verifier_sdk::{gen_pk, CircuitExt};
use snark_verifier_sdk::{gen_evm_proof_shplonk, gen_pk, AggregationCircuit, CircuitExt};
use types::eth::BlockTrace;

impl Prover {
Expand Down
6 changes: 3 additions & 3 deletions prover/src/zkevm/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use halo2_proofs::poly::kzg::strategy::AccumulatorStrategy;
use halo2_proofs::poly::VerificationStrategy;
use halo2_proofs::transcript::TranscriptReadBuffer;
use snark_verifier::system::halo2::transcript::evm::EvmTranscript;
use snark_verifier_sdk::evm::evm_verify;
use snark_verifier_sdk::halo2::aggregation::AggregationCircuit;
use snark_verifier_sdk::halo2::verify_snark_shplonk;
use snark_verifier_sdk::evm_verify;
use snark_verifier_sdk::verify_snark_shplonk;
use snark_verifier_sdk::AggregationCircuit;

pub struct Verifier {
params: ParamsKZG<Bn256>,
Expand Down
2 changes: 1 addition & 1 deletion prover/tests/aggregation_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use prover::zkevm::circuit::{SuperCircuit, TargetCircuit, AGG_DEGREE};
use prover::zkevm::{EvmVerifier, Prover, TargetCircuitProof};
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use snark_verifier_sdk::halo2::aggregation::AggregationCircuit;
use snark_verifier_sdk::AggregationCircuit;
use snark_verifier_sdk::CircuitExt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
Expand Down
6 changes: 3 additions & 3 deletions prover/tests/snark_verifier_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use prover::utils::init_env_and_log;
use prover::zkevm::{EvmVerifier, Prover, Verifier};
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use snark_verifier_sdk::evm::{evm_verify, gen_evm_proof_shplonk, gen_evm_verifier_shplonk};
use snark_verifier_sdk::halo2::aggregation::AggregationCircuit;
use snark_verifier_sdk::AggregationCircuit;
use snark_verifier_sdk::CircuitExt;
use snark_verifier_sdk::{gen_pk, halo2::gen_snark_shplonk};
use snark_verifier_sdk::{evm_verify, gen_evm_proof_shplonk, gen_evm_verifier_shplonk};
use snark_verifier_sdk::{gen_pk, gen_snark_shplonk};
use test_util::mock_plonk;

// This is essentially a same test as snark-verifier/evm-verifier
Expand Down
2 changes: 1 addition & 1 deletion prover/tests/traces
Submodule traces updated 54 files
+64 −56 bridge/01.json
+41,649 −56 bridge/02.json
+49,289 −56 bridge/03.json
+11,855 −56 bridge/04.json
+166,383 −41,500 bridge/05.json
+21,480 −49,250 bridge/06.json
+1,548 −11,806 bridge/07.json
+1,935 −58 bridge/08.json
+4,654 −80,141 bridge/09.json
+190 −86,177 bridge/10.json
+355 −28,470 bridge/11.json
+185 −1,567 bridge/12.json
+356 −2,224 bridge/13.json
+184 −176 bridge/14.json
+198 −64 bridge/15.json
+186 −178 bridge/16.json
+185 −175 bridge/17.json
+1,584 −177 bridge/18.json
+2,240 −178 bridge/19.json
+4,770 −179 bridge/20.json
+1,154 −147 dao/dao-cancel.json
+5,258 −3,523 dao/dao-propose.json
+17,569 −0 dao/deploy-dao.json
+6,418 −0 dao/deploy-votes.json
+62 −47 empty.json
+5,892 −4,863 erc20/10_transfer.json
+2,474 −428 erc20/1_transfer.json
+13,464 −0 erc20/deploy.json
+1,882 −558 erc20/mint.json
+1,000 −45 greeter_setValue.json
+804 −43 native_transfer.json
+1,909 −808 nft/burn.json
+13,479 −0 nft/deploy.json
+1,376 −384 nft/mint.json
+2,433 −1,161 nft/transferFrom.json
+2,035 −295 sushi/chef-add.json
+5,196 −3,001 sushi/chef-deposit.json
+2,228 −244 sushi/chef-set.json
+16,164 −6,432 sushi/chef-withdraw.json
+4,294 −0 sushi/deploy-chef.json
+5,924 −0 sushi/deploy-sushi.json
+1,201 −304 sushi/sushi-approve.json
+1,448 −97 sushi/sushi-mint.json
+1,131 −195 sushi/sushi-transferOwnership.json
+13,620 −0 uniswapv2/deploy-btc.json
+1,837 −0 uniswapv2/deploy-factory.json
+3,720 −0 uniswapv2/deploy-router.json
+4,997 −0 uniswapv2/deploy-weth9.json
+5,214 −2,939 uniswapv2/factory-createPair.json
+180,880 −0 uniswapv2/router-AddLiquidity.json
+141,199 −0 uniswapv2/router-swapExactTokensForTokens.json
+9,771 −5,758 uniswapv2/token-initBalance.json
+0 −51,314 uniswapv2/uniswapv2_router-AddLiquidity.json
+0 −28,797 uniswapv2/uniswapv2_router-swapExactTokensForTokens.json
6 changes: 3 additions & 3 deletions types/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ pub type EthBlock = Block<Transaction>;

#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct ExecutionResult {
#[serde(rename = "l1Fee", default)]
pub l1_fee: u64,
#[serde(rename = "l1DataFee", default)]
pub l1_fee: U256,
pub gas: u64,
pub failed: bool,
#[serde(rename = "returnValue", default)]
Expand All @@ -154,7 +154,7 @@ impl From<&ExecutionResult> for GethExecTrace {
struct_logs.push(step)
}
GethExecTrace {
l1_fee: e.l1_fee,
l1_fee: e.l1_fee.as_u64(),
gas: Gas(e.gas),
failed: e.failed,
return_value: e.return_value.clone(),
Expand Down

0 comments on commit 0ca5710

Please sign in to comment.