Documentation ¶
Index ¶
- Constants
- func GetVoteSignerAddresses(vote *types.Vote) (common.Address, error)
- func UniqueSignatures(signatureSlice []types.Signature) ([]types.Signature, []types.Signature)
- type Forensics
- func (f *Forensics) DetectEquivocationInVotePool(vote *types.Vote, votePool *utils.Pool)
- func (f *Forensics) FindAncestorBlockHash(chain consensus.ChainReader, firstBlockInfo *types.BlockInfo, ...) (common.Hash, []string, []string, error)
- func (f *Forensics) ForensicsMonitoring(chain consensus.ChainReader, engine *XDPoS_v2, ...) error
- func (f *Forensics) ProcessForensics(chain consensus.ChainReader, engine *XDPoS_v2, incomingQC types.QuorumCert) error
- func (f *Forensics) ProcessVoteEquivocation(chain consensus.ChainReader, engine *XDPoS_v2, incomingVote *types.Vote) error
- func (f *Forensics) SendForensicProof(chain consensus.ChainReader, engine *XDPoS_v2, firstQc types.QuorumCert, ...) error
- func (f *Forensics) SendVoteEquivocationProof(vote1, vote2 *types.Vote, signer common.Address) error
- func (f *Forensics) SetCommittedQCs(headers []types.Header, incomingQC types.QuorumCert) error
- func (f *Forensics) SubscribeForensicsEvent(ch chan<- types.ForensicsEvent) event.Subscription
- type SnapshotV2
- type XDPoS_v2
- func (x *XDPoS_v2) Author(header *types.Header) (common.Address, error)
- func (x *XDPoS_v2) Authorize(signer common.Address, signFn clique.SignerFn)
- func (x *XDPoS_v2) AuthorizeFaker(signer common.Address)
- func (x *XDPoS_v2) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (x *XDPoS_v2) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (x *XDPoS_v2) FindParentBlockToAssign(chain consensus.ChainReader) *types.Block
- func (x *XDPoS_v2) GetCurrentEpochSwitchBlock(chain consensus.ChainReader, blockNum *big.Int) (uint64, uint64, error)
- func (x *XDPoS_v2) GetCurrentRoundFaker() types.Round
- func (x *XDPoS_v2) GetForensicsFaker() *Forensics
- func (x *XDPoS_v2) GetLatestCommittedBlockInfo() *types.BlockInfo
- func (x *XDPoS_v2) GetMasternodes(chain consensus.ChainReader, header *types.Header) []common.Address
- func (x *XDPoS_v2) GetMasternodesByHash(chain consensus.ChainReader, hash common.Hash) []common.Address
- func (x *XDPoS_v2) GetMasternodesFromEpochSwitchHeader(epochSwitchHeader *types.Header) []common.Address
- func (x *XDPoS_v2) GetPenalties(chain consensus.ChainReader, header *types.Header) []common.Address
- func (x *XDPoS_v2) GetPropertiesFaker() (types.Round, *types.QuorumCert, *types.QuorumCert, *types.TimeoutCert, ...)
- func (x *XDPoS_v2) GetRoundNumber(header *types.Header) (types.Round, error)
- func (x *XDPoS_v2) GetSnapshot(chain consensus.ChainReader, header *types.Header) (*SnapshotV2, error)
- func (x *XDPoS_v2) GetStandbynodes(chain consensus.ChainReader, header *types.Header) []common.Address
- func (x *XDPoS_v2) GetTimeoutPoolKeyListFaker() []string
- func (x *XDPoS_v2) GetTimeoutPoolSizeFaker(timeout *types.Timeout) int
- func (x *XDPoS_v2) GetVotePoolKeyListFaker() []string
- func (x *XDPoS_v2) GetVotePoolSizeFaker(vote *types.Vote) int
- func (x *XDPoS_v2) HygieneTimeoutPoolFaker()
- func (x *XDPoS_v2) HygieneVotePoolFaker()
- func (x *XDPoS_v2) Initial(chain consensus.ChainReader, header *types.Header) error
- func (x *XDPoS_v2) IsAuthorisedAddress(chain consensus.ChainReader, header *types.Header, address common.Address) bool
- func (x *XDPoS_v2) IsEpochSwitch(header *types.Header) (bool, uint64, error)
- func (x *XDPoS_v2) IsGapPlusOneBlock(header *types.Header) bool
- func (x *XDPoS_v2) OnCountdownTimeout(time time.Time, chain interface{}) error
- func (x *XDPoS_v2) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (x *XDPoS_v2) ProcessQCFaker(chain consensus.ChainReader, qc *types.QuorumCert) error
- func (x *XDPoS_v2) ProposedBlockHandler(chain consensus.ChainReader, blockHeader *types.Header) error
- func (x *XDPoS_v2) ReceivedTimeouts() map[string]map[common.Hash]utils.PoolObj
- func (x *XDPoS_v2) ReceivedVotes() map[string]map[common.Hash]utils.PoolObj
- func (x *XDPoS_v2) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
- func (x *XDPoS_v2) SetNewRoundFaker(blockChainReader consensus.ChainReader, newRound types.Round, resetTimer bool)
- func (x *XDPoS_v2) SetPropertiesFaker(highestQC *types.QuorumCert, highestTC *types.TimeoutCert)
- func (x *XDPoS_v2) SignHash(header *types.Header) (hash common.Hash)
- func (x *XDPoS_v2) SyncInfoHandler(chain consensus.ChainReader, syncInfo *types.SyncInfo) error
- func (x *XDPoS_v2) TimeoutHandler(blockChainReader consensus.ChainReader, timeout *types.Timeout) error
- func (x *XDPoS_v2) UpdateMasternodes(chain consensus.ChainReader, header *types.Header, ms []utils.Masternode) error
- func (x *XDPoS_v2) UpdateParams(header *types.Header)
- func (x *XDPoS_v2) UpdateSkipV2Validation(skip bool)
- func (x *XDPoS_v2) VerifyBlockInfo(blockChainReader consensus.ChainReader, blockInfo *types.BlockInfo, ...) error
- func (x *XDPoS_v2) VerifyHeader(chain consensus.ChainReader, header *types.Header, fullVerify bool) error
- func (x *XDPoS_v2) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, fullVerifies []bool, ...)
- func (x *XDPoS_v2) VerifySyncInfoMessage(chain consensus.ChainReader, syncInfo *types.SyncInfo) (bool, error)
- func (x *XDPoS_v2) VerifyTimeoutMessage(chain consensus.ChainReader, timeoutMsg *types.Timeout) (bool, error)
- func (x *XDPoS_v2) VerifyVoteMessage(chain consensus.ChainReader, vote *types.Vote) (bool, error)
- func (x *XDPoS_v2) VoteHandler(chain consensus.ChainReader, voteMsg *types.Vote) error
- func (x *XDPoS_v2) YourTurn(chain consensus.ChainReader, parent *types.Header, signer common.Address) (bool, error)
Constants ¶
const (
NUM_OF_FORENSICS_QC = 3
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Forensics ¶
type Forensics struct { HighestCommittedQCs []types.QuorumCert // contains filtered or unexported fields }
Forensics instance. Placeholder for future properties to be added
func (*Forensics) DetectEquivocationInVotePool ¶
func (*Forensics) FindAncestorBlockHash ¶
func (*Forensics) ForensicsMonitoring ¶
func (f *Forensics) ForensicsMonitoring(chain consensus.ChainReader, engine *XDPoS_v2, headerQcToBeCommitted []types.Header, incomingQC types.QuorumCert) error
func (*Forensics) ProcessForensics ¶
func (f *Forensics) ProcessForensics(chain consensus.ChainReader, engine *XDPoS_v2, incomingQC types.QuorumCert) error
Entry point for processing forensics. Triggered once processQC is successfully. Forensics runs in a seperate go routine as its no system critical Link to the flow diagram: https://hashlabs.atlassian.net/wiki/spaces/HASHLABS/pages/97878029/Forensics+Diagram+flow
func (*Forensics) ProcessVoteEquivocation ¶
func (f *Forensics) ProcessVoteEquivocation(chain consensus.ChainReader, engine *XDPoS_v2, incomingVote *types.Vote) error
Entry point for processing vote equivocation. Triggered once handle vote is successfully. Forensics runs in a seperate go routine as its no system critical Link to the flow diagram: https://hashlabs.atlassian.net/wiki/spaces/HASHLABS/pages/99516417/Vote+Equivocation+detection+specification
func (*Forensics) SendForensicProof ¶
func (f *Forensics) SendForensicProof(chain consensus.ChainReader, engine *XDPoS_v2, firstQc types.QuorumCert, secondQc types.QuorumCert) error
Last step of forensics which sends out detailed proof to report service.
func (*Forensics) SendVoteEquivocationProof ¶
func (*Forensics) SetCommittedQCs ¶
Set the forensics committed QCs list. The order is from grandparent to current header. i.e it shall follow the QC in its header as follow [hcqc1, hcqc2, hcqc3]
func (*Forensics) SubscribeForensicsEvent ¶
func (f *Forensics) SubscribeForensicsEvent(ch chan<- types.ForensicsEvent) event.Subscription
SubscribeForensicsEvent registers a subscription of ForensicsEvent and starts sending event to the given channel.
type SnapshotV2 ¶
type SnapshotV2 struct { Number uint64 `json:"number"` // Block number where the snapshot was created Hash common.Hash `json:"hash"` // Block hash where the snapshot was created // MasterNodes will get assigned on updateM1 NextEpochMasterNodes []common.Address `json:"masterNodes"` // Set of authorized master nodes at this moment for next epoch // Penalty, subnet record it during snapshot NextEpochPenalties []common.Address `json:"penalties"` // Set of master nodes to be removed from master nodes for next epoch }
Snapshot is the state of the smart contract validator list The validator list is used on next epoch master nodes If we don't have the snapshot, then we have to trace back the gap block smart contract state which is very costly
func (*SnapshotV2) GetMappedMasterNodes ¶
func (s *SnapshotV2) GetMappedMasterNodes() map[common.Address]struct{}
retrieves master nodes list in map type
func (*SnapshotV2) IsMasterNodes ¶
func (s *SnapshotV2) IsMasterNodes(address common.Address) bool
type XDPoS_v2 ¶
type XDPoS_v2 struct { BroadcastCh chan interface{} HookReward func(chain consensus.ChainReader, state *state.StateDB, parentState *state.StateDB, header *types.Header) (map[string]interface{}, error) HookPenalty func(chain consensus.ChainReader, number *big.Int, parentHash common.Hash, candidates []common.Address, config *params.XDPoSConfig) ([]common.Address, error) ForensicsProcessor *Forensics // contains filtered or unexported fields }
func (*XDPoS_v2) Authorize ¶
Authorize injects a private key into the consensus engine to mint new blocks with.
func (*XDPoS_v2) AuthorizeFaker ¶
Fake the signer address, the signing function is incompatible
func (*XDPoS_v2) CalcDifficulty ¶
func (x *XDPoS_v2) 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_v2) Finalize ¶
func (x *XDPoS_v2) 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_v2) FindParentBlockToAssign ¶
func (x *XDPoS_v2) FindParentBlockToAssign(chain consensus.ChainReader) *types.Block
func (*XDPoS_v2) GetCurrentEpochSwitchBlock ¶
func (*XDPoS_v2) GetCurrentRoundFaker ¶
Utils for test to check currentRound value
func (*XDPoS_v2) GetForensicsFaker ¶
func (*XDPoS_v2) GetLatestCommittedBlockInfo ¶
func (*XDPoS_v2) GetMasternodes ¶
func (x *XDPoS_v2) GetMasternodes(chain consensus.ChainReader, header *types.Header) []common.Address
Given header, get master node from the epoch switch block of that epoch
func (*XDPoS_v2) GetMasternodesByHash ¶
func (x *XDPoS_v2) GetMasternodesByHash(chain consensus.ChainReader, hash common.Hash) []common.Address
Given hash, get master node from the epoch switch block of the epoch
func (*XDPoS_v2) GetMasternodesFromEpochSwitchHeader ¶
func (x *XDPoS_v2) GetMasternodesFromEpochSwitchHeader(epochSwitchHeader *types.Header) []common.Address
Get master nodes over extra data of epoch switch block.
func (*XDPoS_v2) GetPenalties ¶
Given header, get master node from the epoch switch block of that epoch
func (*XDPoS_v2) GetPropertiesFaker ¶
func (x *XDPoS_v2) GetPropertiesFaker() (types.Round, *types.QuorumCert, *types.QuorumCert, *types.TimeoutCert, types.Round, *types.BlockInfo)
WARN: This function is designed for testing purpose only! Utils for test to check currentRound values
func (*XDPoS_v2) GetRoundNumber ¶
func (*XDPoS_v2) GetSnapshot ¶
func (x *XDPoS_v2) GetSnapshot(chain consensus.ChainReader, header *types.Header) (*SnapshotV2, error)
func (*XDPoS_v2) GetStandbynodes ¶
func (*XDPoS_v2) GetTimeoutPoolKeyListFaker ¶
func (*XDPoS_v2) GetTimeoutPoolSizeFaker ¶
Utils for test to get Timeout Pool Size
func (*XDPoS_v2) GetVotePoolKeyListFaker ¶
func (*XDPoS_v2) GetVotePoolSizeFaker ¶
Utils for test to get current Pool size
func (*XDPoS_v2) HygieneTimeoutPoolFaker ¶
func (x *XDPoS_v2) HygieneTimeoutPoolFaker()
func (*XDPoS_v2) HygieneVotePoolFaker ¶
func (x *XDPoS_v2) HygieneVotePoolFaker()
func (*XDPoS_v2) IsAuthorisedAddress ¶
func (*XDPoS_v2) IsEpochSwitch ¶
func (*XDPoS_v2) IsGapPlusOneBlock ¶
the block after gap block, whose NextEpoch validators should not be empty
func (*XDPoS_v2) OnCountdownTimeout ¶
Function that will be called by timer when countdown reaches its threshold. In the engine v2, we would need to broadcast timeout messages to other peers
func (*XDPoS_v2) Prepare ¶
Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.
func (*XDPoS_v2) ProcessQCFaker ¶
func (x *XDPoS_v2) ProcessQCFaker(chain consensus.ChainReader, qc *types.QuorumCert) error
for test only
func (*XDPoS_v2) ProposedBlockHandler ¶
func (x *XDPoS_v2) ProposedBlockHandler(chain consensus.ChainReader, blockHeader *types.Header) error
Proposed Block workflow
func (*XDPoS_v2) ReceivedTimeouts ¶
func (*XDPoS_v2) ReceivedVotes ¶
func (*XDPoS_v2) Seal ¶
func (x *XDPoS_v2) 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_v2) SetNewRoundFaker ¶
func (*XDPoS_v2) SetPropertiesFaker ¶
func (x *XDPoS_v2) SetPropertiesFaker(highestQC *types.QuorumCert, highestTC *types.TimeoutCert)
WARN: This function is designed for testing purpose only! Utils for tests to set engine specific values
func (*XDPoS_v2) SignHash ¶
V2 Block
SignerFn is a signer callback function to request a hash to be signed by a backing account. type SignerFn func(accounts.Account, []byte) ([]byte, error)
sigHash returns the hash which is used as input for the delegated-proof-of-stake signing. It is the hash of the entire header apart from the 65 byte signature contained at the end of the extra data.
func (*XDPoS_v2) SyncInfoHandler ¶
func (*XDPoS_v2) TimeoutHandler ¶
func (x *XDPoS_v2) TimeoutHandler(blockChainReader consensus.ChainReader, timeout *types.Timeout) error
Entry point for handling timeout message to process below:
func (*XDPoS_v2) UpdateMasternodes ¶
func (x *XDPoS_v2) UpdateMasternodes(chain consensus.ChainReader, header *types.Header, ms []utils.Masternode) error
func (*XDPoS_v2) UpdateParams ¶
func (*XDPoS_v2) UpdateSkipV2Validation ¶ added in v0.1.2
func (*XDPoS_v2) VerifyBlockInfo ¶
func (x *XDPoS_v2) VerifyBlockInfo(blockChainReader consensus.ChainReader, blockInfo *types.BlockInfo, blockHeader *types.Header) error
To be used by different message verification. Verify local DB block info against the received block information(i.e hash, blockNum, round)
func (*XDPoS_v2) VerifyHeader ¶
func (*XDPoS_v2) VerifyHeaders ¶
func (x *XDPoS_v2) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, fullVerifies []bool, abort <-chan struct{}, results chan<- error)
Verify a list of headers
func (*XDPoS_v2) VerifySyncInfoMessage ¶
func (x *XDPoS_v2) VerifySyncInfoMessage(chain consensus.ChainReader, syncInfo *types.SyncInfo) (bool, error)
SyncInfo workflow
Verify syncInfo and trigger process QC or TC if successful
func (*XDPoS_v2) VerifyTimeoutMessage ¶
func (x *XDPoS_v2) VerifyTimeoutMessage(chain consensus.ChainReader, timeoutMsg *types.Timeout) (bool, error)
Timeout workflow
Verify timeout message type from peers in bft.go
- Get master node list by timeout msg round
- Check signature: - Use ecRecover to get the public key - Use the above public key to find out the xdc address - Use the above xdc address to check against the master node list from step 1(For the running epoch)
- Broadcast(Not part of consensus)
func (*XDPoS_v2) VerifyVoteMessage ¶
Vote workflow
func (*XDPoS_v2) VoteHandler ¶
Consensus entry point for processing vote message to produce QC