Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.
4 changes: 1 addition & 3 deletions bus-mapping/src/evm/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,6 @@ pub fn gen_associated_ops(
state: &mut CircuitInputStateRef,
geth_steps: &[GethExecStep],
) -> Result<Vec<ExecStep>, Error> {
let fn_gen_associated_ops = fn_gen_associated_ops(opcode_id);

// if no errors, continue as normal
let memory_enabled = !geth_steps.iter().all(|s| s.memory.is_empty());
if memory_enabled {
let check_level = if *CHECK_MEM_STRICT { 2 } else { 0 }; // 0: no check, 1: check and log error and fix, 2: check and assert_eq
Expand Down Expand Up @@ -356,6 +353,7 @@ pub fn gen_associated_ops(
}
}
// if no errors, continue as normal
let fn_gen_associated_ops = fn_gen_associated_ops(opcode_id);
fn_gen_associated_ops(state, geth_steps)
}

Expand Down
9 changes: 2 additions & 7 deletions bus-mapping/src/evm/opcodes/error_invalid_opcode.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::circuit_input_builder::{CircuitInputStateRef, ExecStep};
use crate::error::ExecError;
use crate::evm::Opcode;
use crate::Error;
use eth_types::GethExecStep;
Expand All @@ -13,13 +14,7 @@ impl Opcode for InvalidOpcode {
) -> Result<Vec<ExecStep>, Error> {
let geth_step = &geth_steps[0];
let mut exec_step = state.new_step(geth_step)?;

let next_step = if geth_steps.len() > 1 {
Some(&geth_steps[1])
} else {
None
};
exec_step.error = state.get_step_err(geth_step, next_step).unwrap();
exec_step.error = Some(ExecError::InvalidOpcode);

state.gen_restore_context_ops(&mut exec_step, geth_steps)?;
state.handle_return(geth_step)?;
Expand Down
10 changes: 2 additions & 8 deletions zkevm-circuits/src/evm_circuit/execution/error_invalid_opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,9 @@ mod test {
use crate::test_util::CircuitTestBuilder;
use eth_types::bytecode::Bytecode;
use eth_types::{bytecode, ToWord, Word};
use itertools::Itertools;
use lazy_static::lazy_static;
use mock::TestContext;

const TESTING_CALL_DATA_PAIRS: [(usize, usize); 2] = [(0x20, 0x00), (0x1010, 0xff)];

lazy_static! {
static ref TESTING_INVALID_CODES: [Vec<u8>; 6] = [
// Single invalid opcode
Expand All @@ -156,11 +153,8 @@ mod test {

#[test]
fn invalid_opcode_internal() {
for ((call_data_offset, call_data_length), invalid_opcode) in TESTING_CALL_DATA_PAIRS
.iter()
.cartesian_product(TESTING_INVALID_CODES.iter())
{
test_internal_ok(*call_data_offset, *call_data_length, invalid_opcode);
for invalid_code in TESTING_INVALID_CODES.iter() {
test_internal_ok(0x20, 0x00, invalid_code);
}
}

Expand Down