You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🤖 Updated to match the implementation (#21314). Changes from the original spec: TxRollupCostData uses tx.MarshalBinary() rather than tx.Data() (the original sketch would compute the DA cost over only the calldata field — see comment); OperatorCost is split into OperatorCostIsthmus + OperatorCostJovian; the pure-math Bedrock/Ecotone cost funcs are also ported (they are used by e2e tests); and #17817 is fixed in the same PR.
Goal
Create op-core/fees containing OP-Stack L1 cost + operator-fee calculations. Consumers import as opfees. Sibling to op-core/types — no cycle (pure math on bytes + big.Int).
Scope
Port from op-geth's core/types/rollup_cost.go. Production code (op-service, op-batcher) uses only the Fjord-era subset, but e2e tests also use the pre-Fjord pure-math helpers, so those are ported too. The state-reading dispatchers (NewL1CostFunc/NewOperatorCostFunc, which need a ChainConfig + StateGetter) are not ported — post-decoupling they're test-only and are handled in the Phase-4 e2e test migration.
Dependencies: stdlib + go-ethereum core/types (for TxRollupCostData) and params (EIP-2028 gas schedule). No import of op-core/types. No cycle possible.
🤖 Claude says: Implemented in #21314. A few corrections / decisions surfaced while building op-core/fees, for context:
1. TxRollupCostData must use tx.MarshalBinary(), not tx.Data(). The sketch in this issue (return NewRollupCostData(tx.Data())) computes the DA cost over only the calldata field. op-geth's (*Transaction).RollupCostData() computes it over the full binary-encoded transaction and returns empty for deposits — using tx.Data() undercounts badly (e.g. a 9-byte-calldata tx → 4 non-zero bytes instead of the real ~36). The implementation (fees.go#L63) uses MarshalBinary + a deposit short-circuit, enforced by a parity test against op-geth's method across legacy/dynamic-fee/blob/deposit txs. The description has been updated.
2. Pre-Fjord cost funcs are not entirely unused. True for production (op-service/op-batcher use only Fjord), but e2e tests do: op-e2e/actions/derivation/system_config_test.go uses types.L1Cost (Bedrock) and op-e2e/system/fees/fees_test.go uses types.NewL1CostFunc/NewOperatorCostFunc (the state-reading dispatchers). Decision: ported the pure-math legacy funcs (L1CostBedrock, NewL1CostFuncEcotone) now; deferred the state-reading dispatchers to Phase 4, since post-decoupling they're test-only (the L2 STF is op-reth/kona) and would couple this pure-math package to op-core/params + a StateGetter.
3. OperatorCost → OperatorCostIsthmus, plus a new OperatorCostJovian. Renamed so the fork is explicit (consistent with NewL1CostFuncFjord); added the Jovian variant (gasUsed*scalar*100 + constant). The Jovian roadmap note was kept out of the code doc.
4. #17817 was small enough to include here — fixed by always using the Jovian operator-fee formula in txinclude (both the estimate and the actual-cost refund). Jovian is exact on Jovian chains (all production chains) and >= Isthmus for any inputs, so on a pre-Jovian chain it only over-reserves budget. IsthmusCostOracle was renamed to OperatorCostOracle.
Activity
sebastianst commentedon Jun 9, 2026
🤖 Claude says: Implemented in #21314. A few corrections / decisions surfaced while building
op-core/fees, for context:1.
TxRollupCostDatamust usetx.MarshalBinary(), nottx.Data(). The sketch in this issue (return NewRollupCostData(tx.Data())) computes the DA cost over only the calldata field. op-geth's(*Transaction).RollupCostData()computes it over the full binary-encoded transaction and returns empty for deposits — usingtx.Data()undercounts badly (e.g. a 9-byte-calldata tx → 4 non-zero bytes instead of the real ~36). The implementation (fees.go#L63) usesMarshalBinary+ a deposit short-circuit, enforced by a parity test against op-geth's method across legacy/dynamic-fee/blob/deposit txs. The description has been updated.2. Pre-Fjord cost funcs are not entirely unused. True for production (op-service/op-batcher use only Fjord), but e2e tests do:
op-e2e/actions/derivation/system_config_test.gousestypes.L1Cost(Bedrock) andop-e2e/system/fees/fees_test.gousestypes.NewL1CostFunc/NewOperatorCostFunc(the state-reading dispatchers). Decision: ported the pure-math legacy funcs (L1CostBedrock,NewL1CostFuncEcotone) now; deferred the state-reading dispatchers to Phase 4, since post-decoupling they're test-only (the L2 STF is op-reth/kona) and would couple this pure-math package toop-core/params+ aStateGetter.3.
OperatorCost→OperatorCostIsthmus, plus a newOperatorCostJovian. Renamed so the fork is explicit (consistent withNewL1CostFuncFjord); added the Jovian variant (gasUsed*scalar*100 + constant). The Jovian roadmap note was kept out of the code doc.4. #17817 was small enough to include here — fixed by always using the Jovian operator-fee formula in
txinclude(both the estimate and the actual-cost refund). Jovian is exact on Jovian chains (all production chains) and>=Isthmus for any inputs, so on a pre-Jovian chain it only over-reserves budget.IsthmusCostOraclewas renamed toOperatorCostOracle.🤖 Generated by Claude Code
feat(op-core): add op-core/fees (L1 cost + operator-fee math) (ethere…
feat(op-core): add op-core/fees (L1 cost + operator-fee math) (ethere…