diff --git a/Cargo.lock b/Cargo.lock index 6059a5ea4..5c3483fed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1289,6 +1289,7 @@ dependencies = [ "edr_eth", "edr_evm", "indexmap 2.2.6", + "log", "parking_lot 0.12.3", "semver 1.0.23", "serde", diff --git a/crates/edr_solidity/Cargo.toml b/crates/edr_solidity/Cargo.toml index 9b2e11f32..07ae0bc2b 100644 --- a/crates/edr_solidity/Cargo.toml +++ b/crates/edr_solidity/Cargo.toml @@ -11,6 +11,7 @@ alloy-sol-types = { version = "0.7.4", default-features = false, features = ["st edr_eth = { version = "0.3.5", path = "../edr_eth" } edr_evm = { version = "0.3.5", path = "../edr_evm" } indexmap = { version = "2", features = ["serde"] } +log = { version = "0.4.17", default-features = false } parking_lot = { version = "0.12.1", default-features = false } serde = { version = "1.0.158", default-features = false, features = ["std"] } serde_json = { version = "1.0.89", features = ["preserve_order"] } diff --git a/crates/edr_solidity/src/source_map.rs b/crates/edr_solidity/src/source_map.rs index 1b2ddaa57..a7e6c33c0 100644 --- a/crates/edr_solidity/src/source_map.rs +++ b/crates/edr_solidity/src/source_map.rs @@ -2,6 +2,7 @@ use std::sync::Arc; use edr_evm::interpreter::OpCode; +use log::debug; use crate::build_model::{BuildModel, Instruction, JumpType, SourceLocation}; @@ -159,9 +160,12 @@ pub fn decode_instructions( let source_map = &source_maps[instructions.len()]; let pc = bytes_index; - let opcode = match OpCode::new(bytecode[pc]) { - Some(opcode) => opcode, - None => continue, + let opcode = if let Some(opcode) = OpCode::new(bytecode[pc]) { opcode } else { + debug!("Invalid opcode {} at pc: {}", bytecode[pc], pc); + + // We assume this happens because the source maps point to the metadata region of the bytecode. + // That means that the actual instructions have already been decoded and we can stop here. + return instructions; }; let push_data = if opcode.is_push() {