Skip to content

fault-proof: update precompile oracle requiredGas for Glamsterdam (EIP-7904) #19381

Closed

Description

@ajsutton

Problem

The OP Stack fault proof program accelerates precompiles via the L1 PreimageOracle. When the proof client runs a precompile, it calls Oracle.Precompile(address, input, requiredGas). The requiredGas value is embedded in the preimage hint and key:

key = keccak256(address[20] || requiredGas[8] || input[N])

The challenger reads requiredGas from the hint — so client and challenger always agree on the value. loadPrecompilePreimagePart on L1 enforces that the caller forwards at least requiredGas gas to the precompile staticcall. If requiredGas < actual L1 cost, the staticcall OOGs and the oracle stores a failure result silently, corrupting the dispute game.

The bug: Run() currently passes c.RequiredGas(input) (the L2 gas schedule) to Oracle.Precompile(). EIP-7904 (Glamsterdam) raises L1 gas for four precompiles above those values. Since requiredGas only needs to be >= L1 cost and overestimating is safe, this fix can deploy proactively before L1 activates.

Note: RequiredGas() on each oracle wrapper must remain unchanged — it governs L2 gas charging. Only the value passed to Oracle.Precompile() in Run() needs updating.

Affected precompiles (EIP-7904)

Precompile Address Current oracle gas Required after EIP-7904
KZG Point Evaluation 0x0a 50,000 89,363
BLS12-381 G1Add 0x0b 375 643
BLS12-381 G2Add 0x0d 600 765
bn256Pairing 0x08 45,000 + 34,000×k 45,000 + 34,103×k

Solution

Three targeted changes to op-program/client/l2/engineapi/precompiles.go:

1. bn256PairingOracle.Run() — use EIP-7904 per-pair gas

Add a helper using 34,103/pair (was 34,000) and call it instead of b.RequiredGas(input). bn256PairingOracleGranite and bn256PairingOracleJovian both delegate to bn256PairingOracle.Run() so they inherit the fix automatically.

2. kzgPointEvaluationOracle.Run() — use constant 89,363

Replace b.RequiredGas(input) with a constant 89_363.

3. blsOperationOracle — add oracleGas uint64 field

Add an optional oracleGas uint64 field. When non-zero, Run() uses it instead of Orig.RequiredGas(input). Set oracleGas: 643 for G1Add and oracleGas: 765 for G2Add. All other blsOperationOracle instances (G1MSM, G2MSM, Pairing, MapToG1, MapToG2) leave oracleGas at zero — unchanged behaviour.

Files

  • op-program/client/l2/engineapi/precompiles.go
  • op-program/client/l2/engineapi/precompiles_test.go

Acceptance Criteria

  • Oracle.Precompile() is called with EIP-7904 gas for KZG (89,363), G1Add (643), G2Add (765), bn256Pairing (45,000 + 34,103×k)
  • RequiredGas() on all oracle types is unchanged (L2 gas charging unaffected)
  • Tests verify correct gas is passed to Oracle.Precompile() for all four precompiles
  • Existing tests for unaffected precompiles (ecrecover, G1MSM, G2MSM, etc.) pass unchanged
  • go test ./op-program/client/l2/engineapi/... passes

References

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions