beacon

package
v1.10.19 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTTDReached

func IsTTDReached(chain consensus.ChainHeaderReader, parentHash common.Hash, number uint64) (bool, error)

IsTTDReached checks if the TotalTerminalDifficulty has been surpassed on the `parentHash` block. It depends on the parentHash already being stored in the database. If the parentHash is not stored in the database a UnknownAncestor error is returned.

Types

type Beacon

type Beacon struct {
	// contains filtered or unexported fields
}

Beacon is a consensus engine that combines the eth1 consensus and proof-of-stake algorithm. There is a special flag inside to decide whether to use legacy consensus rules or new rules. The transition rule is described in the eth1/2 merge spec. https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3675.md

The beacon here is a half-functional consensus engine with partial functions which is only used for necessary consensus checks. The legacy consensus engine can be any engine implements the consensus interface (except the beacon itself).

func New

func New(ethone consensus.Engine) *Beacon

New creates a consensus engine with the given embedded eth1 engine.

func (*Beacon) APIs

func (beacon *Beacon) APIs(chain consensus.ChainHeaderReader) []rpc.API

APIs implements consensus.Engine, returning the user facing RPC APIs.

func (*Beacon) Author

func (beacon *Beacon) Author(header *types.Header) (common.Address, error)

Author implements consensus.Engine, returning the verified author of the block.

func (*Beacon) CalcDifficulty

func (beacon *Beacon) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int

CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have when created at time given the parent block's time and difficulty.

func (*Beacon) Close

func (beacon *Beacon) Close() error

Close shutdowns the consensus engine

func (*Beacon) Finalize

func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header)

Finalize implements consensus.Engine, setting the final state on the header

func (*Beacon) FinalizeAndAssemble

func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)

FinalizeAndAssemble implements consensus.Engine, setting the final state and assembling the block.

func (*Beacon) InnerEngine

func (beacon *Beacon) InnerEngine() consensus.Engine

InnerEngine returns the embedded eth1 consensus engine.

func (*Beacon) IsPoSHeader

func (beacon *Beacon) IsPoSHeader(header *types.Header) bool

IsPoSHeader reports the header belongs to the PoS-stage with some special fields. This function is not suitable for a part of APIs like Prepare or CalcDifficulty because the header difficulty is not set yet.

func (*Beacon) Prepare

func (beacon *Beacon) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error

Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the beacon protocol. The changes are done inline.

func (*Beacon) Seal

func (beacon *Beacon) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error

Seal generates a new sealing request for the given input block and pushes the result into the given channel.

Note, the method returns immediately and will send the result async. More than one result may also be returned depending on the consensus algorithm.

func (*Beacon) SealHash

func (beacon *Beacon) SealHash(header *types.Header) common.Hash

SealHash returns the hash of a block prior to it being sealed.

func (*Beacon) SetThreads

func (beacon *Beacon) SetThreads(threads int)

SetThreads updates the mining threads. Delegate the call to the eth1 engine if it's threaded.

func (*Beacon) VerifyHeader

func (beacon *Beacon) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error

VerifyHeader checks whether a header conforms to the consensus rules of the stock Ethereum consensus engine.

func (*Beacon) VerifyHeaders

func (beacon *Beacon) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)

VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers concurrently. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications. VerifyHeaders expect the headers to be ordered and continuous.

func (*Beacon) VerifyUncles

func (beacon *Beacon) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

VerifyUncles verifies that the given block's uncles conform to the consensus rules of the Ethereum consensus engine.

Jump to

Keyboard shortcuts

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