Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.
Merged
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
7 changes: 5 additions & 2 deletions zkevm-circuits/src/pi_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,7 @@ impl<F: Field> SubCircuit<F> for PiCircuit<F> {

/// Return the minimum number of rows required to prove the block
fn min_num_rows_block(block: &witness::Block<F>) -> (usize, usize) {
let tx_usage = block.txs.len() as f32 / block.circuits_params.max_txs as f32;
let max_inner_blocks = block.circuits_params.max_inner_blocks;
let max_txs = block.circuits_params.max_txs;

Expand All @@ -1625,8 +1626,10 @@ impl<F: Field> SubCircuit<F> for PiCircuit<F> {
+ N_BYTES_ACCOUNT_ADDRESS
+ N_BYTES_WORD;

// the number of rows is independent of block
(num_rows, num_rows)
(
(tx_usage * block.circuits_params.max_vertical_circuit_rows as f32).ceil() as usize,
num_rows,
)
}

/// Compute the public inputs for this circuit.
Expand Down
9 changes: 5 additions & 4 deletions zkevm-circuits/src/tx_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2722,13 +2722,14 @@ impl<F: Field> SubCircuit<F> for TxCircuit<F> {

/// Return the minimum number of rows required to prove the block
fn min_num_rows_block(block: &witness::Block<F>) -> (usize, usize) {
let tx_usage = block.txs.len() as f32 / block.circuits_params.max_txs as f32;
let calldata_usage = block.txs.iter().map(|tx| tx.call_data.len()).sum::<usize>() as f32
// Since each call data byte at least takes one row in RLP circuit.
// For L2 tx, each call data byte takes two row in RLP circuit.
assert!(block.circuits_params.max_calldata < block.circuits_params.max_rlp_rows);
let tx_usage = (block.txs.iter().map(|tx| tx.call_data.len()).sum::<usize>()) as f32
/ block.circuits_params.max_calldata as f32;

(
(tx_usage.max(calldata_usage) * block.circuits_params.max_vertical_circuit_rows as f32)
.ceil() as usize,
(tx_usage * block.circuits_params.max_vertical_circuit_rows as f32).ceil() as usize,
Self::min_num_rows(
block.circuits_params.max_txs,
block.circuits_params.max_calldata,
Expand Down