header

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: GPL-3.0, LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseFee

func BaseFee(
	config *extras.ChainConfig,
	feeConfig commontype.FeeConfig,
	parent *types.Header,
	timestamp uint64,
) (*big.Int, error)

BaseFee takes the previous header and the timestamp of its child block and calculates the expected base fee for the child block.

Prior to SubnetEVM, the returned base fee will be nil.

func BlockGasCost

func BlockGasCost(
	config *extras.ChainConfig,
	feeConfig commontype.FeeConfig,
	parent *types.Header,
	timestamp uint64,
) *big.Int

BlockGasCost calculates the required block gas cost based on the parent header and the timestamp of the new block. Prior to Subnet-EVM, the returned block gas cost will be nil.

func BlockGasCostWithStep

func BlockGasCostWithStep(
	feeConfig commontype.FeeConfig,
	parentCost *big.Int,
	step uint64,
	timeElapsed uint64,
) uint64

BlockGasCostWithStep calculates the required block gas cost based on the parent cost and the time difference between the parent block and new block.

This is a helper function that allows the caller to manually specify the step value to use.

func EstimateNextBaseFee

func EstimateNextBaseFee(
	config *extras.ChainConfig,
	feeConfig commontype.FeeConfig,
	parent *types.Header,
	timestamp uint64,
) (*big.Int, error)

EstimateNextBaseFee attempts to estimate the base fee of a block built at `timestamp` on top of `parent`.

If timestamp is before parent.Time or the SubnetEVM activation time, then timestamp is set to the maximum of parent.Time and the SubnetEVM activation time.

Warning: This function should only be used in estimation and should not be used when calculating the canonical base fee for a block.

func EstimateRequiredTip

func EstimateRequiredTip(
	config *extras.ChainConfig,
	header *types.Header,
) (*big.Int, error)

EstimateRequiredTip is the estimated tip a transaction would have needed to pay to be included in a given block (assuming it paid a tip proportional to its gas usage).

In reality, the consensus engine does not enforce a minimum tip on individual transactions. The only correctness check performed is that the sum of all tips is >= the required block fee.

This function will return nil for all return values prior to SubnetEVM.

func ExtraPrefix

func ExtraPrefix(
	config *extras.ChainConfig,
	parent *types.Header,
	header *types.Header,
) ([]byte, error)

ExtraPrefix takes the previous header and the timestamp of its child block and calculates the expected extra prefix for the child block.

func GasCapacity

func GasCapacity(
	config *extras.ChainConfig,
	feeConfig commontype.FeeConfig,
	parent *types.Header,
	timestamp uint64,
) (uint64, error)

GasCapacity takes the previous header and the timestamp of its child block and calculates the available gas that can be consumed in the child block.

func GasLimit

func GasLimit(
	config *extras.ChainConfig,
	feeConfig commontype.FeeConfig,
	parent *types.Header,
	timestamp uint64,
) (uint64, error)

GasLimit takes the previous header and the timestamp of its child block and calculates the gas limit for the child block.

func PredicateBytesFromExtra

func PredicateBytesFromExtra(extra []byte) []byte

PredicateBytesFromExtra returns the predicate result bytes from the header's extra data. If the extra data is not long enough, an empty slice is returned.

func SetPredicateBytesInExtra added in v0.7.4

func SetPredicateBytesInExtra(extra []byte, predicateBytes []byte) []byte

SetPredicateBytesInExtra sets the predicate result bytes in the header's extra data. If the extra data is not long enough (i.e., an incomplete header.Extra as built in the miner), it is padded with zeros.

func VerifyExtra

func VerifyExtra(rules extras.AvalancheRules, extra []byte) error

VerifyExtra verifies that the header's Extra field is correctly formatted for rules.

TODO: Should this be merged with VerifyExtraPrefix?

func VerifyExtraPrefix

func VerifyExtraPrefix(
	config *extras.ChainConfig,
	parent *types.Header,
	header *types.Header,
) error

VerifyExtraPrefix verifies that the header's Extra field is correctly formatted.

func VerifyGasLimit

func VerifyGasLimit(
	config *extras.ChainConfig,
	feeConfig commontype.FeeConfig,
	parent *types.Header,
	header *types.Header,
) error

VerifyGasLimit verifies that the gas limit for the header is valid.

func VerifyGasUsed

func VerifyGasUsed(
	config *extras.ChainConfig,
	feeConfig commontype.FeeConfig,
	parent *types.Header,
	header *types.Header,
) error

VerifyGasUsed verifies that the gas used is less than or equal to the gas limit.

Types

type CalculateGasLimitFunc

type CalculateGasLimitFunc func(parentGasUsed, parentGasLimit, gasFloor, gasCeil uint64) uint64

Jump to

Keyboard shortcuts

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