Skip to content

Commit

Permalink
upgrade halo2 to v1.1 mvlookup (#1100)
Browse files Browse the repository at this point in the history
* upgrade halo2 to v1.1 mvlookup

* clippy

* update lookup name

* Revert "update lookup name"

This reverts commit a152c79.

* upgrade halo2

* change some lookup names
  • Loading branch information
lispc authored Feb 2, 2024
1 parent 734d84b commit 67f702d
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 72 deletions.
71 changes: 36 additions & 35 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "
ethers-providers = "=2.0.7"
ethers-signers = "=2.0.7"
ff = "0.13"
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.0" }
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" }
hash-circuit = { package = "poseidon-circuit", git = "https://github.com/scroll-tech/poseidon-circuit.git", branch = "scroll-dev-1201" }
halo2-base = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop", default-features=false, features=["halo2-pse","display"] }
halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop", default-features=false, features=["halo2-pse","display"] }
Expand Down Expand Up @@ -69,7 +69,7 @@ ethers-etherscan = { git = "https://github.com/scroll-tech/ethers-rs.git", branc
ethers-signers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
gobuild = { git = "https://github.com/scroll-tech/gobuild.git" }
[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.0" }
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" }
[patch."https://github.com/privacy-scaling-explorations/poseidon.git"]
poseidon = { git = "https://github.com/scroll-tech/poseidon.git", branch = "main" }

Expand Down
2 changes: 1 addition & 1 deletion gadgets/src/evm_word.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ mod tests {
assert_eq!(
prover.verify(),
Err(vec![VerifyFailure::Lookup {
name: "Encoded word / Pub inputs",
name: "Encoded word / Pub inputs".to_string(),
lookup_index: 32,
location: FailureLocation::InRegion {
region: halo2_proofs::dev::metadata::Region::from((
Expand Down
12 changes: 6 additions & 6 deletions gadgets/src/monotone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,15 @@ mod test {
vec![1, 2, 2, 4, 4],
Err(vec![
Lookup {
name: "Range check",
name: "Range check".to_string(),
lookup_index: 0,
location: FailureLocation::InRegion {
region: halo2_proofs::dev::metadata::Region::from((1, "witness")),
offset: 2,
},
},
Lookup {
name: "Range check",
name: "Range check".to_string(),
lookup_index: 0,
location: FailureLocation::InRegion {
region: halo2_proofs::dev::metadata::Region::from((1, "witness")),
Expand All @@ -254,7 +254,7 @@ mod test {
try_test_circuit(
vec![1, 2, 3, 4, 105],
Err(vec![Lookup {
name: "Range check",
name: "Range check".to_string(),
lookup_index: 0,
location: FailureLocation::InRegion {
region: halo2_proofs::dev::metadata::Region::from((1, "witness")),
Expand All @@ -266,7 +266,7 @@ mod test {
try_test_circuit(
vec![1, 2, 3, 103, 4],
Err(vec![Lookup {
name: "Range check",
name: "Range check".to_string(),
lookup_index: 0,
location: FailureLocation::InRegion {
region: halo2_proofs::dev::metadata::Region::from((1, "witness")),
Expand All @@ -289,7 +289,7 @@ mod test {
try_test_circuit(
vec![1, 2, 3, 4, 105],
Err(vec![Lookup {
name: "Range check",
name: "Range check".to_string(),
lookup_index: 0,
location: FailureLocation::InRegion {
region: halo2_proofs::dev::metadata::Region::from((1, "witness")),
Expand All @@ -301,7 +301,7 @@ mod test {
try_test_circuit(
vec![1, 2, 3, 103, 4],
Err(vec![Lookup {
name: "Range check",
name: "Range check".to_string(),
lookup_index: 0,
location: FailureLocation::InRegion {
region: halo2_proofs::dev::metadata::Region::from((1, "witness")),
Expand Down
2 changes: 1 addition & 1 deletion zkevm-circuits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ serde_json.workspace = true

hash-circuit.workspace = true
misc-precompiled-circuit = { package = "misc-precompiled-circuit", git = "https://github.com/scroll-tech/misc-precompiled-circuit.git", branch = "main" }
halo2_gadgets = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.0", features = ["unstable"] }
halo2_gadgets = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1", features = ["unstable"] }

num-bigint.workspace = true
subtle.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions zkevm-circuits/src/copy_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl<F: Field> SubCircuitConfig<F> for CopyCircuitConfig<F> {
});

// memory word lookup
meta.lookup_any("Memory word lookup", |meta| {
meta.lookup_any("rw lookup", |meta| {
let cond = meta.query_fixed(q_enable, CURRENT)
* meta.query_advice(is_memory, CURRENT)
* is_word_end.is_equal_expression.expr();
Expand Down Expand Up @@ -433,7 +433,7 @@ impl<F: Field> SubCircuitConfig<F> for CopyCircuitConfig<F> {
.collect()
});

meta.lookup_any("Tx calldata lookup", |meta| {
meta.lookup_any("rw lookup", |meta| {
let cond = meta.query_fixed(q_enable, CURRENT)
* meta.query_advice(is_tx_calldata, CURRENT)
* meta.query_advice(non_pad_non_mask, CURRENT);
Expand Down
17 changes: 7 additions & 10 deletions zkevm-circuits/src/copy_circuit/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ fn copy_circuit_invalid_calldatacopy() {

assert_error_matches(
test_copy_circuit_from_block(block),
vec!["Memory word lookup", "Tx calldata lookup"],
vec!["rw lookup", "rw lookup"],
);
}

Expand All @@ -443,7 +443,7 @@ fn copy_circuit_invalid_codecopy() {

assert_error_matches(
test_copy_circuit_from_block(block),
vec!["Memory word lookup", "Bytecode lookup"],
vec!["rw lookup", "Bytecode lookup"],
);
}

Expand All @@ -461,7 +461,7 @@ fn copy_circuit_invalid_extcodecopy() {

assert_error_matches(
test_copy_circuit_from_block(block),
vec!["Memory word lookup", "Bytecode lookup"],
vec!["rw lookup", "Bytecode lookup"],
);
}

Expand All @@ -477,10 +477,7 @@ fn copy_circuit_invalid_sha3() {

let block = block_convert::<Fr>(&builder.block, &builder.code_db).unwrap();

assert_error_matches(
test_copy_circuit_from_block(block),
vec!["Memory word lookup"],
);
assert_error_matches(test_copy_circuit_from_block(block), vec!["rw lookup"]);
}

#[test]
Expand Down Expand Up @@ -580,9 +577,9 @@ fn assert_error_matches(result: Result<(), Vec<VerifyFailure>>, names: Vec<&str>
VerifyFailure::CellNotAssigned { .. } => panic!(),
VerifyFailure::ConstraintPoisoned { .. } => panic!(),
VerifyFailure::Permutation { .. } => panic!(),
// &VerifyFailure::InstanceCellNotAssigned { .. } | &VerifyFailure::Shuffle { .. } => {
// todo!()
// }
&VerifyFailure::InstanceCellNotAssigned { .. } | &VerifyFailure::Shuffle { .. } => {
todo!()
}
}
}
}
2 changes: 1 addition & 1 deletion zkevm-circuits/src/state_circuit/constraint_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl<F: Field> ConstraintBuilder<F> {
// The address is aligned.
let inv_32 = F::from(32).invert().unwrap();
self.add_lookup(
"address % 32 == 0",
"limb fits into u16",
vec![(q.address.limbs[0].clone() * inv_32, q.lookups.u16.clone())],
);

Expand Down
2 changes: 1 addition & 1 deletion zkevm-circuits/src/state_circuit/lexicographic_ordering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Config {
limb_difference_inverse,
};

lookup.range_check_u16(meta, "limb_difference fits into u16", |meta| {
lookup.range_check_u16(meta, "limb fits into u16", |meta| {
meta.query_advice(limb_difference, Rotation::cur())
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ where
let limbs = [0; N].map(|_| meta.advice_column());

for &limb in &limbs {
lookup.range_check_u16(meta, "mpi limb fits into u16", |meta| {
lookup.range_check_u16(meta, "limb fits into u16", |meta| {
meta.query_advice(limb, Rotation::cur())
});
}
Expand Down
Loading

0 comments on commit 67f702d

Please sign in to comment.