Skip to content

Commit

Permalink
add "onephase" feature to disable multi phase behavior. Debug only
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc committed Dec 29, 2022
1 parent c7771ad commit 7587594
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions zkevm-circuits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ pretty_assertions = "1.0.0"
[features]
default = []
test = ["ethers-signers", "mock"]
onephase = []
30 changes: 15 additions & 15 deletions zkevm-circuits/src/keccak_circuit/keccak_packed_multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use halo2_proofs::{
plonk::{Advice, Circuit, Column, ConstraintSystem, Error, Expression, Fixed, TableColumn},
poly::Rotation,
};
use log::{debug, info};
use log::{debug, info, trace};
use std::{env::var, marker::PhantomData, vec};

const MAX_DEGREE: usize = 9;
Expand Down Expand Up @@ -1584,21 +1584,21 @@ impl<F: Field> SubCircuitConfig<F> for KeccakCircuitConfig<F> {
cb.gate(1.expr())
});

info!("Degree: {}", meta.degree());
info!("Minimum rows: {}", meta.minimum_rows());
info!("Total Lookups: {}", total_lookup_counter);
info!("Total Columns: {}", cell_manager.get_width());
info!("num unused cells: {}", cell_manager.get_num_unused_cells());
info!("part_size absorb: {}", get_num_bits_per_absorb_lookup());
info!("part_size theta: {}", get_num_bits_per_theta_c_lookup());
info!(
debug!("Degree: {}", meta.degree());
debug!("Minimum rows: {}", meta.minimum_rows());
debug!("Total Lookups: {}", total_lookup_counter);
debug!("Total Columns: {}", cell_manager.get_width());
debug!("num unused cells: {}", cell_manager.get_num_unused_cells());
debug!("part_size absorb: {}", get_num_bits_per_absorb_lookup());
debug!("part_size theta: {}", get_num_bits_per_theta_c_lookup());
debug!(
"part_size theta c: {}",
get_num_bits_per_lookup(THETA_C_LOOKUP_RANGE)
);
info!("part_size theta t: {}", get_num_bits_per_lookup(4));
info!("part_size rho/pi: {}", get_num_bits_per_rho_pi_lookup());
info!("part_size chi base: {}", get_num_bits_per_base_chi_lookup());
info!(
debug!("part_size theta t: {}", get_num_bits_per_lookup(4));
debug!("part_size rho/pi: {}", get_num_bits_per_rho_pi_lookup());
debug!("part_size chi base: {}", get_num_bits_per_base_chi_lookup());
debug!(
"uniform part sizes: {:?}",
target_part_sizes(get_num_bits_per_theta_c_lookup())
);
Expand Down Expand Up @@ -2074,8 +2074,8 @@ fn keccak<F: Field>(rows: &mut Vec<KeccakRow<F>>, bytes: &[u8], challenges: Chal
.to_vec()
})
.collect::<Vec<_>>();
debug!("hash: {:x?}", &(hash_bytes[0..4].concat()));
debug!("data rlc: {:x?}", data_rlc);
trace!("hash: {:x?}", &(hash_bytes[0..4].concat()));
trace!("data rlc: {:x?}", data_rlc);
}

/// ...
Expand Down
5 changes: 5 additions & 0 deletions zkevm-circuits/src/rlp_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ use gadgets::{
comparator::{ComparatorChip, ComparatorConfig, ComparatorInstruction},
less_than::{LtChip, LtConfig, LtInstruction},
};

#[cfg(feature = "onephase")]
use halo2_proofs::plonk::FirstPhase as SecondPhase;
#[cfg(not(feature = "onephase"))]
use halo2_proofs::plonk::SecondPhase;

use halo2_proofs::{
circuit::{Layouter, Region, SimpleFloorPlanner, Value},
plonk::{Advice, Circuit, Column, ConstraintSystem, Error, Expression, Fixed, VirtualCells},
Expand Down
7 changes: 5 additions & 2 deletions zkevm-circuits/src/super_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,17 @@ impl<F: Field, const MAX_TXS: usize, const MAX_CALLDATA: usize, const MAX_RWS: u

fn configure(meta: &mut ConstraintSystem<F>) -> Self::Config {
let log_circuit_info = |meta: &mut ConstraintSystem<F>, tag: &'static str| {
log::debug!("circuit info after {}: num_fixed_columns {}, num_advice_columns {}, num_instance_columns {}, num_selectors {}, num_permutation_columns {}, degree {}",
log::debug!("circuit info after {}: num_fixed_columns {}, num_advice_columns {}, num_instance_columns {}, num_selectors {}, num_permutation_columns {}, degree {}, num_challenges {}, max_phase {}",
tag,
meta.num_fixed_columns,
meta.num_advice_columns,
meta.num_instance_columns,
meta.num_selectors,
meta.permutation.columns.len(),
meta.degree());
meta.degree(),
meta.num_challenges(),
meta.max_phase()
);
};

let tx_table = TxTable::construct(meta);
Expand Down
9 changes: 8 additions & 1 deletion zkevm-circuits/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ use core::iter::once;
use eth_types::{Field, ToLittleEndian, ToScalar, Word, U256};
use gadgets::binary_number::{BinaryNumberChip, BinaryNumberConfig};
use gadgets::util::{split_u256, split_u256_limb64};
use halo2_proofs::plonk::{Any, Expression, Fixed, VirtualCells};
use halo2_proofs::{
arithmetic::FieldExt,
circuit::{Region, Value},
plonk::{Advice, Column, ConstraintSystem, Error},
};
use halo2_proofs::{circuit::Layouter, plonk::*, poly::Rotation};
use halo2_proofs::{circuit::Layouter, poly::Rotation};

#[cfg(feature = "onephase")]
use halo2_proofs::plonk::FirstPhase as SecondPhase;
#[cfg(not(feature = "onephase"))]
use halo2_proofs::plonk::SecondPhase;

use itertools::Itertools;
use keccak256::plain::Keccak;
use std::array;
Expand Down

0 comments on commit 7587594

Please sign in to comment.