Repository navigation
chore: cherry-pick upstream fixes #3735 #3752 #3746 #3802 #3864 - #54
Conversation
…panic (bluealloy#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 (bluealloy#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 bluealloy#3728 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * test(interpreter): drop pop_address regression test per review Remove `pop_address_truncates_to_low_20_bytes` as requested in review on bluealloy#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) <[email protected]> (cherry picked from commit 939b879)
…ies (bluealloy#3746) `EvmStorageSlot::mark_warm_with_transaction_id` resets `original_value` to `present_value` whenever the slot is cold. But `is_cold_transaction_id` is true both on a genuine transaction-id mismatch AND when the `is_cold` flag is set within the same transaction (e.g. a reverted `StorageWarmed` entry, or an explicit `mark_cold`). The EIP-2200 "original"/committed value is transaction-scoped and independent of the EIP-2929 access list, so it should only be re-baselined when the slot genuinely belongs to a previous transaction. Key the re-baseline on the transaction-id mismatch instead of `is_cold`. This matches go-ethereum, where the EIP-2200 original (`GetCommittedState`, backed by pending/origin storage) is fully decoupled from the access list (`SlotInAccessList`). No observable change for standard execution — all state tests and ~97k blockchain tests pass identically — but it removes a latent coupling that would corrupt `original_value` for any caller that marks a slot cold mid-transaction. (cherry picked from commit 84fe60c)
…ated (bluealloy#3802) Do not overwrite AccountLoad::is_empty with the delegate account's flag. Empty-account / creation-cost checks must reflect the caller account, matching JournalInner::load_account_delegated. (cherry picked from commit 41e8b33)
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Claude review status
🛠️ Review did not finish Attempted head This round did not publish: MODEL_ACTION_FAILED in phase review_retry. Anything listed below is from the last round that did. Re-run the workflow or push a new commit to try again. |
…backend (#66) ## Summary Two rules for upstream picks, learned from the first batches (#54, #57) and from how alloy-rs/evm2 backports revm precompile work: - picks are batched by crate or subsystem, one pull request per batch, so one reviewer can read a whole batch; - a pick that touches a precompile is tested under mutually exclusive feature sets (the `std`-only fallback run, the default set, `--all-features`, and the single backend feature it changes), because `--all-features` selects only the preferred backend in each `cfg_if!` block. `REVIEW.md`'s `mega:cherry-pick` row names both. ## API exceptions None (documentation only). ## Test plan The mutually exclusive feature sets were run on `main` at 43485bf for the perf picks in #57: `--no-default-features --features std` (every fallback) 57/57, `std,blst` 57/57, `std,c-kzg` 57/57, the default set 57/57, `--all-features` 57/57. ## Labels checklist `mega:ci`, `api:superset`.
Summary
Five independent soundness/correctness fixes merged upstream after v112, outside the earlier gas-core sweep (fork #45). Each commit is
git cherry-pick -xof the upstream squash-merge, kept under the upstream subject. All five applied cleanly; no conflict resolution.git diff origin/main..HEADhas the same stable patch-id as the concatenation of the five upstream diffs. No public-API signature change.Commits
1.
fix(interpreter): use IntoAddress in pop_address to avoid const-eval panic (#3735)939b879a0eb5104a71076ab07a9fb9ef796c2381d976ab1ba8e13cda5da83cf8716d5b91776cb4b3StackTr::pop_addressusedAddress::from(value.to_be_bytes()), which infers ruint'sUint::<256,4>::to_be_bytes::<20>(). That const-generic has aconst { assert BYTES == 32 }that some build profiles actually evaluate (coverage, release codegen) and then fail withE0080. Switch to the crate'sIntoAddress(value.into_address()), which converts through a 32-byte word.crates/interpreter/src/interpreter_types.rscrates/interpreter/src/instructions.rs(enable_amsterdam_opcodes) /instructions/stack.rs(dupn_enabled/swapn_enabled/exchange_enabled). This is a default method onStackTr, a different file.2.
fix(bytecode): avoid out-of-bounds pointer in analyze_legacy (#3752)59a5aea8dfbb42360d4814b10490e9747c82e4f9f1c6b25af79a495877df4a29e8efa50679342189analyze_legacyformed a pointer up to 33 bytes past the allocation viaptr::add(UB; Kani/Miri).wrapping_addkeeps the offset defined; the existing< endguard still prevents an OOB read. Named zkVM backends as the risk; the fork's rule 5 is zkVM/no_stdriscv.crates/bytecode/src/legacy/analysis.rs3.
fix(state): re-baseline storage original_value only across tx boundaries (#3746)84fe60ca382aa903180d6e49ecd156d2aa6a1957238801a313344d0b5740caebcc6747055775c857EvmStorageSlot::mark_warm_with_transaction_idre-baselined EIP-2200original_valuewheneveris_cold_transaction_idwas true. That predicate is also true for a slot flagged cold inside the same tx (revertedStorageWarmed/mark_cold). Key the re-baseline on transaction-id mismatch only, matching geth'sGetCommittedStatevs access-list split. Latent: standard execution already keepsoriginal_valueacross an in-tx cold re-warm because a modification requires a prior warm, and a reverted checkpoint reverts both; the new keying is the spec-correct one.crates/state/src/lib.rsoriginal_valuefor SSTORE state-gas is incrates/interpreter/src/instructions/host.rs(state_gas_charge) and the Host defaults incrates/context/interface/src/host.rs. This commit only changes how the slot records the baseline.4.
fix(context): keep is_empty on EIP-7702 account in load_account_delegated (#3802)41e8b33652ef61e3b09a90b814eb97ec58012ae1805bbc2ee5dd8c84dc806a8bb0e4b1e494be69eaHost::load_account_delegateddefault overwroteAccountLoad::is_emptywith the delegate account's flag. A value CALL to a delegated EOA whose delegate is empty would then be charged new-account gas (regular + 8037 state gas). Empty/creation-cost checks must reflect the callee, matchingJournalInner::load_account_delegated(which already kept the callee'sis_empty).crates/context/interface/src/host.rs(one-line deletion in the default method + a 171-line regression test)Host::state_gas_price/state_gas_charge) sits in the Config section of this trait, ~90 lines above. The deleted line is in the Journal section. History gas is ingas.rs/frame.rs. Amsterdam table activation is ininstructions/stack.rs. None of those three hooks were edited.crates/interpreter/src/instructions/contract/call_helpers.rsis a free functionload_account_delegatedthat:Host::load_account_info_skip_cold_load(notHost::load_account_delegated);account.is_emptybefore loading the delegate and returns early on a new-account charge;origin/main..HEAD.No in-tree caller except the new unit test and
examples/cheatcode_inspector(the latter forwards toJournalTr::load_account_delegated, already correct). This bites a consumer that calls the Host default itself (mega-evm's revm-27 engine overrides and delegates toinner.load_account_delegated).5.
fix(interpreter): return MemoryOOG when memory resize fails (#3864)3660eeb0d1f5d586cc49e1bd93a7533a95ddbb4c901101d5119e858049d457a5a0b0e46f8bdbc338resize_memory_coldignoredMemoryTr::resize'sbool.SharedMemory::resizealways returnstrue, so no observable change on the default memory; a customMemoryTr(zkVM memory) that returnsfalsewould otherwise proceed and later access out of bounds. Now returnsInstructionResult::MemoryOOG.crates/interpreter/src/interpreter/shared_memory.rsgas.record_regular_cost(regular gas). History gas lives onGas/GasTrackerincrates/interpreter/src/gas.rsand is merged incrates/handler/src/frame.rs. This hunk does not touch history gas.Semver
Touched crates from
scripts/mega/crates.txt:revm-bytecode,revm-context-interface,revm-interpreter,revm-state. No signature change; expectapi:superset(noapi:exception).Out of scope
The gas-core follow-ups (upstream bluealloy#3893, and the system-call reservoir margin that upstream bluealloy#3892 introduced and bluealloy#3903 reverted) land in separate pull requests.
Labels checklist
mega:cherry-pick,api:superset.