# L2 precompile calls can be impossible to reproduce on L1

L2 bn256Pairing precompile calls consuming near-full block gas cannot be reproduced on L1 by the PreimageOracle, making fault-proof step() impossible and blocking invalid state challenges.

- Payout: Audit contest
- Severity: high
- Program: Optimism
- Found by: Zubat
- Disclosed: 2024-08-16
- Write-up quality: 8/10
- Original: https://github.com/code-423n4/2024-07-optimism-findings/issues/22
- Library page: https://bugbountylibrary.com/r/c4%3A2024-07-optimism%3AH-04
- Tags: area:web3 domain:web3 impact:dos impact:integrity kind:contest platform:code4rena sev:high tech:evm technique:chained technique:source-review vuln:business-logic vuln:dos

**Target:** op-program PreimageOracle / fault dispute game
**Root cause:** Accelerated precompiles with dynamic gas costs (bn256Pairing) can consume nearly the full L2 block gas limit, but reproducing them on L1 via loadPrecompilePreimagePart() requires more gas than the L1 block limit allows due to EIP-150 63/64 forwarding and calldata costs.
**Steps:**
1. Deploy contract whose fallback does `staticcall(gas(), 0x08, 0x80, 165504, 0x0, 0x0)`
2. Call it with 30_000_000 - 70_000 gas so bn256Pairing costs 29_353_000 gas (34_000*k+45_000, k=165504/192)
3. Observe L2 tx succeeds (status 1, gasUsed 29_442_018)
4. Start output cannon dispute game on that block and run challenger
5. Challenger fails to load preimage: needs 29_353_000*64/63=29_818_920 gas, unreachable from EOA (calldata cost 662_016) or contract (30_000_000*63/64=29_531_250)
6. Also hits tx size limit: 165754 > 131072
**How found:** Code review of op-program precompiles.go identifying ecrecover/bn256Pairing/kzgPointEvaluation as accelerated precompiles, then reasoning about dynamic gas cost of bn256Pairing versus L1 reproduction overhead (EIP-150, calldata cost, tx size limit).
**Exploitation:** Attacker submits an L2 tx invoking bn256Pairing with maximal input; the resulting preimage oracle query cannot be satisfied on L1, so step() cannot execute and invalid state transitions cannot be countered, stalling the fault proof.
**Insight:** When auditing fault-proof/optimistic systems, compare L2 execution cost of accelerated operations against the L1 cost to reproduce them including EIP-150 63/64 forwarding and calldata overhead; dynamic-gas precompiles are prime candidates for unreproducible steps.

## Proof of concept (copied exactly from the original report)

**Solidity contract staticcalling 0x08 precompile with large input**

```
contract L2GasLimit {
    fallback() external {
        assembly {
            let success := staticcall(
                gas(),
                0x08,
                0x80,
                165504,
                0x0,
                0x0
            )
            if iszero(success) { revert(0, 0) }
        }
    }
}
```

