Documentation ¶
Index ¶
- Constants
- Variables
- type Consensus
- func (consensus *Consensus) AddPubkeyMetrics()
- func (consensus *Consensus) BlockCommitSigs(blockNum uint64) ([]byte, error)
- func (consensus *Consensus) BlockNum() uint64
- func (consensus *Consensus) BlocksNotSynchronized()
- func (consensus *Consensus) BlocksSynchronized()
- func (consensus *Consensus) Close() error
- func (consensus *Consensus) FinishFinalityCount()
- func (consensus *Consensus) GenerateVdfAndProof(newBlock *types.Block, vrfBlockNumbers []uint64)
- func (consensus *Consensus) GenerateVrfAndProof(newHeader *block.Header) error
- func (consensus *Consensus) GetConsensusLeaderPrivateKey() (*bls.PrivateKeyWrapper, error)
- func (consensus *Consensus) GetConsensusMode() string
- func (consensus *Consensus) GetConsensusPhase() string
- func (consensus *Consensus) GetCurBlockViewID() uint64
- func (consensus *Consensus) GetFinality() int64
- func (consensus *Consensus) GetLastMileBlockIter(bnStart uint64) (*LastMileBlockIter, error)
- func (consensus *Consensus) GetLeaderPrivateKey(leaderKey *bls_core.PublicKey) (*bls.PrivateKeyWrapper, error)
- func (consensus *Consensus) GetLeaderPubKey() *bls_cosi.PublicKeyWrapper
- func (consensus *Consensus) GetNextRnd() ([vdFAndProofSize]byte, [32]byte, error)
- func (consensus *Consensus) GetPrivateKeys() multibls.PrivateKeys
- func (consensus *Consensus) GetPublicKeys() multibls.PublicKeys
- func (consensus *Consensus) GetViewChangingID() uint64
- func (consensus *Consensus) HandleMessageUpdate(ctx context.Context, msg *msg_pb.Message, senderKey *bls.SerializedPublicKey) 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) ReadSignatureBitmapPayload(recvPayload []byte, offset int) (*bls_core.Sign, *bls_cosi.Mask, error)
- func (consensus *Consensus) RegisterPRndChannel(pRndChannel chan []byte)
- func (consensus *Consensus) RegisterRndChannel(rndChannel chan [548]byte)
- func (consensus *Consensus) ResetState()
- func (consensus *Consensus) ResetViewChangeState()
- func (consensus *Consensus) SetBlockNum(blockNum uint64)
- func (consensus *Consensus) SetBlockVerifier(verifier VerifyBlockFunc)
- func (consensus *Consensus) SetCurBlockViewID(viewID uint64)
- func (consensus *Consensus) SetDownloader(d downloader)
- func (consensus *Consensus) SetIsBackup(isBackup bool)
- func (consensus *Consensus) SetMode(m Mode)
- func (consensus *Consensus) SetViewChangingID(viewID uint64)
- func (consensus *Consensus) SetViewIDs(height uint64)
- func (consensus *Consensus) SetupForNewConsensus(blk *types.Block, committedMsg *FBFTMessage)
- func (consensus *Consensus) Start(blockChannel chan *types.Block, ...)
- func (consensus *Consensus) StartFinalityCount()
- func (consensus *Consensus) UpdateBitmaps()
- func (consensus *Consensus) UpdateConsensusInformation() Mode
- func (consensus *Consensus) UpdateLeaderMetrics(numCommits float64, blockNum float64)
- func (consensus *Consensus) UpdatePublicKeys(pubKeys, allowlist []bls_cosi.PublicKeyWrapper) int64
- func (consensus *Consensus) UpdateValidatorMetrics(numSig float64, blockNum float64)
- func (consensus *Consensus) ValidateVdfAndProof(headerObj *block.Header) bool
- func (consensus *Consensus) VdfSeedSize() int
- func (consensus *Consensus) VerifyBlock(block *types.Block) error
- func (consensus *Consensus) WaitForNewRandomness()
- 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) DeleteBlocksLessThan(number uint64)
- func (log *FBFTLog) DeleteMessagesLessThan(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 LockedFBFTPhase
- 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 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)
- func (pm *State) SetIsBackup(isBackup bool)
- func (pm *State) SetMode(s Mode)
- func (pm *State) SetViewChangingID(id uint64)
- type TimeoutType
- type VerifyBlockFunc
Constants ¶
const ( // CommitSigSenderTimeout is the timeout for sending the commit sig to finish block proposal CommitSigSenderTimeout = 10 * time.Second // CommitSigReceiverTimeout is the timeout for the receiving side of the commit sig // if timeout, the receiver should instead ready directly from db for the commit sig CommitSigReceiverTimeout = 8 * 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 ¶
This section is empty.
Types ¶
type Consensus ¶
type Consensus struct { Decider quorum.Decider // FBFTLog stores the pbft messages and blocks during FBFT process FBFTLog *FBFTLog // The blockchain this consensus is working on Blockchain core.BlockChain // Minimal number of peers in the shard // If the number of validators is less than minPeers, the consensus won't start MinPeers int // the publickey of leader LeaderPubKey *bls.PublicKeyWrapper // Shard Id which this node belongs to ShardID uint32 // IgnoreViewIDCheck determines whether to ignore viewID check IgnoreViewIDCheck *abool.AtomicBool // Signal channel for proposing a new block and start new consensus ReadySignal chan ProposalType // Channel to send full commit signatures to finish new block proposal CommitSigChannel chan []byte // The post-consensus job func passed from Node object // Called when consensus on a new block is done PostConsensusJob func(*types.Block) error // The verifier func passed from Node object BlockVerifier VerifyBlockFunc // verified block to state sync broadcast VerifiedNewBlock chan *types.Block // will trigger state syncing when blockNum is low BlockNumLowChan chan struct{} // 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, leader p2p.Peer, multiBLSPriKey multibls.PrivateKeys, Decider quorum.Decider, ) (*Consensus, error)
New create a new Consensus record
func (*Consensus) AddPubkeyMetrics ¶
func (consensus *Consensus) AddPubkeyMetrics()
AddPubkeyMetrics add the list of blskeys to prometheus metrics
func (*Consensus) BlockCommitSigs ¶
BlockCommitSigs returns the byte array of aggregated commit signature and bitmap signed on the block
func (*Consensus) BlocksNotSynchronized ¶
func (consensus *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) Close ¶
Close close the consensus. If current is in normal commit phase, wait until the commit phase end.
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) GetConsensusLeaderPrivateKey ¶
func (consensus *Consensus) GetConsensusLeaderPrivateKey() (*bls.PrivateKeyWrapper, error)
GetConsensusLeaderPrivateKey returns consensus leader private key if node is the leader
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
func (*Consensus) GetFinality ¶
GetFinality returns the finality time in milliseconds of previous consensus
func (*Consensus) GetLastMileBlockIter ¶
func (consensus *Consensus) GetLastMileBlockIter(bnStart uint64) (*LastMileBlockIter, error)
GetLastMileBlockIter get the iterator of the last mile blocks starting from number bnStart
func (*Consensus) GetLeaderPrivateKey ¶
func (consensus *Consensus) GetLeaderPrivateKey(leaderKey *bls_core.PublicKey) (*bls.PrivateKeyWrapper, error)
GetLeaderPrivateKey returns leader private key if node is the leader
func (*Consensus) GetLeaderPubKey ¶ added in v0.0.20
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) GetViewChangingID ¶
GetViewChangingID returns the current view changing ID of the consensus
func (*Consensus) HandleMessageUpdate ¶
func (consensus *Consensus) HandleMessageUpdate(ctx context.Context, msg *msg_pb.Message, senderKey *bls.SerializedPublicKey) error
HandleMessageUpdate will update the consensus state according to received message
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
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 curernt mode is viewchanging
func (*Consensus) NumSignaturesIncludedInBlock ¶
NumSignaturesIncludedInBlock returns the number of signatures included in the block
func (*Consensus) ParseFBFTMessage ¶
func (consensus *Consensus) ParseFBFTMessage(msg *msg_pb.Message) (*FBFTMessage, error)
ParseFBFTMessage parses FBFT message into FBFTMessage structure
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) 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) ResetState ¶
func (consensus *Consensus) ResetState()
ResetState resets the state of the consensus
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) SetBlockVerifier ¶
func (consensus *Consensus) SetBlockVerifier(verifier VerifyBlockFunc)
SetBlockVerifier sets the block verifier
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) 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) SetupForNewConsensus ¶
func (consensus *Consensus) SetupForNewConsensus(blk *types.Block, committedMsg *FBFTMessage)
SetupForNewConsensus sets the state for new consensus
func (*Consensus) Start ¶
func (consensus *Consensus) Start( blockChannel chan *types.Block, stopChan, stoppedChan, startChannel chan struct{}, )
Start waits for the next new block and run consensus
func (*Consensus) StartFinalityCount ¶
func (consensus *Consensus) StartFinalityCount()
StartFinalityCount set the finality counter to current time
func (*Consensus) UpdateBitmaps ¶
func (consensus *Consensus) UpdateBitmaps()
UpdateBitmaps update the bitmaps for prepare and commit phase
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) 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) ValidateVdfAndProof ¶
ValidateVdfAndProof validates the VDF/proof in the current epoch
func (*Consensus) VdfSeedSize ¶
VdfSeedSize returns the number of VRFs for VDF computation
func (*Consensus) VerifyBlock ¶
VerifyBlock is a function used to verify the block and keep trace of verified blocks
func (*Consensus) WaitForNewRandomness ¶
func (consensus *Consensus) WaitForNewRandomness()
WaitForNewRandomness listens to the RndChannel to receive new VDF randomness.
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) DeleteBlocksLessThan ¶
DeleteBlocksLessThan deletes blocks less than given block number
func (*FBFTLog) DeleteMessagesLessThan ¶
DeleteMessagesLessThan deletes messages less than given block 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
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 LockedFBFTPhase ¶ added in v0.0.20
type LockedFBFTPhase struct {
// contains filtered or unexported fields
}
func NewLockedFBFTPhase ¶ added in v0.0.20
func NewLockedFBFTPhase(initialPhrase FBFTPhase) *LockedFBFTPhase
func (*LockedFBFTPhase) Get ¶ added in v0.0.20
func (a *LockedFBFTPhase) Get() FBFTPhase
func (*LockedFBFTPhase) Set ¶ added in v0.0.20
func (a *LockedFBFTPhase) Set(phrase FBFTPhase)
func (*LockedFBFTPhase) String ¶ added in v0.0.20
func (a *LockedFBFTPhase) String() string
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 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) SetIsBackup ¶
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
type VerifyBlockFunc ¶
VerifyBlockFunc is a function used to verify the block and keep trace of verified blocks