Documentation
¶
Index ¶
- Constants
- Variables
- func BroadcastCXReceipts(newBlock *types.Block, consensus *Consensus)
- func BroadcastCXReceiptsWithShardID(block *block.Header, commitSig []byte, commitBitmap []byte, toShardID uint32, ...)
- func BroadcastMissingCXReceipts(c *Consensus)
- func BroadcastNewBlock(host p2p.Host, newBlock *types.Block, nodeConfig *nodeconfig.ConfigType)
- func IsRunningBeaconChain(c *Consensus) bool
- type Consensus
- func (consensus *Consensus) AddConsensusLastMile() error
- func (consensus *Consensus) AddPendingReceipts(receipts *types.CXReceiptsProof)
- func (consensus *Consensus) AddPubkeyMetrics()
- func (consensus *Consensus) Beaconchain() core.BlockChain
- func (consensus *Consensus) BlockChannel(newBlock *types.Block)
- func (consensus *Consensus) BlockCommitSigs(blockNum uint64) ([]byte, error)
- func (consensus *Consensus) BlockNum() uint64
- func (consensus *Consensus) BlockVerifier(newBlock *types.Block) error
- func (consensus *Consensus) Blockchain() core.BlockChain
- func (consensus *Consensus) BlocksNotSynchronized(reason string)
- func (consensus *Consensus) BlocksSynchronized()
- func (consensus *Consensus) ChainReader() engine.ChainReader
- func (consensus *Consensus) Decider() quorum.Decider
- func (consensus *Consensus) DeleteBlocksLessThan(number uint64)
- func (consensus *Consensus) DeleteMessagesLessThan(number uint64)
- func (consensus *Consensus) FBFTLog() FBFT
- func (consensus *Consensus) FinishFinalityCount()
- func (consensus *Consensus) GenerateVdfAndProof(newBlock *types.Block, vrfBlockNumbers []uint64)
- func (consensus *Consensus) GenerateVrfAndProof(newHeader *block.Header) error
- func (consensus *Consensus) GetCommitSigChannel() chan []byte
- func (consensus *Consensus) GetConsensusMode() string
- func (consensus *Consensus) GetConsensusPhase() string
- func (consensus *Consensus) GetCurBlockViewID() uint64
- func (consensus *Consensus) GetFinality() int64
- func (consensus *Consensus) GetHost() p2p.Host
- func (consensus *Consensus) GetLastMileBlockIter(bnStart uint64, cb func(iter *LastMileBlockIter) error) error
- func (consensus *Consensus) GetLeaderPubKey() *bls_cosi.PublicKeyWrapper
- func (consensus *Consensus) GetLogger() *zerolog.Logger
- func (consensus *Consensus) GetNextRnd() ([vdFAndProofSize]byte, [32]byte, error)
- func (consensus *Consensus) GetPrivateKeys() multibls.PrivateKeys
- func (consensus *Consensus) GetPublicKeys() multibls.PublicKeys
- func (consensus *Consensus) GetReadySignal() chan Proposal
- func (consensus *Consensus) GetViewChangingID() uint64
- func (consensus *Consensus) HandleMessageUpdate(ctx context.Context, peer libp2p_peer.ID, msg *msg_pb.Message, ...) error
- func (consensus *Consensus) InitConsensusWithValidators() (err error)
- func (consensus *Consensus) IsBackup() bool
- func (consensus *Consensus) IsLeader() bool
- func (consensus *Consensus) IsValidatorInCommittee(pubKey bls.SerializedPublicKey) bool
- func (consensus *Consensus) IsViewChangingMode() bool
- func (consensus *Consensus) Mode() Mode
- func (consensus *Consensus) NumSignaturesIncludedInBlock(block *types.Block) uint32
- func (consensus *Consensus) ParseFBFTMessage(msg *msg_pb.Message) (*FBFTMessage, error)
- func (consensus *Consensus) PendingCXReceipts() []*types.CXReceiptsProof
- func (consensus *Consensus) PostConsensusProcessing(newBlock *types.Block) error
- func (consensus *Consensus) ProposeNewBlock(commitSigs chan []byte) (*types.Block, error)
- func (consensus *Consensus) ReadSignatureBitmapPayload(recvPayload []byte, offset int) (*bls_core.Sign, *bls_cosi.Mask, error)
- func (consensus *Consensus) ReadySignal(p Proposal)
- func (consensus *Consensus) RegisterPRndChannel(pRndChannel chan []byte)
- func (consensus *Consensus) RegisterRndChannel(rndChannel chan [548]byte)
- func (consensus *Consensus) Registry() *registry.Registry
- func (consensus *Consensus) ResetViewChangeState()
- func (consensus *Consensus) SetBlockNum(blockNum uint64)
- func (consensus *Consensus) SetCurBlockViewID(viewID uint64) uint64
- func (consensus *Consensus) SetDownloader(d downloader)
- func (consensus *Consensus) SetIsBackup(isBackup bool)
- func (consensus *Consensus) SetLeaderPubKey(pub *bls_cosi.PublicKeyWrapper)
- func (consensus *Consensus) SetMode(m Mode)
- func (consensus *Consensus) SetViewChangingID(viewID uint64)
- func (consensus *Consensus) SetViewIDs(height uint64)
- func (consensus *Consensus) Start(stopChan chan struct{})
- func (consensus *Consensus) StartChannel()
- func (consensus *Consensus) StartFinalityCount()
- func (consensus *Consensus) Tick()
- func (consensus *Consensus) UpdateConsensusInformation() Mode
- func (consensus *Consensus) UpdateLeaderMetrics(numCommits float64, blockNum float64)
- func (consensus *Consensus) UpdatePreimageGenerationMetrics(preimageStart uint64, preimageEnd uint64, lastPreimageImport uint64, ...)
- func (consensus *Consensus) UpdatePublicKeys(pubKeys, allowlist []bls_cosi.PublicKeyWrapper) int64
- func (consensus *Consensus) UpdateValidatorMetrics(numSig float64, blockNum float64)
- func (consensus *Consensus) ValidateNewBlock(recvMsg *FBFTMessage) (*types.Block, error)
- func (consensus *Consensus) ValidateVdfAndProof(headerObj *block.Header) bool
- func (consensus *Consensus) VdfSeedSize() int
- func (consensus *Consensus) WaitForConsensusReadyV2(stopChan chan struct{}, stoppedChan chan struct{})
- func (consensus *Consensus) WaitForNewRandomness()
- type DownloadAsync
- type FBFT
- type FBFTLog
- func (log *FBFTLog) AddBlock(block *types.Block)
- func (log *FBFTLog) AddNotVerifiedMessage(msg *FBFTMessage)
- func (log *FBFTLog) AddVerifiedMessage(msg *FBFTMessage)
- func (log *FBFTLog) DeleteBlockByNumber(number uint64)
- func (log *FBFTLog) FindMessageByMaxViewID(msgs []*FBFTMessage) *FBFTMessage
- func (log *FBFTLog) GetBlockByHash(hash common.Hash) *types.Block
- func (log *FBFTLog) GetBlocksByNumber(number uint64) []*types.Block
- func (log *FBFTLog) GetCommittedBlockAndMsgsFromNumber(bn uint64, logger *zerolog.Logger) (*types.Block, *FBFTMessage, error)
- func (log *FBFTLog) GetMessagesByTypeSeq(typ msg_pb.MessageType, blockNum uint64) []*FBFTMessage
- func (log *FBFTLog) GetMessagesByTypeSeqHash(typ msg_pb.MessageType, blockNum uint64, blockHash common.Hash) []*FBFTMessage
- func (log *FBFTLog) GetMessagesByTypeSeqView(typ msg_pb.MessageType, blockNum uint64, viewID uint64) []*FBFTMessage
- func (log *FBFTLog) GetMessagesByTypeSeqViewHash(typ msg_pb.MessageType, blockNum uint64, viewID uint64, blockHash common.Hash) []*FBFTMessage
- func (log *FBFTLog) GetNotVerifiedCommittedMessages(blockNum uint64, viewID uint64, blockHash common.Hash) []*FBFTMessage
- func (log *FBFTLog) HasMatchingAnnounce(blockNum uint64, blockHash common.Hash) bool
- func (log *FBFTLog) HasMatchingPrepared(blockNum uint64, blockHash common.Hash) bool
- func (log *FBFTLog) HasMatchingViewAnnounce(blockNum uint64, viewID uint64, blockHash common.Hash) bool
- func (log *FBFTLog) HasMatchingViewPrepared(blockNum uint64, viewID uint64, blockHash common.Hash) bool
- func (log *FBFTLog) IsBlockVerified(hash common.Hash) bool
- func (log *FBFTLog) MarkBlockVerified(block *types.Block)
- func (log *FBFTLog) PruneCacheBeforeBlock(bn uint64)
- type FBFTMessage
- type FBFTPhase
- type LastMileBlockIter
- type MessageRetry
- type MessageSender
- func (sender *MessageSender) DelayedSendWithRetry(blockNum uint64, msgType msg_pb.MessageType, groups []nodeconfig.GroupID, ...)
- func (sender *MessageSender) Reset(blockNum uint64)
- func (sender *MessageSender) Retry(msgRetry *MessageRetry)
- func (sender *MessageSender) SendWithRetry(blockNum uint64, msgType msg_pb.MessageType, groups []nodeconfig.GroupID, ...) error
- func (sender *MessageSender) SendWithoutRetry(groups []nodeconfig.GroupID, p2pMsg []byte) error
- func (sender *MessageSender) StopAllRetriesExceptCommitted()
- func (sender *MessageSender) StopRetry(msgType msg_pb.MessageType)
- type Mode
- type NetworkMessage
- type Proposal
- type ProposalType
- type State
- func (pm *State) GetCurBlockViewID() uint64
- func (pm *State) GetViewChangeDuraion() time.Duration
- func (pm *State) GetViewChangingID() uint64
- func (pm *State) Mode() Mode
- func (pm *State) SetCurBlockViewID(viewID uint64) uint64
- func (pm *State) SetMode(s Mode)
- func (pm *State) SetViewChangingID(id uint64)
- type TimeoutType
Constants ¶
const ( IncomingReceiptsLimit = 6000 // 2000 * (numShards - 1) SleepPeriod = 20 * time.Millisecond )
Constants of proposing a new block
const ( // CommitSigSenderTimeout is the timeout for sending the commit sig to finish block proposal CommitSigSenderTimeout = 10 * time.Second )
timeout constant
const MaxBlockNumDiff = 100
MaxBlockNumDiff limits the received block number to only 100 further from the current block number
const MaxViewIDDiff = 249
MaxViewIDDiff limits the received view ID to only 249 further from the current view ID
const (
// RetryIntervalInSec is the interval for message retry
RetryIntervalInSec = 7
)
const ( // ValidPayloadLength is the valid length for viewchange payload ValidPayloadLength = 32 + bls.BLSSignatureSizeInBytes )
Variables ¶
var ( // NIL is the m2 type message, which suppose to be nil/empty, however // we cannot sign on empty message, instead we sign on some default "nil" message // to indicate there is no prepared message received when we start view change NIL = []byte{0x01} )
Functions ¶
func BroadcastCXReceipts ¶ added in v1.10.3
BroadcastCXReceipts broadcasts cross shard receipts to correspoding destination shards
func BroadcastCXReceiptsWithShardID ¶ added in v1.10.3
func BroadcastCXReceiptsWithShardID(block *block.Header, commitSig []byte, commitBitmap []byte, toShardID uint32, consensus *Consensus)
BroadcastCXReceiptsWithShardID broadcasts cross shard receipts to given ToShardID
func BroadcastMissingCXReceipts ¶ added in v1.10.3
func BroadcastMissingCXReceipts(c *Consensus)
BroadcastMissingCXReceipts broadcasts missing cross shard receipts per request
func BroadcastNewBlock ¶ added in v1.10.3
func BroadcastNewBlock(host p2p.Host, newBlock *types.Block, nodeConfig *nodeconfig.ConfigType)
BroadcastNewBlock is called by consensus leader to sync new blocks with other clients/nodes. NOTE: For now, just send to the client (basically not broadcasting) TODO (lc): broadcast the new blocks to new nodes doing state sync
func IsRunningBeaconChain ¶ added in v1.10.3
Types ¶
type Consensus ¶
type Consensus struct { // Minimal number of peers in the shard // If the number of validators is less than minPeers, the consensus won't start MinPeers int // Shard Id which this node belongs to ShardID uint32 // IgnoreViewIDCheck determines whether to ignore viewID check IgnoreViewIDCheck *abool.AtomicBool // verified block to state sync broadcast VerifiedNewBlock chan *types.Block // Channel for DRG protocol to send pRnd (preimage of randomness resulting from combined vrf // randomnesses) to consensus. The first 32 bytes are randomness, the rest is for bitmap. PRndChannel chan []byte // Channel for DRG protocol to send VDF. The first 516 bytes are the VDF/Proof and the last 32 // bytes are the seed for deriving VDF RndChannel chan [vdfAndSeedSize]byte // Have a dedicated reader thread pull from this chan, like in node SlashChan chan slash.Record // How long in second the leader needs to wait to propose a new block. BlockPeriod time.Duration // The time due for next block proposal NextBlockDue time.Time // Temporary flag to control whether aggregate signature signing is enabled AggregateSig bool // contains filtered or unexported fields }
Consensus is the main struct with all states and data related to consensus process.
func New ¶
func New( host p2p.Host, shard uint32, multiBLSPriKey multibls.PrivateKeys, registry *registry.Registry, Decider quorum.Decider, minPeers int, aggregateSig bool, ) (*Consensus, error)
New create a new Consensus record
func (*Consensus) AddConsensusLastMile ¶
func (*Consensus) AddPendingReceipts ¶ added in v1.10.3
func (consensus *Consensus) AddPendingReceipts(receipts *types.CXReceiptsProof)
func (*Consensus) AddPubkeyMetrics ¶
func (consensus *Consensus) AddPubkeyMetrics()
AddPubkeyMetrics add the list of blskeys to prometheus metrics
func (*Consensus) Beaconchain ¶
func (consensus *Consensus) Beaconchain() core.BlockChain
Beaconchain returns the beaconchain.
func (*Consensus) BlockChannel ¶
func (*Consensus) BlockCommitSigs ¶
BlockCommitSigs returns the byte array of aggregated commit signature and bitmap signed on the block
func (*Consensus) BlockVerifier ¶
BlockVerifier is called by consensus participants to verify the block (account model) they are running consensus on.
func (*Consensus) Blockchain ¶
func (consensus *Consensus) Blockchain() core.BlockChain
Blockchain returns the blockchain.
func (*Consensus) BlocksNotSynchronized ¶
BlocksNotSynchronized lets the main loop know that block is not synchronized
func (*Consensus) BlocksSynchronized ¶
func (consensus *Consensus) BlocksSynchronized()
BlocksSynchronized lets the main loop know that block synchronization finished thus the blockchain is likely to be up to date.
func (*Consensus) ChainReader ¶
func (consensus *Consensus) ChainReader() engine.ChainReader
ChainReader returns the chain reader. This is mostly the same as Blockchain, but it returns only read methods, so we assume it's safe for concurrent use.
func (*Consensus) DeleteBlocksLessThan ¶
DeleteBlocksLessThan deletes blocks less than given block number
func (*Consensus) DeleteMessagesLessThan ¶
DeleteMessagesLessThan deletes messages less than given block number.
func (*Consensus) FinishFinalityCount ¶
func (consensus *Consensus) FinishFinalityCount()
FinishFinalityCount calculate the current finality
func (*Consensus) GenerateVdfAndProof ¶
GenerateVdfAndProof generates new VDF/Proof from VRFs in the current epoch
func (*Consensus) GenerateVrfAndProof ¶
GenerateVrfAndProof generates new VRF/Proof from hash of previous block
func (*Consensus) GetCommitSigChannel ¶
func (*Consensus) GetConsensusMode ¶
GetConsensusMode returns the current mode of the consensus
func (*Consensus) GetConsensusPhase ¶
GetConsensusPhase returns the current phase of the consensus.
func (*Consensus) GetCurBlockViewID ¶
GetCurBlockViewID returns the current view ID of the consensus Method is thread safe.
func (*Consensus) GetFinality ¶
GetFinality returns the finality time in milliseconds of previous consensus
func (*Consensus) GetLastMileBlockIter ¶
func (consensus *Consensus) GetLastMileBlockIter(bnStart uint64, cb func(iter *LastMileBlockIter) error) error
GetLastMileBlockIter get the iterator of the last mile blocks starting from number bnStart
func (*Consensus) GetLeaderPubKey ¶
func (consensus *Consensus) GetLeaderPubKey() *bls_cosi.PublicKeyWrapper
func (*Consensus) GetNextRnd ¶
GetNextRnd returns the oldest available randomness along with the hash of the block there randomness preimage is committed.
func (*Consensus) GetPrivateKeys ¶
func (consensus *Consensus) GetPrivateKeys() multibls.PrivateKeys
func (*Consensus) GetPublicKeys ¶
func (consensus *Consensus) GetPublicKeys() multibls.PublicKeys
GetPublicKeys returns the public keys
func (*Consensus) GetReadySignal ¶
func (*Consensus) GetViewChangingID ¶
GetViewChangingID returns the current view changing ID of the consensus. Method is thread safe.
func (*Consensus) HandleMessageUpdate ¶
func (consensus *Consensus) HandleMessageUpdate(ctx context.Context, peer libp2p_peer.ID, msg *msg_pb.Message, senderKey *bls.SerializedPublicKey) error
HandleMessageUpdate will update the consensus state according to received message
func (*Consensus) InitConsensusWithValidators ¶
InitConsensusWithValidators initialize shard state from latest epoch and update committee pub keys for consensus
func (*Consensus) IsLeader ¶
IsLeader check if the node is a leader or not by comparing the public key of the node with the leader public key Method is thread safe
func (*Consensus) IsValidatorInCommittee ¶
func (consensus *Consensus) IsValidatorInCommittee(pubKey bls.SerializedPublicKey) bool
IsValidatorInCommittee returns whether the given validator BLS address is part of my committee
func (*Consensus) IsViewChangingMode ¶
IsViewChangingMode return true if current mode is viewchanging. Method is thread safe.
func (*Consensus) NumSignaturesIncludedInBlock ¶
NumSignaturesIncludedInBlock returns the number of signatures included in the block Method is thread safe.
func (*Consensus) ParseFBFTMessage ¶
func (consensus *Consensus) ParseFBFTMessage(msg *msg_pb.Message) (*FBFTMessage, error)
ParseFBFTMessage parses FBFT message into FBFTMessage structure
func (*Consensus) PendingCXReceipts ¶ added in v1.10.3
func (consensus *Consensus) PendingCXReceipts() []*types.CXReceiptsProof
PendingCXReceipts returns node.pendingCXReceiptsProof
func (*Consensus) PostConsensusProcessing ¶ added in v1.10.3
PostConsensusProcessing is called by consensus participants, after consensus is done, to: 1. [leader] send new block to the client 2. [leader] send cross shard tx receipts to destination shard
func (*Consensus) ProposeNewBlock ¶ added in v1.10.3
ProposeNewBlock proposes a new block...
func (*Consensus) ReadSignatureBitmapPayload ¶
func (consensus *Consensus) ReadSignatureBitmapPayload(recvPayload []byte, offset int) (*bls_core.Sign, *bls_cosi.Mask, error)
ReadSignatureBitmapPayload read the payload for signature and bitmap; offset is the beginning position of reading
func (*Consensus) ReadySignal ¶
func (*Consensus) RegisterPRndChannel ¶
RegisterPRndChannel registers the channel for receiving randomness preimage from DRG protocol
func (*Consensus) RegisterRndChannel ¶
RegisterRndChannel registers the channel for receiving final randomness from DRG protocol
func (*Consensus) ResetViewChangeState ¶
func (consensus *Consensus) ResetViewChangeState()
ResetViewChangeState resets the view change structure
func (*Consensus) SetBlockNum ¶
SetBlockNum sets the blockNum in consensus object, called at node bootstrap
func (*Consensus) SetCurBlockViewID ¶
SetCurBlockViewID set the current view ID
func (*Consensus) SetDownloader ¶
func (consensus *Consensus) SetDownloader(d downloader)
Set downloader set the downloader of the shard to consensus TODO: It will be better to move this to consensus.New and register consensus as a service
func (*Consensus) SetIsBackup ¶
SetIsBackup sets the mode of consensus
func (*Consensus) SetLeaderPubKey ¶
func (consensus *Consensus) SetLeaderPubKey(pub *bls_cosi.PublicKeyWrapper)
func (*Consensus) SetViewChangingID ¶
SetViewChangingID set the current view change ID
func (*Consensus) SetViewIDs ¶
SetViewIDs set both current view ID and view changing ID to the height of the blockchain. It is used during client startup to recover the state
func (*Consensus) Start ¶
func (consensus *Consensus) Start( stopChan chan struct{}, )
Start waits for the next new block and run consensus
func (*Consensus) StartChannel ¶
func (consensus *Consensus) StartChannel()
func (*Consensus) StartFinalityCount ¶
func (consensus *Consensus) StartFinalityCount()
StartFinalityCount set the finality counter to current time
func (*Consensus) UpdateConsensusInformation ¶
UpdateConsensusInformation will update shard information (epoch, publicKeys, blockNum, viewID) based on the local blockchain. It is called in two cases for now: 1. consensus object initialization. because of current dependency where chainreader is only available after node is initialized; node is only available after consensus is initialized we need call this function separately after create consensus object 2. after state syncing is finished It will return the mode: (a) node not in committed: Listening mode (b) node in committed but has any err during processing: Syncing mode (c) node in committed and everything looks good: Normal mode
func (*Consensus) UpdateLeaderMetrics ¶
UpdateLeaderMetrics will udpate leader metrics
func (*Consensus) UpdatePreimageGenerationMetrics ¶
func (*Consensus) UpdatePublicKeys ¶
func (consensus *Consensus) UpdatePublicKeys(pubKeys, allowlist []bls_cosi.PublicKeyWrapper) int64
UpdatePublicKeys updates the PublicKeys for quorum on current subcommittee, protected by a mutex
func (*Consensus) UpdateValidatorMetrics ¶
UpdateValidatorMetrics will udpate validator metrics
func (*Consensus) ValidateNewBlock ¶
func (consensus *Consensus) ValidateNewBlock(recvMsg *FBFTMessage) (*types.Block, error)
func (*Consensus) ValidateVdfAndProof ¶
ValidateVdfAndProof validates the VDF/proof in the current epoch
func (*Consensus) VdfSeedSize ¶
VdfSeedSize returns the number of VRFs for VDF computation
func (*Consensus) WaitForConsensusReadyV2 ¶ added in v1.10.3
func (consensus *Consensus) WaitForConsensusReadyV2(stopChan chan struct{}, stoppedChan chan struct{})
WaitForConsensusReadyV2 listen for the readiness signal from consensus and generate new block for consensus. only leader will receive the ready signal
func (*Consensus) WaitForNewRandomness ¶
func (consensus *Consensus) WaitForNewRandomness()
WaitForNewRandomness listens to the RndChannel to receive new VDF randomness.
type DownloadAsync ¶
type DownloadAsync interface {
DownloadAsync()
}
type FBFT ¶
type FBFT interface { GetMessagesByTypeSeq(typ msg_pb.MessageType, blockNum uint64) []*FBFTMessage IsBlockVerified(hash common.Hash) bool DeleteBlockByNumber(number uint64) GetBlockByHash(hash common.Hash) *types.Block AddVerifiedMessage(msg *FBFTMessage) AddBlock(block *types.Block) GetMessagesByTypeSeqHash(typ msg_pb.MessageType, blockNum uint64, blockHash common.Hash) []*FBFTMessage }
type FBFTLog ¶
type FBFTLog struct {
// contains filtered or unexported fields
}
FBFTLog represents the log stored by a node during FBFT process
func (*FBFTLog) AddNotVerifiedMessage ¶
func (log *FBFTLog) AddNotVerifiedMessage(msg *FBFTMessage)
AddNotVerifiedMessage adds a not signature verified pbft message into the log
func (*FBFTLog) AddVerifiedMessage ¶
func (log *FBFTLog) AddVerifiedMessage(msg *FBFTMessage)
AddVerifiedMessage adds a signature verified pbft message into the log
func (*FBFTLog) DeleteBlockByNumber ¶
DeleteBlockByNumber deletes block of specific number
func (*FBFTLog) FindMessageByMaxViewID ¶
func (log *FBFTLog) FindMessageByMaxViewID(msgs []*FBFTMessage) *FBFTMessage
FindMessageByMaxViewID returns the message that has maximum ViewID
func (*FBFTLog) GetBlockByHash ¶
GetBlockByHash returns the block matches the given block hash
func (*FBFTLog) GetBlocksByNumber ¶
GetBlocksByNumber returns the blocks match the given block number
func (*FBFTLog) GetCommittedBlockAndMsgsFromNumber ¶
func (log *FBFTLog) GetCommittedBlockAndMsgsFromNumber(bn uint64, logger *zerolog.Logger) (*types.Block, *FBFTMessage, error)
GetCommittedBlockAndMsgsFromNumber get committed block and message starting from block number bn.
func (*FBFTLog) GetMessagesByTypeSeq ¶
func (log *FBFTLog) GetMessagesByTypeSeq(typ msg_pb.MessageType, blockNum uint64) []*FBFTMessage
GetMessagesByTypeSeq returns pbft messages with matching type, blockNum
func (*FBFTLog) GetMessagesByTypeSeqHash ¶
func (log *FBFTLog) GetMessagesByTypeSeqHash(typ msg_pb.MessageType, blockNum uint64, blockHash common.Hash) []*FBFTMessage
GetMessagesByTypeSeqHash returns pbft messages with matching type, blockNum
func (*FBFTLog) GetMessagesByTypeSeqView ¶
func (log *FBFTLog) GetMessagesByTypeSeqView(typ msg_pb.MessageType, blockNum uint64, viewID uint64) []*FBFTMessage
GetMessagesByTypeSeqView returns pbft messages with matching type, blockNum and viewID
func (*FBFTLog) GetMessagesByTypeSeqViewHash ¶
func (log *FBFTLog) GetMessagesByTypeSeqViewHash(typ msg_pb.MessageType, blockNum uint64, viewID uint64, blockHash common.Hash) []*FBFTMessage
GetMessagesByTypeSeqViewHash returns pbft messages with matching type, blockNum, viewID and blockHash
func (*FBFTLog) GetNotVerifiedCommittedMessages ¶
func (log *FBFTLog) GetNotVerifiedCommittedMessages(blockNum uint64, viewID uint64, blockHash common.Hash) []*FBFTMessage
GetNotVerifiedCommittedMessages returns not verified committed pbft messages with matching blockNum, viewID and blockHash
func (*FBFTLog) HasMatchingAnnounce ¶
HasMatchingAnnounce returns whether the log contains announce type message with given blockNum, blockHash
func (*FBFTLog) HasMatchingPrepared ¶
HasMatchingPrepared returns whether the log contains prepared message with given blockNum, viewID and blockHash
func (*FBFTLog) HasMatchingViewAnnounce ¶
func (log *FBFTLog) HasMatchingViewAnnounce(blockNum uint64, viewID uint64, blockHash common.Hash) bool
HasMatchingViewAnnounce returns whether the log contains announce type message with given blockNum, viewID and blockHash
func (*FBFTLog) HasMatchingViewPrepared ¶
func (log *FBFTLog) HasMatchingViewPrepared(blockNum uint64, viewID uint64, blockHash common.Hash) bool
HasMatchingViewPrepared returns whether the log contains prepared message with given blockNum, viewID and blockHash
func (*FBFTLog) IsBlockVerified ¶
IsBlockVerified checks whether the block is verified
func (*FBFTLog) MarkBlockVerified ¶
MarkBlockVerified marks the block as verified
func (*FBFTLog) PruneCacheBeforeBlock ¶
PruneCacheBeforeBlock prune all blocks before bn
type FBFTMessage ¶
type FBFTMessage struct { MessageType msg_pb.MessageType ViewID uint64 BlockNum uint64 BlockHash common.Hash Block []byte SenderPubkeys []*bls.PublicKeyWrapper SenderPubkeyBitmap []byte LeaderPubkey *bls.PublicKeyWrapper Payload []byte ViewchangeSig *bls_core.Sign ViewidSig *bls_core.Sign M2AggSig *bls_core.Sign M2Bitmap *bls_cosi.Mask M3AggSig *bls_core.Sign M3Bitmap *bls_cosi.Mask Verified bool }
FBFTMessage is the record of pbft messages received by a node during FBFT process
func ParseNewViewMessage ¶
func ParseNewViewMessage(msg *msg_pb.Message, members multibls.PublicKeys) (*FBFTMessage, error)
ParseNewViewMessage parses new view message into FBFTMessage structure
func ParseViewChangeMessage ¶
func ParseViewChangeMessage(msg *msg_pb.Message) (*FBFTMessage, error)
ParseViewChangeMessage parses view change message into FBFTMessage structure
func (*FBFTMessage) HasSingleSender ¶
func (m *FBFTMessage) HasSingleSender() bool
HasSingleSender returns whether the message has only a single sender
func (*FBFTMessage) Hash ¶
func (m *FBFTMessage) Hash() []byte
type LastMileBlockIter ¶
type LastMileBlockIter struct {
// contains filtered or unexported fields
}
LastMileBlockIter is the iterator to iterate over the last mile blocks in consensus cache. All blocks returned are guaranteed to pass the verification.
func (*LastMileBlockIter) Next ¶
func (iter *LastMileBlockIter) Next() *types.Block
Next iterate to the next last mile block
type MessageRetry ¶
type MessageRetry struct {
// contains filtered or unexported fields
}
MessageRetry controls the message that can be retried
type MessageSender ¶
type MessageSender struct {
// contains filtered or unexported fields
}
MessageSender is the wrapper object that controls how a consensus message is sent
func NewMessageSender ¶
func NewMessageSender(host p2p.Host) *MessageSender
NewMessageSender initializes the consensus message sender.
func (*MessageSender) DelayedSendWithRetry ¶
func (sender *MessageSender) DelayedSendWithRetry(blockNum uint64, msgType msg_pb.MessageType, groups []nodeconfig.GroupID, p2pMsg []byte)
DelayedSendWithRetry is similar to SendWithRetry but without the initial message sending but only retries.
func (*MessageSender) Reset ¶
func (sender *MessageSender) Reset(blockNum uint64)
Reset resets the sender's state for new block
func (*MessageSender) Retry ¶
func (sender *MessageSender) Retry(msgRetry *MessageRetry)
Retry will retry the consensus message for <RetryTimes> times.
func (*MessageSender) SendWithRetry ¶
func (sender *MessageSender) SendWithRetry(blockNum uint64, msgType msg_pb.MessageType, groups []nodeconfig.GroupID, p2pMsg []byte) error
SendWithRetry sends message with retry logic.
func (*MessageSender) SendWithoutRetry ¶
func (sender *MessageSender) SendWithoutRetry(groups []nodeconfig.GroupID, p2pMsg []byte) error
SendWithoutRetry sends message without retry logic.
func (*MessageSender) StopAllRetriesExceptCommitted ¶
func (sender *MessageSender) StopAllRetriesExceptCommitted()
StopAllRetriesExceptCommitted stops all the existing retries except committed message (which lives across consensus).
func (*MessageSender) StopRetry ¶
func (sender *MessageSender) StopRetry(msgType msg_pb.MessageType)
StopRetry stops the retry.
type NetworkMessage ¶
type NetworkMessage struct { MessageType msg_pb.MessageType Bytes []byte FBFTMsg *FBFTMessage OptionalAggregateSignature *bls_core.Sign }
NetworkMessage is a message intended to be created only for distribution to all the other quorum members.
type Proposal ¶ added in v1.10.3
type Proposal struct { Type ProposalType Caller string }
func NewProposal ¶ added in v1.10.3
func NewProposal(t ProposalType) Proposal
NewProposal creates a new proposal
type ProposalType ¶
type ProposalType byte
ProposalType is to indicate the type of signal for new block proposal
const ( SyncProposal ProposalType = iota AsyncProposal )
Constant of the type of new block proposal
type State ¶
type State struct {
// contains filtered or unexported fields
}
State contains current mode and current viewID
func (*State) GetCurBlockViewID ¶
GetCurBlockViewID return the current view id
func (*State) GetViewChangeDuraion ¶
GetViewChangeDuraion return the duration of the current view change It increase in the power of difference betweeen view changing ID and current view ID
func (*State) GetViewChangingID ¶
GetViewChangingID return the current view changing id It is meaningful during view change mode
func (*State) SetCurBlockViewID ¶
SetCurBlockViewID sets the current view id
func (*State) SetViewChangingID ¶
SetViewChangingID set the current view changing id It is meaningful during view change mode
type TimeoutType ¶
type TimeoutType int
TimeoutType is the type of timeout in view change protocol
func (TimeoutType) String ¶
func (t TimeoutType) String() string
Source Files
¶
- checks.go
- config.go
- consensus.go
- consensus_block_proposing.go
- consensus_msg_sender.go
- consensus_service.go
- consensus_v2.go
- construct.go
- debug.go
- double_sign.go
- downloader.go
- enums.go
- fbft_log.go
- leader.go
- metrics.go
- post_processing.go
- threshold.go
- validator.go
- view_change.go
- view_change_construct.go
- view_change_msg.go