fee

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

TODO: Before Quasar Edition, address all TODOs in this package and ensure LP-103 compliance.

Index

Constants

This section is empty.

Variables

View Source
var (
	IntrinsicAddChainValidatorTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			intrinsicNetValidatorBandwidth +
			wrappersIntLen +
			wrappersIntLen,
		gas.DBRead:  3,
		gas.DBWrite: 3,
	}
	IntrinsicCreateChainTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			wrappersShortLen +
			ids.IDLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen,
		gas.DBRead:  3,
		gas.DBWrite: 1,
	}
	IntrinsicCreateNetworkTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			wrappersIntLen,
		gas.DBWrite: 1,
	}
	IntrinsicImportTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			wrappersIntLen,
	}
	IntrinsicExportTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			wrappersIntLen,
	}
	IntrinsicRemoveChainValidatorTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.NodeIDLen +
			ids.IDLen +
			wrappersIntLen +
			wrappersIntLen,
		gas.DBRead:  1,
		gas.DBWrite: 3,
	}
	IntrinsicAddPermissionlessValidatorTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			intrinsicValidatorBandwidth +
			ids.IDLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen,
		gas.DBRead:  1,
		gas.DBWrite: 3,
	}
	IntrinsicAddPermissionlessDelegatorTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			intrinsicValidatorBandwidth +
			ids.IDLen +
			wrappersIntLen +
			wrappersIntLen,
		gas.DBRead:  1,
		gas.DBWrite: 2,
	}
	IntrinsicTransferChainOwnershipTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen,
		gas.DBRead:  1,
		gas.DBWrite: 1,
	}
	IntrinsicTransformChainTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			ids.IDLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersLongLen +
			wrappersLongLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen,
		gas.DBRead:  2,
		gas.DBWrite: 1,
	}
	IntrinsicBaseTxComplexities = gas.Dimensions{
		gas.Bandwidth: codecVersionSize +
			wrappersIntLen +
			wrappersIntLen +
			ids.IDLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen,
	}
	IntrinsicConvertNetworkToL1TxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			ids.IDLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen +
			wrappersIntLen,
		gas.DBRead:  3,
		gas.DBWrite: 2,
	}
	IntrinsicRegisterL1ValidatorTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			wrappersLongLen +
			bls.SignatureLen +
			wrappersIntLen,
		gas.DBRead:  5,
		gas.DBWrite: 6,
		gas.Compute: intrinsicBLSPoPVerifyCompute,
	}
	IntrinsicSetL1ValidatorWeightTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			wrappersIntLen,
		gas.DBRead:  3,
		gas.DBWrite: 5,
	}
	IntrinsicIncreaseL1ValidatorBalanceTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			wrappersLongLen,
		gas.DBRead:  1,
		gas.DBWrite: 5,
	}
	IntrinsicDisableL1ValidatorTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			wrappersIntLen +
			wrappersIntLen,
		gas.DBRead:  1,
		gas.DBWrite: 6,
	}
)
View Source
var (
	ErrCalculatingComplexity = errors.New("error calculating complexity")
	ErrCalculatingGas        = errors.New("error calculating gas")
	ErrCalculatingCost       = errors.New("error calculating cost")
)
View Source
var ErrUnsupportedTx = errors.New("unsupported transaction type")

Functions

func AuthComplexity

func AuthComplexity(authIntf verify.Verifiable) (gas.Dimensions, error)

AuthComplexity returns the complexity an authorization adds to a transaction. It does not include the typeID of the authorization. It does includes the complexity that the corresponding credential will add. It does not include the typeID of the credential.

func ConvertNetworkToL1ValidatorComplexity

func ConvertNetworkToL1ValidatorComplexity(l1Validators ...*txs.ConvertNetworkToL1Validator) (gas.Dimensions, error)

ConvertNetworkToL1ValidatorComplexity returns the complexity the validators add to a transaction.

func InputComplexity

func InputComplexity(ins ...*lux.TransferableInput) (gas.Dimensions, error)

InputComplexity returns the complexity inputs add to a transaction. It includes the complexity that the corresponding credentials will add.

func OutputComplexity

func OutputComplexity(outs ...*lux.TransferableOutput) (gas.Dimensions, error)

OutputComplexity returns the complexity outputs add to a transaction.

func OwnerComplexity

func OwnerComplexity(ownerIntf fx.Owner) (gas.Dimensions, error)

OwnerComplexity returns the complexity an owner adds to a transaction. It does not include the typeID of the owner.

func SignerComplexity

func SignerComplexity(s signer.Signer) (gas.Dimensions, error)

SignerComplexity returns the complexity a signer adds to a transaction. It does not include the typeID of the signer.

func TxComplexity

func TxComplexity(warpCodec warp.Codec, txList ...txs.UnsignedTx) (gas.Dimensions, error)

TxComplexity computes the gas-cost dimensions for one or more unsigned PVM txs. The warpCodec is the proto/p/warp codec used by the L1-validator family (Register / SetWeight / Increase / Disable) to parse the warp message embedded in those txs; pass nil if none of the supplied txs carry warp messages — TxComplexity will surface a nil-codec error from the visitor at the first warp parse attempt.

func WarpComplexity

func WarpComplexity(warpCodec warp.Codec, message []byte) (gas.Dimensions, error)

WarpComplexity returns the complexity a warp message adds to a transaction. The warpCodec is the proto/p/warp codec used to parse the supplied message bytes; callers thread it in from their PVM parser bundle.

Types

type Calculator

type Calculator interface {
	CalculateFee(tx txs.UnsignedTx) (uint64, error)
}

Calculator calculates the minimum required fee, in nLUX, that an unsigned transaction must pay for valid inclusion into a block.

func NewDynamicCalculator

func NewDynamicCalculator(
	warpCodec warp.Codec,
	weights gas.Dimensions,
	price gas.Price,
) Calculator

NewDynamicCalculator returns a Calculator that prices txs against the supplied weights and gas price. The warpCodec is the proto/p/warp codec used by the L1-validator family (Register / SetWeight / etc.) to parse the warp message embedded in those txs; pass nil if no L1 validator txs will be priced through this calculator.

func NewSimpleStaticCalculator

func NewSimpleStaticCalculator(config StaticConfig) Calculator

type SimpleCalculator

type SimpleCalculator struct {
	// contains filtered or unexported fields
}

func NewSimpleCalculator

func NewSimpleCalculator(fee uint64) *SimpleCalculator

func (*SimpleCalculator) CalculateFee

func (c *SimpleCalculator) CalculateFee(txs.UnsignedTx) (uint64, error)

type StaticConfig

type StaticConfig struct {
	// Fee that is burned by every non-state creating transaction
	TxFee uint64 `json:"txFee"`

	// Fee that must be burned by every state creating transaction before AP3
	CreateAssetTxFee uint64 `json:"createAssetTxFee"`

	// Fee that must be burned by every network creating transaction after AP3
	CreateNetworkTxFee uint64 `json:"createNetworkTxFee"`

	// Fee that must be burned by every transform chain transaction
	TransformChainTxFee uint64 `json:"transformChainTxFee"`

	// Fee that must be burned by every chain creating transaction after AP3
	CreateChainTxFee uint64 `json:"createChainTxFee"`

	// Transaction fee for adding a network validator
	AddNetworkValidatorFee uint64 `json:"addNetworkValidatorFee"`

	// Transaction fee for adding a network delegator
	AddNetworkDelegatorFee uint64 `json:"addNetworkDelegatorFee"`

	// Transaction fee for adding a chain validator
	AddChainValidatorFee uint64 `json:"addChainValidatorFee"`

	// Transaction fee for adding a chain delegator
	AddChainDelegatorFee uint64 `json:"addChainDelegatorFee"`
}

Jump to

Keyboard shortcuts

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