Documentation
¶
Index ¶
- Constants
- Variables
- func BuildTimeoutVotingHash(epoch uint64, round uint32) [32]byte
- func CalcAddedValidators(curVSet, nxtVSet *cmttypes.ValidatorSet) (added []*cmttypes.Validator)
- func IsCritical(err error) bool
- func IsFutureBlock(err error) bool
- func IsKnownBlock(err error) bool
- func IsParentMissing(err error) bool
- type BlockProbe
- type ConsensusPeer
- type EpochEndInfo
- type EpochState
- func (es *EpochState) AddQCVote(signerIndex uint32, round uint32, blockID types.Bytes32, sig []byte) *block.QuorumCert
- func (es *EpochState) AddTCVote(signerIndex uint32, round uint32, sig []byte, hash [32]byte) *types.TimeoutCert
- func (es *EpochState) CommitteeIndex() int
- func (es *EpochState) CommitteeSize() uint32
- func (es *EpochState) GetMyself() *cmttypes.Validator
- func (es *EpochState) GetValidatorByIndex(index int) ([]byte, *cmttypes.Validator)
- func (es *EpochState) InCommittee() bool
- func (es *EpochState) PrintCommittee()
- type Executor
- func (e *Executor) ApplyBlock(block *block.Block, syncingToHeight int64) ([]byte, *cmttypes.ValidatorSet, error)
- func (e *Executor) Commit() (*abcitypes.CommitResponse, error)
- func (e *Executor) ExtendVote(req *abcitypes.ExtendVoteRequest) (*abcitypes.ExtendVoteResponse, error)
- func (e *Executor) FinalizeBlock(req *abcitypes.FinalizeBlockRequest) (*abcitypes.FinalizeBlockResponse, error)
- func (e *Executor) InitChain(req *abcitypes.InitChainRequest) (*abcitypes.InitChainResponse, error)
- func (e *Executor) PrepareProposal(parent *block.DraftBlock, proposerIndex int) (*abcitypes.PrepareProposalResponse, error)
- func (e *Executor) ProcessProposal(blk *block.Block) (bool, error)
- func (e *Executor) SetEventBus(eventBus cmttypes.BlockEventPublisher)
- func (e *Executor) VerifyVoteExtension(req *abcitypes.VerifyVoteExtensionRequest) (*abcitypes.VerifyVoteExtensionResponse, error)
- type Handshaker
- func (h *Handshaker) Handshake(ctx context.Context, proxyApp proxy.AppConns) error
- func (h *Handshaker) NBlocks() int
- func (h *Handshaker) ReplayBlocks(ctx context.Context, appHash []byte, appBlockHeight int64, ...) ([]byte, error)
- func (h *Handshaker) SetEventBus(eventBus cmttypes.BlockEventPublisher)
- func (h *Handshaker) SetLogger(l log.Logger)
- type IncomingMsg
- type IncomingQueue
- type MsgCache
- type PMBeatInfo
- type PMCmd
- type PMProbeResult
- type PMRoundTimeoutInfo
- type PMVoteInfo
- type Pacemaker
- func (p *Pacemaker) AddIncoming(mi IncomingMsg)
- func (p *Pacemaker) AddTxToCurProposal(newTxID []byte) error
- func (p *Pacemaker) Broadcast(msg block.ConsensusMessage)
- func (p *Pacemaker) BuildProposalMessage(height, round uint32, bnew *block.DraftBlock, tc *types.TimeoutCert) (*block.PMProposalMessage, error)
- func (p *Pacemaker) BuildQueryMessage() (*block.PMQueryMessage, error)
- func (p *Pacemaker) BuildTimeoutMessage(qcHigh *block.DraftQC, ti *PMRoundTimeoutInfo, ...) (*block.PMTimeoutMessage, error)
- func (p *Pacemaker) BuildVoteMessage(proposalMsg *block.PMProposalMessage) (*block.PMVoteMessage, error)
- func (p *Pacemaker) CommitBlock(blk *block.Block, escortQC *block.QuorumCert) error
- func (p *Pacemaker) CreateLeaf(parent *block.DraftBlock, justify *block.DraftQC, round uint32) (error, *block.DraftBlock)
- func (p *Pacemaker) EpochStartKBlockNum() uint32
- func (p *Pacemaker) ExtendedFromLastCommitted(b *block.DraftBlock) bool
- func (p *Pacemaker) OnBeat(epoch uint64, round uint32)
- func (p *Pacemaker) OnBroadcastProposal()
- func (p *Pacemaker) OnCommit(commitReady []commitReadyBlock) (lastCommitted *block.Block)
- func (p *Pacemaker) OnPropose(qc *block.DraftQC, round uint32) *block.DraftBlock
- func (p *Pacemaker) OnReceiveProposal(mi IncomingMsg)
- func (p *Pacemaker) OnReceiveQuery(mi IncomingMsg)
- func (p *Pacemaker) OnReceiveTimeout(mi IncomingMsg)
- func (p *Pacemaker) OnReceiveVote(mi IncomingMsg)
- func (p *Pacemaker) OnRoundTimeout(ti PMRoundTimeoutInfo)
- func (p *Pacemaker) Probe() *PMProbeResult
- func (p *Pacemaker) Regulate()
- func (p *Pacemaker) ScheduleRegulate()
- func (p *Pacemaker) SignMessage(msg block.ConsensusMessage)
- func (p *Pacemaker) Start()
- func (p *Pacemaker) Update(qc *block.QuorumCert) (lastCommitted *block.Block)
- func (p *Pacemaker) UpdateQCHigh(qc *block.DraftQC) bool
- func (p *Pacemaker) ValidateProposal(b *block.DraftBlock) error
- func (p *Pacemaker) ValidateQC(b *block.Block, escortQC *block.QuorumCert) bool
- type QCVoteManager
- func (m *QCVoteManager) AddVote(index uint32, epoch uint64, round uint32, blockID types.Bytes32, sig []byte) *block.QuorumCert
- func (m *QCVoteManager) Aggregate(round uint32, blockID types.Bytes32, epoch uint64) *block.QuorumCert
- func (m *QCVoteManager) CleanUpTo(blockNum uint32)
- func (m *QCVoteManager) Count(round uint32, blockID types.Bytes32) uint32
- func (m *QCVoteManager) Size() uint32
- type Reactor
- type ReactorConfig
- type TCVoteManager
- func (m *TCVoteManager) AddVote(index uint32, epoch uint64, round uint32, sig []byte, hash [32]byte) *types.TimeoutCert
- func (m *TCVoteManager) Aggregate(epoch uint64, round uint32) *types.TimeoutCert
- func (m *TCVoteManager) CleanUpTo(epoch uint64)
- func (m *TCVoteManager) Count(epoch uint64, round uint32) uint32
- func (m *TCVoteManager) Size() uint32
- type ValidatorSetRegistry
- func (vr *ValidatorSetRegistry) Get(num uint32) *cmttypes.ValidatorSet
- func (vr *ValidatorSetRegistry) GetNext(num uint32) *cmttypes.ValidatorSet
- func (vr *ValidatorSetRegistry) Prune()
- func (vr *ValidatorSetRegistry) Update(num uint32, vset *cmttypes.ValidatorSet, updates abcitypes.ValidatorUpdates, ...) (nxtVSet *cmttypes.ValidatorSet, addedValidators []*cmttypes.Validator, ...)
Constants ¶
const ( RoundInterval = 2 * time.Second RoundTimeoutInterval = RoundInterval * 4 // round timeout 8 secs. ProposeTimeLimit = 1300 * time.Millisecond BroadcastTimeLimit = 1400 * time.Millisecond )
const ( RegularRound = roundType(1) TimeoutRound = roundType(3) )
const (
IN_QUEUE_TTL = time.Second * 5
)
const (
PMCmdRegulate = 0 // regulate pacemaker with all fresh start, could be used any time when pacemaker is out of sync
)
Variables ¶
var ( ErrUnrecognizedPayload = errors.New("unrecognized payload") ErrVersionMismatch = errors.New("version mismatch") ErrMalformattedMsg = errors.New("malformatted msg") ErrKnownMsg = errors.New("known msg") ErrProposalRejected = errors.New("proposal rejected") ErrProposalUnknown = errors.New("proposal unknown") ErrForkHappened = errors.New("fork happened") )
var ( ErrParentBlockEmpty = errors.New("parent block empty") ErrPackerEmpty = errors.New("packer is empty") ErrFlowEmpty = errors.New("flow is empty") ErrProposalEmpty = errors.New("proposal is empty") ErrStateCreaterNotReady = errors.New("state creater not ready") ErrInvalidRound = errors.New("invalid round") )
var (
ErrInvalidBlock = errors.New("invalid block")
)
Functions ¶
func BuildTimeoutVotingHash ¶
Timeout Vote Message Hash
func CalcAddedValidators ¶
func CalcAddedValidators(curVSet, nxtVSet *cmttypes.ValidatorSet) (added []*cmttypes.Validator)
func IsCritical ¶
IsCritical returns if the error is consensus related.
func IsFutureBlock ¶
IsFutureBlock returns if the error indicates that the block should be processed later.
func IsKnownBlock ¶
IsKnownBlock returns if the error means the block was already in the chain.
Types ¶
type ConsensusPeer ¶
Consensus Topology Peer
func NewConsensusPeer ¶
func NewConsensusPeer(name string, ip string) *ConsensusPeer
func (*ConsensusPeer) String ¶
func (cp *ConsensusPeer) String() string
type EpochEndInfo ¶
type EpochState ¶
type EpochState struct {
// contains filtered or unexported fields
}
func NewEpochState ¶
func NewPendingEpochState ¶
func NewPendingEpochState(vset *cmttypes.ValidatorSet, myPubKey bls.PublicKey, curEpoch uint64) (*EpochState, error)
func (*EpochState) AddQCVote ¶
func (es *EpochState) AddQCVote(signerIndex uint32, round uint32, blockID types.Bytes32, sig []byte) *block.QuorumCert
func (*EpochState) AddTCVote ¶
func (es *EpochState) AddTCVote(signerIndex uint32, round uint32, sig []byte, hash [32]byte) *types.TimeoutCert
func (*EpochState) CommitteeIndex ¶
func (es *EpochState) CommitteeIndex() int
func (*EpochState) CommitteeSize ¶
func (es *EpochState) CommitteeSize() uint32
func (*EpochState) GetMyself ¶
func (es *EpochState) GetMyself() *cmttypes.Validator
func (*EpochState) GetValidatorByIndex ¶
func (es *EpochState) GetValidatorByIndex(index int) ([]byte, *cmttypes.Validator)
func (*EpochState) InCommittee ¶
func (es *EpochState) InCommittee() bool
func (*EpochState) PrintCommittee ¶
func (es *EpochState) PrintCommittee()
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
func NewExecutor ¶
func NewExecutor(proxyApp cmtproxy.AppConnConsensus, c *chain.Chain) *Executor
func (*Executor) ApplyBlock ¶
func (e *Executor) ApplyBlock(block *block.Block, syncingToHeight int64) ([]byte, *cmttypes.ValidatorSet, error)
ApplyBlock validates the block against the state, executes it against the app, fires the relevant events, commits the app, and saves the new state and responses. It returns the new state. It's the only function that needs to be called from outside this package to process and commit an entire block. It takes a blockID to avoid recomputing the parts hash.
func (*Executor) ExtendVote ¶
func (e *Executor) ExtendVote(req *abcitypes.ExtendVoteRequest) (*abcitypes.ExtendVoteResponse, error)
func (*Executor) FinalizeBlock ¶
func (e *Executor) FinalizeBlock(req *abcitypes.FinalizeBlockRequest) (*abcitypes.FinalizeBlockResponse, error)
func (*Executor) InitChain ¶
func (e *Executor) InitChain(req *abcitypes.InitChainRequest) (*abcitypes.InitChainResponse, error)
func (*Executor) PrepareProposal ¶
func (e *Executor) PrepareProposal(parent *block.DraftBlock, proposerIndex int) (*abcitypes.PrepareProposalResponse, error)
func (*Executor) ProcessProposal ¶
func (*Executor) SetEventBus ¶
func (e *Executor) SetEventBus(eventBus cmttypes.BlockEventPublisher)
SetEventBus - sets the event bus for publishing block related events. If not called, it defaults to types.NopEventBus.
func (*Executor) VerifyVoteExtension ¶
func (e *Executor) VerifyVoteExtension(req *abcitypes.VerifyVoteExtensionRequest) (*abcitypes.VerifyVoteExtensionResponse, error)
type Handshaker ¶
type Handshaker struct {
// contains filtered or unexported fields
}
func NewHandshaker ¶
func NewHandshaker(c *chain.Chain, genDoc *cmttypes.GenesisDoc, ) *Handshaker
func (*Handshaker) NBlocks ¶
func (h *Handshaker) NBlocks() int
NBlocks returns the number of blocks applied to the state.
func (*Handshaker) ReplayBlocks ¶
func (h *Handshaker) ReplayBlocks( ctx context.Context, appHash []byte, appBlockHeight int64, proxyApp proxy.AppConns, ) ([]byte, error)
ReplayBlocks replays all blocks since appBlockHeight and ensures the result matches the current state. Returns the final AppHash or an error.
func (*Handshaker) SetEventBus ¶
func (h *Handshaker) SetEventBus(eventBus cmttypes.BlockEventPublisher)
SetEventBus - sets the event bus for publishing block related events. If not called, it defaults to types.NopEventBus.
func (*Handshaker) SetLogger ¶
func (h *Handshaker) SetLogger(l log.Logger)
type IncomingMsg ¶
type IncomingMsg struct { //Msg block.ConsensusMessage // from envelope Msg block.ConsensusMessage SenderAddr common.Address // extras Hash types.Bytes32 ShortHashStr string EnqueueAt time.Time ExpireAt time.Time ProcessCount uint32 }
func (*IncomingMsg) Expired ¶
func (m *IncomingMsg) Expired() bool
type IncomingQueue ¶
func NewIncomingQueue ¶
func NewIncomingQueue() *IncomingQueue
func (*IncomingQueue) Add ¶
func (q *IncomingQueue) Add(mi IncomingMsg) error
func (*IncomingQueue) DelayedAdd ¶
func (q *IncomingQueue) DelayedAdd(mi IncomingMsg)
func (*IncomingQueue) Len ¶
func (q *IncomingQueue) Len() int
func (*IncomingQueue) Queue ¶
func (q *IncomingQueue) Queue() chan (IncomingMsg)
type PMBeatInfo ¶
type PMBeatInfo struct {
// contains filtered or unexported fields
}
type PMProbeResult ¶
type PMProbeResult struct { CurRound uint32 InCommittee bool CommitteeIndex int CommitteeSize int LastVotingHeight uint32 LastOnBeatRound uint32 QCHigh *block.QuorumCert LastCommitted *BlockProbe ProposalCount int }
type PMRoundTimeoutInfo ¶
type PMRoundTimeoutInfo struct {
// contains filtered or unexported fields
}
struct
type PMVoteInfo ¶
type PMVoteInfo struct {
// contains filtered or unexported fields
}
type Pacemaker ¶
type Pacemaker struct { QCHigh *block.DraftQC TCHigh *types.TimeoutCert // contains filtered or unexported fields }
func NewPacemaker ¶
func (*Pacemaker) AddIncoming ¶ added in v0.0.2
func (p *Pacemaker) AddIncoming(mi IncomingMsg)
func (*Pacemaker) AddTxToCurProposal ¶
Build MBlock
func (*Pacemaker) Broadcast ¶ added in v0.0.2
func (p *Pacemaker) Broadcast(msg block.ConsensusMessage)
func (*Pacemaker) BuildProposalMessage ¶
func (p *Pacemaker) BuildProposalMessage(height, round uint32, bnew *block.DraftBlock, tc *types.TimeoutCert) (*block.PMProposalMessage, error)
func (*Pacemaker) BuildQueryMessage ¶
func (p *Pacemaker) BuildQueryMessage() (*block.PMQueryMessage, error)
BuildQueryMessage
func (*Pacemaker) BuildTimeoutMessage ¶
func (p *Pacemaker) BuildTimeoutMessage(qcHigh *block.DraftQC, ti *PMRoundTimeoutInfo, lastVoteMsg *block.PMVoteMessage) (*block.PMTimeoutMessage, error)
BuildVoteForProposalMsg build VFP message for proposal
func (*Pacemaker) BuildVoteMessage ¶
func (p *Pacemaker) BuildVoteMessage(proposalMsg *block.PMProposalMessage) (*block.PMVoteMessage, error)
BuildVoteMsg build VFP message for proposal txRoot, stateRoot is decoded from proposalMsg.ProposedBlock, carry in cos already decoded outside
func (*Pacemaker) CommitBlock ¶
finalize the block with its own QC
func (*Pacemaker) CreateLeaf ¶
func (p *Pacemaker) CreateLeaf(parent *block.DraftBlock, justify *block.DraftQC, round uint32) (error, *block.DraftBlock)
func (*Pacemaker) EpochStartKBlockNum ¶
func (*Pacemaker) ExtendedFromLastCommitted ¶
func (p *Pacemaker) ExtendedFromLastCommitted(b *block.DraftBlock) bool
check a DraftBlock is the extension of b_locked, max 10 hops
func (*Pacemaker) OnBroadcastProposal ¶
func (p *Pacemaker) OnBroadcastProposal()
func (*Pacemaker) OnReceiveProposal ¶
func (p *Pacemaker) OnReceiveProposal(mi IncomingMsg)
func (*Pacemaker) OnReceiveQuery ¶
func (p *Pacemaker) OnReceiveQuery(mi IncomingMsg)
func (*Pacemaker) OnReceiveTimeout ¶
func (p *Pacemaker) OnReceiveTimeout(mi IncomingMsg)
func (*Pacemaker) OnReceiveVote ¶
func (p *Pacemaker) OnReceiveVote(mi IncomingMsg)
func (*Pacemaker) OnRoundTimeout ¶
func (p *Pacemaker) OnRoundTimeout(ti PMRoundTimeoutInfo)
func (*Pacemaker) Probe ¶
func (p *Pacemaker) Probe() *PMProbeResult
func (*Pacemaker) ScheduleRegulate ¶
func (p *Pacemaker) ScheduleRegulate()
func (*Pacemaker) SignMessage ¶
func (p *Pacemaker) SignMessage(msg block.ConsensusMessage)
func (*Pacemaker) Update ¶
func (p *Pacemaker) Update(qc *block.QuorumCert) (lastCommitted *block.Block)
b_exec <- b_lock <- b <- b' <- bnew*
func (*Pacemaker) ValidateProposal ¶
func (p *Pacemaker) ValidateProposal(b *block.DraftBlock) error
func (*Pacemaker) ValidateQC ¶
type QCVoteManager ¶
type QCVoteManager struct {
// contains filtered or unexported fields
}
func NewQCVoteManager ¶
func NewQCVoteManager(committeeSize uint32) *QCVoteManager
func (*QCVoteManager) AddVote ¶
func (m *QCVoteManager) AddVote(index uint32, epoch uint64, round uint32, blockID types.Bytes32, sig []byte) *block.QuorumCert
func (*QCVoteManager) Aggregate ¶
func (m *QCVoteManager) Aggregate(round uint32, blockID types.Bytes32, epoch uint64) *block.QuorumCert
func (*QCVoteManager) CleanUpTo ¶
func (m *QCVoteManager) CleanUpTo(blockNum uint32)
func (*QCVoteManager) Count ¶
func (m *QCVoteManager) Count(round uint32, blockID types.Bytes32) uint32
func (*QCVoteManager) Size ¶
func (m *QCVoteManager) Size() uint32
type Reactor ¶
----------------------------------------------------------------------------- Reactor defines a reactor for the consensus service.
func NewConsensusReactor ¶
func NewConsensusReactor(ctx context.Context, config *cmtcfg.Config, chain *chain.Chain, p2pSrv p2p.P2P, txpool *txpool.TxPool, blsMaster *types.BlsMaster, proxyApp cmtproxy.AppConns) *Reactor
NewConsensusReactor returns a new Reactor with config
type ReactorConfig ¶
type TCVoteManager ¶
type TCVoteManager struct {
// contains filtered or unexported fields
}
func NewTCVoteManager ¶
func NewTCVoteManager(committeeSize uint32) *TCVoteManager
func (*TCVoteManager) AddVote ¶
func (m *TCVoteManager) AddVote(index uint32, epoch uint64, round uint32, sig []byte, hash [32]byte) *types.TimeoutCert
func (*TCVoteManager) Aggregate ¶
func (m *TCVoteManager) Aggregate(epoch uint64, round uint32) *types.TimeoutCert
func (*TCVoteManager) CleanUpTo ¶
func (m *TCVoteManager) CleanUpTo(epoch uint64)
func (*TCVoteManager) Size ¶
func (m *TCVoteManager) Size() uint32
type ValidatorSetRegistry ¶
type ValidatorSetRegistry struct { CurrentVSet map[uint32]*cmttypes.ValidatorSet NextVSet map[uint32]*cmttypes.ValidatorSet Chain *chain.Chain // contains filtered or unexported fields }
func NewValidatorSetRegistry ¶
func NewValidatorSetRegistry(c *chain.Chain) *ValidatorSetRegistry
func (*ValidatorSetRegistry) Get ¶
func (vr *ValidatorSetRegistry) Get(num uint32) *cmttypes.ValidatorSet
func (*ValidatorSetRegistry) GetNext ¶
func (vr *ValidatorSetRegistry) GetNext(num uint32) *cmttypes.ValidatorSet
func (*ValidatorSetRegistry) Prune ¶
func (vr *ValidatorSetRegistry) Prune()
func (*ValidatorSetRegistry) Update ¶
func (vr *ValidatorSetRegistry) Update(num uint32, vset *cmttypes.ValidatorSet, updates abcitypes.ValidatorUpdates, events []abcitypes.Event) (nxtVSet *cmttypes.ValidatorSet, addedValidators []*cmttypes.Validator, err error)
Source Files
¶
- consensus_peer.go
- epoch_state.go
- errors.go
- executor.go
- handshaker.go
- incoming_queue.go
- msg_cache.go
- pacemaker.go
- pacemaker_assist.go
- pacemaker_broadcast.go
- pacemaker_commit.go
- pacemaker_probe.go
- pacemaker_propose.go
- pacemaker_send.go
- pacemaker_validate.go
- prometheus.go
- qc_vote_manager.go
- reactor.go
- replay_stubs.go
- tc_vote_manager.go
- types.go
- validator_set_registry.go