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

Commit

Permalink
fix: opcode state print
Browse files Browse the repository at this point in the history
  • Loading branch information
johntaiko committed Aug 28, 2023
1 parent 4fdac73 commit b050ba5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
4 changes: 3 additions & 1 deletion eth-types/src/evm_types/opcode_ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ impl OpcodeId {
OpcodeId::MSIZE => (1, 1024),
OpcodeId::GAS => (1, 1024),
OpcodeId::JUMPDEST => (0, 1024),
OpcodeId::PUSH0 => (1, 1024),
OpcodeId::PUSH1 => (1, 1024),
OpcodeId::PUSH2 => (1, 1024),
OpcodeId::PUSH3 => (1, 1024),
Expand Down Expand Up @@ -945,6 +946,7 @@ impl From<u8> for OpcodeId {
0x58u8 => OpcodeId::PC,
0x59u8 => OpcodeId::MSIZE,
0x5bu8 => OpcodeId::JUMPDEST,
0x5fu8 => OpcodeId::PUSH0,
0x60u8 => OpcodeId::PUSH1,
0x61u8 => OpcodeId::PUSH2,
0x62u8 => OpcodeId::PUSH3,
Expand Down Expand Up @@ -1098,6 +1100,7 @@ impl FromStr for OpcodeId {
"PC" => OpcodeId::PC,
"MSIZE" => OpcodeId::MSIZE,
"JUMPDEST" => OpcodeId::JUMPDEST,
"PUSH0" => OpcodeId::PUSH0,
"PUSH1" => OpcodeId::PUSH1,
"PUSH2" => OpcodeId::PUSH2,
"PUSH3" => OpcodeId::PUSH3,
Expand Down Expand Up @@ -1165,7 +1168,6 @@ impl FromStr for OpcodeId {
"RETURN" => OpcodeId::RETURN,
"REVERT" => OpcodeId::REVERT,
"INVALID" => OpcodeId::INVALID(0xfe),
"PUSH0" => OpcodeId::INVALID(0x5f),
"SHA3" | "KECCAK256" => OpcodeId::SHA3,
"ADDRESS" => OpcodeId::ADDRESS,
"BALANCE" => OpcodeId::BALANCE,
Expand Down
4 changes: 1 addition & 3 deletions zkevm-circuits/src/bin/stats/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,10 @@ pub(crate) fn print_circuit_stats_by_states(
// circuit input builder Block, the current execution state, and the step index in circuit
// input builder tx.
fn_height: impl Fn(&circuit_input_builder::Block, ExecutionState, usize) -> usize,
// in taiko context
is_taiko: bool,
) {
let mut implemented_states = Vec::new();
for state in ExecutionState::iter() {
let height = state.get_step_height_option(is_taiko);
let height = state.get_step_height_option(false);
if height.is_some() {
implemented_states.push(state);
}
Expand Down
20 changes: 7 additions & 13 deletions zkevm-circuits/src/bin/stats/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,16 @@ fn main() {
let args: Vec<String> = env::args().collect();

match &args[1][..] {
"evm" => evm_states_stats(false),
"taiko_evm" => evm_states_stats(true),
"state" => state_states_stats(false),
"tako_state" => state_states_stats(true),
"copy" => copy_states_stats(false),
"taiko_copy" => copy_states_stats(true),
"evm" => evm_states_stats(),
"state" => state_states_stats(),
"copy" => copy_states_stats(),
"exec" => get_exec_steps_occupancy(),
&_ => unreachable!("Unsupported arg"),
}
}

/// Prints the stats of EVM circuit per execution state.
fn evm_states_stats(is_taiko: bool) {
fn evm_states_stats() {
print_circuit_stats_by_states(
|state| {
// TODO: Enable CREATE/CREATE2 once they are supported
Expand Down Expand Up @@ -63,13 +60,12 @@ fn evm_states_stats(is_taiko: bool) {
PUSH2(0x50)
},
},
|_, state, _| state.get_step_height_option(is_taiko).unwrap(),
is_taiko,
|_, state, _| state.get_step_height_option(false).unwrap(),
);
}

/// Prints the stats of State circuit per execution state.
fn state_states_stats(is_taiko: bool) {
fn state_states_stats() {
print_circuit_stats_by_states(
|state| {
// TODO: Enable CREATE/CREATE2 once they are supported
Expand All @@ -87,12 +83,11 @@ fn state_states_stats(is_taiko: bool) {
let step_next = &block.txs[0].steps()[step_index + 1];
step_next.rwc.0 - step.rwc.0
},
is_taiko,
);
}

/// Prints the stats of Copy circuit per execution state.
fn copy_states_stats(is_taiko: bool) {
fn copy_states_stats() {
print_circuit_stats_by_states(
|state| {
// TODO: Enable CREATE/CREATE2 once they are supported
Expand All @@ -115,7 +110,6 @@ fn copy_states_stats(is_taiko: bool) {
.map(|c| c.bytes.len() * 2)
.sum::<usize>()
},
is_taiko,
);
}

Expand Down

0 comments on commit b050ba5

Please sign in to comment.