fee

package
v1.18.21 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: BSD-3-Clause Imports: 20 Imported by: 5

Documentation

Overview

compliance.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedTx = errors.New("unsupported transaction type")

	IntrinsicAddNetValidatorTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			intrinsicNetValidatorBandwidth +
			wrappers.IntLen +
			wrappers.IntLen,
		gas.DBRead:  3,
		gas.DBWrite: 3,
	}
	IntrinsicCreateChainTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			wrappers.ShortLen +
			ids.IDLen +
			wrappers.IntLen +
			wrappers.IntLen +
			wrappers.IntLen +
			wrappers.IntLen,
		gas.DBRead:  3,
		gas.DBWrite: 1,
	}
	IntrinsicCreateNetTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			wrappers.IntLen,
		gas.DBWrite: 1,
	}
	IntrinsicImportTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			wrappers.IntLen,
	}
	IntrinsicExportTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			wrappers.IntLen,
	}
	IntrinsicRemoveNetValidatorTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.NodeIDLen +
			ids.IDLen +
			wrappers.IntLen +
			wrappers.IntLen,
		gas.DBRead:  1,
		gas.DBWrite: 3,
	}
	IntrinsicAddPermissionlessValidatorTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			intrinsicValidatorBandwidth +
			ids.IDLen +
			wrappers.IntLen +
			wrappers.IntLen +
			wrappers.IntLen +
			wrappers.IntLen +
			wrappers.IntLen,
		gas.DBRead:  1,
		gas.DBWrite: 3,
	}
	IntrinsicAddPermissionlessDelegatorTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			intrinsicValidatorBandwidth +
			ids.IDLen +
			wrappers.IntLen +
			wrappers.IntLen,
		gas.DBRead:  1,
		gas.DBWrite: 2,
	}
	IntrinsicTransferNetOwnershipTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			wrappers.IntLen +
			wrappers.IntLen +
			wrappers.IntLen,
		gas.DBRead:  1,
		gas.DBWrite: 1,
	}
	IntrinsicBaseTxComplexities = gas.Dimensions{
		gas.Bandwidth: codec.VersionSize +
			wrappers.IntLen +
			wrappers.IntLen +
			ids.IDLen +
			wrappers.IntLen +
			wrappers.IntLen +
			wrappers.IntLen +
			wrappers.IntLen,
	}
	IntrinsicConvertNetToL1TxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			ids.IDLen +
			wrappers.IntLen +
			wrappers.IntLen +
			wrappers.IntLen +
			wrappers.IntLen,
		gas.DBRead:  3,
		gas.DBWrite: 2,
	}
	IntrinsicRegisterL1ValidatorTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			wrappers.LongLen +
			bls.SignatureLen +
			wrappers.IntLen,
		gas.DBRead:  5,
		gas.DBWrite: 6,
		gas.Compute: intrinsicBLSPoPVerifyCompute,
	}
	IntrinsicSetL1ValidatorWeightTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			wrappers.IntLen,
		gas.DBRead:  3,
		gas.DBWrite: 5,
	}
	IntrinsicIncreaseL1ValidatorBalanceTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			wrappers.LongLen,
		gas.DBRead:  1,
		gas.DBWrite: 5,
	}
	IntrinsicDisableL1ValidatorTxComplexities = gas.Dimensions{
		gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] +
			ids.IDLen +
			wrappers.IntLen +
			wrappers.IntLen,
		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")
)

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 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 NewDynamicCalculator

func NewDynamicCalculator(
	weights gas.Dimensions,
	price gas.Price,
) *dynamicCalculator

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(txs ...txs.UnsignedTx) (gas.Dimensions, error)

func WarpComplexity

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

WarpComplexity returns the complexity a warp message adds to a transaction.

Types

type Calculator

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

Calculator defines the interface for fee calculation

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 StaticCalculator added in v1.11.14

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

func NewStaticCalculator added in v1.1.11

func NewStaticCalculator(config StaticConfig, upgradeTimes upgrade.Config) *StaticCalculator

func (*StaticCalculator) CalculateFee added in v1.11.14

func (c *StaticCalculator) CalculateFee(tx txs.UnsignedTx, time time.Time) uint64

[CalculateFee] returns the minimal fee needed to accept [tx], at chain time time

type StaticConfig added in v1.1.11

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 net creating transaction after AP3
	CreateNetTxFee uint64 `json:"createSubnetTxFee"`

	// Fee that must be burned by every transform net transaction
	TransformNetTxFee uint64 `json:"transformSubnetTxFee"`

	// Fee that must be burned by every blockchain creating transaction after AP3
	CreateBlockchainTxFee uint64 `json:"createBlockchainTxFee"`

	// Transaction fee for adding a primary network validator
	AddPrimaryNetworkValidatorFee uint64 `json:"addPrimaryNetworkValidatorFee"`

	// Transaction fee for adding a primary network delegator
	AddPrimaryNetworkDelegatorFee uint64 `json:"addPrimaryNetworkDelegatorFee"`

	// Transaction fee for adding a net validator
	AddNetValidatorFee uint64 `json:"addNetValidatorFee"`

	// Transaction fee for adding a net delegator
	AddNetDelegatorFee uint64 `json:"addSubnetDelegatorFee"`
}

Jump to

Keyboard shortcuts

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