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

Commit

Permalink
define column and constraints
Browse files Browse the repository at this point in the history
lookup constraints

pi circuit block table assignment

pi circuit tx table assignment

new way to get public input

circuit assignment ready

pi circuit pass compile

fix cell un-assignment error

format code and bug fix

fixed copy constraints error

fix existing error during unittest

code cosmetics

fix error due to challenge usage

fix lints and code cosmetics

pi circuit more test with real block data

super circuit keccak dev_load

rewrite gate to clearly the branch

rewrite circuit in bottom up style and fix all constriants

refactor timing for pi circuit keccak table load

nonce/gas_limit to u64

code cosmetics

increase keccak row to cover new pi input circuit

skip signdata generation on non pi circuit test

set max keccak row 35000 to cover new pi input circuit

fix pi bytes endian in witness block

fix fmt

migrate to word lo/hi
  • Loading branch information
hero78119 committed Jun 14, 2023
1 parent fab8e2e commit 1f41365
Show file tree
Hide file tree
Showing 15 changed files with 1,446 additions and 928 deletions.
2 changes: 2 additions & 0 deletions bus-mapping/src/circuit_input_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ impl<'a> CircuitInputBuilder {
let geth_trace = &geth_traces[tx_index];
self.handle_tx(tx, geth_trace, tx_index + 1 == eth_block.transactions.len())?;
}
// set eth_block
self.block.eth_block = eth_block.clone();
self.set_value_ops_call_context_rwc_eor();
self.set_end_block();
Ok(())
Expand Down
13 changes: 2 additions & 11 deletions circuit-benchmarks/src/pi_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ mod tests {
use ark_std::{end_timer, start_timer};
use eth_types::Word;
use halo2_proofs::{
arithmetic::Field,
halo2curves::bn256::{Bn256, Fr, G1Affine},
plonk::{create_proof, keygen_pk, keygen_vk, verify_proof},
poly::{
Expand All @@ -20,13 +19,9 @@ mod tests {
},
};
use rand::SeedableRng;
use rand_chacha::ChaCha20Rng;
use rand_xorshift::XorShiftRng;
use std::env::var;
use zkevm_circuits::{
pi_circuit::{PiCircuit, PublicData},
util::SubCircuit,
};
use zkevm_circuits::{instance::PublicData, pi_circuit::PiCircuit, util::SubCircuit};

#[cfg_attr(not(feature = "benches"), ignore)]
#[test]
Expand All @@ -45,12 +40,8 @@ mod tests {
.parse()
.expect("Cannot parse DEGREE env var as u32");

let mut rng = ChaCha20Rng::seed_from_u64(2);
let randomness = Fr::random(&mut rng);
let rand_rpi = Fr::random(&mut rng);
let public_data = generate_publicdata(MAX_TXS);
let circuit =
PiCircuit::<Fr>::new(MAX_TXS, MAX_CALLDATA, randomness, rand_rpi, public_data);
let circuit = PiCircuit::<Fr>::new(MAX_TXS, MAX_CALLDATA, public_data);
let public_inputs = circuit.instance();
let instance: Vec<&[Fr]> = public_inputs.iter().map(|input| &input[..]).collect();
let instances = &[&instance[..]];
Expand Down
1 change: 1 addition & 0 deletions integration-tests/run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh
set -e
set -o xtrace

ARG_DEFAULT_SUDO=
ARG_DEFAULT_STEPS="setup gendata tests cleanup"
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/integration_test_circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const MAX_EVM_ROWS: usize = 10000;
/// MAX_EXP_STEPS
const MAX_EXP_STEPS: usize = 1000;

const MAX_KECCAK_ROWS: usize = 15000;
const MAX_KECCAK_ROWS: usize = 38000;

const CIRCUITS_PARAMS: CircuitsParams = CircuitsParams {
max_rws: MAX_RWS,
Expand Down
46 changes: 46 additions & 0 deletions zkevm-circuits/src/evm_circuit/param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ pub(crate) const MAX_N_BYTES_INTEGER: usize = 31;
// Number of bytes an EVM word has.
pub(crate) const N_BYTES_WORD: usize = 32;

// Number of bytes an half EVM word has.
pub(crate) const N_BYTES_HALF_WORD: usize = 16;

// Number of bytes an u64 has.
pub(crate) const N_BYTES_U64: usize = 8;

Expand All @@ -106,6 +109,49 @@ pub(crate) const N_BYTES_GAS: usize = N_BYTES_U64;
// Number of bytes that will be used for call data's size.
pub(crate) const N_BYTES_CALLDATASIZE: usize = N_BYTES_U64;

// Number of bytes that will be used for block values
pub(crate) const N_BYTES_COINBASE: usize = N_BYTES_ACCOUNT_ADDRESS;
pub(crate) const N_BYTES_GAS_LIMIT: usize = N_BYTES_U64;
pub(crate) const N_BYTES_NUMBER: usize = N_BYTES_U64;
pub(crate) const N_BYTES_TIMESTAMP: usize = N_BYTES_U64;
pub(crate) const N_BYTES_DIFFICULTY: usize = N_BYTES_WORD;
pub(crate) const N_BYTES_BASE_FEE: usize = N_BYTES_WORD;
pub(crate) const N_BYTES_CHAIN_ID: usize = N_BYTES_U64;
pub(crate) const N_BYTES_PREV_HASH: usize = 256 * N_BYTES_WORD;

pub(crate) const N_BYTES_BLOCK: usize = N_BYTES_COINBASE
+ N_BYTES_GAS_LIMIT
+ N_BYTES_NUMBER
+ N_BYTES_TIMESTAMP
+ N_BYTES_DIFFICULTY
+ N_BYTES_BASE_FEE
+ N_BYTES_CHAIN_ID
+ N_BYTES_PREV_HASH;

pub(crate) const N_BYTES_EXTRA_VALUE: usize = N_BYTES_WORD + N_BYTES_WORD;

// Number of bytes that will be used for tx values
pub(crate) const N_BYTES_TX_NONCE: usize = N_BYTES_U64;
pub(crate) const N_BYTES_TX_GAS_LIMIT: usize = N_BYTES_U64; // gas limit type is U256, different with gas U64
pub(crate) const N_BYTES_TX_GASPRICE: usize = N_BYTES_WORD;
pub(crate) const N_BYTES_TX_FROM: usize = N_BYTES_ACCOUNT_ADDRESS;
pub(crate) const N_BYTES_TX_TO: usize = N_BYTES_ACCOUNT_ADDRESS;
pub(crate) const N_BYTES_TX_IS_CREATE: usize = N_BYTES_U64;
pub(crate) const N_BYTES_TX_VALUE: usize = N_BYTES_WORD;
pub(crate) const N_BYTES_TX_CALLDATA_LEN: usize = N_BYTES_CALLDATASIZE;
pub(crate) const N_BYTES_TX_CALLDATA_GASCOST: usize = N_BYTES_U64;
pub(crate) const N_BYTES_TX_TXSIGNHASH: usize = N_BYTES_WORD;
pub(crate) const N_BYTES_TX: usize = N_BYTES_TX_NONCE
+ N_BYTES_TX_GAS_LIMIT
+ N_BYTES_TX_GASPRICE
+ N_BYTES_TX_FROM
+ N_BYTES_TX_TO
+ N_BYTES_TX_IS_CREATE
+ N_BYTES_TX_VALUE
+ N_BYTES_TX_CALLDATA_LEN
+ N_BYTES_TX_CALLDATA_GASCOST
+ N_BYTES_TX_TXSIGNHASH;

lazy_static::lazy_static! {
// Step slot height in evm circuit
pub(crate) static ref EXECUTION_STATE_HEIGHT_MAP : HashMap<ExecutionState, usize> = get_step_height_map();
Expand Down
Loading

0 comments on commit 1f41365

Please sign in to comment.