XDPoS

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package XDPoS is the adaptor for different consensus engine.

Index

Constants

View Source
const (
	ExtraFieldCheck     = true
	SkipExtraFieldCheck = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	XDPoS *XDPoS
	// contains filtered or unexported fields
}

API is a user facing RPC API to allow controlling the signer and voting mechanisms of the proof-of-authority scheme.

func (*API) GetLatestPoolStatus

func (api *API) GetLatestPoolStatus() MessageStatus

Get current vote pool and timeout pool content and missing messages

func (*API) GetMasternodesByNumber

func (api *API) GetMasternodesByNumber(number *rpc.BlockNumber) MasternodesStatus

func (*API) GetMissedRoundsInEpochByBlockNum added in v1.6.0

func (api *API) GetMissedRoundsInEpochByBlockNum(number *rpc.BlockNumber) (*utils.PublicApiMissedRoundsMetadata, error)

An API exclusively for V2 consensus, designed to assist in troubleshooting miners by identifying who mined during their allocated term.

func (*API) GetSigners

func (api *API) GetSigners(number *rpc.BlockNumber) ([]common.Address, error)

GetSigners retrieves the list of authorized signers at the specified block.

func (*API) GetSignersAtHash

func (api *API) GetSignersAtHash(hash common.Hash) ([]common.Address, error)

GetSignersAtHash retrieves the state snapshot at a given block.

func (*API) GetSnapshot

func (api *API) GetSnapshot(number *rpc.BlockNumber) (*utils.PublicApiSnapshot, error)

GetSnapshot retrieves the state snapshot at a given block.

func (*API) GetSnapshotAtHash

func (api *API) GetSnapshotAtHash(hash common.Hash) (*utils.PublicApiSnapshot, error)

GetSnapshotAtHash retrieves the state snapshot at a given block.

func (*API) GetV2BlockByHash

func (api *API) GetV2BlockByHash(blockHash common.Hash) *V2BlockInfo

Confirm V2 Block Committed Status

func (*API) GetV2BlockByHeader

func (api *API) GetV2BlockByHeader(header *types.Header, uncle bool) *V2BlockInfo

func (*API) GetV2BlockByNumber

func (api *API) GetV2BlockByNumber(number *rpc.BlockNumber) *V2BlockInfo

func (*API) NetworkInformation

func (api *API) NetworkInformation() NetworkInformation

type MasternodesStatus

type MasternodesStatus struct {
	Number          uint64
	Round           types.Round
	MasternodesLen  int
	Masternodes     []common.Address
	PenaltyLen      int
	Penalty         []common.Address
	StandbynodesLen int
	Standbynodes    []common.Address
	Error           error
}

type MessageStatus

type MessageStatus map[string]map[string]SignerTypes

type NetworkInformation

type NetworkInformation struct {
	NetworkId                  *big.Int
	XDCValidatorAddress        common.Address
	RelayerRegistrationAddress common.Address
	XDCXListingAddress         common.Address
	XDCZAddress                common.Address
	LendingAddress             common.Address
	ConsensusConfigs           params.XDPoSConfig
}

type SignerTypes

type SignerTypes struct {
	CurrentNumber  int
	CurrentSigners []common.Address
	MissingSigners []common.Address
}

type V2BlockInfo

type V2BlockInfo struct {
	Hash       common.Hash
	Round      types.Round
	Number     *big.Int
	ParentHash common.Hash
	Committed  bool
	Miner      common.Hash
	Timestamp  *big.Int
	EncodedRLP string
	Error      string
}

type XDPoS

type XDPoS struct {

	// Share Channel
	MinePeriodCh chan int // Miner wait Period Channel

	// Trading and lending service
	GetXDCXService    func() utils.TradingService
	GetLendingService func() utils.LendingService

	// The exact consensus engine with different versions
	EngineV1 *engine_v1.XDPoS_v1
	EngineV2 *engine_v2.XDPoS_v2
	// contains filtered or unexported fields
}

XDPoS is the delegated-proof-of-stake consensus engine proposed to support the Ethereum testnet following the Ropsten attacks.

func New

func New(chainConfig *params.ChainConfig, db ethdb.Database) *XDPoS

New creates a XDPoS delegated-proof-of-stake consensus engine with the initial signers set to the ones provided by the user.

func NewFaker

func NewFaker(db ethdb.Database, chainConfig *params.ChainConfig) *XDPoS

NewFullFaker creates an ethash consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.

func (*XDPoS) APIs

func (x *XDPoS) APIs(chain consensus.ChainReader) []rpc.API
Eth Consensus engine interface implementation

APIs implements consensus.Engine, returning the user facing RPC API to allow controlling the signer voting.

func (*XDPoS) Author

func (x *XDPoS) Author(header *types.Header) (common.Address, error)

Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section.

func (*XDPoS) Authorize

func (x *XDPoS) Authorize(signer common.Address, signFn clique.SignerFn)

Authorize injects a private key into the consensus engine to mint new blocks with.

func (*XDPoS) CacheNoneTIPSigningTxs

func (x *XDPoS) CacheNoneTIPSigningTxs(header *types.Header, txs []*types.Transaction, receipts []*types.Receipt) []*types.Transaction

Cache signing transaction data into BlockSingers cache object

func (*XDPoS) CacheSigningTxs

func (x *XDPoS) CacheSigningTxs(hash common.Hash, txs []*types.Transaction) []*types.Transaction

Cache

func (*XDPoS) CalcDifficulty

func (x *XDPoS) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int

CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have based on the previous blocks in the chain and the current signer.

func (*XDPoS) CalculateMissingRounds added in v1.6.0

func (x *XDPoS) CalculateMissingRounds(chain consensus.ChainReader, header *types.Header) (*utils.PublicApiMissedRoundsMetadata, error)

func (*XDPoS) Finalize

func (x *XDPoS) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, parentState *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)

Finalize implements consensus.Engine, ensuring no uncles are set, nor block rewards given, and returns the final block.

func (*XDPoS) FindParentBlockToAssign

func (x *XDPoS) FindParentBlockToAssign(chain consensus.ChainReader, currentBlock *types.Block) *types.Block

func (*XDPoS) GetAuthorisedSignersFromSnapshot

func (x *XDPoS) GetAuthorisedSignersFromSnapshot(chain consensus.ChainReader, header *types.Header) ([]common.Address, error)

func (*XDPoS) GetCachedSigningTxs

func (x *XDPoS) GetCachedSigningTxs(hash common.Hash) (interface{}, bool)

func (*XDPoS) GetCurrentEpochSwitchBlock

func (x *XDPoS) GetCurrentEpochSwitchBlock(chain consensus.ChainReader, blockNumber *big.Int) (uint64, uint64, error)

func (*XDPoS) GetDb

func (x *XDPoS) GetDb() ethdb.Database

Same DB across all consensus engines

func (*XDPoS) GetMasternodes

func (x *XDPoS) GetMasternodes(chain consensus.ChainReader, header *types.Header) []common.Address

func (*XDPoS) GetMasternodesByNumber

func (x *XDPoS) GetMasternodesByNumber(chain consensus.ChainReader, blockNumber uint64) []common.Address

func (*XDPoS) GetMasternodesFromCheckpointHeader

func (x *XDPoS) GetMasternodesFromCheckpointHeader(checkpointHeader *types.Header) []common.Address

Get master nodes over extra data of previous checkpoint block.

func (*XDPoS) GetPeriod

func (x *XDPoS) GetPeriod() uint64

func (*XDPoS) GetSnapshot

func (x *XDPoS) GetSnapshot(chain consensus.ChainReader, header *types.Header) (*utils.PublicApiSnapshot, error)

func (*XDPoS) GetValidator

func (x *XDPoS) GetValidator(creator common.Address, chain consensus.ChainReader, header *types.Header) (common.Address, error)

func (*XDPoS) HandleProposedBlock

func (x *XDPoS) HandleProposedBlock(chain consensus.ChainReader, header *types.Header) error

func (*XDPoS) Initial

func (x *XDPoS) Initial(chain consensus.ChainReader, header *types.Header) error

func (*XDPoS) IsAuthorisedAddress

func (x *XDPoS) IsAuthorisedAddress(chain consensus.ChainReader, header *types.Header, address common.Address) bool

func (*XDPoS) IsEpochSwitch

func (x *XDPoS) IsEpochSwitch(header *types.Header) (bool, uint64, error)

Check is epoch switch (checkpoint) block

func (*XDPoS) Prepare

func (x *XDPoS) Prepare(chain consensus.ChainReader, header *types.Header) error

Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.

func (*XDPoS) RecoverSigner

func (x *XDPoS) RecoverSigner(header *types.Header) (common.Address, error)

func (*XDPoS) RecoverValidator

func (x *XDPoS) RecoverValidator(header *types.Header) (common.Address, error)

func (*XDPoS) Seal

func (x *XDPoS) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)

Seal implements consensus.Engine, attempting to create a sealed block using the local signing credentials.

func (*XDPoS) SigHash

func (x *XDPoS) SigHash(header *types.Header) (hash common.Hash)

func (*XDPoS) SubscribeForensicsEvent

func (x *XDPoS) SubscribeForensicsEvent(ch chan<- types.ForensicsEvent) event.Subscription

Subscribe to consensus engines forensics events. Currently only exist for engine v2

func (*XDPoS) UpdateMasternodes

func (x *XDPoS) UpdateMasternodes(chain consensus.ChainReader, header *types.Header, ms []utils.Masternode) error

func (*XDPoS) UpdateParams

func (x *XDPoS) UpdateParams(header *types.Header)

Reset parameters after checkpoint due to config may change

func (*XDPoS) VerifyHeader

func (x *XDPoS) VerifyHeader(chain consensus.ChainReader, header *types.Header, fullVerify bool) error

VerifyHeader checks whether a header conforms to the consensus rules.

func (*XDPoS) VerifyHeaders

func (x *XDPoS) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, fullVerifies []bool) (chan<- struct{}, <-chan error)

VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications (the order is that of the input slice).

func (*XDPoS) VerifySeal

func (x *XDPoS) VerifySeal(chain consensus.ChainReader, header *types.Header) error

VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.

func (*XDPoS) VerifyUncles

func (x *XDPoS) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.

func (*XDPoS) YourTurn

func (x *XDPoS) YourTurn(chain consensus.ChainReader, parent *types.Header, signer common.Address) (bool, error)

Directories

Path Synopsis
engines

Jump to

Keyboard shortcuts

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