Documentation
¶
Overview ¶
Package fees implements the OP-Stack L1 data-availability cost and operator-fee calculations. It is pure arithmetic over byte counts and big integers and depends only on the standard library and go-ethereum's core/types (for TxRollupCostData) and params (for the EIP-2028 gas schedule); it has no dependency on op-core/types, so the two packages remain cycle-free siblings.
It covers the L1 cost functions from Bedrock through Fjord and the Isthmus and Jovian operator-fee formulas. Consumers import the package as opfees.
Index ¶
- Variables
- func FlzCompressLen(ib []byte) uint32
- func L1CostBedrock(rollupDataGas uint64, l1BaseFee, overhead, scalar *big.Int) *big.Int
- func L1CostEcotone(rcd RollupCostData, p L1FeeParams) *big.Int
- func L1CostFjord(rcd RollupCostData, p L1FeeParams) *big.Int
- func OperatorCostIsthmus(gasUsed, scalar, constant uint64) *big.Int
- func OperatorCostJovian(gasUsed, scalar, constant uint64) *big.Int
- type L1FeeParams
- type RollupCostData
Constants ¶
This section is empty.
Variables ¶
var ( // L1CostIntercept and L1CostFastlzCoef are the coefficients of the Fjord linear // regression that estimates a transaction's compressed DA size from its FastLZ size. L1CostIntercept = big.NewInt(-42_585_600) L1CostFastlzCoef = big.NewInt(836_500) // MinTransactionSize is the lower bound the Fjord DA-size estimate is clamped to. MinTransactionSize = big.NewInt(100) MinTransactionSizeScaled = new(big.Int).Mul(MinTransactionSize, big.NewInt(1e6)) )
Functions ¶
func FlzCompressLen ¶
FlzCompressLen returns the length of the data after compression through FastLZ, based on https://github.com/Vectorized/solady/blob/5315d937d79b335c668896d7533ac603adac5315/js/solady.js
func L1CostBedrock ¶
L1CostBedrock computes the Bedrock-era data-availability fee: (rollupDataGas + overhead) * l1BaseFee * scalar / 1_000_000. rollupDataGas is the calldata gas of the transaction.
func L1CostEcotone ¶
func L1CostEcotone(rcd RollupCostData, p L1FeeParams) *big.Int
L1CostEcotone returns the Ecotone-era data-availability fee for a transaction (excluding the very first Ecotone block, which still uses L1CostBedrock).
func L1CostFjord ¶
func L1CostFjord(rcd RollupCostData, p L1FeeParams) *big.Int
L1CostFjord returns the Fjord-era data-availability fee for a transaction.
func OperatorCostIsthmus ¶
OperatorCostIsthmus computes the Isthmus operator fee charged to a transaction: (gasUsed * scalar / 1_000_000) + constant, where scalar and constant are the operatorFeeScalar and operatorFeeConstant L1 attributes.
func OperatorCostJovian ¶
OperatorCostJovian computes the Jovian operator fee charged to a transaction: (gasUsed * scalar * 100) + constant, where scalar and constant are the operatorFeeScalar and operatorFeeConstant L1 attributes. Jovian replaces the Isthmus division by 1_000_000 with a multiplication by 100.
Types ¶
type L1FeeParams ¶
type L1FeeParams struct {
L1BaseFee *big.Int
L1BlobBaseFee *big.Int
BaseFeeScalar *big.Int
BlobFeeScalar *big.Int
}
L1FeeParams holds the L1 base fee, blob base fee, and their scalars used to price a transaction's data availability under Ecotone and Fjord. They are read together from the L1-block-info attributes (or the L1Block / gas-price-oracle predeploys).
type RollupCostData ¶
RollupCostData carries the byte counts of a transaction's L1 representation needed to compute its data-availability cost.
func NewRollupCostData ¶
func NewRollupCostData(data []byte) (out RollupCostData)
NewRollupCostData computes the RollupCostData for the given L1 transaction bytes.
func TxRollupCostData ¶
func TxRollupCostData(tx *types.Transaction) RollupCostData
TxRollupCostData computes the RollupCostData for a transaction. It replaces op-geth's (*types.Transaction).RollupCostData() method: deposits incur no DA cost, and the cost data is derived from the full binary-encoded transaction, not just its calldata.
func (RollupCostData) EstimatedDASize ¶
func (cd RollupCostData) EstimatedDASize() *big.Int
EstimatedDASize estimates the number of bytes the transaction occupies in its DA batch using the Fjord linear-regression model.