Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore unknown opcode in stack traces #693

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading