zkevm-circuits icon indicating copy to clipboard operation
zkevm-circuits copied to clipboard

Unify parametrization of circuit sizes

Open ed255 opened this issue 2 years ago • 0 comments

See https://github.com/privacy-scaling-explorations/zkevm-circuits/issues/650#issuecomment-1319441372

Our current circuits can be parametrized with a maximum number of operations supported:

  • TxCircuit: max number of txs
  • CopyCircuit: max number of copied bytes
  • StateCircuit: max number of rw entries
  • ExpCircuit: ?
  • EvmCircuit: max number of rows (Evm Steps take a dynamic number of rows)
  • MPTCircuit: max number of MPT proofs?
  • PiCircuit: max number of txs + max calldata bytes
  • BytecodeCircuit: max number of bytecode bytes

Sometimes these numbers don't correspond to the number of rows enabled (because an operation takes several rows)

For unit tests we'd like the number to be chosen at runtime based on the test input.

  • For this, the bytecode circuit is using Option<usize> to specify the number of rows, and when set to None, it calculates the number of rows based on the input
  • For other circuits it's difficult to decide this value based on the input because there are dependencies (Evm depends on max_txs and max_rws), but maybe it can be done

Tasks:

  • Explore if we could set all the parameters as Option<usize> so that they can be optionally set, or calculated based on inputs
  • Unify the meaning of the size parameter
    • I think what makes more sense is setting the number of operations that the circuit supports. Note that a check should be done to make sure that the given number is possible to achieve based on the k value and the unusable_rows.
  • Put all these parameters in CircuitParams, so that they can all be defined in a single place.

ed255 avatar Nov 30 '22 16:11 ed255