chain

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GenesisGasLimit is the default gas limit of the Genesis block.
	GenesisGasLimit uint64 = 4712388

	// GenesisDifficulty is the default difficulty of the Genesis block.
	GenesisDifficulty = big.NewInt(131072)
)
View Source
var AllForksEnabled = &Forks{
	Homestead:      NewFork(0),
	EIP150:         NewFork(0),
	EIP155:         NewFork(0),
	EIP158:         NewFork(0),
	Byzantium:      NewFork(0),
	Constantinople: NewFork(0),
	Petersburg:     NewFork(0),
	Istanbul:       NewFork(0),
	London:         NewFork(0),
}

Functions

func GetGenesisAccountBalance

func GetGenesisAccountBalance(address types.Address, allocations map[types.Address]*GenesisAccount) (*big.Int, error)

GetGenesisAccountBalance returns balance for genesis account based on its address (expressed in weis). If not found in provided allocations map, 0 is returned.

Types

type AllowListConfig

type AllowListConfig 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 uint64

func NewFork

func NewFork(n uint64) *Fork

func (Fork) Active

func (f Fork) Active(block uint64) bool

func (Fork) Int

func (f Fork) Int() *big.Int

type Forks

type Forks struct {
	Homestead      *Fork `json:"homestead,omitempty"`
	Byzantium      *Fork `json:"byzantium,omitempty"`
	Constantinople *Fork `json:"constantinople,omitempty"`
	Petersburg     *Fork `json:"petersburg,omitempty"`
	Istanbul       *Fork `json:"istanbul,omitempty"`
	London         *Fork `json:"london,omitempty"`
	EIP150         *Fork `json:"EIP150,omitempty"`
	EIP158         *Fork `json:"EIP158,omitempty"`
	EIP155         *Fork `json:"EIP155,omitempty"`
}

Forks specifies when each fork is activated

func (*Forks) At

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

func (*Forks) IsByzantium

func (f *Forks) IsByzantium(block uint64) bool

func (*Forks) IsConstantinople

func (f *Forks) IsConstantinople(block uint64) bool

func (*Forks) IsEIP150

func (f *Forks) IsEIP150(block uint64) bool

func (*Forks) IsEIP155

func (f *Forks) IsEIP155(block uint64) bool

func (*Forks) IsEIP158

func (f *Forks) IsEIP158(block uint64) bool

func (*Forks) IsHomestead

func (f *Forks) IsHomestead(block uint64) bool

func (*Forks) IsLondon

func (f *Forks) IsLondon(block uint64) bool

func (*Forks) IsPetersburg

func (f *Forks) IsPetersburg(block uint64) bool

type ForksInTime

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

type Genesis

type Genesis struct {
	Config *Params `json:"config"`

	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"`

	// 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"`
	Whitelists     *Whitelists            `json:"whitelists,omitempty"`
	BlockGasTarget uint64                 `json:"blockGasTarget"`

	// AllowList configuration
	ContractDeployerAllowList *AllowListConfig `json:"contractDeployerAllowListConfig,omitempty"`
}

Params are all the set of params for the chain

func (*Params) GetEngine

func (p *Params) GetEngine() string

type Whitelists

type Whitelists struct {
	Deployment []types.Address `json:"deployment,omitempty"`
}

Whitelists specifies supported whitelists

Jump to

Keyboard shortcuts

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