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

Commit 3097221

Browse files
lispczhenfeizhang
authored andcommitted
update super circuit row estimation API (#695)
1 parent 5658bc5 commit 3097221

File tree

2 files changed

+47
-127
lines changed

2 files changed

+47
-127
lines changed

zkevm-circuits/src/super_circuit.rs

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,18 @@ impl SubCircuitConfig<Fr> for SuperCircuitConfig<Fr> {
398398
}
399399
}
400400

401+
/// Row usage for each sub circuit
402+
#[derive(Clone, Default, Debug)]
403+
pub struct SubcircuitRowUsage {
404+
/// Subcircuit name
405+
pub name: String,
406+
// TODO: better name?
407+
/// Without padding
408+
pub row_num_real: usize,
409+
/// With padding
410+
pub row_num_total: usize,
411+
}
412+
401413
/// The Super Circuit contains all the zkEVM circuits
402414
#[derive(Clone, Default, Debug)]
403415
pub struct SuperCircuit<
@@ -457,7 +469,7 @@ impl<
457469
num_rows_evm_circuit
458470
}
459471
/// Return the minimum number of rows required to prove the block
460-
pub fn min_num_rows_block_subcircuits(block: &Block<Fr>) -> (Vec<usize>, Vec<usize>) {
472+
pub fn min_num_rows_block_subcircuits(block: &Block<Fr>) -> Vec<SubcircuitRowUsage> {
461473
let evm = EvmCircuit::min_num_rows_block(block);
462474
let state = StateCircuit::min_num_rows_block(block);
463475
let bytecode = BytecodeCircuit::min_num_rows_block(block);
@@ -491,14 +503,37 @@ impl<
491503
#[cfg(feature = "zktrie")]
492504
mpt,
493505
];
494-
let (rows_without_padding, rows_with_padding): (Vec<usize>, Vec<usize>) =
495-
rows.into_iter().unzip();
496-
log::debug!(
497-
"subcircuit rows(without padding): {:?}",
498-
rows_without_padding
499-
);
500-
log::debug!("subcircuit rows(with padding): {:?}", rows_with_padding);
501-
(rows_without_padding, rows_with_padding)
506+
let sub_circuit_names: Vec<String> = [
507+
"evm",
508+
"state",
509+
"bytecode",
510+
"copy",
511+
"keccak",
512+
"tx",
513+
"rlp",
514+
"exp",
515+
"modexp",
516+
"pi",
517+
"poseidon",
518+
"sig",
519+
"ecc",
520+
#[cfg(feature = "zktrie")]
521+
"mpt",
522+
]
523+
.into_iter()
524+
.map(|s| s.to_string())
525+
.collect();
526+
let row_usage_details = sub_circuit_names
527+
.into_iter()
528+
.zip_eq(rows.into_iter())
529+
.map(|(name, (row_num_real, row_num_total))| SubcircuitRowUsage {
530+
name,
531+
row_num_real,
532+
row_num_total,
533+
})
534+
.collect_vec();
535+
log::debug!("row_usage_details {row_usage_details:?}");
536+
row_usage_details
502537
}
503538
}
504539

@@ -583,10 +618,10 @@ impl<
583618

584619
/// Return the minimum number of rows required to prove the block
585620
fn min_num_rows_block(block: &Block<Fr>) -> (usize, usize) {
586-
let (rows_without_padding, rows_with_padding) = Self::min_num_rows_block_subcircuits(block);
621+
let row_usage = Self::min_num_rows_block_subcircuits(block);
587622
(
588-
itertools::max(rows_without_padding).unwrap(),
589-
itertools::max(rows_with_padding).unwrap(),
623+
itertools::max(row_usage.iter().map(|x| x.row_num_real)).unwrap(),
624+
itertools::max(row_usage.iter().map(|x| x.row_num_total)).unwrap(),
590625
)
591626
}
592627

zkevm-circuits/tests/prover_error.rs

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)