From 3ecf53095676cb55c132c84ab1efe2ad2ebea3d9 Mon Sep 17 00:00:00 2001 From: Jacqueline Nabaglo Date: Sun, 4 Jun 2023 10:05:28 -0700 Subject: [PATCH] Minor bugfixes --- evm/src/cpu/kernel/asm/core/exception.asm | 15 ++++++++++++--- evm/src/witness/gas.rs | 1 - evm/src/witness/transition.rs | 1 - 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/evm/src/cpu/kernel/asm/core/exception.asm b/evm/src/cpu/kernel/asm/core/exception.asm index 0fefe29c..7d5c7d9c 100644 --- a/evm/src/cpu/kernel/asm/core/exception.asm +++ b/evm/src/cpu/kernel/asm/core/exception.asm @@ -96,11 +96,20 @@ global exc_invalid_jumpi_destination: global invalid_jump_jumpi_destination_common: + // We have a jump destination on the stack. We want to `PANIC` if it is valid, and jump to + // `fault_exception` if it is not. An address is a valid jump destination if it points to a + // `JUMPDEST` instruction. In practice, since in this implementation memory addresses are + // limited to 32 bits, we check two things: + // 1. the address is no more than 32 bits long, and + // 2. it points to a `JUMPDEST` instruction. // stack: jump_dest + DUP1 + %shr_const(32) + %jumpi(fault_exception) // This keeps one copy of jump_dest on the stack, but that's fine. + // jump_dest is a valid address; check if it points to a `JUMP_DEST`. %mload_current(@SEGMENT_JUMPDEST_BITS) // stack: is_valid_jumpdest - // if valid, then the trap should never have been entered - %jumpi(panic) + %jumpi(panic) // Trap should never have been entered. %jump(fault_exception) @@ -164,7 +173,7 @@ min_stack_len_for_opcode: BYTES 2 // 0x17, OR BYTES 2 // 0x18, XOR BYTES 1 // 0x19, NOT - BYTES 2 // 0x1a, BYTES + BYTES 2 // 0x1a, BYTE BYTES 2 // 0x1b, SHL BYTES 2 // 0x1c, SHR BYTES 2 // 0x1d, SAR diff --git a/evm/src/witness/gas.rs b/evm/src/witness/gas.rs index e03ab8a1..0acb04e4 100644 --- a/evm/src/witness/gas.rs +++ b/evm/src/witness/gas.rs @@ -14,7 +14,6 @@ pub(crate) fn gas_to_charge(op: Operation) -> u64 { match op { Iszero => G_VERYLOW, Not => G_VERYLOW, - Byte => G_VERYLOW, Syscall(_, _, _) => KERNEL_ONLY_INSTR, Eq => G_VERYLOW, BinaryLogic(_) => G_VERYLOW, diff --git a/evm/src/witness/transition.rs b/evm/src/witness/transition.rs index df522374..44e6ebdd 100644 --- a/evm/src/witness/transition.rs +++ b/evm/src/witness/transition.rs @@ -157,7 +157,6 @@ fn fill_op_flag(op: Operation, row: &mut CpuColumnsView) { Operation::Swap(_) => &mut flags.swap, Operation::Iszero => &mut flags.iszero, Operation::Not => &mut flags.not, - Operation::Byte => &mut flags.byte, Operation::Syscall(_, _, _) => &mut flags.syscall, Operation::Eq => &mut flags.eq, Operation::BinaryLogic(logic::Op::And) => &mut flags.and,