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

Commit

Permalink
add test to address the execution state height concern
Browse files Browse the repository at this point in the history
  • Loading branch information
ChihChengLiang committed Jan 31, 2024
1 parent 949c228 commit d72656a
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions zkevm-circuits/src/evm_circuit/param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,35 @@ pub(crate) const N_BYTES_WITHDRAWAL: usize = N_BYTES_U64 //id
+ N_BYTES_U64; // amount

lazy_static::lazy_static! {
static ref INVALID_TX_CONFIG: FeatureConfig = FeatureConfig {
invalid_tx: true,
..Default::default()
};
// Step slot height in evm circuit
pub(crate) static ref EXECUTION_STATE_HEIGHT_MAP : HashMap<ExecutionState, usize> = get_step_height_map();
// We enable the invalid_tx feature to get invalid tx's ExecutionState height
// We garentee the heights of other ExecutionStates remains unchanged in the following test
pub(crate) static ref EXECUTION_STATE_HEIGHT_MAP : HashMap<ExecutionState, usize> = get_step_height_map(*INVALID_TX_CONFIG);
}
fn get_step_height_map() -> HashMap<ExecutionState, usize> {
fn get_step_height_map(feature_config: FeatureConfig) -> HashMap<ExecutionState, usize> {
let mut meta = ConstraintSystem::<Fr>::default();
let circuit = EvmCircuit::configure_with_params(
&mut meta,
FeatureConfig {
// Enable invalid_tx to get ExecutionState height
invalid_tx: true,
..Default::default()
},
);

let circuit = EvmCircuit::configure_with_params(&mut meta, feature_config);
circuit.0.execution.height_map
}
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_get_step_height_map() {
let mainnet_config = FeatureConfig::default();
let map_mainnet = get_step_height_map(mainnet_config);

let map_invalid_tx = {
let mut map = EXECUTION_STATE_HEIGHT_MAP.clone();
map.remove(&ExecutionState::InvalidTx);
map
};
// We show that the invalid tx feature affects none of the other execution state heights
assert_eq!(map_invalid_tx, map_mainnet);
}
}

0 comments on commit d72656a

Please sign in to comment.