fix: dont panic on invalid opcode (#3255)

This commit is contained in:
Matthias Seitz
2023-06-20 01:22:18 +02:00
committed by GitHub
parent 8dfdf658a1
commit 729d4ad30f

View File

@ -212,11 +212,20 @@ impl TracingInspector {
let stack =
self.config.record_stack_snapshots.then(|| interp.stack.clone()).unwrap_or_default();
let op = OpCode::try_from_u8(interp.contract.bytecode.bytecode()[pc])
.or_else(|| {
// if the opcode is invalid, we'll use the invalid opcode to represent it because
// this is invoked before the opcode is executed, the evm will eventually return a
// `Halt` with invalid/unknown opcode as result
let invalid_opcode = 0xfe;
OpCode::try_from_u8(invalid_opcode)
})
.expect("is valid opcode;");
trace.trace.steps.push(CallTraceStep {
depth: data.journaled_state.depth(),
pc,
op: OpCode::try_from_u8(interp.contract.bytecode.bytecode()[pc])
.expect("is valid opcode;"),
op,
contract: interp.contract.address,
stack,
memory,