From 0a6918e499ffc989b52d994a83080fe85574e2a3 Mon Sep 17 00:00:00 2001 From: mega-putin Date: Wed, 18 Nov 2026 04:16:46 +0000 Subject: [PATCH 1/6] test(evm): pin the hardfork gates the spec-gate sweep left unpinned Close the 17 spec-gate survivors from the nightly sweep: one with a test, sixteen with a per-site reachability or observability argument. - sandbox: pin that the REX5 keyless-deploy balance precheck ignores the gas price. - mini_rex: add alias_window_gates.rs, which pins the mainnet MiniRex1 alias window against EQUIVALENCE's observation and against any metered usage. - suppressions: 16 entries; 5 of them are debug_assert-only. --- crates/mega-evm/src/sandbox/execution.rs | 43 ++++ .../tests/mini_rex/alias_window_gates.rs | 142 +++++++++++++ crates/mega-evm/tests/mini_rex/main.rs | 1 + mutants/suppressions.toml | 190 ++++++++++++++++++ 4 files changed, 376 insertions(+) create mode 100644 crates/mega-evm/tests/mini_rex/alias_window_gates.rs diff --git a/crates/mega-evm/src/sandbox/execution.rs b/crates/mega-evm/src/sandbox/execution.rs index 0a831df6f..a4c2a7e9b 100644 --- a/crates/mega-evm/src/sandbox/execution.rs +++ b/crates/mega-evm/src/sandbox/execution.rs @@ -1628,4 +1628,47 @@ mod tests { "deposit-caller state-growth must not be recorded when the storage gas computation fails", ); } + + /// The REX5 keyless-deploy sandbox runs as a fee-free deposit-like transaction, so its + /// balance precheck must ignore the gas price. Force a non-zero `gas_price` here (the + /// production caller always builds `gas_price = 0`) and pin that a signer holding exactly + /// `value` still clears the precheck: gating the fee-free branch one fork later would add + /// `gas_limit * gas_price` and reject the deploy. + #[test] + fn test_rex5_sandbox_balance_precheck_ignores_gas_price() { + use crate::test_utils::MemoryDatabase; + use alloy_primitives::{address, Bytes, TxKind, U256}; + use revm::context::TxEnv; + + let signer = address!("0x00000000000000000000000000000000000000aa"); + let value = U256::from(100u64); + let gas_price: u128 = 7; + let gas_limit: u64 = 100_000; + + let mut db = MemoryDatabase::default().account_balance(signer, value); + + let tx = TxEnv { + caller: signer, + kind: TxKind::Create, + data: Bytes::from_static(&[0x60, 0x00, 0x60, 0x00, 0xf3]), + value, + gas_limit, + gas_price, + nonce: 0, + ..Default::default() + }; + let mut sandbox_tx = crate::MegaTransaction(op_revm::OpTransaction::new(tx)); + sandbox_tx.enveloped_tx = Some(Bytes::new()); + + let mut ctx = crate::MegaContext::new(&mut db, MegaSpecId::REX5); + let outcome = execute_keyless_deploy_sandbox( + &mut ctx, + sandbox_tx, + Some(EvmTxRuntimeLimits::from_spec(MegaSpecId::REX5)), + ); + assert!( + !matches!(outcome, SandboxOutcome::Rejected(KeylessDeployError::InsufficientBalance)), + "REX5 must not charge the gas price in the sandbox balance precheck: {outcome:?}" + ); + } } diff --git a/crates/mega-evm/tests/mini_rex/alias_window_gates.rs b/crates/mega-evm/tests/mini_rex/alias_window_gates.rs new file mode 100644 index 000000000..037ac819d --- /dev/null +++ b/crates/mega-evm/tests/mini_rex/alias_window_gates.rs @@ -0,0 +1,142 @@ +//! The `MegaHardfork::MiniRex1` window is a behavior rollback on mainnet: +//! `MegaSpecId::MINI_REX_1::behavior()` is `EQUIVALENCE`, so the rung executes revm's stock +//! mainnet table with the `MINI_REX` gates *off* (`MegaSpecId::is_enabled` projects both sides +//! through `behavior()`). Blocks in that window are replayed, so the observation must be pinned +//! here rather than only at `EQUIVALENCE`. +//! +//! Everything the `MINI_REX` bookkeeping touches is asserted to be inert in this window: a +//! transaction that writes storage, emits a log, spans two frames and deploys a contract leaves +//! every metered dimension at zero, exposes no volatile-data info, and consumes exactly the gas +//! the same transaction consumes at `EQUIVALENCE`. + +use alloy_primitives::{address, Address, Bytes, U256}; +use mega_evm::{ + test_utils::{BytecodeBuilder, MemoryDatabase}, + EmptyExternalEnv, MegaContext, MegaEvm, MegaSpecId, MegaTransaction, MegaTransactionNew as _, +}; +use revm::{ + bytecode::opcode::*, + context::{BlockEnv, TxEnv}, + handler::EvmTr, + inspector::NoOpInspector, + primitives::TxKind, +}; + +const EOA_CALLER: Address = address!("0000000000000000000000000000000000100000"); +const CALLEE: Address = address!("0000000000000000000000000000000000100001"); +const INNER: Address = address!("0000000000000000000000000000000000100002"); +const BENEFICIARY: Address = address!("00000000000000000000000000000000000BEEF1"); + +const GAS_LIMIT: u64 = 10_000_000; +const INITIAL_BALANCE: u64 = 1_000_000_000; + +fn build_evm( + db: DB, + spec: MegaSpecId, +) -> MegaEvm { + let mut context = MegaContext::new(db, spec).with_block(BlockEnv { + beneficiary: BENEFICIARY, + number: U256::from(10), + basefee: 0, + ..Default::default() + }); + context.modify_chain(|chain| { + chain.operator_fee_scalar = Some(U256::ZERO); + chain.operator_fee_constant = Some(U256::ZERO); + }); + MegaEvm::new(context) +} + +/// CALLEE writes a slot, calls INNER (which writes a slot and emits LOG0), then CREATEs a +/// one-byte contract. Covers the frame-entry, frame-return, storage-gas, code-deposit and +/// volatile-access paths in a single transaction. +fn scenario_db() -> MemoryDatabase { + let inner_code = BytecodeBuilder::default() + .sstore(U256::from(1), U256::from(2)) + .push_number(0u64) + .push_number(0u64) + .append(LOG0) + .stop() + .build(); + let callee_code = BytecodeBuilder::default() + .sstore(U256::from(3), U256::from(4)) + .push_number(0u64) + .push_number(0u64) + .push_number(0u64) + .push_number(0u64) + .push_number(0u64) + .push_address(INNER) + .push_number(100_000u64) + .append(CALL) + .append(POP) + .push_number(1u64) + .push_number(0u64) + .push_number(0u64) + .append(CREATE) + .append(POP) + .stop() + .build(); + + MemoryDatabase::default() + .account_balance(EOA_CALLER, U256::from(INITIAL_BALANCE)) + .account_balance(CALLEE, U256::from(INITIAL_BALANCE)) + .account_code(CALLEE, callee_code) + .account_code(INNER, inner_code) +} + +fn scenario_tx() -> MegaTransaction { + let mut tx = MegaTransaction::new(TxEnv { + caller: EOA_CALLER, + kind: TxKind::Call(CALLEE), + gas_limit: GAS_LIMIT, + gas_price: 0, + data: Bytes::from(vec![0xAAu8; 64]), + ..Default::default() + }); + tx.enveloped_tx = Some(Bytes::new()); + tx +} + +/// `(success, gas used, output length)` for the scenario transaction at `spec`. +fn observe(spec: MegaSpecId) -> (bool, u64, usize) { + let mut evm = build_evm(scenario_db(), spec); + let result = alloy_evm::Evm::transact_raw(&mut evm, scenario_tx()).expect("tx must execute"); + ( + result.result.is_success(), + result.result.tx_gas_used(), + result.result.output().map(|out| out.len()).unwrap_or(0), + ) +} + +/// The `MiniRex1` window must consume exactly the gas `EQUIVALENCE` consumes for the same +/// transaction. Any `MINI_REX` gate that the mutant turns on inside this window shows up here as +/// a gas or outcome difference. +#[test] +fn test_mini_rex_1_window_matches_equivalence_observation() { + let at_equivalence = observe(MegaSpecId::EQUIVALENCE); + let at_window = observe(MegaSpecId::MINI_REX_1); + assert_eq!( + at_window, at_equivalence, + "the MiniRex1 window must observe exactly what EQUIVALENCE observes" + ); + assert!(at_window.0, "scenario transaction must succeed in the window"); +} + +/// No metered dimension may move in the window: the stock table installs no wrapper that feeds +/// the trackers, so running the bookkeeping there cannot record anything. +#[test] +fn test_mini_rex_1_window_leaves_the_trackers_at_zero() { + let mut evm = build_evm(scenario_db(), MegaSpecId::MINI_REX_1); + let result = alloy_evm::Evm::transact_raw(&mut evm, scenario_tx()).expect("tx must execute"); + assert!(result.result.is_success(), "got {:?}", result.result); + + let usage = evm.ctx_ref().additional_limit.borrow().get_usage(); + assert_eq!(usage.compute_gas, 0, "the window must not meter compute gas"); + assert_eq!(usage.data_size, 0, "the window must not meter data size"); + assert_eq!(usage.kv_updates, 0, "the window must not meter KV updates"); + assert_eq!(usage.state_growth, 0, "the window must not meter state growth"); + assert!( + evm.ctx_ref().volatile_data_tracker.borrow().get_volatile_data_info().is_none(), + "the window must not report volatile-data info" + ); +} diff --git a/crates/mega-evm/tests/mini_rex/main.rs b/crates/mega-evm/tests/mini_rex/main.rs index 12601c538..971fb01f8 100644 --- a/crates/mega-evm/tests/mini_rex/main.rs +++ b/crates/mega-evm/tests/mini_rex/main.rs @@ -1,6 +1,7 @@ //! Tests for `MiniRex` hardfork features. mod access_beneficiary_balance; +mod alias_window_gates; mod block_env_access_tracking; mod block_env_gas_limit; mod compute_gas_limit; diff --git a/mutants/suppressions.toml b/mutants/suppressions.toml index 8a080250f..d3251b03f 100644 --- a/mutants/suppressions.toml +++ b/mutants/suppressions.toml @@ -612,3 +612,193 @@ column = 49 mutant = "replace && with || in apply_sandbox_state_journaled_inner" justification = "Equivalent: on equal code hashes, || adds only two copies: a parent that already has code receives the same-hash (identical) bytecode, and an empty-hash parent has None or empty code replaced by the sandbox's empty bytecode, the Some(Bytecode::default()) revm stores itself on any code load of an empty-hash account, so no read, gas cost, result or committed state changes." reviewer = "RealiCZ (cz)" + +# ───────────────────────────────────────────────────────────────────────────── +# spec-gate survivors from the nightly sweep (run 44009245120, main cdcce16d). +# +# Every entry below is a gate the sweep flipped that execution cannot distinguish. The two +# reasons used are: the mutated branch cannot be reached at the spec where the flip takes +# effect, or it runs but cannot change anything the chain can observe. The MiniRex1 alias +# window on mainnet (block/chain.rs:38-39) does execute these code paths with the gate off, +# so the window's observable behaviour is pinned by tests/mini_rex/alias_window_gates.rs; +# these entries cover the branches inside that window that remain unobservable. +# +# The sibling survivor at sandbox/execution.rs:603 is closed by a test instead +# (test_rex5_sandbox_balance_precheck_ignores_gas_price). +# ───────────────────────────────────────────────────────────────────────────── + +# --- crates/mega-evm/src/evm/context.rs:692 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/context.rs" +line = 692 +column = 1 +mutant = "spec-gate if self.spec.is_enabled(MegaSpecId::MINI_REX) { -> if self.spec.is_enabled(MegaSpecId::EQUIVALENCE) {" +justification = "Unobservable in the MiniRex1 window (gate off, mutant turns it on): `on_new_block` only refreshes the cached dynamic storage-gas price. Its readers \u2014 `sstore_set_storage_gas`, `new_account_storage_gas`, `create_contract_storage_gas` \u2014 are reached exclusively through the mini_rex+ instruction tables, and `MINI_REX_1` installs revm's stock mainnet table (instructions.rs:201-203). Nothing reads the refreshed price in this window, and the calculator's field is not part of any execution output." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/execution.rs:427 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/execution.rs" +line = 427 +column = 1 +mutant = "spec-gate if ctx.spec.is_enabled(MegaSpecId::MINI_REX) { -> if ctx.spec.is_enabled(MegaSpecId::EQUIVALENCE) {" +justification = "Unobservable in the window: `before_frame_run` answers `Some` only when a metered dimension already exceeded its limit. The stock table installs no wrapper and `after_frame_run` returns before charging anything (`!is_enabled(MINI_REX)` at execution.rs:509 in the unmutated tree), so every counter stays 0 and the call returns `None` \u2014 the same value the unmutated `None` arm yields." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/execution.rs:1680 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/execution.rs" +line = 1680 +column = 1 +mutant = "spec-gate let is_mini_rex_enabled = ctx.spec.is_enabled(MegaSpecId::MINI_REX); -> let is_mini_rex_enabled = ctx.spec.is_enabled(MegaSpecId::EQUIVALENCE);" +justification = "Unobservable: the flag only orders the additional-limit check against the call-depth check for inspector-intercepted frames, and in the window no limit can be exceeded (counters stay 0), so both orders select the same error. Block replay drives the executor without an inspector, so that intercepted branch is not taken on chain at all." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/execution.rs:1774 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/execution.rs" +line = 1774 +column = 1 +mutant = "spec-gate let gas_remaining_before = match (&action, ctx.spec.is_enabled(MegaSpecId::MINI_REX)) { -> let gas_remaining_before = match (&action, ctx.spec.is_enabled(MegaSpecId::EQUIVALENCE)) {" +justification = "Unobservable in the window: same recording as execution.rs:1539 on the inspected path; its only consumer is `after_frame_run`, which returns before reading it (`!is_enabled(MINI_REX)` at execution.rs:509)." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/execution.rs:509 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/execution.rs" +line = 509 +column = 1 +mutant = "spec-gate if !ctx.spec.is_enabled(MegaSpecId::MINI_REX) { -> if !ctx.spec.is_enabled(MegaSpecId::EQUIVALENCE) {" +justification = "Unobservable in the window: the mutant lets the after-frame accounting run, but it only accumulates counters and compares them against `EvmTxRuntimeLimits::from_spec(MINI_REX_1)`. No wrapper feeds those counters in the window (stock table, instructions.rs:201-203), so every increment is zero and no comparison trips: no halt, no extra gas, no state change. The counters are otherwise read only by gates that are themselves off in this window." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/execution.rs:1586 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/execution.rs" +line = 1586 +column = 1 +mutant = "spec-gate if self.ctx_ref().spec.is_enabled(MegaSpecId::REX4) { -> if self.ctx_ref().spec.is_enabled(MegaSpecId::REX3) {" +justification = "Unreachable at REX3: a volatile-access disable can only be created by `AccessControlInterceptor::handle_disable` (system/intercept.rs:357), whose `ACTIVATION_SPEC` is `MegaSpecId::REX4` (system/intercept.rs:340). At REX3 `disable_depth` is therefore always `None` and `enable_access_if_returning` has nothing to clear." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/execution.rs:1068 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/execution.rs" +line = 1068 +column = 1 +mutant = "spec-gate let is_mini_rex = evm.ctx().spec.is_enabled(MegaSpecId::MINI_REX); -> let is_mini_rex = evm.ctx().spec.is_enabled(MegaSpecId::EQUIVALENCE);" +justification = "Unobservable in the window: `before_frame_return_result::` records the frame's consumption and applies the compute-gas clamp only when the tracker holds a compute limit that has been exceeded. In the window the tracker holds no measured compute gas (no wrapper runs), so the extra `` pass records zero and clamps nothing." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/execution.rs:1102 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/execution.rs" +line = 1102 +column = 1 +mutant = "spec-gate .is_enabled(MegaSpecId::MINI_REX) -> .is_enabled(MegaSpecId::EQUIVALENCE)" +justification = "Unobservable in the window: the attached info comes from `get_volatile_data_info()`, which is `Some` only after a volatile access was marked. Marks are produced solely by the REX4+ `disableVolatileDataAccess` path (`AccessControlInterceptor::ACTIVATION_SPEC` = REX4, system/intercept.rs:340), which the window's stock table never reaches, so both sides attach `None`." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/execution.rs:1539 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/execution.rs" +line = 1539 +column = 1 +mutant = "spec-gate let gas_remaining_before = match (&action, context.spec.is_enabled(MegaSpecId::MINI_REX)) { -> let gas_remaining_before = match (&action, context.spec.is_enabled(MegaSpecId::EQUIVALENCE)) {" +justification = "Unobservable in the window: the recorded value has exactly one consumer, `after_frame_run`, and that consumer returns immediately in the window (`!is_enabled(MINI_REX)` at execution.rs:509 in the unmutated tree). Recording `Some(remaining)` instead of `None` therefore produces a value nothing reads." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/host.rs:442 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/host.rs" +line = 442 +column = 1 +mutant = "spec-gate self.spec.is_enabled(MegaSpecId::MINI_REX) && address == ORACLE_CONTRACT_ADDRESS, -> self.spec.is_enabled(MegaSpecId::EQUIVALENCE) && address == ORACLE_CONTRACT_ADDRESS," +justification = "debug_assert! only: the condition is a debug self-check on `oracle_sload`'s oracle-address predicate. `debug_assert!` is compiled out in release, so relaxing it cannot change behaviour the chain can observe; it only removes a debug-time invariant." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/host.rs:639 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/host.rs" +line = 639 +column = 1 +mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX));" +justification = "debug_assert! only: `create_contract_storage_gas` is called only from the REX+ CREATE paths; asserting MINI_REX instead of REX relaxes a debug-time invariant that is compiled out in release, so execution behaviour is unchanged." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/host.rs:602 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/host.rs" +line = 602 +column = 1 +mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::EQUIVALENCE));" +justification = "debug_assert! only: `additional_limit()` is reached only from the mini_rex+ instruction tables, so the assertion is a debug-time invariant. `debug_assert!` is compiled out in release; relaxing it cannot change execution behaviour." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/host.rs:608 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/host.rs" +line = 608 +column = 1 +mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::EQUIVALENCE));" +justification = "debug_assert! only: `sstore_set_storage_gas` is installed only by the mini_rex+ tables; the assertion is a debug-time invariant, compiled out in release. Relaxing it cannot change execution behaviour." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/host.rs:625 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/host.rs" +line = 625 +column = 1 +mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::EQUIVALENCE));" +justification = "debug_assert! only: `new_account_storage_gas` is installed only by the mini_rex+ tables; the assertion is a debug-time invariant, compiled out in release. Relaxing it cannot change execution behaviour." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/instructions.rs:3083 --- +[[suppress]] +kind = "line" +category = "dead" +file = "crates/mega-evm/src/evm/instructions.rs" +line = 3083 +column = 1 +mutant = "spec-gate .is_enabled(MegaSpecId::REX5) && -> .is_enabled(MegaSpecId::REX4) &&" +justification = "Unreachable: `compute_gas_ext::call_code` is installed only by the mini_rex tables (instructions.rs:201-203 selects them for MINI_REX/MINI_REX_2; the CALLCODE assignment is instructions.rs:1015). From `mod rex` on, CALLCODE is replaced by `forward_gas_ext::call_code` (instructions.rs:305) and at REX4 by `volatile_data_ext::call_code` (instructions.rs:418); `mod rex5` inherits rex4's table (instructions.rs:467). The only specs that reach this line have behaviour <= MINI_REX, where `is_enabled(REX4)`, `is_enabled(REX5)` and `is_enabled(REX6)` are all false, so the mutant keeps `stipend_from_revm` at 0 exactly as the original does." +reviewer = "RealiCZ" + +# --- crates/mega-evm/src/evm/instructions.rs:3083 --- +[[suppress]] +kind = "line" +category = "dead" +file = "crates/mega-evm/src/evm/instructions.rs" +line = 3083 +column = 1 +mutant = "spec-gate .is_enabled(MegaSpecId::REX5) && -> .is_enabled(MegaSpecId::REX6) &&" +justification = "Unreachable: `compute_gas_ext::call_code` is installed only by the mini_rex tables (instructions.rs:201-203 selects them for MINI_REX/MINI_REX_2; the CALLCODE assignment is instructions.rs:1015). From `mod rex` on, CALLCODE is replaced by `forward_gas_ext::call_code` (instructions.rs:305) and at REX4 by `volatile_data_ext::call_code` (instructions.rs:418); `mod rex5` inherits rex4's table (instructions.rs:467). The only specs that reach this line have behaviour <= MINI_REX, where `is_enabled(REX4)`, `is_enabled(REX5)` and `is_enabled(REX6)` are all false, so the mutant keeps `stipend_from_revm` at 0 exactly as the original does." +reviewer = "RealiCZ" From 927b367e32fc1e03ee45c7e5635d0a04cfa02d4f Mon Sep 17 00:00:00 2001 From: mega-putin Date: Wed, 18 Nov 2026 05:49:19 +0000 Subject: [PATCH 2/6] test(evm): pin the alias-window gates a reused context can observe The MiniRex1 window is live on mainnet, and a context can outlive a spec change through `into_inner().ctx.with_cfg(..)`, so six of the sixteen `MINI_REX -> EQUIVALENCE` flips are observable through the public API. - add `evm/gate_reuse_tests.rs`: a latched limit verdict must not reject the next transaction; rescued and charged gas must not move; a halt must not be reclassified as a volatile-data halt; the dynamic storage-gas bucket set must survive a block switch; an inspector that intercepts a nested call must not leave a limit frame behind. - strengthen the alias-window test: the callee returns the nested call's success flag and the created address instead of discarding them. - narrow the suppressions to the ten gates that stay unreachable or unobservable, reclassify the CALL_STIPEND site as equivalent, and name the non-opcode callers in the `debug_assert!` entries. --- crates/mega-evm/src/evm/gate_reuse_tests.rs | 257 ++++++++++++++++++ crates/mega-evm/src/evm/mod.rs | 3 + .../tests/mini_rex/alias_window_gates.rs | 40 ++- mutants/suppressions.toml | 116 ++++++++ 4 files changed, 410 insertions(+), 6 deletions(-) create mode 100644 crates/mega-evm/src/evm/gate_reuse_tests.rs diff --git a/crates/mega-evm/src/evm/gate_reuse_tests.rs b/crates/mega-evm/src/evm/gate_reuse_tests.rs new file mode 100644 index 000000000..bc9a5f3f9 --- /dev/null +++ b/crates/mega-evm/src/evm/gate_reuse_tests.rs @@ -0,0 +1,257 @@ +//! Gates that only become observable once a context outlives a spec change. +//! +//! A block executor builds a fresh context per block, so the `MINI_REX` bookkeeping is empty +//! whenever the ladder reaches the `MiniRex1` alias window. A context can also be carried across +//! a spec change through the public API (`into_inner().ctx.with_cfg(..)`), and then the trackers, +//! the latched limit verdict and the dynamic storage-gas cache still hold the previous spec's +//! state. These tests pin what the alias window must do with that state, so a gate that is +//! flipped one rung cannot quietly act on it. + +use std::{cell::Cell, rc::Rc}; + +use alloy_primitives::{address, Address, Bytes, TxKind, U256}; +use revm::{ + bytecode::opcode::*, + context::{result::ExecutionResult, CfgEnv, ContextTr, JournalTr, TxEnv}, + handler::EvmTr, + interpreter::{ + CallInputs, CallOutcome, Gas, InstructionResult, InterpreterResult, InterpreterTypes, + }, + Inspector, +}; + +use crate::{ + test_utils::{BytecodeBuilder, MemoryDatabase}, + EvmTxRuntimeLimits, MegaContext, MegaEvm, MegaHaltReason, MegaSpecId, MegaTransaction, +}; + +const CALLER: Address = address!("0000000000000000000000000000000000100000"); +const CONTRACT: Address = address!("0000000000000000000000000000000000100001"); +const INNER: Address = address!("0000000000000000000000000000000000100002"); + +const INITIAL_BALANCE: u64 = 1_000_000_000; + +fn db_with_contract(code: alloy_primitives::Bytes) -> MemoryDatabase { + MemoryDatabase::default() + .account_balance(CALLER, U256::from(INITIAL_BALANCE)) + .account_code(CONTRACT, code) +} + +fn tx_to_contract(gas_limit: u64) -> MegaTransaction { + use crate::MegaTransactionNew as _; + let mut tx = MegaTransaction::new(TxEnv { + caller: CALLER, + kind: TxKind::Call(CONTRACT), + gas_limit, + gas_price: 0, + ..Default::default() + }); + tx.enveloped_tx = Some(Bytes::new()); + tx +} + +fn zero_fees(ctx: &mut MegaContext) { + ctx.modify_chain(|chain| { + chain.operator_fee_scalar = Some(U256::ZERO); + chain.operator_fee_constant = Some(U256::ZERO); + }); +} + +/// A `MINI_REX` context whose transaction compute limit is 1, so accessing a block-environment +/// value latches `ExceedsLimit` on the additional-limit tracker. +fn latched_evm( + code: alloy_primitives::Bytes, +) -> MegaEvm { + let mut ctx = MegaContext::new(db_with_contract(code), MegaSpecId::MINI_REX) + .with_tx_runtime_limits( + EvmTxRuntimeLimits::no_limits().with_block_env_access_compute_gas_limit(1), + ); + zero_fees(&mut ctx); + MegaEvm::new(ctx) +} + +/// `TIMESTAMP POP STOP`: the first block-environment access is what the alias window must treat +/// as inert. +fn timestamp_code() -> alloy_primitives::Bytes { + BytecodeBuilder::default().append(TIMESTAMP).append(POP).append(STOP).build() +} + +/// Runs the latching transaction and returns the context that still carries its verdict. +fn latch_then_ctx( + code: alloy_primitives::Bytes, +) -> MegaContext { + let mut evm = latched_evm(code); + let outcome = evm.execute_transaction(tx_to_contract(22_000)).expect("first tx must execute"); + assert!( + outcome.result_and_state.result.is_halt(), + "the seeding transaction must halt on its compute limit" + ); + assert!( + evm.ctx_ref().additional_limit.borrow().rescued_gas > 0, + "the seeding transaction must leave rescued gas behind" + ); + evm.into_inner().ctx +} + +fn to_alias( + ctx: MegaContext, +) -> MegaContext { + ctx.with_cfg(CfgEnv::new_with_spec(MegaSpecId::MINI_REX_1)) +} + +/// The `MINI_REX` gate on frame entry must not act on a verdict inherited from the previous spec: +/// with the gate off, the alias window runs the transaction instead of rejecting it up front. +#[test] +fn test_mini_rex_1_ignores_the_latched_limit_on_frame_entry() { + let ctx = to_alias(latch_then_ctx(timestamp_code())); + let mut evm = MegaEvm::new(ctx); + let outcome = evm + .execute_transaction(tx_to_contract(30_000)) + .expect("the alias window must execute the transaction"); + assert!( + outcome.result_and_state.result.is_success(), + "the alias window must not reject a transaction on a stale limit verdict: {:?}", + outcome.result_and_state.result + ); +} + +/// `try_rescue_gas` is called unconditionally on the frame-return path, so the alias window must +/// not run that path: the rescued-gas total inherited from `MINI_REX` stays untouched. +#[test] +fn test_mini_rex_1_does_not_rescue_gas_for_inherited_state() { + let ctx = to_alias(latch_then_ctx(timestamp_code())); + let before = ctx.additional_limit.borrow().rescued_gas; + let mut evm = MegaEvm::new(ctx); + evm.execute_transaction(tx_to_contract(30_000)).expect("tx must execute"); + let after = evm.ctx_ref().additional_limit.borrow().rescued_gas; + assert_eq!(after, before, "the alias window must not add rescued gas"); +} + +/// The final-frame result path reads `rescued_gas` when it erases the refund. At the alias window +/// it must stay closed, so a transaction consumes exactly what the same transaction consumes on a +/// fresh alias context. +#[test] +fn test_mini_rex_1_charges_the_same_gas_as_a_fresh_context() { + let mut fresh = MegaEvm::new({ + let mut ctx = MegaContext::new(db_with_contract(timestamp_code()), MegaSpecId::MINI_REX_1); + zero_fees(&mut ctx); + ctx + }); + let fresh_gas = fresh + .execute_transaction(tx_to_contract(30_000)) + .expect("fresh tx must execute") + .result_and_state + .result + .tx_gas_used(); + + let mut reused = MegaEvm::new(to_alias(latch_then_ctx(timestamp_code()))); + let reused_gas = reused + .execute_transaction(tx_to_contract(30_000)) + .expect("reused tx must execute") + .result_and_state + .result + .tx_gas_used(); + + assert_eq!( + reused_gas, fresh_gas, + "the alias window must charge the same gas whether or not the context carries MINI_REX state" + ); +} + +/// A halt that happens after a block-environment access must keep the generic limit verdict in +/// the alias window instead of being reclassified as a volatile-data halt. +#[test] +fn test_mini_rex_1_does_not_reclassify_a_halt_as_volatile_data() { + let ctx = to_alias(latch_then_ctx(timestamp_code())); + let mut evm = MegaEvm::new(ctx); + let outcome = evm + .execute_transaction(tx_to_contract(21_002)) + .expect("the transaction must produce an execution result"); + + match &outcome.result_and_state.result { + ExecutionResult::Halt { reason, .. } => { + assert!( + matches!(reason, MegaHaltReason::ComputeGasLimitExceeded { .. }), + "the alias window must keep the generic limit verdict, got {reason:?}" + ); + } + other => panic!("expected a halt, got {other:?}"), + } +} + +/// `on_new_block` refreshes the dynamic storage-gas cache. The alias window has no reader for the +/// refreshed cache, and clearing it would lose the buckets the previous spec priced. +#[test] +fn test_mini_rex_1_keeps_the_dynamic_storage_gas_buckets_across_a_block() { + let mut ctx = MegaContext::new( + db_with_contract( + BytecodeBuilder::default().sstore(U256::from(1), U256::from(2)).stop().build(), + ), + MegaSpecId::MINI_REX, + ); + zero_fees(&mut ctx); + let mut evm = MegaEvm::new(ctx); + evm.execute_transaction(tx_to_contract(1_000_000)).expect("sstore tx must execute"); + let ctx = evm.into_inner().ctx; + let before = ctx.dynamic_storage_gas_cost.borrow().get_bucket_ids(); + assert!(!before.is_empty(), "the seeding transaction must price at least one bucket"); + + let ctx = to_alias(ctx).with_block(Default::default()); + let after = ctx.dynamic_storage_gas_cost.borrow().get_bucket_ids(); + assert_eq!(after, before, "the alias window must not clear the inherited bucket set"); +} + +/// An inspector that answers a nested call must not leave a limit frame behind in the alias +/// window: `push_empty_frame` is only paired with a pop when the `MINI_REX` accounting runs. +struct SkipNestedCall { + intercepted: Rc>, +} + +impl Inspector for SkipNestedCall { + fn call(&mut self, context: &mut CTX, inputs: &mut CallInputs) -> Option { + (context.journal().depth() > 0).then(|| { + self.intercepted.set(self.intercepted.get() + 1); + CallOutcome::new( + InterpreterResult { + result: InstructionResult::Stop, + output: Bytes::new(), + gas: Gas::new(inputs.gas_limit), + }, + 0..0, + ) + }) + } +} + +#[test] +fn test_mini_rex_1_inspector_intercept_leaves_no_limit_frame() { + let callee = BytecodeBuilder::default() + .push_number(0u64) + .push_number(0u64) + .push_number(0u64) + .push_number(0u64) + .push_number(0u64) + .push_address(INNER) + .push_number(100_000u64) + .append(CALL) + .append(POP) + .stop() + .build(); + let inner = BytecodeBuilder::default().stop().build(); + let db = MemoryDatabase::default() + .account_balance(CALLER, U256::from(INITIAL_BALANCE)) + .account_code(CONTRACT, callee) + .account_code(INNER, inner); + let mut ctx = MegaContext::new(db, MegaSpecId::MINI_REX_1); + zero_fees(&mut ctx); + let intercepted = Rc::new(Cell::new(0u32)); + let inspector = SkipNestedCall { intercepted: Rc::clone(&intercepted) }; + let mut evm = MegaEvm::new(ctx).with_inspector(inspector); + + evm.execute_transaction(tx_to_contract(1_000_000)).expect("intercepted tx must execute"); + assert_eq!(intercepted.get(), 1, "the nested call must be intercepted"); + assert!( + !evm.ctx_ref().additional_limit.borrow().data_size.has_active_frame(), + "an intercepted frame must not leave a limit frame behind in the alias window" + ); +} diff --git a/crates/mega-evm/src/evm/mod.rs b/crates/mega-evm/src/evm/mod.rs index 47021e15e..ca715d3b2 100644 --- a/crates/mega-evm/src/evm/mod.rs +++ b/crates/mega-evm/src/evm/mod.rs @@ -782,3 +782,6 @@ mod tests { assert!(result.is_err()); } } + +#[cfg(test)] +mod gate_reuse_tests; diff --git a/crates/mega-evm/tests/mini_rex/alias_window_gates.rs b/crates/mega-evm/tests/mini_rex/alias_window_gates.rs index 037ac819d..4a407ef05 100644 --- a/crates/mega-evm/tests/mini_rex/alias_window_gates.rs +++ b/crates/mega-evm/tests/mini_rex/alias_window_gates.rs @@ -51,13 +51,22 @@ fn build_evm( /// one-byte contract. Covers the frame-entry, frame-return, storage-gas, code-deposit and /// volatile-access paths in a single transaction. fn scenario_db() -> MemoryDatabase { + // INNER writes a slot, emits LOG0 and returns the 32-byte word 0x2a. let inner_code = BytecodeBuilder::default() .sstore(U256::from(1), U256::from(2)) .push_number(0u64) .push_number(0u64) .append(LOG0) - .stop() + .push_number(0x2au64) + .push_number(0u64) + .append(MSTORE) + .push_number(32u64) + .push_number(0u64) + .append(RETURN) .build(); + // CALLEE writes a slot, calls INNER and stores the call's success flag at word 0, then + // CREATEs a contract and stores the returned address at word 32, returning both words. The + // success flag and the address therefore reach the caller instead of being discarded. let callee_code = BytecodeBuilder::default() .sstore(U256::from(3), U256::from(4)) .push_number(0u64) @@ -68,13 +77,17 @@ fn scenario_db() -> MemoryDatabase { .push_address(INNER) .push_number(100_000u64) .append(CALL) - .append(POP) + .push_number(0u64) + .append(MSTORE) .push_number(1u64) .push_number(0u64) .push_number(0u64) .append(CREATE) - .append(POP) - .stop() + .push_number(32u64) + .append(MSTORE) + .push_number(64u64) + .push_number(0u64) + .append(RETURN) .build(); MemoryDatabase::default() @@ -98,13 +111,13 @@ fn scenario_tx() -> MegaTransaction { } /// `(success, gas used, output length)` for the scenario transaction at `spec`. -fn observe(spec: MegaSpecId) -> (bool, u64, usize) { +fn observe(spec: MegaSpecId) -> (bool, u64, Vec) { let mut evm = build_evm(scenario_db(), spec); let result = alloy_evm::Evm::transact_raw(&mut evm, scenario_tx()).expect("tx must execute"); ( result.result.is_success(), result.result.tx_gas_used(), - result.result.output().map(|out| out.len()).unwrap_or(0), + result.result.output().map(|out| out.to_vec()).unwrap_or_default(), ) } @@ -120,6 +133,21 @@ fn test_mini_rex_1_window_matches_equivalence_observation() { "the MiniRex1 window must observe exactly what EQUIVALENCE observes" ); assert!(at_window.0, "scenario transaction must succeed in the window"); + assert_eq!( + at_window.2.len(), + 64, + "the callee must return the call flag and the created address" + ); + assert_eq!( + U256::from_be_slice(&at_window.2[..32]), + U256::from(1u64), + "the nested call must report success to the caller" + ); + assert_ne!( + U256::from_be_slice(&at_window.2[32..]), + U256::ZERO, + "the CREATE must report a deployed address to the caller" + ); } /// No metered dimension may move in the window: the stock table installs no wrapper that feeds diff --git a/mutants/suppressions.toml b/mutants/suppressions.toml index d3251b03f..c16bee6c2 100644 --- a/mutants/suppressions.toml +++ b/mutants/suppressions.toml @@ -802,3 +802,119 @@ column = 1 mutant = "spec-gate .is_enabled(MegaSpecId::REX5) && -> .is_enabled(MegaSpecId::REX6) &&" justification = "Unreachable: `compute_gas_ext::call_code` is installed only by the mini_rex tables (instructions.rs:201-203 selects them for MINI_REX/MINI_REX_2; the CALLCODE assignment is instructions.rs:1015). From `mod rex` on, CALLCODE is replaced by `forward_gas_ext::call_code` (instructions.rs:305) and at REX4 by `volatile_data_ext::call_code` (instructions.rs:418); `mod rex5` inherits rex4's table (instructions.rs:467). The only specs that reach this line have behaviour <= MINI_REX, where `is_enabled(REX4)`, `is_enabled(REX5)` and `is_enabled(REX6)` are all false, so the mutant keeps `stipend_from_revm` at 0 exactly as the original does." reviewer = "RealiCZ" + +# ───────────────────────────────────────────────────────────────────────────── +# spec-gate survivors from the nightly sweep (run 44009245120, main cdcce16d), restricted to the +# gates that remain unobservable after the alias-window tests in +# tests/mini_rex/alias_window_gates.rs and the context-reuse tests in evm/gate_reuse_tests.rs. +# +# Each entry is either unreachable at the spec where the flip takes effect, or reached but unable to +# change anything a block, transaction, receipt or tracer can observe. The MiniRex1 alias window on +# mainnet (block/chain.rs:38-39) does execute these code paths with the gate off, so the reason is +# never "this spec never ran". +# +# The sandbox survivor at sandbox/execution.rs:603 is closed by a test +# (test_rex5_sandbox_balance_precheck_ignores_gas_price). +# +# reviewer: left unset; the sign-off is recorded by the reviewer on the pull request. +# ───────────────────────────────────────────────────────────────────────────── + +# --- crates/mega-evm/src/evm/execution.rs:1774 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/execution.rs" +line = 1774 +column = 1 +mutant = "spec-gate let gas_remaining_before = match (&action, ctx.spec.is_enabled(MegaSpecId::MINI_REX)) { -> let gas_remaining_before = match (&action, ctx.spec.is_enabled(MegaSpecId::EQUIVALENCE)) {" +justification = "Unobservable in the window: the inspected-return path reads gas into the same local snapshot and passes it to the same `after_frame_run`, which returns before reading it in the alias window (execution.rs:509). Neither the normal nor the intercepted callback can observe the snapshot." + +# --- crates/mega-evm/src/evm/execution.rs:1586 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/execution.rs" +line = 1586 +column = 1 +mutant = "spec-gate if self.ctx_ref().spec.is_enabled(MegaSpecId::REX4) { -> if self.ctx_ref().spec.is_enabled(MegaSpecId::REX3) {" +justification = "Reachable check, unobservable state: this line clears a volatile-access disable on frame return. A disable is created only by `AccessControlInterceptor::handle_disable` (system/intercept.rs:357), whose `ACTIVATION_SPEC` is `MegaSpecId::REX4` (system/intercept.rs:340), and the tx-start reset sets the depth to `None`. At REX3 `disable_depth` is therefore always `None`, so `enable_access_if_returning` has nothing to clear; a normal REX3 transaction cannot build the state this clears. Producing one by calling the public `disable_access` from a callback is outside this proof." + +# --- crates/mega-evm/src/evm/execution.rs:1539 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/execution.rs" +line = 1539 +column = 1 +mutant = "spec-gate let gas_remaining_before = match (&action, context.spec.is_enabled(MegaSpecId::MINI_REX)) { -> let gas_remaining_before = match (&action, context.spec.is_enabled(MegaSpecId::EQUIVALENCE)) {" +justification = "Unobservable in the window: the value recorded here is a local snapshot consumed only by `after_frame_run` (execution.rs:1557). In the alias window that consumer returns before reading it (`!is_enabled(MINI_REX)` at execution.rs:509), and `process_next_action` never receives the snapshot." + +# --- crates/mega-evm/src/evm/host.rs:442 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/host.rs" +line = 442 +column = 1 +mutant = "spec-gate self.spec.is_enabled(MegaSpecId::MINI_REX) && address == ORACLE_CONTRACT_ADDRESS, -> self.spec.is_enabled(MegaSpecId::EQUIVALENCE) && address == ORACLE_CONTRACT_ADDRESS," +justification = "`debug_assert!` only, and the only caller already checks the same spec and oracle address (host.rs:192-193), so even a debug build takes the assert on a legal call. Compiled out in release." + +# --- crates/mega-evm/src/evm/host.rs:639 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/host.rs" +line = 639 +column = 1 +mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX));" +justification = "`debug_assert!` only: `create_contract_storage_gas` is reached from instructions.rs:2616-2621 and evm/execution.rs:815-822, which select `new_account_storage_gas` under MINI_REX, and the REX6-only path at :2718 satisfies the original assertion too. Compiled out in release." + +# --- crates/mega-evm/src/evm/host.rs:602 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/host.rs" +line = 602 +column = 1 +mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::EQUIVALENCE));" +justification = "`debug_assert!` only. `additional_limit()` is called from the instruction tables and from the intrinsic accounting at evm/execution.rs:744-752, both guarded by the same spec gate; relaxing the assert removes a debug-time invariant and is compiled out in release." + +# --- crates/mega-evm/src/evm/host.rs:608 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/host.rs" +line = 608 +column = 1 +mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::EQUIVALENCE));" +justification = "`debug_assert!` only: SSTORE enters at instructions.rs:927 and the helper is called at :2862, and the alias window installs the stock handler (instructions.rs:203). Relaxing the assert removes a debug-time invariant and is compiled out in release." + +# --- crates/mega-evm/src/evm/host.rs:625 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/host.rs" +line = 625 +column = 1 +mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::EQUIVALENCE));" +justification = "`debug_assert!` only. Besides the instruction tables, the helper is called from top-level CREATE and empty-account transfer validation at evm/execution.rs:747, :821 and :844, all under the same spec gate. Relaxing the assert is compiled out in release." + +# --- crates/mega-evm/src/evm/instructions.rs:3083 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/instructions.rs" +line = 3083 +column = 1 +mutant = "spec-gate .is_enabled(MegaSpecId::REX5) && -> .is_enabled(MegaSpecId::REX4) &&" +justification = "The gate is evaluated on MINI_REX/MINI_REX_2 CALLCODE, but its true branch is the CALL_STIPEND subtraction, and that branch is unreachable there: the wrapped handler is installed only by the mini_rex table (instructions.rs:201-203, CALLCODE assignment at :1015); from `mod rex` the entry is `forward_gas_ext::call_code` (:305) and from REX4 `volatile_data_ext::call_code` (:418); `mod rex5` inherits rex4's table (:467). On the specs that reach this line `is_enabled(REX4)`, `is_enabled(REX5)` and `is_enabled(REX6)` are all false, so `stipend_from_revm` stays 0. The macro's DELEGATECALL and STATICCALL schemes cannot satisfy the value condition at :3084 either." + +# --- crates/mega-evm/src/evm/instructions.rs:3083 --- +[[suppress]] +kind = "line" +category = "equivalent" +file = "crates/mega-evm/src/evm/instructions.rs" +line = 3083 +column = 1 +mutant = "spec-gate .is_enabled(MegaSpecId::REX5) && -> .is_enabled(MegaSpecId::REX6) &&" +justification = "The gate is evaluated on MINI_REX/MINI_REX_2 CALLCODE, but its true branch is the CALL_STIPEND subtraction, and that branch is unreachable there: the wrapped handler is installed only by the mini_rex table (instructions.rs:201-203, CALLCODE assignment at :1015); from `mod rex` the entry is `forward_gas_ext::call_code` (:305) and from REX4 `volatile_data_ext::call_code` (:418); `mod rex5` inherits rex4's table (:467). On the specs that reach this line `is_enabled(REX4)`, `is_enabled(REX5)` and `is_enabled(REX6)` are all false, so `stipend_from_revm` stays 0. The macro's DELEGATECALL and STATICCALL schemes cannot satisfy the value condition at :3084 either." From ae76e820c02eabac072d1c001f0dc9fdf5a53996 Mon Sep 17 00:00:00 2001 From: mega-putin Date: Wed, 18 Nov 2026 06:12:31 +0000 Subject: [PATCH 3/6] test(evm): keep only the new spec-gate suppressions The previous commit appended the narrowed entries on top of the ones the first commit had already added, so the file carried both generations. Rebuild from main and keep the nine entries that are still needed; host.rs:442 is already suppressed on main. --- mutants/suppressions.toml | 207 ++------------------------------------ 1 file changed, 8 insertions(+), 199 deletions(-) diff --git a/mutants/suppressions.toml b/mutants/suppressions.toml index c16bee6c2..0f46ee975 100644 --- a/mutants/suppressions.toml +++ b/mutants/suppressions.toml @@ -613,196 +613,6 @@ mutant = "replace && with || in apply_sandbox_state_journaled_inner" justification = "Equivalent: on equal code hashes, || adds only two copies: a parent that already has code receives the same-hash (identical) bytecode, and an empty-hash parent has None or empty code replaced by the sandbox's empty bytecode, the Some(Bytecode::default()) revm stores itself on any code load of an empty-hash account, so no read, gas cost, result or committed state changes." reviewer = "RealiCZ (cz)" -# ───────────────────────────────────────────────────────────────────────────── -# spec-gate survivors from the nightly sweep (run 44009245120, main cdcce16d). -# -# Every entry below is a gate the sweep flipped that execution cannot distinguish. The two -# reasons used are: the mutated branch cannot be reached at the spec where the flip takes -# effect, or it runs but cannot change anything the chain can observe. The MiniRex1 alias -# window on mainnet (block/chain.rs:38-39) does execute these code paths with the gate off, -# so the window's observable behaviour is pinned by tests/mini_rex/alias_window_gates.rs; -# these entries cover the branches inside that window that remain unobservable. -# -# The sibling survivor at sandbox/execution.rs:603 is closed by a test instead -# (test_rex5_sandbox_balance_precheck_ignores_gas_price). -# ───────────────────────────────────────────────────────────────────────────── - -# --- crates/mega-evm/src/evm/context.rs:692 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/context.rs" -line = 692 -column = 1 -mutant = "spec-gate if self.spec.is_enabled(MegaSpecId::MINI_REX) { -> if self.spec.is_enabled(MegaSpecId::EQUIVALENCE) {" -justification = "Unobservable in the MiniRex1 window (gate off, mutant turns it on): `on_new_block` only refreshes the cached dynamic storage-gas price. Its readers \u2014 `sstore_set_storage_gas`, `new_account_storage_gas`, `create_contract_storage_gas` \u2014 are reached exclusively through the mini_rex+ instruction tables, and `MINI_REX_1` installs revm's stock mainnet table (instructions.rs:201-203). Nothing reads the refreshed price in this window, and the calculator's field is not part of any execution output." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/execution.rs:427 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/execution.rs" -line = 427 -column = 1 -mutant = "spec-gate if ctx.spec.is_enabled(MegaSpecId::MINI_REX) { -> if ctx.spec.is_enabled(MegaSpecId::EQUIVALENCE) {" -justification = "Unobservable in the window: `before_frame_run` answers `Some` only when a metered dimension already exceeded its limit. The stock table installs no wrapper and `after_frame_run` returns before charging anything (`!is_enabled(MINI_REX)` at execution.rs:509 in the unmutated tree), so every counter stays 0 and the call returns `None` \u2014 the same value the unmutated `None` arm yields." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/execution.rs:1680 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/execution.rs" -line = 1680 -column = 1 -mutant = "spec-gate let is_mini_rex_enabled = ctx.spec.is_enabled(MegaSpecId::MINI_REX); -> let is_mini_rex_enabled = ctx.spec.is_enabled(MegaSpecId::EQUIVALENCE);" -justification = "Unobservable: the flag only orders the additional-limit check against the call-depth check for inspector-intercepted frames, and in the window no limit can be exceeded (counters stay 0), so both orders select the same error. Block replay drives the executor without an inspector, so that intercepted branch is not taken on chain at all." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/execution.rs:1774 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/execution.rs" -line = 1774 -column = 1 -mutant = "spec-gate let gas_remaining_before = match (&action, ctx.spec.is_enabled(MegaSpecId::MINI_REX)) { -> let gas_remaining_before = match (&action, ctx.spec.is_enabled(MegaSpecId::EQUIVALENCE)) {" -justification = "Unobservable in the window: same recording as execution.rs:1539 on the inspected path; its only consumer is `after_frame_run`, which returns before reading it (`!is_enabled(MINI_REX)` at execution.rs:509)." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/execution.rs:509 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/execution.rs" -line = 509 -column = 1 -mutant = "spec-gate if !ctx.spec.is_enabled(MegaSpecId::MINI_REX) { -> if !ctx.spec.is_enabled(MegaSpecId::EQUIVALENCE) {" -justification = "Unobservable in the window: the mutant lets the after-frame accounting run, but it only accumulates counters and compares them against `EvmTxRuntimeLimits::from_spec(MINI_REX_1)`. No wrapper feeds those counters in the window (stock table, instructions.rs:201-203), so every increment is zero and no comparison trips: no halt, no extra gas, no state change. The counters are otherwise read only by gates that are themselves off in this window." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/execution.rs:1586 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/execution.rs" -line = 1586 -column = 1 -mutant = "spec-gate if self.ctx_ref().spec.is_enabled(MegaSpecId::REX4) { -> if self.ctx_ref().spec.is_enabled(MegaSpecId::REX3) {" -justification = "Unreachable at REX3: a volatile-access disable can only be created by `AccessControlInterceptor::handle_disable` (system/intercept.rs:357), whose `ACTIVATION_SPEC` is `MegaSpecId::REX4` (system/intercept.rs:340). At REX3 `disable_depth` is therefore always `None` and `enable_access_if_returning` has nothing to clear." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/execution.rs:1068 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/execution.rs" -line = 1068 -column = 1 -mutant = "spec-gate let is_mini_rex = evm.ctx().spec.is_enabled(MegaSpecId::MINI_REX); -> let is_mini_rex = evm.ctx().spec.is_enabled(MegaSpecId::EQUIVALENCE);" -justification = "Unobservable in the window: `before_frame_return_result::` records the frame's consumption and applies the compute-gas clamp only when the tracker holds a compute limit that has been exceeded. In the window the tracker holds no measured compute gas (no wrapper runs), so the extra `` pass records zero and clamps nothing." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/execution.rs:1102 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/execution.rs" -line = 1102 -column = 1 -mutant = "spec-gate .is_enabled(MegaSpecId::MINI_REX) -> .is_enabled(MegaSpecId::EQUIVALENCE)" -justification = "Unobservable in the window: the attached info comes from `get_volatile_data_info()`, which is `Some` only after a volatile access was marked. Marks are produced solely by the REX4+ `disableVolatileDataAccess` path (`AccessControlInterceptor::ACTIVATION_SPEC` = REX4, system/intercept.rs:340), which the window's stock table never reaches, so both sides attach `None`." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/execution.rs:1539 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/execution.rs" -line = 1539 -column = 1 -mutant = "spec-gate let gas_remaining_before = match (&action, context.spec.is_enabled(MegaSpecId::MINI_REX)) { -> let gas_remaining_before = match (&action, context.spec.is_enabled(MegaSpecId::EQUIVALENCE)) {" -justification = "Unobservable in the window: the recorded value has exactly one consumer, `after_frame_run`, and that consumer returns immediately in the window (`!is_enabled(MINI_REX)` at execution.rs:509 in the unmutated tree). Recording `Some(remaining)` instead of `None` therefore produces a value nothing reads." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/host.rs:442 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/host.rs" -line = 442 -column = 1 -mutant = "spec-gate self.spec.is_enabled(MegaSpecId::MINI_REX) && address == ORACLE_CONTRACT_ADDRESS, -> self.spec.is_enabled(MegaSpecId::EQUIVALENCE) && address == ORACLE_CONTRACT_ADDRESS," -justification = "debug_assert! only: the condition is a debug self-check on `oracle_sload`'s oracle-address predicate. `debug_assert!` is compiled out in release, so relaxing it cannot change behaviour the chain can observe; it only removes a debug-time invariant." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/host.rs:639 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/host.rs" -line = 639 -column = 1 -mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX));" -justification = "debug_assert! only: `create_contract_storage_gas` is called only from the REX+ CREATE paths; asserting MINI_REX instead of REX relaxes a debug-time invariant that is compiled out in release, so execution behaviour is unchanged." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/host.rs:602 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/host.rs" -line = 602 -column = 1 -mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::EQUIVALENCE));" -justification = "debug_assert! only: `additional_limit()` is reached only from the mini_rex+ instruction tables, so the assertion is a debug-time invariant. `debug_assert!` is compiled out in release; relaxing it cannot change execution behaviour." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/host.rs:608 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/host.rs" -line = 608 -column = 1 -mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::EQUIVALENCE));" -justification = "debug_assert! only: `sstore_set_storage_gas` is installed only by the mini_rex+ tables; the assertion is a debug-time invariant, compiled out in release. Relaxing it cannot change execution behaviour." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/host.rs:625 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/host.rs" -line = 625 -column = 1 -mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::EQUIVALENCE));" -justification = "debug_assert! only: `new_account_storage_gas` is installed only by the mini_rex+ tables; the assertion is a debug-time invariant, compiled out in release. Relaxing it cannot change execution behaviour." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/instructions.rs:3083 --- -[[suppress]] -kind = "line" -category = "dead" -file = "crates/mega-evm/src/evm/instructions.rs" -line = 3083 -column = 1 -mutant = "spec-gate .is_enabled(MegaSpecId::REX5) && -> .is_enabled(MegaSpecId::REX4) &&" -justification = "Unreachable: `compute_gas_ext::call_code` is installed only by the mini_rex tables (instructions.rs:201-203 selects them for MINI_REX/MINI_REX_2; the CALLCODE assignment is instructions.rs:1015). From `mod rex` on, CALLCODE is replaced by `forward_gas_ext::call_code` (instructions.rs:305) and at REX4 by `volatile_data_ext::call_code` (instructions.rs:418); `mod rex5` inherits rex4's table (instructions.rs:467). The only specs that reach this line have behaviour <= MINI_REX, where `is_enabled(REX4)`, `is_enabled(REX5)` and `is_enabled(REX6)` are all false, so the mutant keeps `stipend_from_revm` at 0 exactly as the original does." -reviewer = "RealiCZ" - -# --- crates/mega-evm/src/evm/instructions.rs:3083 --- -[[suppress]] -kind = "line" -category = "dead" -file = "crates/mega-evm/src/evm/instructions.rs" -line = 3083 -column = 1 -mutant = "spec-gate .is_enabled(MegaSpecId::REX5) && -> .is_enabled(MegaSpecId::REX6) &&" -justification = "Unreachable: `compute_gas_ext::call_code` is installed only by the mini_rex tables (instructions.rs:201-203 selects them for MINI_REX/MINI_REX_2; the CALLCODE assignment is instructions.rs:1015). From `mod rex` on, CALLCODE is replaced by `forward_gas_ext::call_code` (instructions.rs:305) and at REX4 by `volatile_data_ext::call_code` (instructions.rs:418); `mod rex5` inherits rex4's table (instructions.rs:467). The only specs that reach this line have behaviour <= MINI_REX, where `is_enabled(REX4)`, `is_enabled(REX5)` and `is_enabled(REX6)` are all false, so the mutant keeps `stipend_from_revm` at 0 exactly as the original does." -reviewer = "RealiCZ" - # ───────────────────────────────────────────────────────────────────────────── # spec-gate survivors from the nightly sweep (run 44009245120, main cdcce16d), restricted to the # gates that remain unobservable after the alias-window tests in @@ -820,6 +630,7 @@ reviewer = "RealiCZ" # ───────────────────────────────────────────────────────────────────────────── # --- crates/mega-evm/src/evm/execution.rs:1774 --- + [[suppress]] kind = "line" category = "equivalent" @@ -830,6 +641,7 @@ mutant = "spec-gate let gas_remaining_before = match (&action, ctx.spec.is_enabl justification = "Unobservable in the window: the inspected-return path reads gas into the same local snapshot and passes it to the same `after_frame_run`, which returns before reading it in the alias window (execution.rs:509). Neither the normal nor the intercepted callback can observe the snapshot." # --- crates/mega-evm/src/evm/execution.rs:1586 --- + [[suppress]] kind = "line" category = "equivalent" @@ -840,6 +652,7 @@ mutant = "spec-gate if self.ctx_ref().spec.is_enabled(MegaSpecId::REX4) { -> if justification = "Reachable check, unobservable state: this line clears a volatile-access disable on frame return. A disable is created only by `AccessControlInterceptor::handle_disable` (system/intercept.rs:357), whose `ACTIVATION_SPEC` is `MegaSpecId::REX4` (system/intercept.rs:340), and the tx-start reset sets the depth to `None`. At REX3 `disable_depth` is therefore always `None`, so `enable_access_if_returning` has nothing to clear; a normal REX3 transaction cannot build the state this clears. Producing one by calling the public `disable_access` from a callback is outside this proof." # --- crates/mega-evm/src/evm/execution.rs:1539 --- + [[suppress]] kind = "line" category = "equivalent" @@ -850,16 +663,7 @@ mutant = "spec-gate let gas_remaining_before = match (&action, context.spec.is_e justification = "Unobservable in the window: the value recorded here is a local snapshot consumed only by `after_frame_run` (execution.rs:1557). In the alias window that consumer returns before reading it (`!is_enabled(MINI_REX)` at execution.rs:509), and `process_next_action` never receives the snapshot." # --- crates/mega-evm/src/evm/host.rs:442 --- -[[suppress]] -kind = "line" -category = "equivalent" -file = "crates/mega-evm/src/evm/host.rs" -line = 442 -column = 1 -mutant = "spec-gate self.spec.is_enabled(MegaSpecId::MINI_REX) && address == ORACLE_CONTRACT_ADDRESS, -> self.spec.is_enabled(MegaSpecId::EQUIVALENCE) && address == ORACLE_CONTRACT_ADDRESS," -justification = "`debug_assert!` only, and the only caller already checks the same spec and oracle address (host.rs:192-193), so even a debug build takes the assert on a legal call. Compiled out in release." -# --- crates/mega-evm/src/evm/host.rs:639 --- [[suppress]] kind = "line" category = "equivalent" @@ -870,6 +674,7 @@ mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::REX)); -> deb justification = "`debug_assert!` only: `create_contract_storage_gas` is reached from instructions.rs:2616-2621 and evm/execution.rs:815-822, which select `new_account_storage_gas` under MINI_REX, and the REX6-only path at :2718 satisfies the original assertion too. Compiled out in release." # --- crates/mega-evm/src/evm/host.rs:602 --- + [[suppress]] kind = "line" category = "equivalent" @@ -880,6 +685,7 @@ mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); - justification = "`debug_assert!` only. `additional_limit()` is called from the instruction tables and from the intrinsic accounting at evm/execution.rs:744-752, both guarded by the same spec gate; relaxing the assert removes a debug-time invariant and is compiled out in release." # --- crates/mega-evm/src/evm/host.rs:608 --- + [[suppress]] kind = "line" category = "equivalent" @@ -890,6 +696,7 @@ mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); - justification = "`debug_assert!` only: SSTORE enters at instructions.rs:927 and the helper is called at :2862, and the alias window installs the stock handler (instructions.rs:203). Relaxing the assert removes a debug-time invariant and is compiled out in release." # --- crates/mega-evm/src/evm/host.rs:625 --- + [[suppress]] kind = "line" category = "equivalent" @@ -900,6 +707,7 @@ mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); - justification = "`debug_assert!` only. Besides the instruction tables, the helper is called from top-level CREATE and empty-account transfer validation at evm/execution.rs:747, :821 and :844, all under the same spec gate. Relaxing the assert is compiled out in release." # --- crates/mega-evm/src/evm/instructions.rs:3083 --- + [[suppress]] kind = "line" category = "equivalent" @@ -910,6 +718,7 @@ mutant = "spec-gate .is_enabled(MegaSpecId::REX5) && -> .is_enabled(MegaSpecId:: justification = "The gate is evaluated on MINI_REX/MINI_REX_2 CALLCODE, but its true branch is the CALL_STIPEND subtraction, and that branch is unreachable there: the wrapped handler is installed only by the mini_rex table (instructions.rs:201-203, CALLCODE assignment at :1015); from `mod rex` the entry is `forward_gas_ext::call_code` (:305) and from REX4 `volatile_data_ext::call_code` (:418); `mod rex5` inherits rex4's table (:467). On the specs that reach this line `is_enabled(REX4)`, `is_enabled(REX5)` and `is_enabled(REX6)` are all false, so `stipend_from_revm` stays 0. The macro's DELEGATECALL and STATICCALL schemes cannot satisfy the value condition at :3084 either." # --- crates/mega-evm/src/evm/instructions.rs:3083 --- + [[suppress]] kind = "line" category = "equivalent" From 544366df784e32b288a0e66d6d95850ec0364dbd Mon Sep 17 00:00:00 2001 From: mega-putin Date: Wed, 18 Nov 2026 07:00:14 +0000 Subject: [PATCH 4/6] test(evm): correct the suppression heading and the reuse-test commentary - label the `host.rs:639` entry with its own line and state that its gate is `REX`, not `MINI_REX`. - stop claiming code-deposit coverage in the alias-window scenario: the initcode is a single `STOP` byte, so the deployed runtime is empty. - record in `gate_reuse_tests.rs` that reusing a context only builds a distinguishable state, and that the bucket-set and halt-reason assertions must be revisited if `with_cfg`'s reuse semantics change. --- crates/mega-evm/src/evm/gate_reuse_tests.rs | 6 ++++++ crates/mega-evm/tests/mini_rex/alias_window_gates.rs | 5 +++-- mutants/suppressions.toml | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/mega-evm/src/evm/gate_reuse_tests.rs b/crates/mega-evm/src/evm/gate_reuse_tests.rs index bc9a5f3f9..4e46faf6c 100644 --- a/crates/mega-evm/src/evm/gate_reuse_tests.rs +++ b/crates/mega-evm/src/evm/gate_reuse_tests.rs @@ -6,6 +6,12 @@ //! the latched limit verdict and the dynamic storage-gas cache still hold the previous spec's //! state. These tests pin what the alias window must do with that state, so a gate that is //! flipped one rung cannot quietly act on it. +//! +//! Carrying a context across the change is only a way to build a distinguishable state here; it is +//! not a promise that the trackers, the latched verdict or the storage-gas cache are meant to +//! survive a fork in production. If `with_cfg`'s reuse semantics change, revisit the bucket-set +//! assertion and the halt-reason assertion first: they are the two that read state a fresh context +//! would not have. use std::{cell::Cell, rc::Rc}; diff --git a/crates/mega-evm/tests/mini_rex/alias_window_gates.rs b/crates/mega-evm/tests/mini_rex/alias_window_gates.rs index 4a407ef05..fe480845f 100644 --- a/crates/mega-evm/tests/mini_rex/alias_window_gates.rs +++ b/crates/mega-evm/tests/mini_rex/alias_window_gates.rs @@ -48,8 +48,9 @@ fn build_evm( } /// CALLEE writes a slot, calls INNER (which writes a slot and emits LOG0), then CREATEs a -/// one-byte contract. Covers the frame-entry, frame-return, storage-gas, code-deposit and -/// volatile-access paths in a single transaction. +/// one-byte contract. Covers the frame-entry, frame-return, storage-gas and volatile-access +/// paths in a single transaction. The CREATE deploys an initcode of a single `STOP` byte, so the +/// deployed runtime code is empty and this scenario does not exercise a non-zero code deposit. fn scenario_db() -> MemoryDatabase { // INNER writes a slot, emits LOG0 and returns the 32-byte word 0x2a. let inner_code = BytecodeBuilder::default() diff --git a/mutants/suppressions.toml b/mutants/suppressions.toml index 0f46ee975..65b3a5119 100644 --- a/mutants/suppressions.toml +++ b/mutants/suppressions.toml @@ -662,7 +662,7 @@ column = 1 mutant = "spec-gate let gas_remaining_before = match (&action, context.spec.is_enabled(MegaSpecId::MINI_REX)) { -> let gas_remaining_before = match (&action, context.spec.is_enabled(MegaSpecId::EQUIVALENCE)) {" justification = "Unobservable in the window: the value recorded here is a local snapshot consumed only by `after_frame_run` (execution.rs:1557). In the alias window that consumer returns before reading it (`!is_enabled(MINI_REX)` at execution.rs:509), and `process_next_action` never receives the snapshot." -# --- crates/mega-evm/src/evm/host.rs:442 --- +# --- crates/mega-evm/src/evm/host.rs:639 --- [[suppress]] kind = "line" @@ -671,7 +671,7 @@ file = "crates/mega-evm/src/evm/host.rs" line = 639 column = 1 mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX));" -justification = "`debug_assert!` only: `create_contract_storage_gas` is reached from instructions.rs:2616-2621 and evm/execution.rs:815-822, which select `new_account_storage_gas` under MINI_REX, and the REX6-only path at :2718 satisfies the original assertion too. Compiled out in release." +justification = "`debug_assert!` only: the assertion's own gate is `REX`, not `MINI_REX`. `create_contract_storage_gas` is reached from instructions.rs:2616-2621 and evm/execution.rs:815-822, both of which select `new_account_storage_gas` under `MINI_REX`, so the `REX` paths keep calling it; the REX6-only path at :2718 satisfies the original assertion as well. Compiled out in release." # --- crates/mega-evm/src/evm/host.rs:602 --- From 33e86220a8e098c37b94fe2e5b10e8d7f19b21a3 Mon Sep 17 00:00:00 2001 From: mega-putin Date: Wed, 18 Nov 2026 07:10:28 +0000 Subject: [PATCH 5/6] test(evm): sign the new suppressions --- mutants/suppressions.toml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mutants/suppressions.toml b/mutants/suppressions.toml index 65b3a5119..4b4b8369a 100644 --- a/mutants/suppressions.toml +++ b/mutants/suppressions.toml @@ -639,6 +639,7 @@ line = 1774 column = 1 mutant = "spec-gate let gas_remaining_before = match (&action, ctx.spec.is_enabled(MegaSpecId::MINI_REX)) { -> let gas_remaining_before = match (&action, ctx.spec.is_enabled(MegaSpecId::EQUIVALENCE)) {" justification = "Unobservable in the window: the inspected-return path reads gas into the same local snapshot and passes it to the same `after_frame_run`, which returns before reading it in the alias window (execution.rs:509). Neither the normal nor the intercepted callback can observe the snapshot." +reviewer = "RealiCZ (cz)" # --- crates/mega-evm/src/evm/execution.rs:1586 --- @@ -650,6 +651,7 @@ line = 1586 column = 1 mutant = "spec-gate if self.ctx_ref().spec.is_enabled(MegaSpecId::REX4) { -> if self.ctx_ref().spec.is_enabled(MegaSpecId::REX3) {" justification = "Reachable check, unobservable state: this line clears a volatile-access disable on frame return. A disable is created only by `AccessControlInterceptor::handle_disable` (system/intercept.rs:357), whose `ACTIVATION_SPEC` is `MegaSpecId::REX4` (system/intercept.rs:340), and the tx-start reset sets the depth to `None`. At REX3 `disable_depth` is therefore always `None`, so `enable_access_if_returning` has nothing to clear; a normal REX3 transaction cannot build the state this clears. Producing one by calling the public `disable_access` from a callback is outside this proof." +reviewer = "RealiCZ (cz)" # --- crates/mega-evm/src/evm/execution.rs:1539 --- @@ -661,6 +663,7 @@ line = 1539 column = 1 mutant = "spec-gate let gas_remaining_before = match (&action, context.spec.is_enabled(MegaSpecId::MINI_REX)) { -> let gas_remaining_before = match (&action, context.spec.is_enabled(MegaSpecId::EQUIVALENCE)) {" justification = "Unobservable in the window: the value recorded here is a local snapshot consumed only by `after_frame_run` (execution.rs:1557). In the alias window that consumer returns before reading it (`!is_enabled(MINI_REX)` at execution.rs:509), and `process_next_action` never receives the snapshot." +reviewer = "RealiCZ (cz)" # --- crates/mega-evm/src/evm/host.rs:639 --- @@ -672,6 +675,7 @@ line = 639 column = 1 mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX));" justification = "`debug_assert!` only: the assertion's own gate is `REX`, not `MINI_REX`. `create_contract_storage_gas` is reached from instructions.rs:2616-2621 and evm/execution.rs:815-822, both of which select `new_account_storage_gas` under `MINI_REX`, so the `REX` paths keep calling it; the REX6-only path at :2718 satisfies the original assertion as well. Compiled out in release." +reviewer = "RealiCZ (cz)" # --- crates/mega-evm/src/evm/host.rs:602 --- @@ -683,6 +687,7 @@ line = 602 column = 1 mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::EQUIVALENCE));" justification = "`debug_assert!` only. `additional_limit()` is called from the instruction tables and from the intrinsic accounting at evm/execution.rs:744-752, both guarded by the same spec gate; relaxing the assert removes a debug-time invariant and is compiled out in release." +reviewer = "RealiCZ (cz)" # --- crates/mega-evm/src/evm/host.rs:608 --- @@ -694,6 +699,7 @@ line = 608 column = 1 mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::EQUIVALENCE));" justification = "`debug_assert!` only: SSTORE enters at instructions.rs:927 and the helper is called at :2862, and the alias window installs the stock handler (instructions.rs:203). Relaxing the assert removes a debug-time invariant and is compiled out in release." +reviewer = "RealiCZ (cz)" # --- crates/mega-evm/src/evm/host.rs:625 --- @@ -705,6 +711,7 @@ line = 625 column = 1 mutant = "spec-gate debug_assert!(self.spec.is_enabled(MegaSpecId::MINI_REX)); -> debug_assert!(self.spec.is_enabled(MegaSpecId::EQUIVALENCE));" justification = "`debug_assert!` only. Besides the instruction tables, the helper is called from top-level CREATE and empty-account transfer validation at evm/execution.rs:747, :821 and :844, all under the same spec gate. Relaxing the assert is compiled out in release." +reviewer = "RealiCZ (cz)" # --- crates/mega-evm/src/evm/instructions.rs:3083 --- @@ -716,6 +723,7 @@ line = 3083 column = 1 mutant = "spec-gate .is_enabled(MegaSpecId::REX5) && -> .is_enabled(MegaSpecId::REX4) &&" justification = "The gate is evaluated on MINI_REX/MINI_REX_2 CALLCODE, but its true branch is the CALL_STIPEND subtraction, and that branch is unreachable there: the wrapped handler is installed only by the mini_rex table (instructions.rs:201-203, CALLCODE assignment at :1015); from `mod rex` the entry is `forward_gas_ext::call_code` (:305) and from REX4 `volatile_data_ext::call_code` (:418); `mod rex5` inherits rex4's table (:467). On the specs that reach this line `is_enabled(REX4)`, `is_enabled(REX5)` and `is_enabled(REX6)` are all false, so `stipend_from_revm` stays 0. The macro's DELEGATECALL and STATICCALL schemes cannot satisfy the value condition at :3084 either." +reviewer = "RealiCZ (cz)" # --- crates/mega-evm/src/evm/instructions.rs:3083 --- @@ -727,3 +735,4 @@ line = 3083 column = 1 mutant = "spec-gate .is_enabled(MegaSpecId::REX5) && -> .is_enabled(MegaSpecId::REX6) &&" justification = "The gate is evaluated on MINI_REX/MINI_REX_2 CALLCODE, but its true branch is the CALL_STIPEND subtraction, and that branch is unreachable there: the wrapped handler is installed only by the mini_rex table (instructions.rs:201-203, CALLCODE assignment at :1015); from `mod rex` the entry is `forward_gas_ext::call_code` (:305) and from REX4 `volatile_data_ext::call_code` (:418); `mod rex5` inherits rex4's table (:467). On the specs that reach this line `is_enabled(REX4)`, `is_enabled(REX5)` and `is_enabled(REX6)` are all false, so `stipend_from_revm` stays 0. The macro's DELEGATECALL and STATICCALL schemes cannot satisfy the value condition at :3084 either." +reviewer = "RealiCZ (cz)" From 788bd4a8f6a9090fbaf736acf26ee2ba9ae3a703 Mon Sep 17 00:00:00 2001 From: RealiCZ Date: Thu, 19 Nov 2026 16:35:57 +0800 Subject: [PATCH 6/6] test(evm): drop the unset-reviewer note now that the entries are signed The section header no longer claims the reviewer is unset, since every entry in it names the reviewer. --- mutants/suppressions.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/mutants/suppressions.toml b/mutants/suppressions.toml index 4b4b8369a..1406c67ef 100644 --- a/mutants/suppressions.toml +++ b/mutants/suppressions.toml @@ -625,8 +625,6 @@ reviewer = "RealiCZ (cz)" # # The sandbox survivor at sandbox/execution.rs:603 is closed by a test # (test_rex5_sandbox_balance_precheck_ignores_gas_price). -# -# reviewer: left unset; the sign-off is recorded by the reviewer on the pull request. # ───────────────────────────────────────────────────────────────────────────── # --- crates/mega-evm/src/evm/execution.rs:1774 ---