fees

package
v1.20.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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. It depends on go-ethereum's core/types and params for the transaction envelope and EIP-2028 gas schedule, and on op-core/types to classify OP Stack transaction types.

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

Constants

View Source
const (
	// IsthmusL1AttributesLen is the length of the Isthmus-style L1-attributes deposit calldata.
	IsthmusL1AttributesLen = 176
	// JovianL1AttributesLen is the length of the Jovian-style L1-attributes deposit calldata,
	// which appends the uint16 daFootprintGasScalar to the Isthmus layout.
	JovianL1AttributesLen = 178
)

Variables

View Source
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 CalcDAFootprint added in v1.19.5

func CalcDAFootprint(txs []*types.Transaction) (uint64, error)

CalcDAFootprint calculates the total DA footprint of a block for an OP Stack chain. Jovian introduces a DA footprint block limit which is stored in the BlobGasUsed header field and that is taken into account during base fee updates. CalcDAFootprint must not be called for pre-Jovian blocks. Deposit and post-exec transactions do not contribute to the footprint.

func ExtractDAFootprintGasScalar added in v1.19.5

func ExtractDAFootprintGasScalar(data []byte) (uint16, error)

ExtractDAFootprintGasScalar extracts the DA footprint gas scalar from the L1 attributes transaction data of a Jovian-enabled block.

func FlzCompressLen

func FlzCompressLen(ib []byte) uint32

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

func L1CostBedrock(rollupDataGas uint64, l1BaseFee, overhead, scalar *big.Int) *big.Int

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

func OperatorCostIsthmus(gasUsed, scalar, constant uint64) *big.Int

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

func OperatorCostJovian(gasUsed, scalar, constant uint64) *big.Int

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

type RollupCostData struct {
	Zeroes, Ones uint64
	FastLzSize   uint64
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL