Skip to content

Commit

Permalink
fix: ignore unknown opcode in stack traces (#693)
Browse files Browse the repository at this point in the history
* fix: ignore unknown opcode in stack traces

* Add changeset
  • Loading branch information
agostbiro authored Oct 2, 2024
1 parent ec998cd commit 7047e6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wicked-tomatoes-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/edr": patch
---

Fixed panic from unknown opcode in stack traces
7 changes: 6 additions & 1 deletion crates/edr_solidity/src/contracts_identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ impl BytecodeTrie {
fn is_matching_metadata(code: &[u8], last_byte: u32) -> bool {
let mut byte = 0;
while byte < last_byte {
let opcode = OpCode::new(code[byte as usize]).unwrap();
// It's possible we don't recognize the opcode if it's from an unknown chain, so
// just return false in that case.
let Some(opcode) = OpCode::new(code[byte as usize]) else {
return false;
};

let next = code.get(byte as usize + 1).copied().and_then(OpCode::new);

if opcode == OpCode::REVERT && next == Some(OpCode::INVALID) {
Expand Down

0 comments on commit 7047e6c

Please sign in to comment.