params

package
v0.7.12 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: GPL-3.0, LGPL-3.0 Imports: 13 Imported by: 40

Documentation

Index

Constants

View Source
const (
	BlobTxBytesPerFieldElement         = 32                       // Size of each field element in bytes
	BlobTxFieldElementsPerBlob         = 4096                     // Number of field elements stored in a single data blob
	BlobTxBlobGasPerBlob               = 1 << 17                  // Gas consumption of a single data blob (== 131072)
	BlobTxMinBlobGasprice              = 1                        // Minimum gas price for data blobs
	BlobTxBlobGaspriceUpdateFraction   = 3338477                  // Controls the maximum rate of change for blob gas price
	BlobTxPointEvaluationPrecompileGas = 50000                    // Gas price for the point evaluation precompile
	BlobTxTargetBlobGasPerBlock        = 3 * BlobTxBlobGasPerBlob // Target consumable blob gas for data blobs per block (for 1559-like pricing)
	MaxBlobGasPerBlock                 = 6 * BlobTxBlobGasPerBlob // Maximum consumable blob gas for data blobs per block
)

Blob gas constants - these values are defined by EIP-4844

View Source
const (
	Wei   = 1
	GWei  = 1e9
	Ether = 1e18
)

These are the multipliers for ether denominations. Example: To get the wei value of an amount in 'gwei', use

new(big.Int).Mul(value, big.NewInt(params.GWei))
View Source
const (
	// BloomBitsBlocks is the number of blocks a single bloom bit section vector
	// contains on the server side.
	BloomBitsBlocks uint64 = 4096

	// BloomBitsBlocksClient is the number of blocks a single bloom bit section vector
	// contains on the light client side
	BloomBitsBlocksClient uint64 = 32768

	// BloomConfirms is the number of confirmation blocks before a bloom section is
	// considered probably final and its rotated bits are calculated.
	BloomConfirms = 256

	// CHTFrequency is the block frequency for creating CHTs
	CHTFrequency = 32768

	// BloomTrieFrequency is the block frequency for creating BloomTrie on both
	// server/client sides.
	BloomTrieFrequency = 32768

	// HelperTrieConfirmations is the number of confirmations before a client is expected
	// to have the given HelperTrie available.
	HelperTrieConfirmations = 2048

	// HelperTrieProcessConfirmations is the number of confirmations before a HelperTrie
	// is generated
	HelperTrieProcessConfirmations = 256

	// CheckpointFrequency is the block frequency for creating checkpoint
	CheckpointFrequency = 32768

	// CheckpointProcessConfirmations is the number before a checkpoint is generated
	CheckpointProcessConfirmations = 256

	// FullImmutabilityThreshold is the number of blocks after which a chain segment is
	// considered immutable (i.e. soft finality). It is used by the downloader as a
	// hard limit against deep ancestors, by the blockchain against deep reorgs, by
	// the freezer as the cutoff threshold and by clique as the snapshot trust limit.
	FullImmutabilityThreshold = 90000

	// LightImmutabilityThreshold is the number of blocks after which a header chain
	// segment is considered immutable for light client(i.e. soft finality). It is used by
	// the downloader as a hard limit against deep ancestors, by the blockchain against deep
	// reorgs, by the light pruner as the pruning validity guarantee.
	LightImmutabilityThreshold = 30000
)
View Source
const (
	VersionMajor = 1        // Major version component of the current release
	VersionMinor = 13       // Minor version component of the current release
	VersionPatch = 14       // Patch version component of the current release
	VersionMeta  = "stable" // Version metadata to append to the version string
)
View Source
const (
	// TODO: Value to pass to geth's Rules by default where the appropriate
	// context is not available in the lux code. (similar to context.TODO())
	IsMergeTODO = true
)
View Source
const WarpQuorumDenominator = 3

WarpQuorumDenominator is the denominator used to calculate the quorum for Warp messages. A quorum is achieved when the sum of the validators' weights that signed the message is greater than (total_weight * quorum_numerator) / WarpQuorumDenominator.

Variables

View Source
var (
	// MainnetNetworkUpgrades defines the network upgrade timestamps for mainnet
	MainnetNetworkUpgrades = extras.NetworkUpgrades{
		EVMTimestamp:     utils.NewUint64(0),
		DurangoTimestamp: nil,
		EtnaTimestamp:    nil,
		FortunaTimestamp: nil,
		GraniteTimestamp: nil,
	}

	EVMChainID = big.NewInt(43214)

	// For legacy tests
	MinGasPrice        int64 = 225_000_000_000
	TestInitialBaseFee int64 = 225_000_000_000
	TestMaxBaseFee     int64 = 225_000_000_000

	DynamicFeeExtraDataSize        = 80
	RollupWindow            uint64 = 10

	DefaultFeeConfig = commontype.FeeConfig{
		GasLimit:        big.NewInt(8_000_000),
		TargetBlockRate: 2,

		MinBaseFee:               big.NewInt(25_000_000_000),
		TargetGas:                big.NewInt(15_000_000),
		BaseFeeChangeDenominator: big.NewInt(36),

		MinBlockGasCost:  big.NewInt(0),
		MaxBlockGasCost:  big.NewInt(1_000_000),
		BlockGasCostStep: big.NewInt(200_000),
	}
)
View Source
var (
	// EVMDefaultConfig is the default configuration
	// without any network upgrades.
	EVMDefaultChainConfig = &ChainConfig{
		ChainID:                  DefaultChainID,
		HomesteadBlock:           big.NewInt(0),
		EIP150Block:              big.NewInt(0),
		EIP155Block:              big.NewInt(0),
		EIP158Block:              big.NewInt(0),
		ByzantiumBlock:           big.NewInt(0),
		ConstantinopleBlock:      big.NewInt(0),
		PetersburgBlock:          big.NewInt(0),
		IstanbulBlock:            big.NewInt(0),
		MuirGlacierBlock:         big.NewInt(0),
		MandatoryNetworkUpgrades: MainnetNetworkUpgrades,
		GenesisPrecompiles:       Precompiles{},
	}

	TestChainConfig = &ChainConfig{
		LuxContext:          LuxContext{utils.TestConsensusContext()},
		ChainID:             big.NewInt(1),
		FeeConfig:           DefaultFeeConfig,
		AllowFeeRecipients:  false,
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		MandatoryNetworkUpgrades: MandatoryNetworkUpgrades{
			EVMTimestamp:     utils.NewUint64(0),
			DurangoTimestamp: utils.NewUint64(0),
		},
	}

	TestEVMConfig = &ChainConfig{
		LuxContext:          LuxContext{utils.TestConsensusContext()},
		ChainID:             big.NewInt(1),
		FeeConfig:           DefaultFeeConfig,
		AllowFeeRecipients:  false,
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		MandatoryNetworkUpgrades: MandatoryNetworkUpgrades{
			EVMTimestamp: utils.NewUint64(0),
		},
	}

	TestPreEVMConfig = &ChainConfig{
		LuxContext:               LuxContext{utils.TestConsensusContext()},
		ChainID:                  big.NewInt(1),
		FeeConfig:                DefaultFeeConfig,
		AllowFeeRecipients:       false,
		HomesteadBlock:           big.NewInt(0),
		EIP150Block:              big.NewInt(0),
		EIP155Block:              big.NewInt(0),
		EIP158Block:              big.NewInt(0),
		ByzantiumBlock:           big.NewInt(0),
		ConstantinopleBlock:      big.NewInt(0),
		PetersburgBlock:          big.NewInt(0),
		IstanbulBlock:            big.NewInt(0),
		MuirGlacierBlock:         big.NewInt(0),
		MandatoryNetworkUpgrades: MandatoryNetworkUpgrades{},
		GenesisPrecompiles:       Precompiles{},
		UpgradeConfig:            UpgradeConfig{},
	}

	TestRules = TestChainConfig.LuxRules(new(big.Int), 0)
)
View Source
var (
	DefaultChainID = big.NewInt(43214)
)
View Source
var Version = func() string {
	return fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
}()

Version holds the textual version string.

View Source
var VersionWithMeta = func() string {
	v := Version
	if VersionMeta != "" {
		v += "-" + VersionMeta
	}
	return v
}()

VersionWithMeta holds the textual version string including the metadata.

Functions

func GetExtra

func GetExtra(c *ChainConfig) *extras.ChainConfig

func GetRulesExtra added in v0.5.5

func GetRulesExtra(rules Rules) *extras.Rules

GetRulesExtra returns the Lux-specific rules for the given Ethereum rules.

func SetEthUpgrades

func SetEthUpgrades(c *ChainConfig, luxUpgrades extras.NetworkUpgrades)

SetEthUpgrades enables Etheruem network upgrades using the same time as the Lux network upgrade that enables them.

TODO: Prior to Cancun, Lux upgrades are referenced inline in the code in place of their Ethereum counterparts. The original Ethereum names should be restored for maintainability.

func SetNetworkUpgradeDefaults

func SetNetworkUpgradeDefaults(c *ChainConfig)

func VersionWithCommit

func VersionWithCommit(gitCommit, gitDate string) string

Types

type ChainConfig

type ChainConfig struct {
	LuxContext `json:"-"` // Lux specific context set during VM initialization. Not serialized.

	ChainID            *big.Int             `json:"chainId"`                      // chainId identifies the current chain and is used for replay protection
	FeeConfig          commontype.FeeConfig `json:"feeConfig"`                    // Set the configuration for the dynamic fee algorithm
	AllowFeeRecipients bool                 `json:"allowFeeRecipients,omitempty"` // Allows fees to be collected by block builders.

	HomesteadBlock *big.Int `json:"homesteadBlock,omitempty"` // Homestead switch block (nil = no fork, 0 = already homestead)

	// EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150)
	EIP150Block *big.Int `json:"eip150Block,omitempty"` // EIP150 HF block (nil = no fork)
	EIP155Block *big.Int `json:"eip155Block,omitempty"` // EIP155 HF block
	EIP158Block *big.Int `json:"eip158Block,omitempty"` // EIP158 HF block

	ByzantiumBlock      *big.Int `json:"byzantiumBlock,omitempty"`      // Byzantium switch block (nil = no fork, 0 = already on byzantium)
	ConstantinopleBlock *big.Int `json:"constantinopleBlock,omitempty"` // Constantinople switch block (nil = no fork, 0 = already activated)
	PetersburgBlock     *big.Int `json:"petersburgBlock,omitempty"`     // Petersburg switch block (nil = same as Constantinople)
	IstanbulBlock       *big.Int `json:"istanbulBlock,omitempty"`       // Istanbul switch block (nil = no fork, 0 = already on istanbul)
	MuirGlacierBlock    *big.Int `json:"muirGlacierBlock,omitempty"`    // Eip-2384 (bomb delay) switch block (nil = no fork, 0 = already activated)
	BerlinBlock         *big.Int `json:"berlinBlock,omitempty"`         // Berlin switch block (nil = no fork, 0 = already on berlin)
	LondonBlock         *big.Int `json:"londonBlock,omitempty"`         // London switch block (nil = no fork, 0 = already on london)

	// Time based forks
	ShanghaiTime *uint64 `json:"shanghaiTime,omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai)
	CancunTime   *uint64 `json:"cancunTime,omitempty"`   // Cancun switch time (nil = no fork, 0 = already on cancun)

	MandatoryNetworkUpgrades             // Config for timestamps that enable mandatory network upgrades. Skip encoding/decoding directly into ChainConfig.
	OptionalNetworkUpgrades              // Config for optional timestamps that enable network upgrades
	GenesisPrecompiles       Precompiles `json:"-"` // Config for enabling precompiles from genesis. JSON encode/decode will be handled by the custom marshaler/unmarshaler.
	UpgradeConfig            `json:"-"`  // Config specified in upgradeBytes (lux network upgrades or enable/disabling precompiles). Skip encoding/decoding directly into ChainConfig.
}

ChainConfig is the core config which determines the blockchain settings.

ChainConfig is stored in the database on a per block basis. This means that any network, identified by its genesis block, can have its own set of configuration options.

func Copy

func Copy(c *ChainConfig) ChainConfig

func WithExtra

func WithExtra(c *ChainConfig, extra *extras.ChainConfig) *ChainConfig

WithExtra sets the extra payload on `c` and returns the modified argument.

func (*ChainConfig) AllowedFeeRecipients

func (c *ChainConfig) AllowedFeeRecipients() bool

AllowedFeeRecipients returns the original AllowedFeeRecipients parameter contained in the genesis ChainConfig. Implements precompile.ChainConfig interface.

func (*ChainConfig) CheckCompatible

func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64, time uint64) *ConfigCompatError

CheckCompatible checks whether scheduled fork transitions have been imported with a mismatching chain configuration.

func (*ChainConfig) CheckConfigForkOrder

func (c *ChainConfig) CheckConfigForkOrder() error

CheckConfigForkOrder checks that we don't "skip" any forks, geth isn't pluggable enough to guarantee that forks can be implemented in a different order than on official networks

func (*ChainConfig) CheckMandatoryCompatible

func (c *ChainConfig) CheckMandatoryCompatible(newcfg *MandatoryNetworkUpgrades, time uint64) error

CheckMandatoryCompatible checks if the mandatory network upgrades are compatible

func (*ChainConfig) CheckPrecompilesCompatible

func (c *ChainConfig) CheckPrecompilesCompatible(precompileUpgrades []extras.PrecompileUpgrade, time uint64) error

CheckPrecompilesCompatible checks that precompiles are compatible

func (*ChainConfig) CheckStateUpgradesCompatible

func (c *ChainConfig) CheckStateUpgradesCompatible(stateUpgrades []extras.StateUpgrade, time uint64) error

CheckStateUpgradesCompatible checks that state upgrades are compatible

func (*ChainConfig) Description

func (c *ChainConfig) Description() string

Description returns a human-readable description of ChainConfig.

func (*ChainConfig) GetFeeConfig

func (c *ChainConfig) GetFeeConfig() commontype.FeeConfig

GetFeeConfig returns the original FeeConfig contained in the genesis ChainConfig. Implements precompile.ChainConfig interface.

func (*ChainConfig) IsBerlin added in v0.5.5

func (c *ChainConfig) IsBerlin(num *big.Int) bool

IsBerlin returns whether num is either equal to the Berlin fork block or greater.

func (*ChainConfig) IsByzantium

func (c *ChainConfig) IsByzantium(num *big.Int) bool

IsByzantium returns whether num is either equal to the Byzantium fork block or greater.

func (*ChainConfig) IsCancun

func (c *ChainConfig) IsCancun(time uint64) bool

IsCancun returns whether time represents a block with a timestamp after the Cancun upgrade time.

func (*ChainConfig) IsConstantinople

func (c *ChainConfig) IsConstantinople(num *big.Int) bool

IsConstantinople returns whether num is either equal to the Constantinople fork block or greater.

func (*ChainConfig) IsDUpgrade

func (c *ChainConfig) IsDUpgrade(time uint64) bool

IsDUpgrade returns whether time represents a block with a timestamp after the DUpgrade upgrade time.

func (*ChainConfig) IsEIP150

func (c *ChainConfig) IsEIP150(num *big.Int) bool

IsEIP150 returns whether num is either equal to the EIP150 fork block or greater.

func (*ChainConfig) IsEIP155

func (c *ChainConfig) IsEIP155(num *big.Int) bool

IsEIP155 returns whether num is either equal to the EIP155 fork block or greater.

func (*ChainConfig) IsEIP158

func (c *ChainConfig) IsEIP158(num *big.Int) bool

IsEIP158 returns whether num is either equal to the EIP158 fork block or greater.

func (*ChainConfig) IsEVM added in v0.7.10

func (c *ChainConfig) IsEVM(time uint64) bool

IsEVM returns whether time represents a block with a timestamp after the EVM upgrade time.

func (*ChainConfig) IsHomestead

func (c *ChainConfig) IsHomestead(num *big.Int) bool

IsHomestead returns whether num is either equal to the homestead block or greater.

func (*ChainConfig) IsIstanbul

func (c *ChainConfig) IsIstanbul(num *big.Int) bool

IsIstanbul returns whether num is either equal to the Istanbul fork block or greater.

func (*ChainConfig) IsLondon added in v0.5.5

func (c *ChainConfig) IsLondon(num *big.Int) bool

IsLondon returns whether num is either equal to the London fork block or greater.

func (*ChainConfig) IsMuirGlacier

func (c *ChainConfig) IsMuirGlacier(num *big.Int) bool

IsMuirGlacier returns whether num is either equal to the Muir Glacier (EIP-2384) fork block or greater.

func (*ChainConfig) IsPetersburg

func (c *ChainConfig) IsPetersburg(num *big.Int) bool

IsPetersburg returns whether num is either - equal to or greater than the PetersburgBlock fork block, - OR is nil, and Constantinople is active

func (*ChainConfig) IsPrecompileEnabled

func (c *ChainConfig) IsPrecompileEnabled(address common.Address, timestamp uint64) bool

IsPrecompileEnabled returns whether precompile with [address] is enabled at [timestamp].

func (*ChainConfig) IsShanghai added in v0.5.5

func (c *ChainConfig) IsShanghai(num *big.Int, time uint64) bool

IsShanghai returns whether time represents a block with a timestamp after the Shanghai upgrade time.

func (*ChainConfig) LuxRules

func (c *ChainConfig) LuxRules(blockNum *big.Int, timestamp uint64) Rules

LuxRules returns the Lux modified rules to support Lux network upgrades

func (ChainConfig) MarshalJSON

func (c ChainConfig) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of c. This is a custom marshaler to handle the Precompiles field.

func (*ChainConfig) Rules added in v0.5.5

func (c *ChainConfig) Rules(num *big.Int, timestamp uint64) Rules

Rules returns the Ethereum chainrules to use for the given block number and timestamp.

func (*ChainConfig) ToEthChainConfig added in v0.7.8

func (c *ChainConfig) ToEthChainConfig() *ethparams.ChainConfig

ToEthChainConfig converts Lux ChainConfig to ethereum ChainConfig

func (*ChainConfig) ToWithUpgradesJSON

func (c *ChainConfig) ToWithUpgradesJSON() *ChainConfigWithUpgradesJSON

ToWithUpgradesJSON converts the ChainConfig to ChainConfigWithUpgradesJSON with upgrades explicitly displayed. ChainConfig does not include upgrades in its JSON output. This is a workaround for showing upgrades in the JSON output.

func (*ChainConfig) UnmarshalJSON

func (c *ChainConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON parses the JSON-encoded data and stores the result in the object pointed to by c. This is a custom unmarshaler to handle the Precompiles field. Precompiles was presented as an inline object in the JSON. This custom unmarshaler ensures backwards compatibility with the old format.

func (*ChainConfig) Verify

func (c *ChainConfig) Verify() error

Verify verifies chain config and returns error

type ChainConfigWithUpgradesJSON

type ChainConfigWithUpgradesJSON struct {
	ChainConfig
	UpgradeConfig UpgradeConfig `json:"upgrades,omitempty"`
}

func (ChainConfigWithUpgradesJSON) MarshalJSON

func (cu ChainConfigWithUpgradesJSON) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. This is a workaround for the fact that the embedded ChainConfig struct has a MarshalJSON method, which prevents the default JSON marshalling from working for UpgradeConfig. TODO: consider removing this method by allowing external tag for the embedded ChainConfig struct.

func (*ChainConfigWithUpgradesJSON) UnmarshalJSON

func (cu *ChainConfigWithUpgradesJSON) UnmarshalJSON(input []byte) error

type ConfigCompatError

type ConfigCompatError struct {
	What string

	// block numbers of the stored and new configurations if block based forking
	StoredBlock, NewBlock *big.Int

	// timestamps of the stored and new configurations if time based forking
	StoredTime, NewTime *uint64

	// the block number to which the local chain must be rewound to correct the error
	RewindToBlock uint64

	// the timestamp to which the local chain must be rewound to correct the error
	RewindToTime uint64
}

ConfigCompatError is raised if the locally-stored blockchain is initialised with a ChainConfig that would alter the past.

func (*ConfigCompatError) Error

func (err *ConfigCompatError) Error() string

type LuxContext

type LuxContext struct {
	ConsensusCtx *consensus.Context
}

LuxContext provides Lux specific context directly into the EVM.

type MandatoryNetworkUpgrades

type MandatoryNetworkUpgrades = extras.NetworkUpgrades

Type aliases for extras package types

type OptionalNetworkUpgrades

type OptionalNetworkUpgrades = extras.NetworkUpgrades

Type aliases for extras package types

type Precompiles

type Precompiles = extras.Precompiles

Type aliases for extras package types

type Rules

type Rules struct {
	ChainID                                                 *big.Int
	IsHomestead, IsEIP150, IsEIP155, IsEIP158               bool
	IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
	IsCancun                                                bool

	// Rules for Lux releases
	IsEVM      bool
	IsDUpgrade bool

	// ActivePrecompiles maps addresses to stateful precompiled contracts that are enabled
	// for this rule set.
	// Note: none of these addresses should conflict with the address space used by
	// any existing precompiles.
	ActivePrecompiles map[common.Address]precompileconfig.Config
	// Predicaters maps addresses to stateful precompile Predicaters
	// that are enabled for this rule set.
	Predicaters map[common.Address]precompileconfig.Predicater
	// AccepterPrecompiles map addresses to stateful precompile accepter functions
	// that are enabled for this rule set.
	AccepterPrecompiles map[common.Address]precompileconfig.Accepter
}

Rules wraps ChainConfig and is merely syntactic sugar or can be used for functions that do not have or require information about the block.

Rules is a one time interface meaning that it shouldn't be used in between transition phases.

func (*Rules) IsPrecompileEnabled

func (r *Rules) IsPrecompileEnabled(addr common.Address) bool

IsPrecompileEnabled returns true if the precompile at [addr] is enabled for this rule set.

func (*Rules) PredicaterExists

func (r *Rules) PredicaterExists(addr common.Address) bool

func (*Rules) PredicatersExist

func (r *Rules) PredicatersExist() bool

type UpgradeConfig

type UpgradeConfig struct {
	// Config for optional timestamps that enable network upgrades.
	// Note: if OptionalUpgrades is specified in the JSON all previously activated
	// forks must be present or upgradeBytes will be rejected.
	OptionalNetworkUpgrades *extras.NetworkUpgrades `json:"networkUpgrades,omitempty"`

	// Config for modifying state as a network upgrade.
	StateUpgrades []extras.StateUpgrade `json:"stateUpgrades,omitempty"`

	// Config for enabling and disabling precompiles as network upgrades.
	PrecompileUpgrades []extras.PrecompileUpgrade `json:"precompileUpgrades,omitempty"`
}

UpgradeConfig includes the following configs that may be specified in upgradeBytes: - Timestamps that enable lux network upgrades, - Enabling or disabling precompiles as network upgrades.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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