arbos/
reverted_tx_gas.rs

1//! Hardcoded per-tx gas overrides for previously-reverted transactions.
2//!
3//! When a tx hash appears in this table, `RevertedTxHook` short-circuits
4//! execution and forces the recorded `l2GasUsed`. Used to repair historical
5//! Sepolia divergence from a Stylus ARM/x86 determinism incident; replays
6//! must apply the same override or block hashes diverge.
7
8use alloy_primitives::{B256, b256};
9
10/// Lookup the recorded L2 gas-used for a tx hash. `Some(g)` means the tx
11/// must be force-reverted with `g` total L2 gas (excludes poster gas).
12///
13/// Both entries stem from the same Sepolia ARM-vs-x86 Stylus determinism
14/// incident at block ~204,060,000: a contract activated at v40 with the
15/// default MaxStackDepth recurses deeply enough that Cranelift's stack
16/// frames consume Rust call stack differently on ARM vs x86, so the two
17/// architectures terminate at different ink levels and report different gas.
18/// arbreth runs on arm64, so this override is required for replay parity.
19pub fn lookup(tx_hash: B256) -> Option<u64> {
20    // tx 0x58df300a — block 204,060,366. Canon: gasUsed=0xb226=45_606,
21    // l2-only (canon - 432 calldata) = 45_174.
22    const SEPOLIA_STYLUS_INCIDENT_A: B256 =
23        b256!("58df300a7f04fe31d41d24672786cbe1c58b4f3d8329d0d74392d814dd9f7e40");
24    // tx 0xe22b6570 — block 204,060,502. Same canon shape (45_606 → 45_174).
25    const SEPOLIA_STYLUS_INCIDENT_B: B256 =
26        b256!("e22b6570bd5e539adb0363602edfc2ceeb979802d7697dcd3b203d2d734176da");
27    if tx_hash == SEPOLIA_STYLUS_INCIDENT_A || tx_hash == SEPOLIA_STYLUS_INCIDENT_B {
28        return Some(45_174);
29    }
30    None
31}