Skip to content

Commit

Permalink
optimize follower ccc
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc committed Mar 21, 2024
1 parent 79153a9 commit c625e05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
15 changes: 13 additions & 2 deletions prover/src/zkevm/circuit/l2_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,19 @@ pub fn calculate_row_usage_of_witness_block(
);
assert_eq!(rows[10].name, "poseidon");
assert_eq!(rows[13].name, "mpt");
// empirical estimation is each row in mpt cost 1.5 hash (aka 12 rows)
let mpt_poseidon_rows = rows[13].row_num_real * 12;
// We collected real metrics from Scroll mainnet, and here is the graph
// https://ibb.co/gVfvW7h
// 6 is already very very conservative. Besides, considering a chunk consists of many txs,
// using this number is safe.
let poseidon_estimate_ratio = if witness_block.txs.len() > 1 {
// follower ccc
6
} else {
// singer ccc or single tx block follower ccc,
// even i think 6 is safe, here we still keep the old value
12
};
let mpt_poseidon_rows = rows[13].row_num_real * poseidon_estimate_ratio;
if witness_block.mpt_updates.smt_traces.is_empty() {
rows[10].row_num_real += mpt_poseidon_rows;
log::debug!("calculate_row_usage_of_witness_block light mode, adding {mpt_poseidon_rows} poseidon rows");
Expand Down

0 comments on commit c625e05

Please sign in to comment.