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

[word lo/hi] pi circuit replace rand/rlc by keccak hash #1345

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
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 @@ -109,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