Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Halo2 ecc snark verifier rebase 0329 #10

Open
wants to merge 2 commits into
base: auditing-freeze
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@
/target
testdata

.gitignore
Cargo.lock

# local files
*.srs
*.log
*.snark
*.sol
*.pkey
13 changes: 12 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,20 @@ debug-assertions = false
lto = "fat"
# codegen-units = 1
panic = "abort"
incremental = false
incremental = true

# For performance profiling
[profile.flamegraph]
inherits = "release"
debug = true

[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "halo2-ecc-snark-verifier-0323" }
[patch."https://github.com/privacy-scaling-explorations/poseidon.git"]
poseidon = { git = "https://github.com/scroll-tech/poseidon.git", branch = "scroll-dev-0220" }
# [patch."https://github.com/privacy-scaling-explorations/halo2wrong.git"]
# ecc = { git = "https://github.com/scroll-tech/halo2wrong.git", branch = "halo2-ecc-snark-verifier-0323" }
# 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/privacy-scaling-explorations/halo2curves.git"]
halo2curves = { git = "https://github.com/scroll-tech/halo2curves.git", branch = "0.3.1-derive-serde" }
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2022-10-28
nightly-2022-12-10
32 changes: 18 additions & 14 deletions snark-verifier-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ serde_json = "1.0"
serde_with = { version = "2.2", optional = true }
bincode = "1.3.3"
ark-std = { version = "0.3.0", features = ["print-trace"], optional = true }
halo2-base = { git = "https://github.com/axiom-crypto/halo2-lib.git", branch = "axiom-dev-0301", default-features = false }

halo2-base = { git = "https://github.com/scroll-tech/halo2-lib.git", branch = "halo2-ecc-snark-verifier-rebase-0329", default-features=false, features=["halo2-scroll","display"] }
snark-verifier = { path = "../snark-verifier", default-features = false }

# loader_evm
Expand All @@ -27,14 +28,11 @@ ethereum-types = { version = "0.14", default-features = false, features = ["std"
# bytes = { version = "1.2", optional = true }
# rlp = { version = "0.5", default-features = false, features = ["std"], optional = true }

# zkevm benchmarks
zkevm-circuits = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", features = ["test"], optional = true }
bus-mapping = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", optional = true }
eth-types = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", optional = true }
mock = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", optional = true }

env_logger = "0.10.0"
log = "0.4.17"
[dev-dependencies]
ark-std = { version = "0.3.0", features = ["print-trace"] }
ethers-signers = { version = "0.17.0" }
paste = "1.0.7"
pprof = { version = "0.11", features = ["criterion", "flamegraph"] }
criterion = "0.4"
Expand All @@ -43,17 +41,23 @@ criterion-macro = "0.4"
crossterm = { version = "0.25" }
tui = { version = "0.19", default-features = false, features = ["crossterm"] }

# # zkevm benchmarks
# zkevm-circuits = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "halo2-ecc-snark-verifier-0323", default-features=false, features = ["test"] }
# bus-mapping = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "halo2-ecc-snark-verifier-0323" }
# eth-types = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "halo2-ecc-snark-verifier-0323" }
# mock = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "halo2-ecc-snark-verifier-0323" }

[features]
default = ["loader_halo2", "loader_evm", "halo2-axiom", "halo2-base/jemallocator", "display"]
default = ["loader_halo2", "loader_evm", "halo2-scroll", "halo2-base/jemallocator"]
display = ["snark-verifier/display", "dep:ark-std"]
loader_evm = ["snark-verifier/loader_evm", "dep:ethereum-types"]
loader_halo2 = ["snark-verifier/loader_halo2"]
parallel = ["snark-verifier/parallel"]
# EXACTLY one of halo2-pse / halo2-axiom should always be turned on; not sure how to enforce this with Cargo
halo2-pse = ["snark-verifier/halo2-pse", "dep:serde_with"]
# EXACTLY one of halo2-scroll / halo2-axiom should always be turned on; not sure how to enforce this with Cargo
halo2-scroll = ["snark-verifier/halo2-scroll", "dep:serde_with"]
halo2-axiom = ["snark-verifier/halo2-axiom"]

zkevm = ["dep:zkevm-circuits", "dep:bus-mapping", "dep:mock", "dep:eth-types"]
#zkevm = [ "dep:bus-mapping", "dep:mock" ]

[[bench]]
name = "standard_plonk"
Expand All @@ -62,10 +66,10 @@ harness = false

[[bench]]
name = "zkevm"
required-features = ["loader_halo2", "loader_evm", "zkevm", "halo2-pse"]
required-features = ["loader_halo2", "loader_evm", "zkevm", "halo2-scroll"]
harness = false

[[bench]]
name = "zkevm_plus_state"
required-features = ["loader_halo2", "loader_evm", "zkevm", "halo2-pse"]
harness = false
required-features = ["loader_halo2", "zkevm", "halo2-scroll", "halo2-base/jemallocator"]
harness = false
2 changes: 1 addition & 1 deletion snark-verifier-sdk/benches/standard_plonk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ mod application {
layouter.assign_region(
|| "",
|mut region| {
#[cfg(feature = "halo2-pse")]
#[cfg(feature = "halo2-scroll")]
{
region.assign_advice(|| "", config.a, 0, || Value::known(self.0))?;
region.assign_fixed(|| "", config.q_a, 0, || Value::known(-Fr::one()))?;
Expand Down
10 changes: 10 additions & 0 deletions snark-verifier-sdk/configs/two_layer_recursion_first_layer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"strategy": "Simple",
"degree": 21,
"num_advice": 5,
"num_lookup_advice": 1,
"num_fixed": 1,
"lookup_bits": 20,
"limb_bits": 88,
"num_limbs": 3
}
10 changes: 10 additions & 0 deletions snark-verifier-sdk/configs/two_layer_recursion_second_layer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"strategy": "Simple",
"degree": 26,
"num_advice": 1,
"num_lookup_advice": 1,
"num_fixed": 1,
"lookup_bits": 22,
"limb_bits": 88,
"num_limbs": 3
}
8 changes: 7 additions & 1 deletion snark-verifier-sdk/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ where
MSMAccumulator = DualMSM<'params, Bn256>,
>,
{
#[cfg(debug_assertions)]
{
use halo2_base::halo2_proofs::{dev::MockProver, poly::commitment::Params};
MockProver::run(params.k(), &circuit, instances.clone()).unwrap().assert_satisfied();
}

let instances = instances.iter().map(|instances| instances.as_slice()).collect_vec();

#[cfg(feature = "display")]
Expand Down Expand Up @@ -184,7 +190,7 @@ pub fn evm_verify(deployment_code: Vec<u8>, instances: Vec<Vec<Fr>>, proof: Vec<
let verifier = evm.deploy(caller, deployment_code.into(), 0.into()).address.unwrap();
let result = evm.call_raw(caller, verifier, calldata.into(), 0.into());

dbg!(result.gas_used);
log::info!("gas used: {}", result.gas_used);

!result.reverted
};
Expand Down
16 changes: 16 additions & 0 deletions snark-verifier-sdk/src/evm_circuits/evm_circuit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use eth_types::Field;
use zkevm_circuits::evm_circuit::EvmCircuit;

use crate::CircuitExt;

impl<F: Field> CircuitExt<F> for EvmCircuit<F> {
/// Return the number of instances of the circuit.
/// This may depend on extra circuit parameters but NOT on private witnesses.
fn num_instance(&self) -> Vec<usize> {
vec![0]
}

fn instances(&self) -> Vec<Vec<F>> {
vec![]
}
}
Loading