From 915e8121dea8a565cc4acd6e3287005658f81036 Mon Sep 17 00:00:00 2001 From: Eduard S Date: Thu, 23 Feb 2023 15:15:16 +0100 Subject: [PATCH] docs: add documentation on evm_circuit::cached --- zkevm-circuits/src/evm_circuit.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zkevm-circuits/src/evm_circuit.rs b/zkevm-circuits/src/evm_circuit.rs index 6d6040d668..51e6e4eb2d 100644 --- a/zkevm-circuits/src/evm_circuit.rs +++ b/zkevm-circuits/src/evm_circuit.rs @@ -291,13 +291,14 @@ pub(crate) mod cached { use halo2_proofs::halo2curves::bn256::Fr; use lazy_static::lazy_static; - /// Cache struct Cache { cs: ConstraintSystem, config: (EvmCircuitConfig, Challenges), } lazy_static! { + /// Cached values of the ConstraintSystem after the EVM Circuit configuration and the EVM + /// Circuit configuration. These values are calculated just once. static ref CACHE: Cache = { let mut meta = ConstraintSystem::::default(); let config = EvmCircuit::::configure(&mut meta); @@ -305,6 +306,11 @@ pub(crate) mod cached { }; } + /// Wrapper over the EvmCircuit that behaves the same way and also + /// implements the halo2 Circuit trait, but reuses the precalculated + /// results of the configuration which are cached in the public variable + /// `CACHE`. This wrapper is useful for testing because it allows running + /// many unit tests while reusing the configuration step of the circuit. pub struct EvmCircuitCached(EvmCircuit); impl Circuit for EvmCircuitCached {