Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ strip = false

# Make sure debug symbols are in the bench profile
[profile.bench]
debug = 2
inherits = "release"
strip = false
inherits = "profiling"

[profile.ethtests]
inherits = "test"
Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/instructions/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn jumpi<WIRE: InterpreterTypes, H: ?Sized>(context: InstructionContext<'_,
/// Validates jump target and performs the actual jump.
#[inline(always)]
fn jump_inner<WIRE: InterpreterTypes>(interpreter: &mut Interpreter<WIRE>, target: U256) {
let target = as_usize_or_fail!(interpreter, target, InstructionResult::InvalidJump);
let target = as_usize_saturated!(target);
if !interpreter.bytecode.is_valid_legacy_jump(target) {
interpreter.halt(InstructionResult::InvalidJump);
return;
Expand Down
16 changes: 3 additions & 13 deletions crates/interpreter/src/instructions/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,7 @@ macro_rules! push {
#[collapse_debuginfo(yes)]
macro_rules! as_u64_saturated {
($v:expr) => {
match $v.as_limbs() {
x => {
if (x[1] == 0) & (x[2] == 0) & (x[3] == 0) {
x[0]
} else {
u64::MAX
}
}
}
u64::try_from($v).unwrap_or(u64::MAX)
};
}

Expand All @@ -173,7 +165,7 @@ macro_rules! as_u64_saturated {
#[collapse_debuginfo(yes)]
macro_rules! as_usize_saturated {
($v:expr) => {
usize::try_from($crate::as_u64_saturated!($v)).unwrap_or(usize::MAX)
usize::try_from($v).unwrap_or(usize::MAX)
};
}

Expand All @@ -182,9 +174,7 @@ macro_rules! as_usize_saturated {
#[collapse_debuginfo(yes)]
macro_rules! as_isize_saturated {
($v:expr) => {
// `isize_try_from(u64::MAX)`` will fail and return isize::MAX
// This is expected behavior as we are saturating the value.
isize::try_from($crate::as_u64_saturated!($v)).unwrap_or(isize::MAX)
isize::try_from($v).unwrap_or(isize::MAX)
};
}

Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/instructions/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub fn codecopy<WIRE: InterpreterTypes, H: Host + ?Sized>(
pub fn calldataload<WIRE: InterpreterTypes, H: ?Sized>(context: InstructionContext<'_, H, WIRE>) {
popn_top!([], offset_ptr, context.interpreter);
let mut word = B256::ZERO;
let offset = as_usize_saturated!(offset_ptr);
let offset = as_usize_saturated!(*offset_ptr);
let input = context.interpreter.input.input();
let input_len = input.len();
if offset < input_len {
Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/instructions/tx_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ pub fn blob_hash<WIRE: InterpreterTypes, H: Host + ?Sized>(
) {
check!(context.interpreter, CANCUN);
popn_top!([], index, context.interpreter);
let i = as_usize_saturated!(index);
let i = as_usize_saturated!(*index);
*index = context.host.blob_hash(i).unwrap_or_default();
}
9 changes: 4 additions & 5 deletions crates/interpreter/src/interpreter/ext_bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,14 @@ impl Jumps for ExtBytecode {

#[inline]
fn is_valid_legacy_jump(&mut self, offset: usize) -> bool {
self.base
.legacy_jump_table()
.expect("Panic if not legacy")
.is_valid(offset)
let jt = self.base.legacy_jump_table();
// SAFETY: Only called by legacy bytecode. Panics in debug mode.
unsafe { jt.unwrap_unchecked() }.is_valid(offset)
}

#[inline]
fn opcode(&self) -> u8 {
// SAFETY: `instruction_pointer` always point to bytecode.
// SAFETY: `instruction_pointer` always points to bytecode.
unsafe { *self.instruction_pointer }
}

Expand Down
Loading