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
  • Loading branch information
Wu Sung-Ming authored and hero78119 committed Apr 18, 2023
1 parent 3aa36a2 commit 6314f6a
Show file tree
Hide file tree
Showing 9 changed files with 1,364 additions and 718 deletions.
7 changes: 0 additions & 7 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,7 +19,6 @@ mod tests {
},
};
use rand::SeedableRng;
use rand_chacha::ChaCha20Rng;
use rand_xorshift::XorShiftRng;
use std::env::var;
use zkevm_circuits::{
Expand All @@ -45,15 +43,10 @@ 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, MAX_CALLDATA>();
let circuit = PiTestCircuit::<Fr, MAX_TXS, MAX_CALLDATA>(PiCircuit::<Fr>::new(
MAX_TXS,
MAX_CALLDATA,
randomness,
rand_rpi,
public_data,
));
let public_inputs = circuit.0.instance();
Expand Down
43 changes: 43 additions & 0 deletions zkevm-circuits/src/evm_circuit/param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,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_WORD;
pub(crate) const N_BYTES_TX_GAS_LIMIT: usize = N_BYTES_WORD; // 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 6314f6a

Please sign in to comment.