Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit cbffb50

Browse files
lispcnoel2004roynalnaruto
authored
opt: reduce agg circuit phase (#1296)
* 1 * better log * assert cs * set max phase in aggregator to 1 Signed-off-by: noelwei <fan@scroll.io> * do not init logger inside single test Signed-off-by: noelwei <fan@scroll.io> --------- Signed-off-by: noelwei <fan@scroll.io> Co-authored-by: noelwei <fan@scroll.io> Co-authored-by: Rohit Narurkar <rohit.narurkar@proton.me>
1 parent eda6381 commit cbffb50

File tree

14 files changed

+111
-30
lines changed

14 files changed

+111
-30
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aggregator/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ gadgets = { path = "../gadgets" }
1111
zkevm-circuits = { path = "../zkevm-circuits" }
1212

1313
ark-std.workspace = true
14+
ctor.workspace = true
1415
env_logger.workspace = true
1516
ethers-core.workspace = true
1617
hex.workspace = true

aggregator/src/aggregation/circuit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<const N_SNARKS: usize> Circuit<Fr> for AggregationCircuit<N_SNARKS> {
137137
},
138138
);
139139

140-
let challenges = Challenges::construct(meta);
140+
let challenges = Challenges::construct_p1(meta);
141141
let config = AggregationConfig::configure(meta, &params, challenges);
142142
log::info!(
143143
"aggregation circuit configured with k = {} and {:?} advice columns",

aggregator/src/aggregation/config.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,31 @@ impl<const N_SNARKS: usize> AggregationConfig<N_SNARKS> {
190190
EccChip::construct(self.base_field_config.clone())
191191
}
192192
}
193+
194+
#[test]
195+
fn aggregation_circuit_degree() {
196+
use halo2_ecc::fields::fp::FpStrategy;
197+
let mut cs = ConstraintSystem::<Fr>::default();
198+
let param = ConfigParams {
199+
strategy: FpStrategy::Simple,
200+
degree: 20,
201+
num_advice: vec![59],
202+
num_lookup_advice: vec![7],
203+
num_fixed: 2,
204+
lookup_bits: 18,
205+
limb_bits: 88,
206+
num_limbs: 3,
207+
};
208+
let challenges = Challenges::construct_p1(&mut cs);
209+
AggregationConfig::<{ crate::constants::MAX_AGG_SNARKS }>::configure(
210+
&mut cs, &param, challenges,
211+
);
212+
cs = cs.chunk_lookups();
213+
let stats = zkevm_circuits::util::circuit_stats(&cs);
214+
let degree = cs.degree();
215+
let phases = cs.max_phase();
216+
assert!(degree <= 9);
217+
assert!(phases <= 1);
218+
log::info!("stats {stats:#?}");
219+
log::info!("agg circuit degree: {}", degree);
220+
}

aggregator/src/aggregation/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5461,7 +5461,7 @@ mod tests {
54615461
}
54625462

54635463
fn configure(meta: &mut ConstraintSystem<Fr>) -> Self::Config {
5464-
let challenges = Challenges::construct(meta);
5464+
let challenges = Challenges::construct_p1(meta);
54655465
let challenges_expr = challenges.exprs(meta);
54665466

54675467
let pow_rand_table = PowOfRandTable::construct(meta, &challenges_expr);

aggregator/src/aggregation/decoder/seq_exec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ mod tests {
11541154

11551155
let inst_tbl = SeqInstTable::configure(meta);
11561156

1157-
let chng_mock = MockChallenges::construct(meta);
1157+
let chng_mock = MockChallenges::construct_p1(meta);
11581158
let chng = chng_mock.exprs(meta);
11591159

11601160
let config = SeqExecConfig::configure(

aggregator/src/tests/aggregation.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ use crate::{
1313

1414
#[test]
1515
fn test_max_agg_snarks_aggregation_circuit() {
16-
env_logger::init();
17-
1816
let k = 20;
1917

2018
// This set up requires one round of keccak for chunk's data hash
@@ -47,7 +45,7 @@ fn test_14_snark_aggregation_circuit() {
4745
#[ignore = "it takes too much time"]
4846
#[test]
4947
fn test_aggregation_circuit_all_possible_num_snarks() {
50-
env_logger::init();
48+
//env_logger::init();
5149

5250
let k = 20;
5351

@@ -66,7 +64,7 @@ fn test_aggregation_circuit_all_possible_num_snarks() {
6664
#[ignore = "it takes too much time"]
6765
#[test]
6866
fn test_aggregation_circuit_full() {
69-
env_logger::init();
67+
//env_logger::init();
7068
let process_id = process::id();
7169
let k = 25;
7270

aggregator/src/tests/blob.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl Circuit<Fr> for BlobCircuit {
5858
fn configure(meta: &mut ConstraintSystem<Fr>) -> Self::Config {
5959
let u8_table = U8Table::construct(meta);
6060
let range_table = RangeTable::construct(meta);
61-
let challenges = Challenges::construct(meta);
61+
let challenges = Challenges::construct_p1(meta);
6262
let keccak_table = KeccakTable::construct(meta);
6363

6464
let rlc = RlcConfig::configure(meta, &keccak_table, challenges);

aggregator/src/tests/compression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::{
2323
#[ignore = "it takes too much time"]
2424
#[test]
2525
fn test_mock_compression() {
26-
env_logger::init();
26+
// env_logger::init();
2727

2828
if std::path::Path::new("data").is_dir() {
2929
println!("data folder already exists\n");

aggregator/src/tests/mock_chunk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl Circuit<Fr> for MockChunkCircuit {
7777
fn configure(meta: &mut ConstraintSystem<Fr>) -> Self::Config {
7878
meta.set_minimum_degree(4);
7979

80-
let challenges = Challenges::construct(meta);
80+
let challenges = Challenges::construct_p1(meta);
8181
let keccak_table = KeccakTable::construct(meta);
8282
let rlc_config = RlcConfig::configure(meta, &keccak_table, challenges);
8383
let instance = meta.instance_column();

0 commit comments

Comments
 (0)