Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
super circuit keccak dev_load
Browse files Browse the repository at this point in the history
  • Loading branch information
hero78119 committed Apr 6, 2023
1 parent ddcfef7 commit 9ed1957
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions zkevm-circuits/src/pi_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl PublicData {
.collect_vec()
}

fn get_pi_bytes(&self, max_txs: usize, max_calldata: usize) -> Vec<u8> {
pub fn get_pi_bytes(&self, max_txs: usize, max_calldata: usize) -> Vec<u8> {
// Assign block table
let block_values = self.get_block_table_values();
let result = iter::empty()
Expand Down Expand Up @@ -2260,6 +2260,8 @@ mod pi_circuit_test {

#[test]
fn test_1tx_1maxtx() {
const MAX_TXS: usize = 1;
const MAX_CALLDATA: usize = 32;
let mut rng = ChaChaRng::seed_from_u64(2);
let wallet_a = LocalWallet::new(&mut rng).with_chain_id(MOCK_CHAIN_ID.as_u64());

Expand Down Expand Up @@ -2296,6 +2298,8 @@ mod pi_circuit_test {
let mut builder = BlockData::new_from_geth_data_with_params(
block.clone(),
CircuitsParams {
max_txs: MAX_TXS,
max_calldata: MAX_CALLDATA,
max_rws: 1 << (degree - 1),
..Default::default()
},
Expand All @@ -2311,7 +2315,7 @@ mod pi_circuit_test {
builder.block.eth_block = block.eth_block.clone();
let block = block_convert(&builder.block, &builder.code_db).unwrap();
// MAX_TXS, MAX_TXS align with `CircuitsParams`
let circuit = PiTestCircuit::<Fr, 1, 256>::new_from_block(&block);
let circuit = PiTestCircuit::<Fr, MAX_TXS, MAX_CALLDATA>::new_from_block(&block);
let public_inputs = circuit.0.instance();

let prover = match MockProver::run(degree, &circuit, public_inputs) {
Expand Down
12 changes: 11 additions & 1 deletion zkevm-circuits/src/super_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ use std::array;
pub struct SuperCircuitConfig<F: Field> {
block_table: BlockTable,
mpt_table: MptTable,
keccak_table: KeccakTable,
evm_circuit: EvmCircuitConfig<F>,
state_circuit: StateCircuitConfig<F>,
tx_circuit: TxCircuitConfig<F>,
Expand Down Expand Up @@ -202,14 +203,15 @@ impl<F: Field> SubCircuitConfig<F> for SuperCircuitConfig<F> {
bytecode_table,
block_table: block_table.clone(),
copy_table,
keccak_table,
keccak_table: keccak_table.clone(),
exp_table,
},
);

Self {
block_table,
mpt_table,
keccak_table,
evm_circuit,
state_circuit,
copy_circuit,
Expand Down Expand Up @@ -399,6 +401,14 @@ impl<F: Field, const MAX_TXS: usize, const MAX_CALLDATA: usize, const MOCK_RANDO
Value::known(block.randomness),
)?;

let rpi_bytes = self.pi_circuit.public_data.get_pi_bytes(
block.circuits_params.max_txs,
block.circuits_params.max_calldata,
);
config
.keccak_table
.dev_load(&mut layouter, vec![&rpi_bytes], &challenges)?;

self.synthesize_sub(&config, &challenges, &mut layouter)
}
}
Expand Down

0 comments on commit 9ed1957

Please sign in to comment.