diff --git a/crates/interpreter/src/instructions/macros.rs b/crates/interpreter/src/instructions/macros.rs index ec6e6cb775..ba828a2a89 100644 --- a/crates/interpreter/src/instructions/macros.rs +++ b/crates/interpreter/src/instructions/macros.rs @@ -17,6 +17,7 @@ macro_rules! check { }; } +#[macro_export] macro_rules! gas { ($interp:expr, $gas:expr) => { gas!($interp, $gas, ()) @@ -47,6 +48,7 @@ macro_rules! gas_or_fail { }; } +#[macro_export] macro_rules! shared_memory_resize { ($interp:expr, $offset:expr, $len:expr) => { shared_memory_resize!($interp, $offset, $len, ()) @@ -55,7 +57,7 @@ macro_rules! shared_memory_resize { let size = $offset.saturating_add($len); if size > $interp.shared_memory.len() { // We are fine with saturating to usize if size is close to MAX value. - let rounded_size = crate::interpreter::next_multiple_of_32(size); + let rounded_size = $crate::interpreter::next_multiple_of_32(size); #[cfg(feature = "memory_limit")] if $interp.shared_memory.limit_reached(size) { @@ -65,7 +67,10 @@ macro_rules! shared_memory_resize { // Gas is calculated in evm words (256bits). let words_num = rounded_size / 32; - if !$interp.gas.record_memory(crate::gas::memory_gas(words_num)) { + if !$interp + .gas + .record_memory($crate::gas::memory_gas(words_num)) + { $interp.instruction_result = InstructionResult::MemoryLimitOOG; return $ret; } @@ -94,21 +99,23 @@ macro_rules! pop_address { }; } +#[macro_export] macro_rules! pop { ($interp:expr, $x1:ident) => { - pop_ret!($interp, $x1, ()) + $crate::pop_ret!($interp, $x1, ()) }; ($interp:expr, $x1:ident, $x2:ident) => { - pop_ret!($interp, $x1, $x2, ()) + $crate::pop_ret!($interp, $x1, $x2, ()) }; ($interp:expr, $x1:ident, $x2:ident, $x3:ident) => { - pop_ret!($interp, $x1, $x2, $x3, ()) + $crate::pop_ret!($interp, $x1, $x2, $x3, ()) }; ($interp:expr, $x1:ident, $x2:ident, $x3:ident, $x4:ident) => { - pop_ret!($interp, $x1, $x2, $x3, $x4, ()) + $crate::pop_ret!($interp, $x1, $x2, $x3, $x4, ()) }; } +#[macro_export] macro_rules! pop_ret { ($interp:expr, $x1:ident, $ret:expr) => { if $interp.stack.len() < 1 { diff --git a/crates/interpreter/src/lib.rs b/crates/interpreter/src/lib.rs index 861853dcd1..c70c25cd91 100644 --- a/crates/interpreter/src/lib.rs +++ b/crates/interpreter/src/lib.rs @@ -19,7 +19,7 @@ mod host; mod inner_models; mod instruction_result; pub mod instructions; -mod interpreter; +pub mod interpreter; // Reexport primary types. pub use call_outcome::CallOutcome; diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index 7f5f6fec51..771b52d779 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -17,7 +17,7 @@ mod identity; #[cfg(feature = "c-kzg")] pub mod kzg_point_evaluation; mod modexp; -mod secp256k1; +pub mod secp256k1; pub mod utilities; use core::hash::Hash; @@ -260,7 +260,7 @@ impl PrecompileSpecId { /// Note that 32 + 128 = 160 = 20 bytes (the length of an address). This function is used /// as a convenience for specifying the addresses of the various precompiles. #[inline] -const fn u64_to_address(x: u64) -> Address { +pub const fn u64_to_address(x: u64) -> Address { let x = x.to_be_bytes(); Address::new([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], diff --git a/crates/precompile/src/secp256k1.rs b/crates/precompile/src/secp256k1.rs index ec9d3fa274..d35a342bc3 100644 --- a/crates/precompile/src/secp256k1.rs +++ b/crates/precompile/src/secp256k1.rs @@ -6,6 +6,8 @@ pub const ECRECOVER: PrecompileWithAddress = PrecompileWithAddress( Precompile::Standard(ec_recover_run), ); +pub use self::secp256k1::ecrecover; + #[cfg(not(feature = "secp256k1"))] #[allow(clippy::module_inception)] mod secp256k1 {