From 1c8392ee1768c6dcbdccb26e4032df4f215ae2da Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 24 Jul 2024 13:24:24 +0200 Subject: [PATCH 1/8] chore: Port the BytecodeTrie from ContractsIdentifier --- crates/edr_napi/index.d.ts | 18 ++ crates/edr_napi/index.js | 3 +- crates/edr_napi/src/trace.rs | 1 + .../src/trace/contracts_identifier.rs | 156 ++++++++++++++++++ 4 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 crates/edr_napi/src/trace/contracts_identifier.rs diff --git a/crates/edr_napi/index.d.ts b/crates/edr_napi/index.d.ts index 5d643baa5..af1db6e42 100644 --- a/crates/edr_napi/index.d.ts +++ b/crates/edr_napi/index.d.ts @@ -841,6 +841,24 @@ export class Contract { get receive(): ContractFunction | undefined getFunctionFromSelector(selector: Uint8Array): ContractFunction | undefined } +/** + * This class represent a somewhat special Trie of bytecodes. + * + * What makes it special is that every node has a set of all of its descendants and its depth. + */ +export class BytecodeTrie { + readonly depth: number + constructor(depth: number) + get descendants(): Array + get match(): Bytecode | undefined + add(bytecode: Bytecode): void + /** + * Searches for a bytecode. If it's an exact match, it is returned. If there's no match, but a + * prefix of the code is found in the trie, the node of the longest prefix is returned. If the + * entire code is covered by the trie, and there's no match, we return undefined. + */ + search(code: Uint8Array, currentCodeByte: number): Bytecode | BytecodeTrie | undefined +} export class Exit { get kind(): ExitCode isError(): boolean diff --git a/crates/edr_napi/index.js b/crates/edr_napi/index.js index 6e14cd085..fa594dac3 100644 --- a/crates/edr_napi/index.js +++ b/crates/edr_napi/index.js @@ -310,7 +310,7 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, createModelsAndDecodeBytecodes, getLibraryAddressPositions, linkHexStringBytecode, SourceFile, SourceLocation, ContractFunctionType, ContractFunctionVisibility, ContractFunction, CustomError, Instruction, JumpType, jumpTypeToString, Bytecode, ContractType, Contract, Exit, ExitCode, Opcode, opcodeToString, isPush, isJump, getPushLength, getOpcodeLength, isCall, isCreate, VmTracer, RawTrace } = nativeBinding +const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, createModelsAndDecodeBytecodes, getLibraryAddressPositions, linkHexStringBytecode, SourceFile, SourceLocation, ContractFunctionType, ContractFunctionVisibility, ContractFunction, CustomError, Instruction, JumpType, jumpTypeToString, Bytecode, ContractType, Contract, BytecodeTrie, Exit, ExitCode, Opcode, opcodeToString, isPush, isJump, getPushLength, getOpcodeLength, isCall, isCreate, VmTracer, RawTrace } = nativeBinding module.exports.SpecId = SpecId module.exports.EdrContext = EdrContext @@ -334,6 +334,7 @@ module.exports.jumpTypeToString = jumpTypeToString module.exports.Bytecode = Bytecode module.exports.ContractType = ContractType module.exports.Contract = Contract +module.exports.BytecodeTrie = BytecodeTrie module.exports.Exit = Exit module.exports.ExitCode = ExitCode module.exports.Opcode = Opcode diff --git a/crates/edr_napi/src/trace.rs b/crates/edr_napi/src/trace.rs index 5f4412697..dcca27713 100644 --- a/crates/edr_napi/src/trace.rs +++ b/crates/edr_napi/src/trace.rs @@ -21,6 +21,7 @@ mod library_utils; mod model; mod source_map; +mod contracts_identifier; mod exit; mod message_trace; mod opcodes; diff --git a/crates/edr_napi/src/trace/contracts_identifier.rs b/crates/edr_napi/src/trace/contracts_identifier.rs new file mode 100644 index 000000000..ff1f2f055 --- /dev/null +++ b/crates/edr_napi/src/trace/contracts_identifier.rs @@ -0,0 +1,156 @@ +use std::{collections::HashMap, rc::Rc}; + +use napi::{ + bindgen_prelude::{ClassInstance, Object, Uint8Array, Undefined}, + Either, Env, JsObject, +}; +use napi_derive::napi; + +use super::model::Bytecode; +use crate::utils::ClassInstanceRef; + +// TODO: Remove me once we do not need to surface this to JS +/// A cursor that differentiates between the Rust root trie and the JS leaf +/// trie. +enum BytecodeTrieCursor<'a> { + Root(&'a mut BytecodeTrie), + Leaf(Rc>), +} + +/// This class represent a somewhat special Trie of bytecodes. +/// +/// What makes it special is that every node has a set of all of its descendants +/// and its depth. +#[napi] +pub struct BytecodeTrie { + child_nodes: HashMap>>, + descendants: Vec>>, + match_: Option>>, + #[napi(readonly)] + pub depth: u32, +} + +#[napi] +impl BytecodeTrie { + #[napi(constructor)] + pub fn new(depth: u32) -> BytecodeTrie { + BytecodeTrie { + child_nodes: HashMap::new(), + descendants: Vec::new(), + match_: None, + depth, + } + } + + #[napi(getter, ts_return_type = "Array")] + pub fn descendants(&self, env: Env) -> napi::Result> { + self.descendants + .iter() + .map(|descendant| descendant.as_object(env)) + .collect() + } + + #[napi(getter, js_name = "match", ts_return_type = "Bytecode | undefined")] + pub fn match_(&self, env: Env) -> napi::Result> { + match &self.match_ { + Some(match_) => match_.as_object(env).map(Either::A), + None => Ok(Either::B(())), + } + } + + #[napi] + pub fn add(&mut self, bytecode: ClassInstance, env: Env) -> napi::Result<()> { + let bytecode = Rc::new(ClassInstanceRef::from_obj(bytecode, env)?); + + // TODO: Get rid of the cursor once we don't need to differentiate between Rust + // and JS objects + let mut cursor = BytecodeTrieCursor::Root(self); + + let bytecode_normalized_code = &bytecode.borrow(env)?.normalized_code; + for (index, byte) in bytecode_normalized_code.iter().enumerate() { + // Add a descendant + match &mut cursor { + BytecodeTrieCursor::Root(trie) => trie.descendants.push(bytecode.clone()), + BytecodeTrieCursor::Leaf(trie) => { + trie.borrow_mut(env)?.descendants.push(bytecode.clone()); + } + } + + // Get or insert the child node + let node = { + let child_nodes = match &mut cursor { + BytecodeTrieCursor::Root(trie) => &mut trie.child_nodes, + BytecodeTrieCursor::Leaf(trie) => &mut trie.borrow_mut(env)?.child_nodes, + }; + + match child_nodes.entry(*byte) { + std::collections::hash_map::Entry::Occupied(entry) => entry.into_mut(), + std::collections::hash_map::Entry::Vacant(entry) => { + let inst = BytecodeTrie::new(index as u32).into_instance(env)?; + let inst_ref = Rc::new(ClassInstanceRef::from_obj(inst, env)?); + entry.insert(inst_ref) + } + } + .clone() + }; + + cursor = BytecodeTrieCursor::Leaf(node); + } + + // If multiple contracts with the exact same bytecode are added we keep the last + // of them. Note that this includes the metadata hash, so the chances of + // happening are pretty remote, except in super artificial cases that we + // have in our test suite. + let match_ = match &mut cursor { + BytecodeTrieCursor::Root(trie) => &mut trie.match_, + BytecodeTrieCursor::Leaf(trie) => &mut trie.borrow_mut(env)?.match_, + }; + *match_ = Some(bytecode.clone()); + + Ok(()) + } + + /// Searches for a bytecode. If it's an exact match, it is returned. If + /// there's no match, but a prefix of the code is found in the trie, the + /// node of the longest prefix is returned. If the entire code is + /// covered by the trie, and there's no match, we return undefined. + #[napi(ts_return_type = "Bytecode | BytecodeTrie | undefined")] + pub fn search( + &mut self, + code: Uint8Array, + current_code_byte: u32, + env: Env, + ) -> napi::Result> { + if current_code_byte > code.len() as u32 { + return Ok(Either::B(())); + } + + let mut cursor = BytecodeTrieCursor::Root(self); + for byte in code.iter().skip(current_code_byte as usize) { + let child_node = match &mut cursor { + BytecodeTrieCursor::Root(trie) => trie.child_nodes.get(byte).cloned(), + BytecodeTrieCursor::Leaf(trie) => { + trie.borrow_mut(env)?.child_nodes.get(byte).cloned() + } + }; + + if let Some(node) = child_node { + cursor = BytecodeTrieCursor::Leaf(node); + } else { + return match &mut cursor { + BytecodeTrieCursor::Root(..) => Ok(Either::B(())), + BytecodeTrieCursor::Leaf(trie) => trie.as_object(env).map(Either::A), + }; + } + } + + let match_ = match cursor { + BytecodeTrieCursor::Root(trie) => &trie.match_, + BytecodeTrieCursor::Leaf(ref trie) => &trie.borrow_mut(env)?.match_, + }; + match match_ { + Some(bytecode) => Ok(Either::A(bytecode.as_object(env)?)), + None => Ok(Either::B(())), + } + } +} From e777cd75b6f1073b825c97a1aff50fa7b9453b25 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 24 Jul 2024 16:28:49 +0200 Subject: [PATCH 2/8] Migrate some library utils --- crates/edr_napi/index.d.ts | 3 ++ crates/edr_napi/index.js | 5 +++- crates/edr_napi/src/trace/library_utils.rs | 32 +++++++++++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/crates/edr_napi/index.d.ts b/crates/edr_napi/index.d.ts index af1db6e42..288822f93 100644 --- a/crates/edr_napi/index.d.ts +++ b/crates/edr_napi/index.d.ts @@ -349,6 +349,9 @@ export interface SubscriptionEvent { export function createModelsAndDecodeBytecodes(solcVersion: string, compilerInput: any, compilerOutput: any): Array export function getLibraryAddressPositions(bytecodeOutput: any): Array export function linkHexStringBytecode(code: string, address: string, position: number): string +export function zeroOutAddresses(code: Uint8Array, addressesPositions: Array): void +export function zeroOutSlices(code: Uint8Array, pos: Array): void +export function normalizeLibraryRuntimeBytecodeIfNecessary(code: Uint8Array): void export const enum ContractFunctionType { CONSTRUCTOR = 0, FUNCTION = 1, diff --git a/crates/edr_napi/index.js b/crates/edr_napi/index.js index fa594dac3..061bcf32c 100644 --- a/crates/edr_napi/index.js +++ b/crates/edr_napi/index.js @@ -310,7 +310,7 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, createModelsAndDecodeBytecodes, getLibraryAddressPositions, linkHexStringBytecode, SourceFile, SourceLocation, ContractFunctionType, ContractFunctionVisibility, ContractFunction, CustomError, Instruction, JumpType, jumpTypeToString, Bytecode, ContractType, Contract, BytecodeTrie, Exit, ExitCode, Opcode, opcodeToString, isPush, isJump, getPushLength, getOpcodeLength, isCall, isCreate, VmTracer, RawTrace } = nativeBinding +const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, createModelsAndDecodeBytecodes, getLibraryAddressPositions, linkHexStringBytecode, zeroOutAddresses, zeroOutSlices, normalizeLibraryRuntimeBytecodeIfNecessary, SourceFile, SourceLocation, ContractFunctionType, ContractFunctionVisibility, ContractFunction, CustomError, Instruction, JumpType, jumpTypeToString, Bytecode, ContractType, Contract, BytecodeTrie, Exit, ExitCode, Opcode, opcodeToString, isPush, isJump, getPushLength, getOpcodeLength, isCall, isCreate, VmTracer, RawTrace } = nativeBinding module.exports.SpecId = SpecId module.exports.EdrContext = EdrContext @@ -322,6 +322,9 @@ module.exports.ExceptionalHalt = ExceptionalHalt module.exports.createModelsAndDecodeBytecodes = createModelsAndDecodeBytecodes module.exports.getLibraryAddressPositions = getLibraryAddressPositions module.exports.linkHexStringBytecode = linkHexStringBytecode +module.exports.zeroOutAddresses = zeroOutAddresses +module.exports.zeroOutSlices = zeroOutSlices +module.exports.normalizeLibraryRuntimeBytecodeIfNecessary = normalizeLibraryRuntimeBytecodeIfNecessary module.exports.SourceFile = SourceFile module.exports.SourceLocation = SourceLocation module.exports.ContractFunctionType = ContractFunctionType diff --git a/crates/edr_napi/src/trace/library_utils.rs b/crates/edr_napi/src/trace/library_utils.rs index 512d750de..1519e4d15 100644 --- a/crates/edr_napi/src/trace/library_utils.rs +++ b/crates/edr_napi/src/trace/library_utils.rs @@ -1,10 +1,13 @@ //! Port of the hardhat-network's `library-utils.ts` to Rust. +use edr_eth::Address; use edr_evm::hex; use edr_solidity::{artifacts::CompilerOutputBytecode, library_utils}; -use napi::bindgen_prelude::Buffer; +use napi::bindgen_prelude::{Buffer, Uint8Array}; use napi_derive::napi; +use super::{model::ImmutableReference, opcodes::Opcode}; + #[napi] pub fn get_library_address_positions(bytecode_output: serde_json::Value) -> Vec { let bytecode_output: CompilerOutputBytecode = serde_json::from_value(bytecode_output).unwrap(); @@ -38,3 +41,30 @@ pub fn normalize_compiler_output_bytecode( pub fn link_hex_string_bytecode(code: String, address: String, position: u32) -> String { edr_solidity::library_utils::link_hex_string_bytecode(code, &address, position) } + +#[napi] +pub fn zero_out_addresses(mut code: Uint8Array, addresses_positions: Vec) { + for pos in addresses_positions { + code[pos as usize..][..Address::len_bytes()].fill(0); + } +} + +#[napi] +pub fn zero_out_slices(mut code: Uint8Array, pos: Vec) { + for ImmutableReference { start, length } in &pos { + code[*start as usize..][..*length as usize].fill(0); + } +} + +#[napi] +pub fn normalize_library_runtime_bytecode_if_necessary(code: Uint8Array) { + // Libraries' protection normalization: + // Solidity 0.4.20 introduced a protection to prevent libraries from being + // called directly. This is done by modifying the code on deployment, and + // hard-coding the contract address. The first instruction is a PUSH20 of + // the address, which we zero-out as a way of normalizing it. Note that it's + // also zeroed-out in the compiler output. + if code.first().copied() == Some(Opcode::PUSH20 as u8) { + zero_out_addresses(code, vec![1]); + } +} From 759944c7875fdbe763df76a5129be9085f1d10c8 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 24 Jul 2024 17:14:50 +0200 Subject: [PATCH 3/8] Migrate some Opcode helpers --- crates/edr_napi/index.d.ts | 4 +- crates/edr_napi/index.js | 5 +-- .../src/trace/contracts_identifier.rs | 23 ++++++++++- crates/edr_napi/src/trace/opcodes.rs | 40 ++++++++++--------- crates/edr_napi/src/trace/source_map.rs | 12 +++--- 5 files changed, 53 insertions(+), 31 deletions(-) diff --git a/crates/edr_napi/index.d.ts b/crates/edr_napi/index.d.ts index 288822f93..2b4d5f0b6 100644 --- a/crates/edr_napi/index.d.ts +++ b/crates/edr_napi/index.d.ts @@ -391,6 +391,8 @@ export interface SourceMap { location: SourceMapLocation jumpType: JumpType } +/** Returns true if the lastByte is placed right when the metadata starts or after it. */ +export function isMatchingMetadata(code: Uint8Array, lastByte: number): boolean /** Represents the exit code of the EVM. */ export const enum ExitCode { /** Execution was successful. */ @@ -709,8 +711,6 @@ export const enum Opcode { export function opcodeToString(opcode: Opcode): string export function isPush(opcode: Opcode): boolean export function isJump(opcode: Opcode): boolean -export function getPushLength(opcode: Opcode): number -export function getOpcodeLength(opcode: Opcode): number export function isCall(opcode: Opcode): boolean export function isCreate(opcode: Opcode): boolean export interface TracingMessage { diff --git a/crates/edr_napi/index.js b/crates/edr_napi/index.js index 061bcf32c..e2c056276 100644 --- a/crates/edr_napi/index.js +++ b/crates/edr_napi/index.js @@ -310,7 +310,7 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, createModelsAndDecodeBytecodes, getLibraryAddressPositions, linkHexStringBytecode, zeroOutAddresses, zeroOutSlices, normalizeLibraryRuntimeBytecodeIfNecessary, SourceFile, SourceLocation, ContractFunctionType, ContractFunctionVisibility, ContractFunction, CustomError, Instruction, JumpType, jumpTypeToString, Bytecode, ContractType, Contract, BytecodeTrie, Exit, ExitCode, Opcode, opcodeToString, isPush, isJump, getPushLength, getOpcodeLength, isCall, isCreate, VmTracer, RawTrace } = nativeBinding +const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, createModelsAndDecodeBytecodes, getLibraryAddressPositions, linkHexStringBytecode, zeroOutAddresses, zeroOutSlices, normalizeLibraryRuntimeBytecodeIfNecessary, SourceFile, SourceLocation, ContractFunctionType, ContractFunctionVisibility, ContractFunction, CustomError, Instruction, JumpType, jumpTypeToString, Bytecode, ContractType, Contract, BytecodeTrie, isMatchingMetadata, Exit, ExitCode, Opcode, opcodeToString, isPush, isJump, isCall, isCreate, VmTracer, RawTrace } = nativeBinding module.exports.SpecId = SpecId module.exports.EdrContext = EdrContext @@ -338,14 +338,13 @@ module.exports.Bytecode = Bytecode module.exports.ContractType = ContractType module.exports.Contract = Contract module.exports.BytecodeTrie = BytecodeTrie +module.exports.isMatchingMetadata = isMatchingMetadata module.exports.Exit = Exit module.exports.ExitCode = ExitCode module.exports.Opcode = Opcode module.exports.opcodeToString = opcodeToString module.exports.isPush = isPush module.exports.isJump = isJump -module.exports.getPushLength = getPushLength -module.exports.getOpcodeLength = getOpcodeLength module.exports.isCall = isCall module.exports.isCreate = isCreate module.exports.VmTracer = VmTracer diff --git a/crates/edr_napi/src/trace/contracts_identifier.rs b/crates/edr_napi/src/trace/contracts_identifier.rs index ff1f2f055..73d66fdbd 100644 --- a/crates/edr_napi/src/trace/contracts_identifier.rs +++ b/crates/edr_napi/src/trace/contracts_identifier.rs @@ -6,7 +6,7 @@ use napi::{ }; use napi_derive::napi; -use super::model::Bytecode; +use super::{model::Bytecode, opcodes::Opcode}; use crate::utils::ClassInstanceRef; // TODO: Remove me once we do not need to surface this to JS @@ -154,3 +154,24 @@ impl BytecodeTrie { } } } + +/// Returns true if the lastByte is placed right when the metadata starts or +/// after it. +#[napi] +pub fn is_matching_metadata(code: Uint8Array, last_byte: u32) -> bool { + let mut byte = 0; + while byte < last_byte { + let opcode = Opcode::from_repr(code[byte as usize]).unwrap(); + let next = code + .get(byte as usize + 1) + .and_then(|x| Opcode::from_repr(*x)); + + if opcode == Opcode::REVERT && next == Some(Opcode::INVALID) { + return true; + } + + byte += u32::from(opcode.len()); + } + + false +} diff --git a/crates/edr_napi/src/trace/opcodes.rs b/crates/edr_napi/src/trace/opcodes.rs index 3a9f6f885..52623638e 100644 --- a/crates/edr_napi/src/trace/opcodes.rs +++ b/crates/edr_napi/src/trace/opcodes.rs @@ -313,6 +313,22 @@ pub enum Opcode { SELFDESTRUCT = 0xff, } +impl Opcode { + /// Returns the length of the opcode in bytes. + pub fn len(self) -> u8 { + if self >= Opcode::PUSH1 && self <= Opcode::PUSH32 { + return 1 + self.push_len(); + } + + 1 + } + + /// Returns how much data will be pushed onto the stack by the opcode. + pub fn push_len(self) -> u8 { + self as u8 - Opcode::PUSH1 as u8 + 1 + } +} + #[napi] pub fn opcode_to_string(opcode: Opcode) -> &'static str { opcode.into() @@ -328,20 +344,6 @@ pub fn is_jump(opcode: Opcode) -> bool { opcode == Opcode::JUMP || opcode == Opcode::JUMPI } -#[napi] -pub fn get_push_length(opcode: Opcode) -> u8 { - opcode as u8 - Opcode::PUSH1 as u8 + 1 -} - -#[napi] -pub fn get_opcode_length(opcode: Opcode) -> u8 { - if !is_push(opcode) { - return 1; - } - - 1 + get_push_length(opcode) -} - #[napi] fn is_call(opcode: Opcode) -> bool { opcode == Opcode::CALL @@ -358,10 +360,10 @@ fn is_create(opcode: Opcode) -> bool { #[cfg(test)] mod tests { #[test] - fn test_get_push_length() { - use super::get_push_length; - assert_eq!(get_push_length(super::Opcode::PUSH1), 1); - assert_eq!(get_push_length(super::Opcode::PUSH2), 2); - assert_eq!(get_push_length(super::Opcode::PUSH32), 32); + fn test_len() { + use super::Opcode; + assert_eq!(Opcode::PUSH1.len(), 1); + assert_eq!(Opcode::PUSH2.len(), 2); + assert_eq!(Opcode::PUSH32.len(), 32); } } diff --git a/crates/edr_napi/src/trace/source_map.rs b/crates/edr_napi/src/trace/source_map.rs index 383a72da0..84c449a90 100644 --- a/crates/edr_napi/src/trace/source_map.rs +++ b/crates/edr_napi/src/trace/source_map.rs @@ -9,7 +9,7 @@ use super::model::{SourceFile, SourceLocation}; use crate::{ trace::{ model::{Instruction, JumpType}, - opcodes::{get_opcode_length, get_push_length, is_jump, is_push, Opcode}, + opcodes::{is_jump, is_push, Opcode}, }, utils::ClassInstanceRef, }; @@ -113,8 +113,8 @@ fn add_unmapped_instructions( let opcode = Opcode::from_repr(bytecode[bytes_index]).expect("Invalid opcode"); let push_data: Option = if is_push(opcode) { - let push_data = &bytecode - [(bytes_index + 1)..(bytes_index + 1 + (get_push_length(opcode) as usize))]; + let push_data = + &bytecode[(bytes_index + 1)..(bytes_index + 1 + (opcode.push_len() as usize))]; Some(Buffer::from(push_data)) } else { @@ -131,7 +131,7 @@ fn add_unmapped_instructions( instructions.push(instruction); - bytes_index += get_opcode_length(opcode) as usize; + bytes_index += opcode.len() as usize; } Ok(()) @@ -157,7 +157,7 @@ pub fn decode_instructions( let opcode = Opcode::from_repr(bytecode[pc]).expect("Invalid opcode"); let push_data = if is_push(opcode) { - let length = get_push_length(opcode); + let length = opcode.push_len(); let push_data = &bytecode[(bytes_index + 1)..(bytes_index + 1 + (length as usize))]; Some(Buffer::from(push_data)) @@ -194,7 +194,7 @@ pub fn decode_instructions( instructions.push(instruction); - bytes_index += get_opcode_length(opcode) as usize; + bytes_index += opcode.len() as usize; } if is_deployment { From ee91fde809636dce73a961f2d5e5d0435198ccbb Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 24 Jul 2024 19:57:25 +0200 Subject: [PATCH 4/8] Finish the ContractsIdentifier port --- crates/edr_napi/index.d.ts | 8 +- crates/edr_napi/index.js | 6 +- .../src/trace/contracts_identifier.rs | 266 +++++++++++++++++- crates/edr_napi/src/trace/library_utils.rs | 32 +-- 4 files changed, 272 insertions(+), 40 deletions(-) diff --git a/crates/edr_napi/index.d.ts b/crates/edr_napi/index.d.ts index 2b4d5f0b6..fa0efdd45 100644 --- a/crates/edr_napi/index.d.ts +++ b/crates/edr_napi/index.d.ts @@ -349,9 +349,6 @@ export interface SubscriptionEvent { export function createModelsAndDecodeBytecodes(solcVersion: string, compilerInput: any, compilerOutput: any): Array export function getLibraryAddressPositions(bytecodeOutput: any): Array export function linkHexStringBytecode(code: string, address: string, position: number): string -export function zeroOutAddresses(code: Uint8Array, addressesPositions: Array): void -export function zeroOutSlices(code: Uint8Array, pos: Array): void -export function normalizeLibraryRuntimeBytecodeIfNecessary(code: Uint8Array): void export const enum ContractFunctionType { CONSTRUCTOR = 0, FUNCTION = 1, @@ -862,6 +859,11 @@ export class BytecodeTrie { */ search(code: Uint8Array, currentCodeByte: number): Bytecode | BytecodeTrie | undefined } +export class ContractsIdentifier { + constructor(enableCache?: boolean | undefined | null) + addBytecode(bytecode: Bytecode): void + getBytecodeForCall(code: Uint8Array, isCreate: boolean): Bytecode | undefined +} export class Exit { get kind(): ExitCode isError(): boolean diff --git a/crates/edr_napi/index.js b/crates/edr_napi/index.js index e2c056276..33e42812a 100644 --- a/crates/edr_napi/index.js +++ b/crates/edr_napi/index.js @@ -310,7 +310,7 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, createModelsAndDecodeBytecodes, getLibraryAddressPositions, linkHexStringBytecode, zeroOutAddresses, zeroOutSlices, normalizeLibraryRuntimeBytecodeIfNecessary, SourceFile, SourceLocation, ContractFunctionType, ContractFunctionVisibility, ContractFunction, CustomError, Instruction, JumpType, jumpTypeToString, Bytecode, ContractType, Contract, BytecodeTrie, isMatchingMetadata, Exit, ExitCode, Opcode, opcodeToString, isPush, isJump, isCall, isCreate, VmTracer, RawTrace } = nativeBinding +const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, createModelsAndDecodeBytecodes, getLibraryAddressPositions, linkHexStringBytecode, SourceFile, SourceLocation, ContractFunctionType, ContractFunctionVisibility, ContractFunction, CustomError, Instruction, JumpType, jumpTypeToString, Bytecode, ContractType, Contract, BytecodeTrie, isMatchingMetadata, ContractsIdentifier, Exit, ExitCode, Opcode, opcodeToString, isPush, isJump, isCall, isCreate, VmTracer, RawTrace } = nativeBinding module.exports.SpecId = SpecId module.exports.EdrContext = EdrContext @@ -322,9 +322,6 @@ module.exports.ExceptionalHalt = ExceptionalHalt module.exports.createModelsAndDecodeBytecodes = createModelsAndDecodeBytecodes module.exports.getLibraryAddressPositions = getLibraryAddressPositions module.exports.linkHexStringBytecode = linkHexStringBytecode -module.exports.zeroOutAddresses = zeroOutAddresses -module.exports.zeroOutSlices = zeroOutSlices -module.exports.normalizeLibraryRuntimeBytecodeIfNecessary = normalizeLibraryRuntimeBytecodeIfNecessary module.exports.SourceFile = SourceFile module.exports.SourceLocation = SourceLocation module.exports.ContractFunctionType = ContractFunctionType @@ -339,6 +336,7 @@ module.exports.ContractType = ContractType module.exports.Contract = Contract module.exports.BytecodeTrie = BytecodeTrie module.exports.isMatchingMetadata = isMatchingMetadata +module.exports.ContractsIdentifier = ContractsIdentifier module.exports.Exit = Exit module.exports.ExitCode = ExitCode module.exports.Opcode = Opcode diff --git a/crates/edr_napi/src/trace/contracts_identifier.rs b/crates/edr_napi/src/trace/contracts_identifier.rs index 73d66fdbd..a8ad15b76 100644 --- a/crates/edr_napi/src/trace/contracts_identifier.rs +++ b/crates/edr_napi/src/trace/contracts_identifier.rs @@ -1,12 +1,17 @@ use std::{collections::HashMap, rc::Rc}; +use edr_eth::Address; +use edr_evm::hex; use napi::{ - bindgen_prelude::{ClassInstance, Object, Uint8Array, Undefined}, + bindgen_prelude::{ClassInstance, Either3, Object, Uint8Array, Undefined}, Either, Env, JsObject, }; use napi_derive::napi; -use super::{model::Bytecode, opcodes::Opcode}; +use super::{ + model::{Bytecode, ImmutableReference}, + opcodes::Opcode, +}; use crate::utils::ClassInstanceRef; // TODO: Remove me once we do not need to surface this to JS @@ -17,6 +22,11 @@ enum BytecodeTrieCursor<'a> { Leaf(Rc>), } +enum BytecodeTrieCursorRef<'a> { + Root(&'a BytecodeTrie), + Leaf(Rc>), +} + /// This class represent a somewhat special Trie of bytecodes. /// /// What makes it special is that every node has a set of all of its descendants @@ -153,6 +163,47 @@ impl BytecodeTrie { None => Ok(Either::B(())), } } + + pub fn search_inner( + &self, + code: &Uint8Array, + current_code_byte: u32, + env: Env, + ) -> napi::Result< + Either3>, Rc>, Undefined>, + > { + if current_code_byte > code.len() as u32 { + return Ok(Either3::C(())); + } + + let mut cursor = BytecodeTrieCursorRef::Root(self); + for byte in code.iter().skip(current_code_byte as usize) { + let child_node = match &mut cursor { + BytecodeTrieCursorRef::Root(trie) => trie.child_nodes.get(byte).cloned(), + BytecodeTrieCursorRef::Leaf(trie) => { + trie.borrow_mut(env)?.child_nodes.get(byte).cloned() + } + }; + + if let Some(node) = child_node { + cursor = BytecodeTrieCursorRef::Leaf(node); + } else { + return Ok(match &mut cursor { + BytecodeTrieCursorRef::Root(..) => Either3::C(()), + BytecodeTrieCursorRef::Leaf(trie) => Either3::B(trie.clone()), + }); + } + } + + let match_ = match cursor { + BytecodeTrieCursorRef::Root(trie) => &trie.match_, + BytecodeTrieCursorRef::Leaf(ref trie) => &trie.borrow_mut(env)?.match_, + }; + match match_ { + Some(bytecode) => Ok(Either3::A(bytecode.clone())), + None => Ok(Either3::C(())), + } + } } /// Returns true if the lastByte is placed right when the metadata starts or @@ -175,3 +226,214 @@ pub fn is_matching_metadata(code: Uint8Array, last_byte: u32) -> bool { false } + +#[napi] +pub struct ContractsIdentifier { + trie: Rc>, + cache: HashMap>>, + enable_cache: bool, +} + +#[napi] +impl ContractsIdentifier { + #[napi(constructor)] + pub fn new(enable_cache: Option, env: Env) -> ContractsIdentifier { + let enable_cache = enable_cache.unwrap_or(true); + + // TODO: This shouldn't be necessary once we do not need to call it via JS in + // `fn search` TODO: Does it really matter that it's -1 in the JS + // implementation? + let trie = BytecodeTrie::new(0).into_instance(env).unwrap(); + let trie = Rc::new(ClassInstanceRef::from_obj(trie, env).unwrap()); + + ContractsIdentifier { + trie, + cache: HashMap::new(), + enable_cache, + } + } + + #[napi] + pub fn add_bytecode( + &mut self, + bytecode: ClassInstance, + env: Env, + ) -> napi::Result<()> { + self.trie.borrow_mut(env)?.add(bytecode, env)?; + self.cache.clear(); + + Ok(()) + } + + fn search_bytecode( + &mut self, + is_create: bool, + code: Uint8Array, + normalize_libraries: Option, + trie: Option>, + first_byte_to_search: Option, + env: Env, + ) -> napi::Result>>> { + let normalize_libraries = normalize_libraries.unwrap_or(true); + let first_byte_to_search = first_byte_to_search.unwrap_or(0); + let trie = trie + .map(|trie| ClassInstanceRef::from_obj(trie, env)) + .transpose()? + .map_or_else(|| self.trie.clone(), Rc::new); + + Self::search_bytecode_inner( + is_create, + code, + normalize_libraries, + trie, + first_byte_to_search, + env, + ) + } + + fn search_bytecode_inner( + is_create: bool, + code: Uint8Array, + normalize_libraries: bool, + trie: Rc>, + first_byte_to_search: u32, + env: Env, + ) -> napi::Result>>> { + let search_result = trie + .borrow(env)? + .search_inner(&code, first_byte_to_search, env)?; + + let search_result = match search_result { + Either3::A(bytecode) => return Ok(Some(bytecode.clone())), + Either3::B(trie) => trie, + Either3::C(()) => return Ok(None), + }; + + let search_result_ref = search_result.borrow(env)?; + + // Deployment messages have their abi-encoded arguments at the end of the + // bytecode. + // + // We don't know how long those arguments are, as we don't know which contract + // is being deployed, hence we don't know the signature of its + // constructor. + // + // To make things even harder, we can't trust that the user actually passed the + // right amount of arguments. + // + // Luckily, the chances of a complete deployment bytecode being the prefix of + // another one are remote. For example, most of the time it ends with + // its metadata hash, which will differ. + // + // We take advantage of this last observation, and just return the bytecode that + // exactly matched the searchResult (sub)trie that we got. + match &search_result_ref.match_ { + Some(bytecode) if is_create && bytecode.borrow(env)?.is_deployment => { + return Ok(Some(bytecode.clone())); + } + _ => {} + }; + + if normalize_libraries { + for bytecode_with_libraries in &search_result_ref.descendants { + let bytecode_with_libraries = bytecode_with_libraries.borrow(env)?; + + if bytecode_with_libraries.library_address_positions.is_empty() + && bytecode_with_libraries.immutable_references.is_empty() + { + continue; + } + + let mut normalized_code = code.clone(); + // zero out addresses + for pos in &bytecode_with_libraries.library_address_positions { + normalized_code[*pos as usize..][..Address::len_bytes()].fill(0); + } + // zero out slices + for ImmutableReference { start, length } in + &bytecode_with_libraries.immutable_references + { + normalized_code[*start as usize..][..*length as usize].fill(0); + } + + let normalized_result = Self::search_bytecode_inner( + is_create, + normalized_code, + false, + search_result.clone(), + search_result_ref.depth + 1, + env, + ); + + if let Ok(Some(bytecode)) = normalized_result { + return Ok(Some(bytecode.clone())); + }; + } + } + + // If we got here we may still have the contract, but with a different metadata + // hash. + // + // We check if we got to match the entire executable bytecode, and are just + // stuck because of the metadata. If that's the case, we can assume that + // any descendant will be a valid Bytecode, so we just choose the most + // recently added one. + // + // The reason this works is because there's no chance that Solidity includes an + // entire bytecode (i.e. with metadata), as a prefix of another one. + if is_matching_metadata(code, search_result_ref.depth) + && !search_result_ref.descendants.is_empty() + { + return Ok(Some( + search_result_ref.descendants[search_result_ref.descendants.len() - 1].clone(), + )); + } + + Ok(None) + } + + #[napi(ts_return_type = "Bytecode | undefined")] + pub fn get_bytecode_for_call( + &mut self, + code: Uint8Array, + is_create: bool, + env: Env, + ) -> napi::Result> { + let mut normalized_code = code.clone(); + normalize_library_runtime_bytecode_if_necessary(&mut normalized_code); + + let normalized_code_hex = hex::encode(normalized_code.as_ref()); + if self.enable_cache { + let cached = self.cache.get(&normalized_code_hex); + + if let Some(cached) = cached { + return Ok(Either::A(cached.as_object(env)?)); + } + } + + let result = self.search_bytecode(is_create, normalized_code, None, None, None, env)?; + + if self.enable_cache { + if let Some(result) = &result { + self.cache.insert(normalized_code_hex, result.clone()); + } + } + + match result { + Some(bytecode) => Ok(Either::A(bytecode.as_object(env)?)), + None => Ok(Either::B(())), + } + } +} + +fn normalize_library_runtime_bytecode_if_necessary(code: &mut Uint8Array) { + // Libraries' protection normalization: + // Solidity 0.4.20 introduced a protection to prevent libraries from being + // called directly. This is done by modifying the code on deployment, and + // hard-coding the contract address. The first instruction is a PUSH20 of + // the address, which we zero-out as a way of normalizing it. Note that it's + // also zeroed-out in the compiler output. + if code.first().copied() == Some(Opcode::PUSH20 as u8) { + code[1..][..Address::len_bytes()].fill(0); + } +} diff --git a/crates/edr_napi/src/trace/library_utils.rs b/crates/edr_napi/src/trace/library_utils.rs index 1519e4d15..512d750de 100644 --- a/crates/edr_napi/src/trace/library_utils.rs +++ b/crates/edr_napi/src/trace/library_utils.rs @@ -1,13 +1,10 @@ //! Port of the hardhat-network's `library-utils.ts` to Rust. -use edr_eth::Address; use edr_evm::hex; use edr_solidity::{artifacts::CompilerOutputBytecode, library_utils}; -use napi::bindgen_prelude::{Buffer, Uint8Array}; +use napi::bindgen_prelude::Buffer; use napi_derive::napi; -use super::{model::ImmutableReference, opcodes::Opcode}; - #[napi] pub fn get_library_address_positions(bytecode_output: serde_json::Value) -> Vec { let bytecode_output: CompilerOutputBytecode = serde_json::from_value(bytecode_output).unwrap(); @@ -41,30 +38,3 @@ pub fn normalize_compiler_output_bytecode( pub fn link_hex_string_bytecode(code: String, address: String, position: u32) -> String { edr_solidity::library_utils::link_hex_string_bytecode(code, &address, position) } - -#[napi] -pub fn zero_out_addresses(mut code: Uint8Array, addresses_positions: Vec) { - for pos in addresses_positions { - code[pos as usize..][..Address::len_bytes()].fill(0); - } -} - -#[napi] -pub fn zero_out_slices(mut code: Uint8Array, pos: Vec) { - for ImmutableReference { start, length } in &pos { - code[*start as usize..][..*length as usize].fill(0); - } -} - -#[napi] -pub fn normalize_library_runtime_bytecode_if_necessary(code: Uint8Array) { - // Libraries' protection normalization: - // Solidity 0.4.20 introduced a protection to prevent libraries from being - // called directly. This is done by modifying the code on deployment, and - // hard-coding the contract address. The first instruction is a PUSH20 of - // the address, which we zero-out as a way of normalizing it. Note that it's - // also zeroed-out in the compiler output. - if code.first().copied() == Some(Opcode::PUSH20 as u8) { - zero_out_addresses(code, vec![1]); - } -} From a8d654f95c8197a9363226b0fc535a24cc179099 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Thu, 25 Jul 2024 09:06:27 +0200 Subject: [PATCH 5/8] Remove unused get_library_address_positions --- crates/edr_napi/index.d.ts | 1 - crates/edr_napi/index.js | 3 +-- crates/edr_napi/src/trace/library_utils.rs | 8 -------- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/crates/edr_napi/index.d.ts b/crates/edr_napi/index.d.ts index fa0efdd45..f5c07d5e5 100644 --- a/crates/edr_napi/index.d.ts +++ b/crates/edr_napi/index.d.ts @@ -347,7 +347,6 @@ export interface SubscriptionEvent { result: any } export function createModelsAndDecodeBytecodes(solcVersion: string, compilerInput: any, compilerOutput: any): Array -export function getLibraryAddressPositions(bytecodeOutput: any): Array export function linkHexStringBytecode(code: string, address: string, position: number): string export const enum ContractFunctionType { CONSTRUCTOR = 0, diff --git a/crates/edr_napi/index.js b/crates/edr_napi/index.js index 33e42812a..5d82ceb4c 100644 --- a/crates/edr_napi/index.js +++ b/crates/edr_napi/index.js @@ -310,7 +310,7 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, createModelsAndDecodeBytecodes, getLibraryAddressPositions, linkHexStringBytecode, SourceFile, SourceLocation, ContractFunctionType, ContractFunctionVisibility, ContractFunction, CustomError, Instruction, JumpType, jumpTypeToString, Bytecode, ContractType, Contract, BytecodeTrie, isMatchingMetadata, ContractsIdentifier, Exit, ExitCode, Opcode, opcodeToString, isPush, isJump, isCall, isCreate, VmTracer, RawTrace } = nativeBinding +const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, createModelsAndDecodeBytecodes, linkHexStringBytecode, SourceFile, SourceLocation, ContractFunctionType, ContractFunctionVisibility, ContractFunction, CustomError, Instruction, JumpType, jumpTypeToString, Bytecode, ContractType, Contract, BytecodeTrie, isMatchingMetadata, ContractsIdentifier, Exit, ExitCode, Opcode, opcodeToString, isPush, isJump, isCall, isCreate, VmTracer, RawTrace } = nativeBinding module.exports.SpecId = SpecId module.exports.EdrContext = EdrContext @@ -320,7 +320,6 @@ module.exports.Response = Response module.exports.SuccessReason = SuccessReason module.exports.ExceptionalHalt = ExceptionalHalt module.exports.createModelsAndDecodeBytecodes = createModelsAndDecodeBytecodes -module.exports.getLibraryAddressPositions = getLibraryAddressPositions module.exports.linkHexStringBytecode = linkHexStringBytecode module.exports.SourceFile = SourceFile module.exports.SourceLocation = SourceLocation diff --git a/crates/edr_napi/src/trace/library_utils.rs b/crates/edr_napi/src/trace/library_utils.rs index 512d750de..8c100fd87 100644 --- a/crates/edr_napi/src/trace/library_utils.rs +++ b/crates/edr_napi/src/trace/library_utils.rs @@ -1,17 +1,9 @@ //! Port of the hardhat-network's `library-utils.ts` to Rust. use edr_evm::hex; -use edr_solidity::{artifacts::CompilerOutputBytecode, library_utils}; use napi::bindgen_prelude::Buffer; use napi_derive::napi; -#[napi] -pub fn get_library_address_positions(bytecode_output: serde_json::Value) -> Vec { - let bytecode_output: CompilerOutputBytecode = serde_json::from_value(bytecode_output).unwrap(); - - library_utils::get_library_address_positions(&bytecode_output) -} - /// Normalizes the compiler output bytecode by replacing the library addresses /// with zeros. pub fn normalize_compiler_output_bytecode( From 7f42081ca48fbbb5bdcf68616594f4faaa114b65 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Thu, 25 Jul 2024 10:23:39 +0200 Subject: [PATCH 6/8] Simplify the ContractsIdentifier port --- crates/edr_napi/index.d.ts | 20 -- crates/edr_napi/index.js | 4 +- .../src/trace/contracts_identifier.rs | 222 ++++-------------- 3 files changed, 48 insertions(+), 198 deletions(-) diff --git a/crates/edr_napi/index.d.ts b/crates/edr_napi/index.d.ts index f5c07d5e5..d9f0e3c43 100644 --- a/crates/edr_napi/index.d.ts +++ b/crates/edr_napi/index.d.ts @@ -387,8 +387,6 @@ export interface SourceMap { location: SourceMapLocation jumpType: JumpType } -/** Returns true if the lastByte is placed right when the metadata starts or after it. */ -export function isMatchingMetadata(code: Uint8Array, lastByte: number): boolean /** Represents the exit code of the EVM. */ export const enum ExitCode { /** Execution was successful. */ @@ -840,24 +838,6 @@ export class Contract { get receive(): ContractFunction | undefined getFunctionFromSelector(selector: Uint8Array): ContractFunction | undefined } -/** - * This class represent a somewhat special Trie of bytecodes. - * - * What makes it special is that every node has a set of all of its descendants and its depth. - */ -export class BytecodeTrie { - readonly depth: number - constructor(depth: number) - get descendants(): Array - get match(): Bytecode | undefined - add(bytecode: Bytecode): void - /** - * Searches for a bytecode. If it's an exact match, it is returned. If there's no match, but a - * prefix of the code is found in the trie, the node of the longest prefix is returned. If the - * entire code is covered by the trie, and there's no match, we return undefined. - */ - search(code: Uint8Array, currentCodeByte: number): Bytecode | BytecodeTrie | undefined -} export class ContractsIdentifier { constructor(enableCache?: boolean | undefined | null) addBytecode(bytecode: Bytecode): void diff --git a/crates/edr_napi/index.js b/crates/edr_napi/index.js index 5d82ceb4c..333003859 100644 --- a/crates/edr_napi/index.js +++ b/crates/edr_napi/index.js @@ -310,7 +310,7 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, createModelsAndDecodeBytecodes, linkHexStringBytecode, SourceFile, SourceLocation, ContractFunctionType, ContractFunctionVisibility, ContractFunction, CustomError, Instruction, JumpType, jumpTypeToString, Bytecode, ContractType, Contract, BytecodeTrie, isMatchingMetadata, ContractsIdentifier, Exit, ExitCode, Opcode, opcodeToString, isPush, isJump, isCall, isCreate, VmTracer, RawTrace } = nativeBinding +const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, createModelsAndDecodeBytecodes, linkHexStringBytecode, SourceFile, SourceLocation, ContractFunctionType, ContractFunctionVisibility, ContractFunction, CustomError, Instruction, JumpType, jumpTypeToString, Bytecode, ContractType, Contract, ContractsIdentifier, Exit, ExitCode, Opcode, opcodeToString, isPush, isJump, isCall, isCreate, VmTracer, RawTrace } = nativeBinding module.exports.SpecId = SpecId module.exports.EdrContext = EdrContext @@ -333,8 +333,6 @@ module.exports.jumpTypeToString = jumpTypeToString module.exports.Bytecode = Bytecode module.exports.ContractType = ContractType module.exports.Contract = Contract -module.exports.BytecodeTrie = BytecodeTrie -module.exports.isMatchingMetadata = isMatchingMetadata module.exports.ContractsIdentifier = ContractsIdentifier module.exports.Exit = Exit module.exports.ExitCode = ExitCode diff --git a/crates/edr_napi/src/trace/contracts_identifier.rs b/crates/edr_napi/src/trace/contracts_identifier.rs index a8ad15b76..be4359d5a 100644 --- a/crates/edr_napi/src/trace/contracts_identifier.rs +++ b/crates/edr_napi/src/trace/contracts_identifier.rs @@ -3,7 +3,7 @@ use std::{collections::HashMap, rc::Rc}; use edr_eth::Address; use edr_evm::hex; use napi::{ - bindgen_prelude::{ClassInstance, Either3, Object, Uint8Array, Undefined}, + bindgen_prelude::{ClassInstance, Uint8Array, Undefined}, Either, Env, JsObject, }; use napi_derive::napi; @@ -14,36 +14,20 @@ use super::{ }; use crate::utils::ClassInstanceRef; -// TODO: Remove me once we do not need to surface this to JS -/// A cursor that differentiates between the Rust root trie and the JS leaf -/// trie. -enum BytecodeTrieCursor<'a> { - Root(&'a mut BytecodeTrie), - Leaf(Rc>), -} - -enum BytecodeTrieCursorRef<'a> { - Root(&'a BytecodeTrie), - Leaf(Rc>), -} - /// This class represent a somewhat special Trie of bytecodes. /// /// What makes it special is that every node has a set of all of its descendants /// and its depth. -#[napi] +#[derive(Clone)] pub struct BytecodeTrie { - child_nodes: HashMap>>, + child_nodes: HashMap>, descendants: Vec>>, match_: Option>>, - #[napi(readonly)] - pub depth: u32, + depth: Option, } -#[napi] impl BytecodeTrie { - #[napi(constructor)] - pub fn new(depth: u32) -> BytecodeTrie { + pub fn new(depth: Option) -> BytecodeTrie { BytecodeTrie { child_nodes: HashMap::new(), descendants: Vec::new(), @@ -52,70 +36,28 @@ impl BytecodeTrie { } } - #[napi(getter, ts_return_type = "Array")] - pub fn descendants(&self, env: Env) -> napi::Result> { - self.descendants - .iter() - .map(|descendant| descendant.as_object(env)) - .collect() - } - - #[napi(getter, js_name = "match", ts_return_type = "Bytecode | undefined")] - pub fn match_(&self, env: Env) -> napi::Result> { - match &self.match_ { - Some(match_) => match_.as_object(env).map(Either::A), - None => Ok(Either::B(())), - } - } - - #[napi] pub fn add(&mut self, bytecode: ClassInstance, env: Env) -> napi::Result<()> { let bytecode = Rc::new(ClassInstanceRef::from_obj(bytecode, env)?); - // TODO: Get rid of the cursor once we don't need to differentiate between Rust - // and JS objects - let mut cursor = BytecodeTrieCursor::Root(self); + let mut cursor = self; let bytecode_normalized_code = &bytecode.borrow(env)?.normalized_code; for (index, byte) in bytecode_normalized_code.iter().enumerate() { - // Add a descendant - match &mut cursor { - BytecodeTrieCursor::Root(trie) => trie.descendants.push(bytecode.clone()), - BytecodeTrieCursor::Leaf(trie) => { - trie.borrow_mut(env)?.descendants.push(bytecode.clone()); - } - } + cursor.descendants.push(bytecode.clone()); - // Get or insert the child node - let node = { - let child_nodes = match &mut cursor { - BytecodeTrieCursor::Root(trie) => &mut trie.child_nodes, - BytecodeTrieCursor::Leaf(trie) => &mut trie.borrow_mut(env)?.child_nodes, - }; + let node = cursor + .child_nodes + .entry(*byte) + .or_insert_with(|| Box::new(BytecodeTrie::new(Some(index as u32)))); - match child_nodes.entry(*byte) { - std::collections::hash_map::Entry::Occupied(entry) => entry.into_mut(), - std::collections::hash_map::Entry::Vacant(entry) => { - let inst = BytecodeTrie::new(index as u32).into_instance(env)?; - let inst_ref = Rc::new(ClassInstanceRef::from_obj(inst, env)?); - entry.insert(inst_ref) - } - } - .clone() - }; - - cursor = BytecodeTrieCursor::Leaf(node); + cursor = node; } // If multiple contracts with the exact same bytecode are added we keep the last // of them. Note that this includes the metadata hash, so the chances of // happening are pretty remote, except in super artificial cases that we // have in our test suite. - let match_ = match &mut cursor { - BytecodeTrieCursor::Root(trie) => &mut trie.match_, - BytecodeTrieCursor::Leaf(trie) => &mut trie.borrow_mut(env)?.match_, - }; - *match_ = Some(bytecode.clone()); + cursor.match_ = Some(bytecode.clone()); Ok(()) } @@ -124,92 +66,37 @@ impl BytecodeTrie { /// there's no match, but a prefix of the code is found in the trie, the /// node of the longest prefix is returned. If the entire code is /// covered by the trie, and there's no match, we return undefined. - #[napi(ts_return_type = "Bytecode | BytecodeTrie | undefined")] pub fn search( - &mut self, - code: Uint8Array, - current_code_byte: u32, - env: Env, - ) -> napi::Result> { - if current_code_byte > code.len() as u32 { - return Ok(Either::B(())); - } - - let mut cursor = BytecodeTrieCursor::Root(self); - for byte in code.iter().skip(current_code_byte as usize) { - let child_node = match &mut cursor { - BytecodeTrieCursor::Root(trie) => trie.child_nodes.get(byte).cloned(), - BytecodeTrieCursor::Leaf(trie) => { - trie.borrow_mut(env)?.child_nodes.get(byte).cloned() - } - }; - - if let Some(node) = child_node { - cursor = BytecodeTrieCursor::Leaf(node); - } else { - return match &mut cursor { - BytecodeTrieCursor::Root(..) => Ok(Either::B(())), - BytecodeTrieCursor::Leaf(trie) => trie.as_object(env).map(Either::A), - }; - } - } - - let match_ = match cursor { - BytecodeTrieCursor::Root(trie) => &trie.match_, - BytecodeTrieCursor::Leaf(ref trie) => &trie.borrow_mut(env)?.match_, - }; - match match_ { - Some(bytecode) => Ok(Either::A(bytecode.as_object(env)?)), - None => Ok(Either::B(())), - } - } - - pub fn search_inner( &self, code: &Uint8Array, current_code_byte: u32, - env: Env, - ) -> napi::Result< - Either3>, Rc>, Undefined>, - > { + ) -> Option>, &Self>> { if current_code_byte > code.len() as u32 { - return Ok(Either3::C(())); + return None; } - let mut cursor = BytecodeTrieCursorRef::Root(self); + let mut cursor = self; + for byte in code.iter().skip(current_code_byte as usize) { - let child_node = match &mut cursor { - BytecodeTrieCursorRef::Root(trie) => trie.child_nodes.get(byte).cloned(), - BytecodeTrieCursorRef::Leaf(trie) => { - trie.borrow_mut(env)?.child_nodes.get(byte).cloned() - } - }; + let child_node = cursor.child_nodes.get(byte); if let Some(node) = child_node { - cursor = BytecodeTrieCursorRef::Leaf(node); + cursor = node; } else { - return Ok(match &mut cursor { - BytecodeTrieCursorRef::Root(..) => Either3::C(()), - BytecodeTrieCursorRef::Leaf(trie) => Either3::B(trie.clone()), - }); + return Some(Either::B(cursor)); } } - let match_ = match cursor { - BytecodeTrieCursorRef::Root(trie) => &trie.match_, - BytecodeTrieCursorRef::Leaf(ref trie) => &trie.borrow_mut(env)?.match_, - }; - match match_ { - Some(bytecode) => Ok(Either3::A(bytecode.clone())), - None => Ok(Either3::C(())), - } + cursor + .match_ + .as_ref() + .map(|bytecode| Either::A(bytecode.clone())) } } /// Returns true if the lastByte is placed right when the metadata starts or /// after it. -#[napi] -pub fn is_matching_metadata(code: Uint8Array, last_byte: u32) -> bool { +fn is_matching_metadata(code: Uint8Array, last_byte: u32) -> bool { let mut byte = 0; while byte < last_byte { let opcode = Opcode::from_repr(code[byte as usize]).unwrap(); @@ -229,7 +116,7 @@ pub fn is_matching_metadata(code: Uint8Array, last_byte: u32) -> bool { #[napi] pub struct ContractsIdentifier { - trie: Rc>, + trie: BytecodeTrie, cache: HashMap>>, enable_cache: bool, } @@ -237,17 +124,11 @@ pub struct ContractsIdentifier { #[napi] impl ContractsIdentifier { #[napi(constructor)] - pub fn new(enable_cache: Option, env: Env) -> ContractsIdentifier { + pub fn new(enable_cache: Option) -> ContractsIdentifier { let enable_cache = enable_cache.unwrap_or(true); - // TODO: This shouldn't be necessary once we do not need to call it via JS in - // `fn search` TODO: Does it really matter that it's -1 in the JS - // implementation? - let trie = BytecodeTrie::new(0).into_instance(env).unwrap(); - let trie = Rc::new(ClassInstanceRef::from_obj(trie, env).unwrap()); - ContractsIdentifier { - trie, + trie: BytecodeTrie::new(None), cache: HashMap::new(), enable_cache, } @@ -259,7 +140,7 @@ impl ContractsIdentifier { bytecode: ClassInstance, env: Env, ) -> napi::Result<()> { - self.trie.borrow_mut(env)?.add(bytecode, env)?; + self.trie.add(bytecode, env)?; self.cache.clear(); Ok(()) @@ -270,16 +151,13 @@ impl ContractsIdentifier { is_create: bool, code: Uint8Array, normalize_libraries: Option, - trie: Option>, + trie: Option<&BytecodeTrie>, first_byte_to_search: Option, env: Env, ) -> napi::Result>>> { let normalize_libraries = normalize_libraries.unwrap_or(true); let first_byte_to_search = first_byte_to_search.unwrap_or(0); - let trie = trie - .map(|trie| ClassInstanceRef::from_obj(trie, env)) - .transpose()? - .map_or_else(|| self.trie.clone(), Rc::new); + let trie = trie.unwrap_or(&self.trie); Self::search_bytecode_inner( is_create, @@ -295,22 +173,16 @@ impl ContractsIdentifier { is_create: bool, code: Uint8Array, normalize_libraries: bool, - trie: Rc>, + trie: &BytecodeTrie, first_byte_to_search: u32, env: Env, ) -> napi::Result>>> { - let search_result = trie - .borrow(env)? - .search_inner(&code, first_byte_to_search, env)?; - - let search_result = match search_result { - Either3::A(bytecode) => return Ok(Some(bytecode.clone())), - Either3::B(trie) => trie, - Either3::C(()) => return Ok(None), + let search_result = match trie.search(&code, first_byte_to_search) { + None => return Ok(None), + Some(Either::A(bytecode)) => return Ok(Some(bytecode.clone())), + Some(Either::B(trie)) => trie, }; - let search_result_ref = search_result.borrow(env)?; - // Deployment messages have their abi-encoded arguments at the end of the // bytecode. // @@ -326,8 +198,8 @@ impl ContractsIdentifier { // its metadata hash, which will differ. // // We take advantage of this last observation, and just return the bytecode that - // exactly matched the searchResult (sub)trie that we got. - match &search_result_ref.match_ { + // exactly matched the search_result (sub)trie that we got. + match &search_result.match_ { Some(bytecode) if is_create && bytecode.borrow(env)?.is_deployment => { return Ok(Some(bytecode.clone())); } @@ -335,7 +207,7 @@ impl ContractsIdentifier { }; if normalize_libraries { - for bytecode_with_libraries in &search_result_ref.descendants { + for bytecode_with_libraries in &search_result.descendants { let bytecode_with_libraries = bytecode_with_libraries.borrow(env)?; if bytecode_with_libraries.library_address_positions.is_empty() @@ -360,8 +232,8 @@ impl ContractsIdentifier { is_create, normalized_code, false, - search_result.clone(), - search_result_ref.depth + 1, + search_result, + search_result.depth.map_or(0, |depth| depth + 1), env, ); @@ -381,12 +253,12 @@ impl ContractsIdentifier { // // The reason this works is because there's no chance that Solidity includes an // entire bytecode (i.e. with metadata), as a prefix of another one. - if is_matching_metadata(code, search_result_ref.depth) - && !search_result_ref.descendants.is_empty() - { - return Ok(Some( - search_result_ref.descendants[search_result_ref.descendants.len() - 1].clone(), - )); + if let Some(search_depth) = search_result.depth { + if is_matching_metadata(code, search_depth) && !search_result.descendants.is_empty() { + return Ok(Some( + search_result.descendants[search_result.descendants.len() - 1].clone(), + )); + } } Ok(None) From f22b5c262acb08c53727815dcd002a4c390ad02c Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Thu, 25 Jul 2024 10:53:10 +0200 Subject: [PATCH 7/8] patch(hardhat): Re-use the ContractsIdentifier from EDR --- patches/gen-hardhat-patches.sh | 4 + patches/hardhat@2.22.6.patch | 646 +++++++++++++++++++++++++++++---- pnpm-lock.yaml | 24 +- 3 files changed, 585 insertions(+), 89 deletions(-) diff --git a/patches/gen-hardhat-patches.sh b/patches/gen-hardhat-patches.sh index 797215717..c2a4b07c3 100755 --- a/patches/gen-hardhat-patches.sh +++ b/patches/gen-hardhat-patches.sh @@ -24,6 +24,10 @@ COMMITS=( 49c66b6947283d9c9414f5e6faf2f94dcf05cc58 # refactor: Re-use MessageTrace and VmTracer from EDR now 3aeeb564394349824221ea9814f49cb5f8002d78 + # refactor: Simplify BytecodeTrie logic + dd34257cec2ceddc4e7065aa9147378d8f75da98 + # refactor: Re-use the ContractsIdentifier from EDR + 0bdc767826aba3b7ae2c4de02687d1743fb05813 ) for commit in "${COMMITS[@]}"; do diff --git a/patches/hardhat@2.22.6.patch b/patches/hardhat@2.22.6.patch index 86cdb0e9e..addede992 100644 --- a/patches/hardhat@2.22.6.patch +++ b/patches/hardhat@2.22.6.patch @@ -648,27 +648,220 @@ index 84ef3e0b7f068a5e3a5757df847a1ae8179719c7..9cb43155249ed229b4f126252a04884f \ No newline at end of file +{"version":3,"file":"compiler-to-model.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/compiler-to-model.ts"],"names":[],"mappings":";;;AAAA,4CAAsE;AAA7D,qHAAA,8BAA8B,OAAA"} \ No newline at end of file +diff --git a/internal/hardhat-network/stack-traces/contracts-identifier.d.ts b/internal/hardhat-network/stack-traces/contracts-identifier.d.ts +index c802d994e1cd68ed6e719af31bcbc4f64f95f72a..815e8d5368e77c414f9bf970b589b144f4eced48 100644 +--- a/internal/hardhat-network/stack-traces/contracts-identifier.d.ts ++++ b/internal/hardhat-network/stack-traces/contracts-identifier.d.ts +@@ -1,15 +1,3 @@ +-import { Bytecode } from "./model"; +-export declare class ContractsIdentifier { +- private readonly _enableCache; +- private _trie; +- private _cache; +- constructor(_enableCache?: boolean); +- addBytecode(bytecode: Bytecode): void; +- getBytecodeForCall(code: Uint8Array, isCreate: boolean): Bytecode | undefined; +- private _searchBytecode; +- /** +- * Returns true if the lastByte is placed right when the metadata starts or after it. +- */ +- private _isMatchingMetadata; +-} ++import { ContractsIdentifier } from "@nomicfoundation/edr"; ++export { ContractsIdentifier }; + //# sourceMappingURL=contracts-identifier.d.ts.map +\ No newline at end of file +diff --git a/internal/hardhat-network/stack-traces/contracts-identifier.d.ts.map b/internal/hardhat-network/stack-traces/contracts-identifier.d.ts.map +index e759a7ab0c03b9617f5065b62fa4bdeefbb5f7a3..b1ccf83611c17d02716328248a28ada6424e41f3 100644 +--- a/internal/hardhat-network/stack-traces/contracts-identifier.d.ts.map ++++ b/internal/hardhat-network/stack-traces/contracts-identifier.d.ts.map +@@ -1 +1 @@ +-{"version":3,"file":"contracts-identifier.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/contracts-identifier.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAmFnC,qBAAa,mBAAmB;IAIlB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAHzC,OAAO,CAAC,KAAK,CAAwB;IACrC,OAAO,CAAC,MAAM,CAAoC;gBAErB,YAAY,UAAO;IAEzC,WAAW,CAAC,QAAQ,EAAE,QAAQ;IAK9B,kBAAkB,CACvB,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,OAAO,GAChB,QAAQ,GAAG,SAAS;IAwBvB,OAAO,CAAC,eAAe;IAyFvB;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAc5B"} +\ No newline at end of file ++{"version":3,"file":"contracts-identifier.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/contracts-identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,CAAC"} +\ No newline at end of file diff --git a/internal/hardhat-network/stack-traces/contracts-identifier.js b/internal/hardhat-network/stack-traces/contracts-identifier.js -index ba689479fddf360a1520672660c6d153211f80eb..d1574086a3c577e04f513d75fd305e15afc564ed 100644 +index ba689479fddf360a1520672660c6d153211f80eb..1fc5fd60719f8b92c91a2bef10adc30b8a2209fe 100644 --- a/internal/hardhat-network/stack-traces/contracts-identifier.js +++ b/internal/hardhat-network/stack-traces/contracts-identifier.js -@@ -154,7 +154,7 @@ class ContractsIdentifier { - for (let byte = 0; byte < lastByte;) { - const opcode = code[byte]; - // Solidity always emits REVERT INVALID right before the metadata +@@ -1,166 +1,6 @@ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.ContractsIdentifier = void 0; +-const ethereumjs_util_1 = require("@nomicfoundation/ethereumjs-util"); +-const library_utils_1 = require("./library-utils"); +-const opcodes_1 = require("./opcodes"); +-/** +- * This class represent a somewhat special Trie of bytecodes. +- * +- * What makes it special is that every node has a set of all of its descendants and its depth. +- */ +-class BytecodeTrie { +- static isBytecodeTrie(o) { +- if (o === undefined || o === null) { +- return false; +- } +- return "childNodes" in o; +- } +- constructor(depth) { +- this.depth = depth; +- this.childNodes = new Map(); +- this.descendants = []; +- } +- add(bytecode) { +- // eslint-disable-next-line @typescript-eslint/no-this-alias +- let trieNode = this; +- for (let currentCodeByte = 0; currentCodeByte <= bytecode.normalizedCode.length; currentCodeByte += 1) { +- if (currentCodeByte === bytecode.normalizedCode.length) { +- // If multiple contracts with the exact same bytecode are added we keep the last of them. +- // Note that this includes the metadata hash, so the chances of happening are pretty remote, +- // except in super artificial cases that we have in our test suite. +- trieNode.match = bytecode; +- return; +- } +- const byte = bytecode.normalizedCode[currentCodeByte]; +- trieNode.descendants.push(bytecode); +- let childNode = trieNode.childNodes.get(byte); +- if (childNode === undefined) { +- childNode = new BytecodeTrie(currentCodeByte); +- trieNode.childNodes.set(byte, childNode); +- } +- trieNode = childNode; +- } +- } +- /** +- * Searches for a bytecode. If it's an exact match, it is returned. If there's no match, but a +- * prefix of the code is found in the trie, the node of the longest prefix is returned. If the +- * entire code is covered by the trie, and there's no match, we return undefined. +- */ +- search(code, currentCodeByte = 0) { +- if (currentCodeByte > code.length) { +- return undefined; +- } +- // eslint-disable-next-line @typescript-eslint/no-this-alias +- let trieNode = this; +- for (; currentCodeByte <= code.length; currentCodeByte += 1) { +- if (currentCodeByte === code.length) { +- return trieNode.match; +- } +- const childNode = trieNode.childNodes.get(code[currentCodeByte]); +- if (childNode === undefined) { +- return trieNode; +- } +- trieNode = childNode; +- } +- } +-} +-class ContractsIdentifier { +- constructor(_enableCache = true) { +- this._enableCache = _enableCache; +- this._trie = new BytecodeTrie(-1); +- this._cache = new Map(); +- } +- addBytecode(bytecode) { +- this._trie.add(bytecode); +- this._cache.clear(); +- } +- getBytecodeForCall(code, isCreate) { +- const normalizedCode = (0, library_utils_1.normalizeLibraryRuntimeBytecodeIfNecessary)(code); +- let normalizedCodeHex; +- if (this._enableCache) { +- normalizedCodeHex = (0, ethereumjs_util_1.bytesToHex)(normalizedCode); +- const cached = this._cache.get(normalizedCodeHex); +- if (cached !== undefined) { +- return cached; +- } +- } +- const result = this._searchBytecode(isCreate, normalizedCode); +- if (this._enableCache) { +- if (result !== undefined) { +- this._cache.set(normalizedCodeHex, result); +- } +- } +- return result; +- } +- _searchBytecode(isCreate, code, normalizeLibraries = true, trie = this._trie, firstByteToSearch = 0) { +- const searchResult = trie.search(code, firstByteToSearch); +- if (searchResult === undefined) { +- return undefined; +- } +- if (!BytecodeTrie.isBytecodeTrie(searchResult)) { +- return searchResult; +- } +- // Deployment messages have their abi-encoded arguments at the end of the bytecode. +- // +- // We don't know how long those arguments are, as we don't know which contract is being +- // deployed, hence we don't know the signature of its constructor. +- // +- // To make things even harder, we can't trust that the user actually passed the right +- // amount of arguments. +- // +- // Luckily, the chances of a complete deployment bytecode being the prefix of another one are +- // remote. For example, most of the time it ends with its metadata hash, which will differ. +- // +- // We take advantage of this last observation, and just return the bytecode that exactly +- // matched the searchResult (sub)trie that we got. +- if (isCreate && +- searchResult.match !== undefined && +- searchResult.match.isDeployment) { +- return searchResult.match; +- } +- if (normalizeLibraries) { +- for (const bytecodeWithLibraries of searchResult.descendants) { +- if (bytecodeWithLibraries.libraryAddressPositions.length === 0 && +- bytecodeWithLibraries.immutableReferences.length === 0) { +- continue; +- } +- const normalizedLibrariesCode = (0, library_utils_1.zeroOutAddresses)(code, bytecodeWithLibraries.libraryAddressPositions); +- const normalizedCode = (0, library_utils_1.zeroOutSlices)(normalizedLibrariesCode, bytecodeWithLibraries.immutableReferences); +- const normalizedResult = this._searchBytecode(isCreate, normalizedCode, false, searchResult, searchResult.depth + 1); +- if (normalizedResult !== undefined) { +- return normalizedResult; +- } +- } +- } +- // If we got here we may still have the contract, but with a different metadata hash. +- // +- // We check if we got to match the entire executable bytecode, and are just stuck because +- // of the metadata. If that's the case, we can assume that any descendant will be a valid +- // Bytecode, so we just choose the most recently added one. +- // +- // The reason this works is because there's no chance that Solidity includes an entire +- // bytecode (i.e. with metadata), as a prefix of another one. +- if (this._isMatchingMetadata(code, searchResult.depth) && +- searchResult.descendants.length > 0) { +- return searchResult.descendants[searchResult.descendants.length - 1]; +- } +- return undefined; +- } +- /** +- * Returns true if the lastByte is placed right when the metadata starts or after it. +- */ +- _isMatchingMetadata(code, lastByte) { +- for (let byte = 0; byte < lastByte;) { +- const opcode = code[byte]; +- // Solidity always emits REVERT INVALID right before the metadata - if (opcode === opcodes_1.Opcode.REVERT && code[byte + 1] === opcodes_1.Opcode.INVALID) { -+ if (opcode === 253 /* Opcode.REVERT */ && code[byte + 1] === 254 /* Opcode.INVALID */) { - return true; - } - byte += (0, opcodes_1.getOpcodeLength)(opcode); +- return true; +- } +- byte += (0, opcodes_1.getOpcodeLength)(opcode); +- } +- return false; +- } +-} +-exports.ContractsIdentifier = ContractsIdentifier; ++const edr_1 = require("@nomicfoundation/edr"); ++Object.defineProperty(exports, "ContractsIdentifier", { enumerable: true, get: function () { return edr_1.ContractsIdentifier; } }); + //# sourceMappingURL=contracts-identifier.js.map +\ No newline at end of file diff --git a/internal/hardhat-network/stack-traces/contracts-identifier.js.map b/internal/hardhat-network/stack-traces/contracts-identifier.js.map -index ea3db2d854dbfe213045cba3bd985fa9b558747e..db61d48a2093a97f132425d7ad044838ae029ae0 100644 +index ea3db2d854dbfe213045cba3bd985fa9b558747e..d6cda6c576d233bfc0f94c1b1d9e8949c808b813 100644 --- a/internal/hardhat-network/stack-traces/contracts-identifier.js.map +++ b/internal/hardhat-network/stack-traces/contracts-identifier.js.map @@ -1 +1 @@ -{"version":3,"file":"contracts-identifier.js","sourceRoot":"","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C;IACf,CAAC;CACF;AAhJD,kDAgJC"} \ No newline at end of file -+{"version":3,"file":"contracts-identifier.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/contracts-identifier.ts"],"names":[],"mappings":";;;AAAA,sEAA8D;AAE9D,mDAIyB;AAEzB,uCAAoD;AAEpD;;;;GAIG;AACH,MAAM,YAAY;IACT,MAAM,CAAC,cAAc,CAAC,CAAM;QACjC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,EAAE;YACjC,OAAO,KAAK,CAAC;SACd;QAED,OAAO,YAAY,IAAI,CAAC,CAAC;IAC3B,CAAC;IAMD,YAA4B,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;QAJzB,eAAU,GAA8B,IAAI,GAAG,EAAE,CAAC;QAClD,gBAAW,GAAe,EAAE,CAAC;IAGD,CAAC;IAEtC,GAAG,CAAC,QAAkB;QAC3B,4DAA4D;QAC5D,IAAI,QAAQ,GAAiB,IAAI,CAAC;QAClC,KACE,IAAI,eAAe,GAAG,CAAC,EACvB,eAAe,IAAI,QAAQ,CAAC,cAAc,CAAC,MAAM,EACjD,eAAe,IAAI,CAAC,EACpB;YACA,IAAI,eAAe,KAAK,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE;gBACtD,yFAAyF;gBACzF,4FAA4F;gBAC5F,mEAAmE;gBACnE,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC;gBAC1B,OAAO;aACR;YAED,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;YACtD,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAEpC,IAAI,SAAS,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC9C,IAAI,SAAS,KAAK,SAAS,EAAE;gBAC3B,SAAS,GAAG,IAAI,YAAY,CAAC,eAAe,CAAC,CAAC;gBAC9C,QAAQ,CAAC,UAAU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AAC,MAAM,CAAC,CAAC;SACjC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAhJD,kDAgJC"} ++{"version":3,"file":"contracts-identifier.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/contracts-identifier.ts"],"names":[],"mappings":";;;AAAA,8CAA2D;AAClD,oGADA,yBAAmB,OACA"} \ No newline at end of file diff --git a/internal/hardhat-network/stack-traces/debug.js b/internal/hardhat-network/stack-traces/debug.js index d0ee28a6c8f2eb4137e9dd9858b0c806896659b0..fb59aae80924fb451919ee725cc19c564e5f20c7 100644 @@ -788,7 +981,7 @@ index 01d194cc72fe5a33ea86ad45ad28c8d7d507d426..5301d4b464874872ab999f8fb960d5f9 const calledFunction = trace.bytecode.contract.getFunctionFromSelector(trace.calldata.slice(0, 4)); if (calledFunction !== undefined) { - const isValidCalldata = calledFunction.isValidCalldata(trace.calldata.slice(4)); -+ const isValidCalldata = ++ const isValidCalldata = + // if we don't know the param types, we just assume that the call is valid + calledFunction.paramTypes === undefined || + abi_helpers_1.AbiHelpers.isValidCalldata(calledFunction.paramTypes, trace.calldata.slice(4)); @@ -1037,34 +1230,39 @@ index eeba5c914068055d7cd9d7db13a741a02c44a378..0710b8fddb32f9d281fda8af5a17e7cc +{"version":3,"file":"error-inferrer.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/error-inferrer.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAgE;AAChE,4CAA4D;AAC5D,sEAA+D;AAC/D,oDAA4B;AAE5B,8CAA2D;AAC3D,wDAAoD;AACpD,yDAAqD;AAGrD,mDAWyB;AAUzB,uCAAqD;AACrD,iEAgBgC;AAEhC,MAAM,2CAA2C,GAAG,OAAO,CAAC;AAC5D,MAAM,mCAAmC,GAAG,OAAO,CAAC;AACpD,MAAM,wCAAwC,GAAG,OAAO,CAAC;AAQzD,+EAA+E;AAE/E,MAAa,aAAa;IACjB,6BAA6B,CAClC,KAA8B;QAE9B,IAAI,IAAI,CAA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AAS,EAAE;QACtB,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;IAEzB,IAAI,IAAI,CAAC,IAAI,6CAAqC,EAAE;QAClD,QAAQ,GAAG,gDAAyB,CAAC;KACtC;SAAM,IAAI,IAAI,CAAC,IAAI,0CAAkC,EAAE;QACtD,QAAQ,GAAG,6CAAsB,CAAC;KACnC;SAAM,IAAI,IAAI,CAAC,IAAI,yCAAiC,EAAE;QACrD,QAAQ,GAAG,4CAAqB,CAAC;KAClC;IAED,OAAO;QACL,QAAQ,EAAE,QAAQ;QAClB,QAAQ,EACN,IAAI,CAAC,IAAI,+CAAuC;YAC9C,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI;QAC5B,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU;QACzC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO;QACzC,IAAI,EAAE,QAAQ,CAAC,qBAAqB,EAAE;QACtC,KAAK,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;KAC5D,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/internal/hardhat-network/stack-traces/library-utils.d.ts b/internal/hardhat-network/stack-traces/library-utils.d.ts -index 276b7c9d5556f1d7f62ddb07330bfb47f9dfaed8..0d369f51dc42a0fa5cc476ebebcea82660bd9a0d 100644 +index 276b7c9d5556f1d7f62ddb07330bfb47f9dfaed8..39203ae37a9b40e9b87695d3edac78aab5602afe 100644 --- a/internal/hardhat-network/stack-traces/library-utils.d.ts +++ b/internal/hardhat-network/stack-traces/library-utils.d.ts -@@ -1,8 +1,5 @@ +@@ -1,12 +1,3 @@ -/// -import { CompilerOutputBytecode } from "../../../types"; -export declare function getLibraryAddressPositions(bytecodeOutput: CompilerOutputBytecode): number[]; -export declare function normalizeCompilerOutputBytecode(compilerOutputBytecodeObject: string, addressesPositions: number[]): Buffer; -export declare function linkHexStringBytecode(code: string, address: string, position: number): string; -+import { getLibraryAddressPositions, linkHexStringBytecode } from "@nomicfoundation/edr"; -+export { getLibraryAddressPositions, linkHexStringBytecode }; - export declare function zeroOutAddresses(code: Uint8Array, addressesPositions: number[]): Uint8Array; - export declare function zeroOutSlices(code: Uint8Array, slices: Array<{ - start: number; +-export declare function zeroOutAddresses(code: Uint8Array, addressesPositions: number[]): Uint8Array; +-export declare function zeroOutSlices(code: Uint8Array, slices: Array<{ +- start: number; +- length: number; +-}>): Uint8Array; +-export declare function normalizeLibraryRuntimeBytecodeIfNecessary(code: Uint8Array): Uint8Array; ++import { linkHexStringBytecode } from "@nomicfoundation/edr"; ++export { linkHexStringBytecode }; + //# sourceMappingURL=library-utils.d.ts.map +\ No newline at end of file diff --git a/internal/hardhat-network/stack-traces/library-utils.d.ts.map b/internal/hardhat-network/stack-traces/library-utils.d.ts.map -index e152c9c958bb5b68dabe49d4dcde39305e1dae14..b440fa562609d5e98936a361131f3fc5b0de2799 100644 +index e152c9c958bb5b68dabe49d4dcde39305e1dae14..358533b0026ba17c015ea66db6dd35af34be7d3a 100644 --- a/internal/hardhat-network/stack-traces/library-utils.d.ts.map +++ b/internal/hardhat-network/stack-traces/library-utils.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"library-utils.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/library-utils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,sBAAsB,GACrC,MAAM,EAAE,CAWV;AAED,wBAAgB,+BAA+B,CAC7C,4BAA4B,EAAE,MAAM,EACpC,kBAAkB,EAAE,MAAM,EAAE,GAC3B,MAAM,CAWR;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,UAWjB;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAChB,kBAAkB,EAAE,MAAM,EAAE,GAC3B,UAAU,CAOZ;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAC/C,UAAU,CAUZ;AAED,wBAAgB,0CAA0C,CACxD,IAAI,EAAE,UAAU,GACf,UAAU,CAWZ"} \ No newline at end of file -+{"version":3,"file":"library-utils.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/library-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,CAAC;AAE7D,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAChB,kBAAkB,EAAE,MAAM,EAAE,GAC3B,UAAU,CAOZ;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAC/C,UAAU,CAUZ;AAED,wBAAgB,0CAA0C,CACxD,IAAI,EAAE,UAAU,GACf,UAAU,CAWZ"} ++{"version":3,"file":"library-utils.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/library-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,qBAAqB,EAAE,CAAC"} \ No newline at end of file diff --git a/internal/hardhat-network/stack-traces/library-utils.js b/internal/hardhat-network/stack-traces/library-utils.js -index db42dd45000c9fbe8c7210fd3c0f1605d8363ec6..9463287db24ca4c5e4eaf349cfdfe6495814f649 100644 +index db42dd45000c9fbe8c7210fd3c0f1605d8363ec6..fd9d26f8404e650a64a3fb7de66eff108683dc8b 100644 --- a/internal/hardhat-network/stack-traces/library-utils.js +++ b/internal/hardhat-network/stack-traces/library-utils.js -@@ -1,36 +1,9 @@ +@@ -1,65 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.normalizeLibraryRuntimeBytecodeIfNecessary = exports.zeroOutSlices = exports.zeroOutAddresses = exports.linkHexStringBytecode = exports.normalizeCompilerOutputBytecode = exports.getLibraryAddressPositions = void 0; @@ -1098,30 +1296,50 @@ index db42dd45000c9fbe8c7210fd3c0f1605d8363ec6..9463287db24ca4c5e4eaf349cfdfe649 - code.slice(position * 2 + address.length)); -} -exports.linkHexStringBytecode = linkHexStringBytecode; -+exports.normalizeLibraryRuntimeBytecodeIfNecessary = exports.zeroOutSlices = exports.zeroOutAddresses = exports.linkHexStringBytecode = exports.getLibraryAddressPositions = void 0; +-function zeroOutAddresses(code, addressesPositions) { +- const addressesSlices = addressesPositions.map((start) => ({ +- start, +- length: 20, +- })); +- return zeroOutSlices(code, addressesSlices); +-} +-exports.zeroOutAddresses = zeroOutAddresses; +-function zeroOutSlices(code, slices) { +- for (const { start, length } of slices) { +- code = Buffer.concat([ +- code.slice(0, start), +- Buffer.alloc(length, 0), +- code.slice(start + length), +- ]); +- } +- return code; +-} +-exports.zeroOutSlices = zeroOutSlices; +-function normalizeLibraryRuntimeBytecodeIfNecessary(code) { +- // Libraries' protection normalization: +- // Solidity 0.4.20 introduced a protection to prevent libraries from being called directly. +- // This is done by modifying the code on deployment, and hard-coding the contract address. +- // The first instruction is a PUSH20 of the address, which we zero-out as a way of normalizing +- // it. Note that it's also zeroed-out in the compiler output. +- if (code[0] === opcodes_1.Opcode.PUSH20) { +- return zeroOutAddresses(code, [1]); +- } +- return code; +-} +-exports.normalizeLibraryRuntimeBytecodeIfNecessary = normalizeLibraryRuntimeBytecodeIfNecessary; ++exports.linkHexStringBytecode = void 0; +const edr_1 = require("@nomicfoundation/edr"); -+Object.defineProperty(exports, "getLibraryAddressPositions", { enumerable: true, get: function () { return edr_1.getLibraryAddressPositions; } }); +Object.defineProperty(exports, "linkHexStringBytecode", { enumerable: true, get: function () { return edr_1.linkHexStringBytecode; } }); - function zeroOutAddresses(code, addressesPositions) { - const addressesSlices = addressesPositions.map((start) => ({ - start, -@@ -56,7 +29,7 @@ function normalizeLibraryRuntimeBytecodeIfNecessary(code) { - // This is done by modifying the code on deployment, and hard-coding the contract address. - // The first instruction is a PUSH20 of the address, which we zero-out as a way of normalizing - // it. Note that it's also zeroed-out in the compiler output. -- if (code[0] === opcodes_1.Opcode.PUSH20) { -+ if (code[0] === 115 /* Opcode.PUSH20 */) { - return zeroOutAddresses(code, [1]); - } - return code; + //# sourceMappingURL=library-utils.js.map +\ No newline at end of file diff --git a/internal/hardhat-network/stack-traces/library-utils.js.map b/internal/hardhat-network/stack-traces/library-utils.js.map -index 20ac80eaddd2143758710ce259d5d7884abceaf5..5b6b56da5c8fd4da8d0f76c2dc42a0b5cfdc744c 100644 +index 20ac80eaddd2143758710ce259d5d7884abceaf5..6d25b62e5639cd34c35adcae5219b681f558f73a 100644 --- a/internal/hardhat-network/stack-traces/library-utils.js.map +++ b/internal/hardhat-network/stack-traces/library-utils.js.map @@ -1 +1 @@ -{"version":3,"file":"library-utils.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/library-utils.ts"],"names":[],"mappings":";;;AAEA,uCAAmC;AAEnC,SAAgB,0BAA0B,CACxC,cAAsC;IAEtC,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE;QAC/D,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC5C,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;gBAC5B,SA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CAAC,MAAM,CAAC;YACnB,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;YACpB,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;SAC3B,CAAC,CAAC;KACJ;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAbD,sCAaC;AAED,SAAgB,0CAA0C,CACxD,IAAgB;IAEhB,uCAAuC;IACvC,2FAA2F;IAC3F,0FAA0F;IAC1F,8FAA8F;IAC9F,6DAA6D;IAC7D,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,gBAAM,CAAC,MAAM,EAAE;QAC7B,OAAO,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;KACpC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAbD,gGAaC"} \ No newline at end of file -+{"version":3,"file":"library-utils.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/library-utils.ts"],"names":[],"mappings":";;;AAAA,8CAG8B;AAGrB,2GALP,gCAA0B,OAKO;AAAE,sGAJnC,2BAAqB,OAImC;AAE1D,SAAgB,gBAAgB,CAC9B,IAAgB,EAChB,kBAA4B;IAE5B,MAAM,eAAe,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACzD,KAAK;QACL,MAAM,EAAE,EAAE;KACX,CAAC,CAAC,CAAC;IAEJ,OAAO,aAAa,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AAC9C,CAAC;AAVD,4CAUC;AAED,SAAgB,aAAa,CAC3B,IAAgB,EAChB,MAAgD;IAEhD,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,MAAM,EAAE;QACtC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;YACnB,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;YACpB,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;SAC3B,CAAC,CAAC;KACJ;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAbD,sCAaC;AAED,SAAgB,0CAA0C,CACxD,IAAgB;IAEhB,uCAAuC;IACvC,2FAA2F;IAC3F,0FAA0F;IAC1F,8FAA8F;IAC9F,6DAA6D;IAC7D,IAAI,IAAI,CAAC,CAAC,CAAC,4BAAkB,EAAE;QAC7B,OAAO,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;KACpC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAbD,gGAaC"} ++{"version":3,"file":"library-utils.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/library-utils.ts"],"names":[],"mappings":";;;AAAA,8CAA6D;AAEpD,sGAFA,2BAAqB,OAEA"} \ No newline at end of file diff --git a/internal/hardhat-network/stack-traces/mapped-inlined-internal-functions-heuristics.js b/internal/hardhat-network/stack-traces/mapped-inlined-internal-functions-heuristics.js index 8783fd3bc38c59336b3e40ec8df9ea2bd31a53dd..0cfa46d222ce243f2ea9cea24d9b88a3f8e95ec2 100644 @@ -1750,7 +1968,7 @@ index aec9e57266d011c7adadcd635625b258d29e0da5..b47eda32725b35c38662665b0b5cc205 +{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/model.ts"],"names":[],"mappings":";;;AAAA,8CAa8B;AAG5B,iGAfA,sBAAgB,OAeA;AAChB,+FAfA,oBAAc,OAeA;AACd,2FAfA,gBAAU,OAeA;AAGV,4FAfA,iBAAW,OAeA;AACX,4FAfA,iBAAW,OAeA;AAEX,iGAfA,sBAAgB,OAeA;AAChB,yFAfA,cAAQ,OAeA;AAER,yFAfA,cAAQ,OAeA"} \ No newline at end of file diff --git a/internal/hardhat-network/stack-traces/opcodes.d.ts b/internal/hardhat-network/stack-traces/opcodes.d.ts -index c976b094bdd241f713bb794c3feda83451189ee9..d2b13eb1b99a3f4bfe1f61f73323ef7e7dd9dcae 100644 +index c976b094bdd241f713bb794c3feda83451189ee9..24bab4900ca849abfd07cae9fbf96bf55bc7e498 100644 --- a/internal/hardhat-network/stack-traces/opcodes.d.ts +++ b/internal/hardhat-network/stack-traces/opcodes.d.ts @@ -1,266 +1,2 @@ @@ -2019,23 +2237,23 @@ index c976b094bdd241f713bb794c3feda83451189ee9..d2b13eb1b99a3f4bfe1f61f73323ef7e -export declare function getOpcodeLength(opcode: Opcode): number; -export declare function isCall(opcode: Opcode): boolean; -export declare function isCreate(opcode: Opcode): boolean; -+export { Opcode, isPush, isJump, getPushLength, getOpcodeLength, isCall, isCreate, opcodeToString, } from "@nomicfoundation/edr"; ++export { Opcode, isPush, isJump, isCall, isCreate, opcodeToString, } from "@nomicfoundation/edr"; //# sourceMappingURL=opcodes.d.ts.map \ No newline at end of file diff --git a/internal/hardhat-network/stack-traces/opcodes.d.ts.map b/internal/hardhat-network/stack-traces/opcodes.d.ts.map -index 33143d06969570a0f445630c2ef43ad0bd72e4ec..d8f7ea70232fd8dbe0b27bcacda9073fc95e5280 100644 +index 33143d06969570a0f445630c2ef43ad0bd72e4ec..4494584f86773b51f4b562091f4a5000e454b2f8 100644 --- a/internal/hardhat-network/stack-traces/opcodes.d.ts.map +++ b/internal/hardhat-network/stack-traces/opcodes.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"opcodes.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/opcodes.ts"],"names":[],"mappings":"AAAA,oBAAY,MAAM;IAEhB,IAAI,IAAO;IACX,GAAG,IAAO;IACV,GAAG,IAAO;IACV,GAAG,IAAO;IACV,GAAG,IAAO;IACV,IAAI,IAAO;IACX,GAAG,IAAO;IACV,IAAI,IAAO;IACX,MAAM,IAAO;IACb,MAAM,IAAO;IACb,GAAG,KAAO;IACV,UAAU,KAAO;IAGjB,eAAe,KAAO;IACt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,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IAEtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IAGtB,MAAM,MAAO;IACb,IAAI,MAAO;IACX,QAAQ,MAAO;IACf,MAAM,MAAO;IACb,YAAY,MAAO;IACnB,OAAO,MAAO;IAGd,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IAGtB,UAAU,MAAO;IAGjB,eAAe,MAAO;IACtB,eAAe,MAAO;IAGtB,MAAM,MAAO;IACb,OAAO,MAAO;IACd,YAAY,MAAO;CACpB;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,WAEpC;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,WAEpC;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,UAE3C;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,UAM7C;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,WAOpC;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,WAEtC"} \ No newline at end of file -+{"version":3,"file":"opcodes.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/opcodes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,MAAM,EACN,aAAa,EACb,eAAe,EACf,MAAM,EACN,QAAQ,EACR,cAAc,GACf,MAAM,sBAAsB,CAAC"} ++{"version":3,"file":"opcodes.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/opcodes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,cAAc,GACf,MAAM,sBAAsB,CAAC"} \ No newline at end of file diff --git a/internal/hardhat-network/stack-traces/opcodes.js b/internal/hardhat-network/stack-traces/opcodes.js -index 79a21c15b4540522c70969d961b53afe420a13de..ea3936d11ebfb882f20dd196f81a511caf5b7028 100644 +index 79a21c15b4540522c70969d961b53afe420a13de..5116b30d70bad4df43859109a6f26685dd0e9864 100644 --- a/internal/hardhat-network/stack-traces/opcodes.js +++ b/internal/hardhat-network/stack-traces/opcodes.js -@@ -1,320 +1,12 @@ +@@ -1,320 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isCreate = exports.isCall = exports.getOpcodeLength = exports.getPushLength = exports.isJump = exports.isPush = exports.opcodeName = exports.Opcode = void 0; @@ -2355,25 +2573,23 @@ index 79a21c15b4540522c70969d961b53afe420a13de..ea3936d11ebfb882f20dd196f81a511c - return opcode === Opcode.CREATE || opcode === Opcode.CREATE2; -} -exports.isCreate = isCreate; -+exports.opcodeToString = exports.isCreate = exports.isCall = exports.getOpcodeLength = exports.getPushLength = exports.isJump = exports.isPush = void 0; ++exports.opcodeToString = exports.isCreate = exports.isCall = exports.isJump = exports.isPush = void 0; +var edr_1 = require("@nomicfoundation/edr"); +Object.defineProperty(exports, "isPush", { enumerable: true, get: function () { return edr_1.isPush; } }); +Object.defineProperty(exports, "isJump", { enumerable: true, get: function () { return edr_1.isJump; } }); -+Object.defineProperty(exports, "getPushLength", { enumerable: true, get: function () { return edr_1.getPushLength; } }); -+Object.defineProperty(exports, "getOpcodeLength", { enumerable: true, get: function () { return edr_1.getOpcodeLength; } }); +Object.defineProperty(exports, "isCall", { enumerable: true, get: function () { return edr_1.isCall; } }); +Object.defineProperty(exports, "isCreate", { enumerable: true, get: function () { return edr_1.isCreate; } }); +Object.defineProperty(exports, "opcodeToString", { enumerable: true, get: function () { return edr_1.opcodeToString; } }); //# sourceMappingURL=opcodes.js.map \ No newline at end of file diff --git a/internal/hardhat-network/stack-traces/opcodes.js.map b/internal/hardhat-network/stack-traces/opcodes.js.map -index 9a8272264f21d996492dc1efdeddf2619211adc1..c572f64326e70d71e7efb9cecba0f007e7679213 100644 +index 9a8272264f21d996492dc1efdeddf2619211adc1..23ca8748ee87ec1b5e77b525f7c40bb551f7e2c0 100644 --- a/internal/hardhat-network/stack-traces/opcodes.js.map +++ b/internal/hardhat-network/stack-traces/opcodes.js.map @@ -1 +1 @@ -{"version":3,"file":"opcodes.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/opcodes.ts"],"names":[],"mappings":";;;AAAA,IAAY,MAkTX;AAlTD,WAAY,MAAM;IAChB,wBAAwB;IACxB,mCAAW,CAAA;IACX,iCAAU,CAAA;IACV,iCAAU,CAAA;IACV,iCAAU,CAAA;IACV,iCAAU,CAAA;IACV,mCAAW,CAAA;IACX,iCAAU,CAAA;IACV,mCAAW,CAAA;IACX,uCAAa,CAAA;IACb,uCAAa,CAAA;IACb,kCAAU,CAAA;IACV,gDAAiB,CAAA;IAEjB,cAAc;IACd,0DAAsB,CAAA;IACtB,0DAAsB,CAAA;IACtB,0DAAsB,CAAA;IACtB,0DAAsB,CAAA;IAEtB,oCAAoC;IACpC,gCAAS,CAAA;IACT,gCAAS,CAAA;IACT,kCAAU,CAAA;IACV,kCAAU,CAAA;IACV,gCAAS,CAAA;IACT,wCAAa,CAAA;IACb,kCAAU,CAAA;IACV,gCAAS,CAAA;IACT,kCAAU,CAAA;IACV,kCAAU,CAAA;IACV,oCAAW,CAAA;IACX,kCAAU,CAAA;IACV,kCAAU,CAAA;IACV,kCAAU,CAAA;IAEV,cAAc;IACd,0DAAsB,CAAA;IACtB,0DAAsB,CAAA;IAEtB,2BAA2B;IAC3B,oCAAW,CAAA;IAEX,cAAc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C;AAED,SAAgB,MAAM,CAAC,MAAc;IACnC,OAAO,MAAM,KAAK,MAAM,CAAC,IAAI,IAAI,MAAM,KAAK,MAAM,CAAC,KAAK,CAAC;AAC3D,CAAC;AAFD,wBAEC;AAED,SAAgB,aAAa,CAAC,MAAc;IAC1C,OAAO,MAAM,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;AACnC,CAAC;AAFD,sCAEC;AAED,SAAgB,eAAe,CAAC,MAAc;IAC5C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QACnB,OAAO,CAAC,CAAC;KACV;IAED,OAAO,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC;AAND,0CAMC;AAED,SAAgB,MAAM,CAAC,MAAc;IACnC,OAAO,CACL,MAAM,KAAK,MAAM,CAAC,IAAI;QACtB,MAAM,KAAK,MAAM,CAAC,QAAQ;QAC1B,MAAM,KAAK,MAAM,CAAC,YAAY;QAC9B,MAAM,KAAK,MAAM,CAAC,UAAU,CAC7B,CAAC;AACJ,CAAC;AAPD,wBAOC;AAED,SAAgB,QAAQ,CAAC,MAAc;IACrC,OAAO,MAAM,KAAK,MAAM,CAAC,MAAM,IAAI,MAAM,KAAK,MAAM,CAAC,OAAO,CAAC;AAC/D,CAAC;AAFD,4BAEC"} \ No newline at end of file -+{"version":3,"file":"opcodes.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/opcodes.ts"],"names":[],"mappings":";;;AAAA,4CAS8B;AAP5B,6FAAA,MAAM,OAAA;AACN,6FAAA,MAAM,OAAA;AACN,oGAAA,aAAa,OAAA;AACb,sGAAA,eAAe,OAAA;AACf,6FAAA,MAAM,OAAA;AACN,+FAAA,QAAQ,OAAA;AACR,qGAAA,cAAc,OAAA"} ++{"version":3,"file":"opcodes.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/stack-traces/opcodes.ts"],"names":[],"mappings":";;;AAAA,4CAO8B;AAL5B,6FAAA,MAAM,OAAA;AACN,6FAAA,MAAM,OAAA;AACN,6FAAA,MAAM,OAAA;AACN,+FAAA,QAAQ,OAAA;AACR,qGAAA,cAAc,OAAA"} \ No newline at end of file diff --git a/internal/hardhat-network/stack-traces/solidityTracer.js b/internal/hardhat-network/stack-traces/solidityTracer.js index 08f4e6bf80b81fed910dccc3052b9c886fd0338e..0d6416f3fdedcec4f91a63321e935e91e982aa2d 100644 @@ -2704,7 +2920,7 @@ index 4f1197ec3e27c8e0584276629b6783add9687573..647237545b1920df6bf24b55511b4533 enableTransientStorage: boolean; + enableRip7212: boolean; } - + export function getNodeConfig( @@ -256,6 +257,7 @@ export class EdrProviderWrapper }), @@ -2722,7 +2938,7 @@ index 4f1197ec3e27c8e0584276629b6783add9687573..647237545b1920df6bf24b55511b4533 + + // For other consumers in JS we need to marshall the entire trace over FFI const trace = rawTrace.trace(); - + // beforeTx event @@ -383,8 +388,6 @@ export class EdrProviderWrapper edrTracingStepToMinimalInterpreterStep(traceItem) @@ -2750,7 +2966,7 @@ index 4f1197ec3e27c8e0584276629b6783add9687573..647237545b1920df6bf24b55511b4533 - this._vmTracer?.addBeforeMessage(traceItem); } } - + @@ -577,17 +576,7 @@ export class EdrProviderWrapper rawTrace: RawTrace ): Promise { @@ -2767,7 +2983,7 @@ index 4f1197ec3e27c8e0584276629b6783add9687573..647237545b1920df6bf24b55511b4533 - } - } + vmTracer.observe(rawTrace); - + let vmTrace = vmTracer.getLastTopLevelMessageTrace(); const vmTracerError = vmTracer.getLastError(); diff --git a/src/internal/hardhat-network/provider/vm/exit.ts b/src/internal/hardhat-network/provider/vm/exit.ts @@ -3576,6 +3792,248 @@ index e801691fe54b61794278083d0b802cdd05bb98fb..63bbf517f1e62e1e1dfeba76b4df7aaa - } -} +export { createModelsAndDecodeBytecodes } from "@nomicfoundation/edr"; +diff --git a/src/internal/hardhat-network/stack-traces/contracts-identifier.ts b/src/internal/hardhat-network/stack-traces/contracts-identifier.ts +index 7a479a62cfad681807b6408449458dfcd6960fe7..0f176f37fa6994a051065364d584f22a6b1a0f85 100644 +--- a/src/internal/hardhat-network/stack-traces/contracts-identifier.ts ++++ b/src/internal/hardhat-network/stack-traces/contracts-identifier.ts +@@ -1,235 +1,2 @@ +-import { bytesToHex } from "@nomicfoundation/ethereumjs-util"; +- +-import { +- normalizeLibraryRuntimeBytecodeIfNecessary, +- zeroOutAddresses, +- zeroOutSlices, +-} from "./library-utils"; +-import { Bytecode } from "./model"; +-import { getOpcodeLength, Opcode } from "./opcodes"; +- +-/** +- * This class represent a somewhat special Trie of bytecodes. +- * +- * What makes it special is that every node has a set of all of its descendants and its depth. +- */ +-class BytecodeTrie { +- public static isBytecodeTrie(o: any): o is BytecodeTrie { +- if (o === undefined || o === null) { +- return false; +- } +- +- return "childNodes" in o; +- } +- +- public readonly childNodes: Map = new Map(); +- public readonly descendants: Bytecode[] = []; +- public match?: Bytecode; +- +- constructor(public readonly depth: number) {} +- +- public add(bytecode: Bytecode) { +- // eslint-disable-next-line @typescript-eslint/no-this-alias +- let trieNode: BytecodeTrie = this; +- for ( +- let currentCodeByte = 0; +- currentCodeByte <= bytecode.normalizedCode.length; +- currentCodeByte += 1 +- ) { +- if (currentCodeByte === bytecode.normalizedCode.length) { +- // If multiple contracts with the exact same bytecode are added we keep the last of them. +- // Note that this includes the metadata hash, so the chances of happening are pretty remote, +- // except in super artificial cases that we have in our test suite. +- trieNode.match = bytecode; +- return; +- } +- +- const byte = bytecode.normalizedCode[currentCodeByte]; +- trieNode.descendants.push(bytecode); +- +- let childNode = trieNode.childNodes.get(byte); +- if (childNode === undefined) { +- childNode = new BytecodeTrie(currentCodeByte); +- trieNode.childNodes.set(byte, childNode); +- } +- +- trieNode = childNode; +- } +- } +- +- /** +- * Searches for a bytecode. If it's an exact match, it is returned. If there's no match, but a +- * prefix of the code is found in the trie, the node of the longest prefix is returned. If the +- * entire code is covered by the trie, and there's no match, we return undefined. +- */ +- public search( +- code: Uint8Array, +- currentCodeByte: number = 0 +- ): Bytecode | BytecodeTrie | undefined { +- if (currentCodeByte > code.length) { +- return undefined; +- } +- +- // eslint-disable-next-line @typescript-eslint/no-this-alias +- let trieNode: BytecodeTrie = this; +- for (; currentCodeByte <= code.length; currentCodeByte += 1) { +- if (currentCodeByte === code.length) { +- return trieNode.match; +- } +- +- const childNode = trieNode.childNodes.get(code[currentCodeByte]); +- +- if (childNode === undefined) { +- return trieNode; +- } +- +- trieNode = childNode; +- } +- } +-} +- +-export class ContractsIdentifier { +- private _trie = new BytecodeTrie(-1); +- private _cache: Map = new Map(); +- +- constructor(private readonly _enableCache = true) {} +- +- public addBytecode(bytecode: Bytecode) { +- this._trie.add(bytecode); +- this._cache.clear(); +- } +- +- public getBytecodeForCall( +- code: Uint8Array, +- isCreate: boolean +- ): Bytecode | undefined { +- const normalizedCode = normalizeLibraryRuntimeBytecodeIfNecessary(code); +- +- let normalizedCodeHex: string | undefined; +- if (this._enableCache) { +- normalizedCodeHex = bytesToHex(normalizedCode); +- const cached = this._cache.get(normalizedCodeHex); +- +- if (cached !== undefined) { +- return cached; +- } +- } +- +- const result = this._searchBytecode(isCreate, normalizedCode); +- +- if (this._enableCache) { +- if (result !== undefined) { +- this._cache.set(normalizedCodeHex!, result); +- } +- } +- +- return result; +- } +- +- private _searchBytecode( +- isCreate: boolean, +- code: Uint8Array, +- normalizeLibraries = true, +- trie = this._trie, +- firstByteToSearch = 0 +- ): Bytecode | undefined { +- const searchResult = trie.search(code, firstByteToSearch); +- +- if (searchResult === undefined) { +- return undefined; +- } +- +- if (!BytecodeTrie.isBytecodeTrie(searchResult)) { +- return searchResult; +- } +- +- // Deployment messages have their abi-encoded arguments at the end of the bytecode. +- // +- // We don't know how long those arguments are, as we don't know which contract is being +- // deployed, hence we don't know the signature of its constructor. +- // +- // To make things even harder, we can't trust that the user actually passed the right +- // amount of arguments. +- // +- // Luckily, the chances of a complete deployment bytecode being the prefix of another one are +- // remote. For example, most of the time it ends with its metadata hash, which will differ. +- // +- // We take advantage of this last observation, and just return the bytecode that exactly +- // matched the searchResult (sub)trie that we got. +- if ( +- isCreate && +- searchResult.match !== undefined && +- searchResult.match.isDeployment +- ) { +- return searchResult.match; +- } +- +- if (normalizeLibraries) { +- for (const bytecodeWithLibraries of searchResult.descendants) { +- if ( +- bytecodeWithLibraries.libraryAddressPositions.length === 0 && +- bytecodeWithLibraries.immutableReferences.length === 0 +- ) { +- continue; +- } +- +- const normalizedLibrariesCode = zeroOutAddresses( +- code, +- bytecodeWithLibraries.libraryAddressPositions +- ); +- +- const normalizedCode = zeroOutSlices( +- normalizedLibrariesCode, +- bytecodeWithLibraries.immutableReferences +- ); +- +- const normalizedResult = this._searchBytecode( +- isCreate, +- normalizedCode, +- false, +- searchResult, +- searchResult.depth + 1 +- ); +- +- if (normalizedResult !== undefined) { +- return normalizedResult; +- } +- } +- } +- +- // If we got here we may still have the contract, but with a different metadata hash. +- // +- // We check if we got to match the entire executable bytecode, and are just stuck because +- // of the metadata. If that's the case, we can assume that any descendant will be a valid +- // Bytecode, so we just choose the most recently added one. +- // +- // The reason this works is because there's no chance that Solidity includes an entire +- // bytecode (i.e. with metadata), as a prefix of another one. +- if ( +- this._isMatchingMetadata(code, searchResult.depth) && +- searchResult.descendants.length > 0 +- ) { +- return searchResult.descendants[searchResult.descendants.length - 1]; +- } +- +- return undefined; +- } +- +- /** +- * Returns true if the lastByte is placed right when the metadata starts or after it. +- */ +- private _isMatchingMetadata(code: Uint8Array, lastByte: number): boolean { +- for (let byte = 0; byte < lastByte; ) { +- const opcode = code[byte]; +- +- // Solidity always emits REVERT INVALID right before the metadata +- if (opcode === Opcode.REVERT && code[byte + 1] === Opcode.INVALID) { +- return true; +- } +- +- byte += getOpcodeLength(opcode); +- } +- +- return false; +- } +-} ++import { ContractsIdentifier } from "@nomicfoundation/edr"; ++export { ContractsIdentifier }; diff --git a/src/internal/hardhat-network/stack-traces/debug.ts b/src/internal/hardhat-network/stack-traces/debug.ts index 03c423f31895ca495059bba42b5568ea10cbaeb7..fb848f6396ca13128d445a532845adcca050c6de 100644 --- a/src/internal/hardhat-network/stack-traces/debug.ts @@ -3598,7 +4056,7 @@ index 03c423f31895ca495059bba42b5568ea10cbaeb7..fb848f6396ca13128d445a532845adcc - ? chalk.bold(`(${JumpType[inst.jumpType]})`) + ? chalk.bold(`(${jumpTypeToString(inst.jumpType)})`) : ""; - + console.log( - `${margin} ${pc} ${Opcode[inst.opcode]} ${jump}`.padEnd(50), + `${margin} ${pc} ${opcodeToString(inst.opcode)} ${jump}`.padEnd(50), @@ -3625,7 +4083,7 @@ index e185841f421641b2fe9a7fa34aeaf7b0813723cb..95698cada44b39bf4f1c591b7a8ef6f5 +++ b/src/internal/hardhat-network/stack-traces/error-inferrer.ts @@ -641,9 +641,13 @@ export class ErrorInferrer { ); - + if (calledFunction !== undefined) { - const isValidCalldata = calledFunction.isValidCalldata( - trace.calldata.slice(4) @@ -3637,22 +4095,19 @@ index e185841f421641b2fe9a7fa34aeaf7b0813723cb..95698cada44b39bf4f1c591b7a8ef6f5 + calledFunction.paramTypes, + trace.calldata.slice(4) + ); - + if (!isValidCalldata) { return [ diff --git a/src/internal/hardhat-network/stack-traces/library-utils.ts b/src/internal/hardhat-network/stack-traces/library-utils.ts -index 9f45bebdcde3092695f44efcd3e6b06222d344bb..8538a24e5a46ff577f9342fbe7fb3ef484fb98cd 100644 +index 9f45bebdcde3092695f44efcd3e6b06222d344bb..de1a0538791e8653a788ba02fd1e006cb8501ef9 100644 --- a/src/internal/hardhat-network/stack-traces/library-utils.ts +++ b/src/internal/hardhat-network/stack-traces/library-utils.ts -@@ -1,53 +1,10 @@ +@@ -1,92 +1,3 @@ -import { CompilerOutputBytecode } from "../../../types"; ++import { linkHexStringBytecode } from "@nomicfoundation/edr"; + +-import { Opcode } from "./opcodes"; - -+import { -+ getLibraryAddressPositions, -+ linkHexStringBytecode, -+} from "@nomicfoundation/edr"; - import { Opcode } from "./opcodes"; - -export function getLibraryAddressPositions( - bytecodeOutput: CompilerOutputBytecode -): number[] { @@ -3699,10 +4154,49 @@ index 9f45bebdcde3092695f44efcd3e6b06222d344bb..8538a24e5a46ff577f9342fbe7fb3ef4 - code.slice(position * 2 + address.length) - ); -} -+export { getLibraryAddressPositions, linkHexStringBytecode }; - - export function zeroOutAddresses( - code: Uint8Array, +- +-export function zeroOutAddresses( +- code: Uint8Array, +- addressesPositions: number[] +-): Uint8Array { +- const addressesSlices = addressesPositions.map((start) => ({ +- start, +- length: 20, +- })); +- +- return zeroOutSlices(code, addressesSlices); +-} +- +-export function zeroOutSlices( +- code: Uint8Array, +- slices: Array<{ start: number; length: number }> +-): Uint8Array { +- for (const { start, length } of slices) { +- code = Buffer.concat([ +- code.slice(0, start), +- Buffer.alloc(length, 0), +- code.slice(start + length), +- ]); +- } +- +- return code; +-} +- +-export function normalizeLibraryRuntimeBytecodeIfNecessary( +- code: Uint8Array +-): Uint8Array { +- // Libraries' protection normalization: +- // Solidity 0.4.20 introduced a protection to prevent libraries from being called directly. +- // This is done by modifying the code on deployment, and hard-coding the contract address. +- // The first instruction is a PUSH20 of the address, which we zero-out as a way of normalizing +- // it. Note that it's also zeroed-out in the compiler output. +- if (code[0] === Opcode.PUSH20) { +- return zeroOutAddresses(code, [1]); +- } +- +- return code; +-} ++export { linkHexStringBytecode }; diff --git a/src/internal/hardhat-network/stack-traces/message-trace.ts b/src/internal/hardhat-network/stack-traces/message-trace.ts index ddfe86ce4d1ff90969db10bc6bd1f0f6667a5715..f4da68574666d43e9c0494e00db3f6415b23d086 100644 --- a/src/internal/hardhat-network/stack-traces/message-trace.ts @@ -3720,7 +4214,7 @@ index ddfe86ce4d1ff90969db10bc6bd1f0f6667a5715..f4da68574666d43e9c0494e00db3f641 + CreateMessageTrace, + CallMessageTrace, } from "@nomicfoundation/edr"; - + +export { PrecompileMessageTrace, CreateMessageTrace, CallMessageTrace }; + export type MessageTrace = @@ -3729,7 +4223,7 @@ index ddfe86ce4d1ff90969db10bc6bd1f0f6667a5715..f4da68574666d43e9c0494e00db3f641 @@ -19,38 +23,6 @@ export type DecodedEvmMessageTrace = | DecodedCreateMessageTrace | DecodedCallMessageTrace; - + -export interface BaseMessageTrace { - value: bigint; - returnData: Uint8Array; @@ -4209,10 +4703,10 @@ index 534ae112a663f90fce98e68efca01db3d391c96f..c8c58387f660815730ddfc5b49f0d3cc + Contract, +}; diff --git a/src/internal/hardhat-network/stack-traces/opcodes.ts b/src/internal/hardhat-network/stack-traces/opcodes.ts -index e0602c17fb8c0c48b740d5e6bb8925cfaba67740..52a10924b4fdba9dea211c0ddeb1910e7cf46c02 100644 +index e0602c17fb8c0c48b740d5e6bb8925cfaba67740..54329f2587d8cb398d7567840ce7295f68428358 100644 --- a/src/internal/hardhat-network/stack-traces/opcodes.ts +++ b/src/internal/hardhat-network/stack-traces/opcodes.ts -@@ -1,344 +1,10 @@ +@@ -1,344 +1,8 @@ -export enum Opcode { - // Arithmetic operations - STOP = 0x00, @@ -4561,8 +5055,6 @@ index e0602c17fb8c0c48b740d5e6bb8925cfaba67740..52a10924b4fdba9dea211c0ddeb1910e + Opcode, + isPush, + isJump, -+ getPushLength, -+ getOpcodeLength, + isCall, + isCreate, + opcodeToString, @@ -4795,7 +5287,7 @@ index 3f53d4b3a181af665a91ff6d562edd090ad7a5e7..027a3a5f064654026921f939e6550f6e enableTransientStorage?: boolean; + enableRip7212?: boolean; } - + export type HardhatNetworkAccountsUserConfig = @@ -155,6 +156,7 @@ export interface HardhatNetworkConfig { chains: HardhatNetworkChainsConfig; @@ -4803,7 +5295,7 @@ index 3f53d4b3a181af665a91ff6d562edd090ad7a5e7..027a3a5f064654026921f939e6550f6e enableTransientStorage?: boolean; + enableRip7212?: boolean; } - + export type HardhatNetworkAccountsConfig = diff --git a/types/config.d.ts b/types/config.d.ts index 935aea29d60a4e7b3ff69a1f6b6ecc5ebabbd926..53f3ffb7dbdce8a90c2137a2b9960c1f9bd713b7 100644 diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 23a83e1e2..c5ba85920 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,7 +9,7 @@ overrides: patchedDependencies: hardhat@2.22.6: - hash: q3nnrfsdmjujtkscve3dm62mmu + hash: 2xv63rgn6ejog2ah3azyw26aiy path: patches/hardhat@2.22.6.patch importers: @@ -66,7 +66,7 @@ importers: version: 4.4.1 hardhat: specifier: 2.22.6 - version: 2.22.6(patch_hash=q3nnrfsdmjujtkscve3dm62mmu)(ts-node@10.9.2(@types/node@18.15.13)(typescript@5.0.4))(typescript@5.0.4) + version: 2.22.6(patch_hash=2xv63rgn6ejog2ah3azyw26aiy)(ts-node@10.9.2(@types/node@18.15.13)(typescript@5.0.4))(typescript@5.0.4) lodash: specifier: ^4.17.11 version: 4.17.21 @@ -186,7 +186,7 @@ importers: version: 7.0.1 hardhat: specifier: 2.22.6 - version: 2.22.6(patch_hash=q3nnrfsdmjujtkscve3dm62mmu)(ts-node@10.9.2(@types/node@18.15.13)(typescript@5.0.4))(typescript@5.0.4) + version: 2.22.6(patch_hash=2xv63rgn6ejog2ah3azyw26aiy)(ts-node@10.9.2(@types/node@18.15.13)(typescript@5.0.4))(typescript@5.0.4) mocha: specifier: ^10.0.0 version: 10.3.0 @@ -216,10 +216,10 @@ importers: devDependencies: '@defi-wonderland/smock': specifier: ^2.4.0 - version: 2.4.0(@ethersproject/abi@5.7.0)(@ethersproject/abstract-provider@5.7.0)(@ethersproject/abstract-signer@5.7.0)(@nomiclabs/hardhat-ethers@2.2.3(ethers@5.7.2)(hardhat@2.22.6(patch_hash=q3nnrfsdmjujtkscve3dm62mmu)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4)))(ethers@5.7.2)(hardhat@2.22.6(patch_hash=q3nnrfsdmjujtkscve3dm62mmu)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4)) + version: 2.4.0(@ethersproject/abi@5.7.0)(@ethersproject/abstract-provider@5.7.0)(@ethersproject/abstract-signer@5.7.0)(@nomiclabs/hardhat-ethers@2.2.3(ethers@5.7.2)(hardhat@2.22.6(patch_hash=2xv63rgn6ejog2ah3azyw26aiy)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4)))(ethers@5.7.2)(hardhat@2.22.6(patch_hash=2xv63rgn6ejog2ah3azyw26aiy)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4)) '@nomiclabs/hardhat-ethers': specifier: ^2.2.3 - version: 2.2.3(ethers@5.7.2)(hardhat@2.22.6(patch_hash=q3nnrfsdmjujtkscve3dm62mmu)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4)) + version: 2.2.3(ethers@5.7.2)(hardhat@2.22.6(patch_hash=2xv63rgn6ejog2ah3azyw26aiy)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4)) chai: specifier: ^4.3.6 version: 4.4.1 @@ -228,7 +228,7 @@ importers: version: 5.7.2 hardhat: specifier: 2.22.6 - version: 2.22.6(patch_hash=q3nnrfsdmjujtkscve3dm62mmu)(ts-node@10.9.2(@types/node@18.15.13)(typescript@5.0.4))(typescript@5.0.4) + version: 2.22.6(patch_hash=2xv63rgn6ejog2ah3azyw26aiy)(ts-node@10.9.2(@types/node@18.15.13)(typescript@5.0.4))(typescript@5.0.4) mocha: specifier: ^10.0.0 version: 10.3.0 @@ -3082,16 +3082,16 @@ snapshots: dependencies: '@jridgewell/trace-mapping': 0.3.9 - '@defi-wonderland/smock@2.4.0(@ethersproject/abi@5.7.0)(@ethersproject/abstract-provider@5.7.0)(@ethersproject/abstract-signer@5.7.0)(@nomiclabs/hardhat-ethers@2.2.3(ethers@5.7.2)(hardhat@2.22.6(patch_hash=q3nnrfsdmjujtkscve3dm62mmu)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4)))(ethers@5.7.2)(hardhat@2.22.6(patch_hash=q3nnrfsdmjujtkscve3dm62mmu)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4))': + '@defi-wonderland/smock@2.4.0(@ethersproject/abi@5.7.0)(@ethersproject/abstract-provider@5.7.0)(@ethersproject/abstract-signer@5.7.0)(@nomiclabs/hardhat-ethers@2.2.3(ethers@5.7.2)(hardhat@2.22.6(patch_hash=2xv63rgn6ejog2ah3azyw26aiy)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4)))(ethers@5.7.2)(hardhat@2.22.6(patch_hash=2xv63rgn6ejog2ah3azyw26aiy)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4))': dependencies: '@ethersproject/abi': 5.7.0 '@ethersproject/abstract-provider': 5.7.0 '@ethersproject/abstract-signer': 5.7.0 '@nomicfoundation/ethereumjs-util': 9.0.4 - '@nomiclabs/hardhat-ethers': 2.2.3(ethers@5.7.2)(hardhat@2.22.6(patch_hash=q3nnrfsdmjujtkscve3dm62mmu)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4)) + '@nomiclabs/hardhat-ethers': 2.2.3(ethers@5.7.2)(hardhat@2.22.6(patch_hash=2xv63rgn6ejog2ah3azyw26aiy)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4)) diff: 5.0.0 ethers: 5.7.2 - hardhat: 2.22.6(patch_hash=q3nnrfsdmjujtkscve3dm62mmu)(ts-node@10.9.2(@types/node@18.15.13)(typescript@5.0.4))(typescript@5.0.4) + hardhat: 2.22.6(patch_hash=2xv63rgn6ejog2ah3azyw26aiy)(ts-node@10.9.2(@types/node@18.15.13)(typescript@5.0.4))(typescript@5.0.4) lodash.isequal: 4.5.0 lodash.isequalwith: 4.4.0 rxjs: 7.8.1 @@ -3602,10 +3602,10 @@ snapshots: '@nomicfoundation/solidity-analyzer-win32-ia32-msvc': 0.1.1 '@nomicfoundation/solidity-analyzer-win32-x64-msvc': 0.1.1 - '@nomiclabs/hardhat-ethers@2.2.3(ethers@5.7.2)(hardhat@2.22.6(patch_hash=q3nnrfsdmjujtkscve3dm62mmu)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4))': + '@nomiclabs/hardhat-ethers@2.2.3(ethers@5.7.2)(hardhat@2.22.6(patch_hash=2xv63rgn6ejog2ah3azyw26aiy)(ts-node@10.9.2(typescript@5.0.4))(typescript@5.0.4))': dependencies: ethers: 5.7.2 - hardhat: 2.22.6(patch_hash=q3nnrfsdmjujtkscve3dm62mmu)(ts-node@10.9.2(@types/node@18.15.13)(typescript@5.0.4))(typescript@5.0.4) + hardhat: 2.22.6(patch_hash=2xv63rgn6ejog2ah3azyw26aiy)(ts-node@10.9.2(@types/node@18.15.13)(typescript@5.0.4))(typescript@5.0.4) '@scure/base@1.1.5': {} @@ -4872,7 +4872,7 @@ snapshots: hard-rejection@2.1.0: {} - hardhat@2.22.6(patch_hash=q3nnrfsdmjujtkscve3dm62mmu)(ts-node@10.9.2(@types/node@18.15.13)(typescript@5.0.4))(typescript@5.0.4): + hardhat@2.22.6(patch_hash=2xv63rgn6ejog2ah3azyw26aiy)(ts-node@10.9.2(@types/node@18.15.13)(typescript@5.0.4))(typescript@5.0.4): dependencies: '@ethersproject/abi': 5.7.0 '@metamask/eth-sig-util': 4.0.1 From 00eef2771e8fa4b1d39d55320abd784969401bed Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Thu, 25 Jul 2024 13:29:51 +0200 Subject: [PATCH 8/8] fixup: Fix a simple test --- crates/edr_napi/src/trace/opcodes.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/edr_napi/src/trace/opcodes.rs b/crates/edr_napi/src/trace/opcodes.rs index 52623638e..a7ab7ad8a 100644 --- a/crates/edr_napi/src/trace/opcodes.rs +++ b/crates/edr_napi/src/trace/opcodes.rs @@ -362,8 +362,15 @@ mod tests { #[test] fn test_len() { use super::Opcode; - assert_eq!(Opcode::PUSH1.len(), 1); - assert_eq!(Opcode::PUSH2.len(), 2); - assert_eq!(Opcode::PUSH32.len(), 32); + assert_eq!(Opcode::ADD.len(), 1); + assert_eq!(Opcode::BALANCE.len(), 1); + + assert_eq!(Opcode::PUSH1.len(), 2); + assert_eq!(Opcode::PUSH2.len(), 3); + assert_eq!(Opcode::PUSH32.len(), 33); + + assert_eq!(Opcode::PUSH1.push_len(), 1); + assert_eq!(Opcode::PUSH2.push_len(), 2); + assert_eq!(Opcode::PUSH32.push_len(), 32); } }