Skip to content

Commit 939b879

Browse files
pjdurdenclaude
andauthored
fix(interpreter): use IntoAddress in pop_address to avoid const-eval panic (#3735)
* fix(interpreter): use IntoAddress in pop_address to avoid const-eval panic `StackTr::pop_address` converted the popped word with `Address::from(value.to_be_bytes())`. Since `Address: From<[u8; 20]>`, type inference forces ruint's const-generic `Uint::<256, 4>::to_be_bytes::<20>()`, whose `const { Self::assert_bytes(BYTES) }` requires `BYTES == Self::BYTES` (32 for U256). That unreachable const block is only sometimes dead-code eliminated; build profiles that actually evaluate it (cargo-fuzz coverage, release codegen) hit `error[E0080]: BYTES must be equal to Self::BYTES`, breaking downstream builds (#3728). Use the crate's existing `IntoAddress` converter (`value.into_address()`), which does `Address::from_word(B256::from(value.to_be_bytes()))`. Its `to_be_bytes()` infers the correct `[u8; 32]` size, so there is no fragile const-generic instantiation, and `pop_address` now reuses the canonical U256->Address conversion instead of inlining its own. Add a regression test asserting `pop_address` truncates a full 32-byte word to its low 20 bytes and returns `None` on an empty stack. Closes #3728 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(interpreter): drop pop_address regression test per review Remove `pop_address_truncates_to_low_20_bytes` as requested in review on #3735 — the truncation behaviour is covered by the shared `IntoAddress` conversion path and the dedicated test is not needed. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent eea3e18 commit 939b879

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

crates/interpreter/src/interpreter_types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{CallInput, InstructionResult, InterpreterAction};
1+
use crate::{instructions::utility::IntoAddress, CallInput, InstructionResult, InterpreterAction};
22
use core::{
33
cell::Ref,
44
ops::{Deref, Range},
@@ -222,7 +222,7 @@ pub trait StackTr {
222222
/// Internally call [`StackTr::pop`] and converts [`U256`] into [`Address`].
223223
#[must_use]
224224
fn pop_address(&mut self) -> Option<Address> {
225-
self.pop().map(|value| Address::from(value.to_be_bytes()))
225+
self.pop().map(|value| value.into_address())
226226
}
227227

228228
/// Exchanges two values on the stack.

0 commit comments

Comments
 (0)