Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Merge 7468473 into d4e7bbb
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkiebell committed Nov 12, 2022
2 parents d4e7bbb + 7468473 commit ce0599a
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 30 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/autogen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ jobs:
run: |
docker compose run --use-aliases --no-TTY --rm --entrypoint bash dev -c 'cargo fmt --all'
- name: EVM verifier
- name: Dummy and Pi circuit EVM & aggregation verifier
run: |
docker compose run --use-aliases --no-TTY --rm --entrypoint bash dev -c 'ONLY_EVM=1 ./scripts/autogen.sh autogen_verifier_'
docker compose run --use-aliases --no-TTY --rm --entrypoint bash dev -c './ONLY_EVM=0 ./scripts/autogen.sh autogen_verifier_dummy autogen_verifier_pi'
- name: Super circuit EVM verifier
run: |
docker compose run --use-aliases --no-TTY --rm --entrypoint bash dev -c './ONLY_EVM=1 ./scripts/autogen.sh autogen_verifier_super'
- name: Patch genesis templates
run: docker run --rm -v $(pwd):/host -w /host node:lts-alpine scripts/patch_genesis.mjs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/heavy_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ jobs:
docker compose down -v --remove-orphans
docker compose build bootnode dev
- name: Pi Circuit
- name: Pi Circuit aggregation
run: |
docker compose run --use-aliases --no-TTY --rm --entrypoint bash dev -c 'COORDINATOR_CIRCUIT_NAME=pi ./scripts/heavy_ci.sh'
docker compose run --use-aliases --no-TTY --rm --entrypoint bash dev -c 'COORDINATOR_AGGREGATE_PROOF=true COORDINATOR_CIRCUIT_NAME=pi ./scripts/heavy_ci.sh'
./scripts/ci_commit_errors.sh pi
- name: Super Circuit
Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
eth-types = { git = "https://github.com/pinkiebell/zkevm-circuits.git", rev = "93abf023f061c719d8737478b2d87539c517431a" }
eth-types = { git = "https://github.com/pinkiebell/zkevm-circuits.git", rev = "6bc581922807485cd9e89b4308fc08d679e5b6c2" }
hyper = { version = "0.14.16", features = ["server"] }
log = "0.4.14"
serde = { version = "1.0.136", features = ["derive"] }
Expand Down
1 change: 1 addition & 0 deletions common/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ pub struct CircuitConfig {
pub min_k: usize,
pub pad_to: usize,
pub min_k_aggregation: usize,
pub keccak_padding: usize,
}

fn default_bool() -> bool {
Expand Down
6 changes: 3 additions & 3 deletions docker/geth/templates/l1-testnet.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docker/geth/templates/l2-testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@
"code": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80633dbb202b146100465780636e296e451461005b578063b29e0acf1461008c575b600080fd5b6100596100543660046105ef565b61009f565b005b6100636100ca565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61005961009a366004610660565b61018e565b6100c46202000073936a70c0b28532aa22240dce21f89a8399d6ac61868686866101b3565b50505050565b6000805473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff215301610171576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f78446f6d61696e4d65737361676553656e646572206973206e6f74207365740060448201526064015b60405180910390fd5b5060005473ffffffffffffffffffffffffffffffffffffffff1690565b6100c46201000073936a70c0b28532aa22240dce21f89a8399d6ac618686868661035e565b6000806101c342620151806106c5565b905060004244015a0190506000338888886040516024016101e7949392919061074e565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fb29e0acf00000000000000000000000000000000000000000000000000000000179052517f5d4d3bcd00000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff8b1690635d4d3bcd906102b8908c908890889088908890600401610792565b6020604051808303816000875af11580156102d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102fb9190610831565b508773ffffffffffffffffffffffffffffffffffffffff167fcb0f7ffd78f9aee47a248fae8db181db6eee833039123e026dcbff529522e52a338989868a60405161034a95949392919061084a565b60405180910390a250505050505050505050565b3373ffffffffffffffffffffffffffffffffffffffff8716146103dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f73656e64657200000000000000000000000000000000000000000000000000006044820152606401610168565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16633b1623fe6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561043f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104639190610898565b73ffffffffffffffffffffffffffffffffffffffff16146104e0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f6d657373616765206f726967696e0000000000000000000000000000000000006044820152606401610168565b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861617815561052d908490848461055d565b5050600080547fffffffffffffffffffffffff000000000000000000000000000000000000000016905550505050565b608081838237600080838387895af161057a573d6000803e3d6000fd5b5050505050565b73ffffffffffffffffffffffffffffffffffffffff811681146105a357600080fd5b50565b60008083601f8401126105b857600080fd5b50813567ffffffffffffffff8111156105d057600080fd5b6020830191508360208285010111156105e857600080fd5b9250929050565b6000806000806060858703121561060557600080fd5b843561061081610581565b9350602085013567ffffffffffffffff81111561062c57600080fd5b610638878288016105a6565b909450925050604085013563ffffffff8116811461065557600080fd5b939692955090935050565b6000806000806060858703121561067657600080fd5b843561068181610581565b9350602085013561069181610581565b9250604085013567ffffffffffffffff8111156106ad57600080fd5b6106b9878288016105a6565b95989497509550505050565b808201808211156106ff577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600073ffffffffffffffffffffffffffffffffffffffff808716835280861660208401525060606040830152610788606083018486610705565b9695505050505050565b73ffffffffffffffffffffffffffffffffffffffff8616815260006020868184015285604084015284606084015260a0608084015283518060a085015260005b818110156107ee5785810183015185820160c0015282016107d2565b50600060c0828601015260c07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116850101925050509695505050505050565b60006020828403121561084357600080fd5b5051919050565b73ffffffffffffffffffffffffffffffffffffffff8616815260806020820152600061087a608083018688610705565b905083604083015263ffffffff831660608301529695505050505050565b6000602082840312156108aa57600080fd5b81516108b581610581565b939250505056fea164736f6c6343000810000a"
}
}
}
}
8 changes: 4 additions & 4 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ license = "MIT OR Apache-2.0"

[dependencies]
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", tag = "v2022_10_22" }
bus-mapping = { git = "https://github.com/pinkiebell/zkevm-circuits.git", rev = "93abf023f061c719d8737478b2d87539c517431a" }
eth-types = { git = "https://github.com/pinkiebell/zkevm-circuits.git", rev = "93abf023f061c719d8737478b2d87539c517431a" }
zkevm-circuits = { git = "https://github.com/pinkiebell/zkevm-circuits.git", rev = "93abf023f061c719d8737478b2d87539c517431a" }
bus-mapping = { git = "https://github.com/pinkiebell/zkevm-circuits.git", rev = "6bc581922807485cd9e89b4308fc08d679e5b6c2" }
eth-types = { git = "https://github.com/pinkiebell/zkevm-circuits.git", rev = "6bc581922807485cd9e89b4308fc08d679e5b6c2" }
zkevm-circuits = { git = "https://github.com/pinkiebell/zkevm-circuits.git", rev = "6bc581922807485cd9e89b4308fc08d679e5b6c2" }
plonk_verifier = { git = "https://github.com/privacy-scaling-explorations/plonk-verifier.git", rev = "2cd8b9d1e57949979db1cbfa8506518e63d27e93" }
env_logger = "0.9.0"
ethers-providers = "0.17.0"
Expand All @@ -25,7 +25,7 @@ itertools = "0.10.3"
clap = { version = "4.0.14", features = ["derive", "env"] }

# autogen
mock = { git = "https://github.com/pinkiebell/zkevm-circuits.git", rev = "93abf023f061c719d8737478b2d87539c517431a", optional = true }
mock = { git = "https://github.com/pinkiebell/zkevm-circuits.git", rev = "6bc581922807485cd9e89b4308fc08d679e5b6c2", optional = true }
ethers-signers = { version = "0.17.0", optional = true }

[features]
Expand Down
9 changes: 6 additions & 3 deletions prover/src/circuit_autogen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ macro_rules! match_circuit_params {
max_rws: 491520,
min_k: 19,
pad_to: 491520,
min_k_aggregation: 20,
min_k_aggregation: 21,
keccak_padding: 1000,
};
$on_match
}
Expand All @@ -24,7 +25,8 @@ macro_rules! match_circuit_params {
max_rws: 1015808,
min_k: 20,
pad_to: 1015808,
min_k_aggregation: 20,
min_k_aggregation: 21,
keccak_padding: 2380,
};
$on_match
}
Expand All @@ -37,7 +39,8 @@ macro_rules! match_circuit_params {
max_rws: 2064384,
min_k: 21,
pad_to: 2064384,
min_k_aggregation: 20,
min_k_aggregation: 21,
keccak_padding: 4761,
};
$on_match
}
Expand Down
2 changes: 2 additions & 0 deletions prover/src/circuit_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ impl CircuitWitness {
let circuit_params = CircuitsParams {
max_rws: circuit_config.max_rws,
max_txs: circuit_config.max_txs,
keccak_padding: Some(circuit_config.keccak_padding),
};
let keccak_inputs = Vec::new();
let code_db = CodeDB::new();
Expand Down Expand Up @@ -81,6 +82,7 @@ impl CircuitWitness {
let circuit_params = CircuitsParams {
max_rws: circuit_config.max_rws,
max_txs: circuit_config.max_txs,
keccak_padding: Some(circuit_config.keccak_padding),
};
let builder = BuilderClient::new(geth_client, circuit_params).await?;
let (builder, eth_block) = builder.gen_inputs(*block_num).await?;
Expand Down
1 change: 1 addition & 0 deletions prover/src/super_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub fn gen_circuit<
keccak_inputs,
bytecode_size: witness.circuit_config.max_bytecode,
pi_circuit,
circuits_params: witness.block.circuits_params.clone(),
};

Ok(circuit)
Expand Down
15 changes: 9 additions & 6 deletions prover/tests/autogen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ macro_rules! estimate {
min_k: 0,
pad_to: 0,
min_k_aggregation: 0,
// TODO: proper worst-case estimate
keccak_padding: BLOCK_GAS_LIMIT / 63,
};
let circuit_witness;

Expand Down Expand Up @@ -247,6 +249,7 @@ macro_rules! estimate {
let circuit_params = CircuitsParams {
max_rws: circuit_config.max_rws,
max_txs: circuit_config.max_txs,
keccak_padding: Some(circuit_config.keccak_padding),
};
let mut builder =
BlockData::new_from_geth_data_with_params(block.clone(), circuit_params)
Expand Down Expand Up @@ -279,17 +282,17 @@ macro_rules! estimate {
}
// calculate circuit stats
{
circuit_config.pad_to = MAX_RWS;

let highest_row =
run_assembly::<MAX_TXS, MAX_CALLDATA, MAX_BYTECODE, MAX_RWS>(circuit_witness)
.unwrap();
let log2_ceil = |n| u32::BITS - (n as u32).leading_zeros() - (n & (n - 1) == 0) as u32;
let k = log2_ceil(highest_row);
// TODO: estimate aggregation circuit requirements
let agg_k = 20;
let k = log2_ceil(highest_row) as usize;
let remaining_rows = (1 << k) - highest_row;
circuit_config.min_k = k as usize;
circuit_config.pad_to = MAX_RWS;
circuit_config.min_k_aggregation = agg_k;
circuit_config.min_k = k;
// TODO: estimate aggregation circuit requirements
circuit_config.min_k_aggregation = 21;

$scope(circuit_config, highest_row, remaining_rows);
}
Expand Down

0 comments on commit ce0599a

Please sign in to comment.