header

package
v1.13.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: GPL-3.0, LGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseFee

func BaseFee(
	config *extras.ChainConfig,
	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 AP3, the returned base fee will be nil.

func BlockGasCost

func BlockGasCost(
	config *extras.ChainConfig,
	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 AP4, the returned block gas cost will be nil.

func BlockGasCostWithStep

func BlockGasCostWithStep(
	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,
	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 AP3 activation time, then timestamp is set to the maximum of parent.Time and the AP3 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 Apricot Phase 4.

func ExtraPrefix

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

ExtraPrefix returns what the prefix of the header's Extra field should be based on the desired target excess.

If the `desiredTargetExcess` is nil, the parent's target excess is used.

func GasCapacity

func GasCapacity(
	config *extras.ChainConfig,
	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,
	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(rules extras.AvalancheRules, 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 RemainingAtomicGasCapacity

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

RemainingAtomicGasCapacity returns the maximum amount ExtDataGasUsed could be on `header` while still being valid based on the initial capacity and consumed gas.

func SetPredicateBytesInExtra

func SetPredicateBytesInExtra(rules extras.AvalancheRules, 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,
	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,
	parent *types.Header,
	header *types.Header,
) error

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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