chain

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: Apache-2.0 Imports: 13 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// GenesisBaseFeeEM is the initial base fee elasticity multiplier for EIP-1559 blocks.
	GenesisBaseFeeEM = 2

	// GenesisGasLimit is the default gas limit of the Genesis block.
	GenesisGasLimit uint64 = 4712388

	// GenesisDifficulty is the default difficulty of the Genesis block.
	GenesisDifficulty uint64 = 131072

	// BaseFeeChangeDenom is the value to bound the amount the base fee can change between blocks
	BaseFeeChangeDenom = uint64(8)
)
View Source
const (
	Homestead           = "homestead"
	Byzantium           = "byzantium"
	Constantinople      = "constantinople"
	Petersburg          = "petersburg"
	Istanbul            = "istanbul"
	London              = "london"
	EIP150              = "EIP150"
	EIP158              = "EIP158"
	EIP155              = "EIP155"
	QuorumCalcAlignment = "quorumcalcalignment"
	TxHashWithType      = "txHashWithType"
	LondonFix           = "londonfix"
)

predefined forks

Variables

AllForksEnabled should contain all supported forks by current edge version

View Source
var (
	// ErrBurnContractAddressMissing is the error when a contract address is not provided
	ErrBurnContractAddressMissing = errors.New("burn contract address missing")
)
View Source
var (
	// GenesisBaseFee is the initial base fee for EIP-1559 blocks.
	GenesisBaseFee = ethgo.Gwei(1).Uint64()
)

Functions

This section is empty.

Types

type AddressListConfig added in v0.9.0

type AddressListConfig struct {
	// AdminAddresses is the list of the initial admin addresses
	AdminAddresses []types.Address `json:"adminAddresses,omitempty"`

	// EnabledAddresses is the list of the initial enabled addresses
	EnabledAddresses []types.Address `json:"enabledAddresses,omitempty"`
}

type Chain

type Chain struct {
	Name      string   `json:"name"`
	Genesis   *Genesis `json:"genesis"`
	Params    *Params  `json:"params"`
	Bootnodes []string `json:"bootnodes,omitempty"`
}

Chain is the blockchain chain configuration

func Import

func Import(chain string) (*Chain, error)

func ImportFromFile

func ImportFromFile(filename string) (*Chain, error)

ImportFromFile imports a chain from a filepath

type Fork

type Fork struct {
	Block  uint64                  `json:"block"`
	Params *forkmanager.ForkParams `json:"params,omitempty"`
}

func NewFork

func NewFork(n uint64) Fork

func (Fork) Active

func (f Fork) Active(block uint64) bool

func (Fork) Copy added in v1.3.1

func (f Fork) Copy() Fork

Copy creates a deep copy of Fork

type Forks

type Forks map[string]Fork

Forks is map which contains all forks and their starting blocks from genesis

func (*Forks) At

func (f *Forks) At(block uint64) ForksInTime

At returns ForksInTime instance that shows which supported forks are enabled for the block

func (Forks) Copy added in v1.3.1

func (f Forks) Copy() *Forks

Copy creates a deep copy of Forks map

func (*Forks) IsActive added in v1.0.0

func (f *Forks) IsActive(name string, block uint64) bool

IsActive returns true if fork defined by name exists and defined for the block

func (*Forks) RemoveFork added in v1.0.0

func (f *Forks) RemoveFork(name string) *Forks

func (*Forks) SetFork added in v1.0.0

func (f *Forks) SetFork(name string, value Fork)

SetFork adds/updates fork defined by name

type ForksInTime

type ForksInTime struct {
	Homestead,
	Byzantium,
	Constantinople,
	Petersburg,
	Istanbul,
	London,
	EIP150,
	EIP158,
	EIP155,
	QuorumCalcAlignment,
	TxHashWithType,
	LondonFix bool
}

ForksInTime should contain all supported forks by current edge version

type Genesis

type Genesis struct {
	Nonce      [8]byte                           `json:"nonce"`
	Timestamp  uint64                            `json:"timestamp"`
	ExtraData  []byte                            `json:"extraData,omitempty"`
	GasLimit   uint64                            `json:"gasLimit"`
	Difficulty uint64                            `json:"difficulty"`
	Mixhash    types.Hash                        `json:"mixHash"`
	Coinbase   types.Address                     `json:"coinbase"`
	Alloc      map[types.Address]*GenesisAccount `json:"alloc,omitempty"`
	BaseFee    uint64                            `json:"baseFee"`
	BaseFeeEM  uint64                            `json:"baseFeeEM"`

	// BaseFeeChangeDenom is the value to bound the amount the base fee can change between blocks
	BaseFeeChangeDenom uint64 `json:"baseFeeChangeDenom,omitempty"`

	// Override
	StateRoot types.Hash

	// Only for testing
	Number     uint64     `json:"number"`
	GasUsed    uint64     `json:"gasUsed"`
	ParentHash types.Hash `json:"parentHash"`
}

Genesis specifies the header fields, state of a genesis block

func (*Genesis) GenesisHeader

func (g *Genesis) GenesisHeader() *types.Header

GenesisHeader converts the initially defined genesis struct to a header

func (*Genesis) Hash

func (g *Genesis) Hash() types.Hash

Hash computes the genesis hash

func (*Genesis) MarshalJSON

func (g *Genesis) MarshalJSON() ([]byte, error)

MarshalJSON implements the json interface

func (*Genesis) UnmarshalJSON

func (g *Genesis) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json interface

type GenesisAccount

type GenesisAccount struct {
	Code       []byte                    `json:"code,omitempty"`
	Storage    map[types.Hash]types.Hash `json:"storage,omitempty"`
	Balance    *big.Int                  `json:"balance,omitempty"`
	Nonce      uint64                    `json:"nonce,omitempty"`
	PrivateKey []byte                    `json:"secretKey,omitempty"` // for tests
}

GenesisAccount is an account in the state of the genesis block.

func (*GenesisAccount) MarshalJSON

func (g *GenesisAccount) MarshalJSON() ([]byte, error)

func (*GenesisAccount) UnmarshalJSON

func (g *GenesisAccount) UnmarshalJSON(data []byte) error

type Params

type Params struct {
	Forks          *Forks                 `json:"forks"`
	ChainID        int64                  `json:"chainID"`
	Engine         map[string]interface{} `json:"engine"`
	BlockGasTarget uint64                 `json:"blockGasTarget"`

	// Access control configuration
	ContractDeployerAllowList *AddressListConfig `json:"contractDeployerAllowList,omitempty"`
	ContractDeployerBlockList *AddressListConfig `json:"contractDeployerBlockList,omitempty"`
	TransactionsAllowList     *AddressListConfig `json:"transactionsAllowList,omitempty"`
	TransactionsBlockList     *AddressListConfig `json:"transactionsBlockList,omitempty"`
	BridgeAllowList           *AddressListConfig `json:"bridgeAllowList,omitempty"`
	BridgeBlockList           *AddressListConfig `json:"bridgeBlockList,omitempty"`

	// Governance contract where the token will be sent to and burn in london fork
	BurnContract map[uint64]types.Address `json:"burnContract"`
	// Destination address to initialize default burn contract with
	BurnContractDestinationAddress types.Address `json:"burnContractDestinationAddress,omitempty"`
}

Params are all the set of params for the chain

func (*Params) CalculateBurnContract added in v0.9.0

func (p *Params) CalculateBurnContract(block uint64) (types.Address, error)

CalculateBurnContract calculates burn contract address for the given block number

func (*Params) GetEngine

func (p *Params) GetEngine() string

Jump to

Keyboard shortcuts

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