Skip to content

Commit

Permalink
chore: create unknown opcodes as unchecked (#88)
Browse files Browse the repository at this point in the history
this could be an opcode that is manually added to the evm
  • Loading branch information
mattsse authored Apr 7, 2024
1 parent e97596f commit 5baa6b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
15 changes: 5 additions & 10 deletions src/tracing/js/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,16 +387,11 @@ impl OpObj {
let to_string = FunctionObjectBuilder::new(
context.realm(),
NativeFunction::from_copy_closure(move |_this, _args, _ctx| {
let op = OpCode::new(value)
.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::new(invalid_opcode)
})
.expect("is valid opcode;");
let op = OpCode::new(value).unwrap_or_else(|| {
// unknown opcode, this could be an additional opcode that is not part of the
// enum
unsafe { OpCode::new_unchecked(value) }
});
let s = op.to_string();
Ok(JsValue::from(js_string!(s)))
}),
Expand Down
13 changes: 4 additions & 9 deletions src/tracing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,10 @@ impl TracingInspector {
None
};

let op = OpCode::new(interp.current_opcode())
.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::new(invalid_opcode)
})
.expect("is valid opcode;");
let op = OpCode::new(interp.current_opcode()).unwrap_or_else(|| {
// unknown opcode, this could be an additional opcode that is not part of the enum
unsafe { OpCode::new_unchecked(interp.current_opcode()) }
});

trace.trace.steps.push(CallTraceStep {
depth: context.journaled_state.depth(),
Expand Down

0 comments on commit 5baa6b3

Please sign in to comment.