Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.
Merged
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
8 changes: 7 additions & 1 deletion zkevm-circuits/src/evm_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,26 @@ pub(crate) mod cached {
use halo2_proofs::halo2curves::bn256::Fr;
use lazy_static::lazy_static;

/// Cache
struct Cache {
cs: ConstraintSystem<Fr>,
config: (EvmCircuitConfig<Fr>, 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::<Fr>::default();
let config = EvmCircuit::<Fr>::configure(&mut meta);
Cache { cs: meta, config }
};
}

/// 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<Fr>);

impl Circuit<Fr> for EvmCircuitCached {
Expand Down