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..4e46faf6c --- /dev/null +++ b/crates/mega-evm/src/evm/gate_reuse_tests.rs @@ -0,0 +1,263 @@ +//! 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. +//! +//! 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}; + +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/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..fe480845f --- /dev/null +++ b/crates/mega-evm/tests/mini_rex/alias_window_gates.rs @@ -0,0 +1,171 @@ +//! 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 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() + .sstore(U256::from(1), U256::from(2)) + .push_number(0u64) + .push_number(0u64) + .append(LOG0) + .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) + .push_number(0u64) + .push_number(0u64) + .push_number(0u64) + .push_number(0u64) + .push_address(INNER) + .push_number(100_000u64) + .append(CALL) + .push_number(0u64) + .append(MSTORE) + .push_number(1u64) + .push_number(0u64) + .push_number(0u64) + .append(CREATE) + .push_number(32u64) + .append(MSTORE) + .push_number(64u64) + .push_number(0u64) + .append(RETURN) + .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, 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.to_vec()).unwrap_or_default(), + ) +} + +/// 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"); + 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 +/// 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..1406c67ef 100644 --- a/mutants/suppressions.toml +++ b/mutants/suppressions.toml @@ -612,3 +612,125 @@ 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), 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). +# ───────────────────────────────────────────────────────────────────────────── + +# --- 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." +reviewer = "RealiCZ (cz)" + +# --- 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." +reviewer = "RealiCZ (cz)" + +# --- 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." +reviewer = "RealiCZ (cz)" + +# --- 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: 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 --- + +[[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." +reviewer = "RealiCZ (cz)" + +# --- 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." +reviewer = "RealiCZ (cz)" + +# --- 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." +reviewer = "RealiCZ (cz)" + +# --- 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." +reviewer = "RealiCZ (cz)" + +# --- 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." +reviewer = "RealiCZ (cz)"