Documentation ¶
Index ¶
- Constants
- Variables
- func CompareHRS(h1 int64, r1 int32, s1 cstypes.RoundStepType, h2 int64, r2 int32, ...) int
- func IsDataCorruptionError(err error) bool
- func MsgToProto(msg Message) (*tmcons.Message, error)
- func NewReplayBlockExecutor(appClient abciclient.Client, stateStore sm.Store, blockStore sm.BlockStore, ...) *sm.BlockExecutor
- func ReplayerWithLogger(logger log.Logger) func(r *BlockReplayer)
- func ReplayerWithProTxHash(proTxHash types.ProTxHash) func(r *BlockReplayer)
- func RunReplayFile(ctx context.Context, logger log.Logger, cfg config.Config, ...) error
- func SkipStateStoreBootstrap(sm *State)
- func WALToProto(msg WALMessage) (*tmcons.WALMessage, error)
- func WithStopFunc(stopFns ...func(cs *State) bool) func(cs *State)
- func WithTimeoutTicker(timeoutTicker TimeoutTicker) func(cs *State)
- type ActionEvent
- type ActionHandler
- type AddCommitAction
- type AddCommitEvent
- type AddProposalBlockPartAction
- type AddProposalBlockPartEvent
- type AddVoteAction
- type AddVoteEvent
- type AddVoteFunc
- type AddVoteMiddlewareFunc
- type ApplyCommitAction
- type ApplyCommitEvent
- type BaseWAL
- func (wal *BaseWAL) FlushAndSync() error
- func (wal *BaseWAL) Group() *auto.Group
- func (wal *BaseWAL) OnStart(ctx context.Context) error
- func (wal *BaseWAL) OnStop()
- func (wal *BaseWAL) SearchForEndHeight(height int64, options *WALSearchOptions) (rd io.ReadCloser, found bool, err error)
- func (wal *BaseWAL) SetFlushInterval(i time.Duration)
- func (wal *BaseWAL) Wait()
- func (wal *BaseWAL) Write(msg WALMessage) error
- func (wal *BaseWAL) WriteSync(msg WALMessage) error
- type BlockPartMessage
- type BlockReplayer
- type BlockSyncReactor
- type CommitMessage
- type Controller
- type DataCorruptionError
- type EndHeightMessage
- type EnterCommitAction
- type EnterCommitEvent
- type EnterNewRoundAction
- type EnterNewRoundEvent
- type EnterPrecommitAction
- type EnterPrecommitEvent
- type EnterPrecommitWaitAction
- type EnterPrecommitWaitEvent
- type EnterPrevoteAction
- type EnterPrevoteEvent
- type EnterPrevoteWaitAction
- type EnterPrevoteWaitEvent
- type EnterProposeAction
- type EnterProposeEvent
- type EventPublisher
- func (p *EventPublisher) PublishCommitEvent(commit *types.Commit) error
- func (p *EventPublisher) PublishCompleteProposalEvent(event types.EventDataCompleteProposal)
- func (p *EventPublisher) PublishLockEvent(rs cstypes.RoundState)
- func (p *EventPublisher) PublishNewRoundEvent(event types.EventDataNewRound)
- func (p *EventPublisher) PublishNewRoundStepEvent(rs cstypes.RoundState)
- func (p *EventPublisher) PublishPolkaEvent(rs cstypes.RoundState)
- func (p *EventPublisher) PublishRelockEvent(rs cstypes.RoundState)
- func (p *EventPublisher) PublishValidBlockEvent(rs cstypes.RoundState)
- func (p *EventPublisher) PublishVoteEvent(vote *types.Vote) error
- type EventType
- type Gossiper
- type Handshaker
- type HasCommitMessage
- type HasVoteMessage
- type Message
- type Metrics
- func (m *Metrics) MarkBlockGossipComplete()
- func (m *Metrics) MarkBlockGossipStarted()
- func (m *Metrics) MarkLateVote(vt tmproto.SignedMsgType)
- func (m *Metrics) MarkProposalProcessed(accepted bool)
- func (m *Metrics) MarkRound(r int32, st time.Time)
- func (m *Metrics) MarkStep(s cstypes.RoundStepType)
- func (m *Metrics) MarkVoteExtensionReceived(accepted bool)
- func (m *Metrics) MarkVoteReceived(vt tmproto.SignedMsgType, power, totalPower int64)
- func (m *Metrics) RecordConsMetrics(block *types.Block)
- type NewRoundStepMessage
- type NewValidBlockMessage
- type PeerState
- func (ps *PeerState) ApplyHasCommitMessage(msg *HasCommitMessage)
- func (ps *PeerState) ApplyHasVoteMessage(msg *HasVoteMessage) error
- func (ps *PeerState) ApplyNewRoundStepMessage(msg *NewRoundStepMessage)
- func (ps *PeerState) ApplyNewValidBlockMessage(msg *NewValidBlockMessage)
- func (ps *PeerState) ApplyProposalPOLMessage(msg *ProposalPOLMessage)
- func (ps *PeerState) ApplyVoteSetBitsMessage(msg *VoteSetBitsMessage, ourVotes *bits.BitArray)
- func (ps *PeerState) BlockPartsSent() int
- func (ps *PeerState) CommitsSent() int
- func (ps *PeerState) EnsureVoteBitArrays(height int64, numValidators int)
- func (ps *PeerState) GetHeight() int64
- func (ps *PeerState) GetProTxHash() types.ProTxHash
- func (ps *PeerState) GetRoundState() *cstypes.PeerRoundState
- func (ps *PeerState) InitProposalBlockParts(partSetHeader types.PartSetHeader)
- func (ps *PeerState) IsRunning() bool
- func (ps *PeerState) MarshalZerologObject(e *zerolog.Event)
- func (ps *PeerState) PickVoteToSend(votes types.VoteSetReader) (*types.Vote, bool)
- func (ps *PeerState) RecordBlockPart() int
- func (ps *PeerState) RecordCommit() int
- func (ps *PeerState) RecordVote() int
- func (ps *PeerState) SetHasCommit(commit *types.Commit)
- func (ps *PeerState) SetHasProposal(proposal *types.Proposal)
- func (ps *PeerState) SetHasProposalBlockPart(height int64, round int32, index int)
- func (ps *PeerState) SetHasVote(vote *types.Vote) error
- func (ps *PeerState) SetProTxHash(proTxHash types.ProTxHash)
- func (ps *PeerState) SetRunning(v bool)
- func (ps *PeerState) String() string
- func (ps *PeerState) StringIndented(indent string) string
- func (ps *PeerState) ToJSON() ([]byte, error)
- func (ps *PeerState) UpdateProposalBlockParts(partSet *types.PartSet)
- func (ps *PeerState) UpdateRoundState(fn func(prs *cstypes.PeerRoundState))
- func (ps *PeerState) VotesSent() int
- type Prevoter
- type ProposalCompletedAction
- type ProposalCompletedEvent
- type ProposalMessage
- type ProposalPOLMessage
- type Proposaler
- type Reactor
- func (r *Reactor) GetConsensusState() *State
- func (r *Reactor) GetPeerState(peerID types.NodeID) (*PeerState, bool)
- func (r *Reactor) OnStart(ctx context.Context) error
- func (r *Reactor) OnStop()
- func (r *Reactor) SetBlockSyncingMetrics(v float64)
- func (r *Reactor) SetStateSyncingMetrics(v float64)
- func (r *Reactor) String() string
- func (r *Reactor) SwitchToConsensus(ctx context.Context, state sm.State, skipWAL bool)
- func (r *Reactor) WaitSync() bool
- type State
- func (cs *State) AddProposalBlockPart(ctx context.Context, height int64, round int32, part *types.Part, ...) error
- func (cs *State) CreateProposalBlock(ctx context.Context) (*types.Block, error)
- func (cs *State) GetRoundState() cstypes.RoundState
- func (cs *State) GetRoundStateJSON() ([]byte, error)
- func (cs *State) GetRoundStateSimpleJSON() ([]byte, error)
- func (cs *State) GetStateData() StateData
- func (cs *State) GetValidatorSet() (int64, *types.ValidatorSet)
- func (cs *State) GetValidators() (int64, []*types.Validator)
- func (cs *State) OnStart(ctx context.Context) error
- func (cs *State) OnStop()
- func (cs *State) OpenWAL(ctx context.Context, walFile string) (WAL, error)
- func (cs *State) PrivValidator() types.PrivValidator
- func (cs *State) PublishCommitEvent(commit *types.Commit) error
- func (cs *State) ReplayFile(ctx context.Context, file string, console bool) error
- func (cs *State) SetPrivValidator(ctx context.Context, priv types.PrivValidator)
- func (cs *State) SetProposal(ctx context.Context, proposal *types.Proposal, peerID types.NodeID) error
- func (cs *State) SetProposalAndBlock(ctx context.Context, proposal *types.Proposal, parts *types.PartSet, ...) error
- func (cs *State) SetProposedAppVersion(ver uint64)
- func (cs *State) String() string
- type StateData
- type StateDataStore
- type StateEvent
- type StateOption
- type TimedWALMessage
- type TimeoutTicker
- type TryAddCommitAction
- type TryAddCommitEvent
- type TryFinalizeCommitAction
- type TryFinalizeCommitEvent
- type VoteMessage
- type VoteSetBitsMessage
- type VoteSetMaj23Message
- type WAL
- type WALDecoder
- type WALEncoder
- type WALFlusher
- type WALMessage
- type WALSearchOptions
- type WALSearcher
- type WALWriteFlusher
- type WALWriter
Constants ¶
const ( // MetricsSubsystem is a subsystem shared by all metrics exposed by this // package. MetricsSubsystem = "consensus" )
Variables ¶
var ( ErrPeerStateHeightRegression = errors.New("peer state height regression") ErrPeerStateInvalidStartTime = errors.New("peer state invalid startTime") ErrPeerStateSetNilVote = errors.New("peer state set a nil vote") ErrPeerStateInvalidVoteIndex = errors.New("peer sent a vote with an invalid vote index") )
var ( ErrInvalidProposalNotSet = errors.New("error invalid proposal not set") ErrInvalidProposalForCommit = errors.New("error invalid proposal for commit") ErrUnableToVerifyProposal = errors.New("error unable to verify proposal") ErrInvalidProposalSignature = errors.New("error invalid proposal signature") ErrInvalidProposalCoreHeight = errors.New("error invalid proposal core height") ErrInvalidProposalPOLRound = errors.New("error invalid proposal POL round") ErrAddingVote = errors.New("error adding vote") ErrPrivValidatorNotSet = errors.New("priv-validator is not set") )
Consensus sentinel errors
Functions ¶
func CompareHRS ¶
func CompareHRS(h1 int64, r1 int32, s1 cstypes.RoundStepType, h2 int64, r2 int32, s2 cstypes.RoundStepType) int
func IsDataCorruptionError ¶
IsDataCorruptionError returns true if data has been corrupted inside WAL.
func MsgToProto ¶
MsgToProto takes a consensus message type and returns the proto defined consensus message.
TODO: This needs to be removed, but WALToProto depends on this.
func NewReplayBlockExecutor ¶
func NewReplayBlockExecutor( appClient abciclient.Client, stateStore sm.Store, blockStore sm.BlockStore, eventBus *eventbus.EventBus, opts ...func(e *sm.BlockExecutor), ) *sm.BlockExecutor
NewReplayBlockExecutor returns a new instance of state.BlockExecutor configured for BlockReplayer
func ReplayerWithLogger ¶
func ReplayerWithLogger(logger log.Logger) func(r *BlockReplayer)
ReplayerWithLogger sets logger to BlockReplayer
func ReplayerWithProTxHash ¶
func ReplayerWithProTxHash(proTxHash types.ProTxHash) func(r *BlockReplayer)
ReplayerWithProTxHash sets node's pro-tx hash to BlockReplayer
func RunReplayFile ¶
func RunReplayFile( ctx context.Context, logger log.Logger, cfg config.Config, csConfig *config.ConsensusConfig, console bool, ) error
replay the wal file
func SkipStateStoreBootstrap ¶
func SkipStateStoreBootstrap(sm *State)
SkipStateStoreBootstrap is a state option forces the constructor to skip state bootstrapping during construction.
func WALToProto ¶
func WALToProto(msg WALMessage) (*tmcons.WALMessage, error)
WALToProto takes a WAL message and return a proto walMessage and error.
func WithStopFunc ¶
func WithTimeoutTicker ¶
func WithTimeoutTicker(timeoutTicker TimeoutTicker) func(cs *State)
Types ¶
type ActionEvent ¶
type ActionEvent interface {
GetType() EventType
}
type ActionHandler ¶
type ActionHandler interface {
Execute(ctx context.Context, event StateEvent) error
}
ActionHandler is an action handler interface
type AddCommitAction ¶
type AddCommitAction struct {
// contains filtered or unexported fields
}
func (*AddCommitAction) Execute ¶
func (c *AddCommitAction) Execute(ctx context.Context, stateEvent StateEvent) error
type AddCommitEvent ¶
func (*AddCommitEvent) GetType ¶
func (e *AddCommitEvent) GetType() EventType
GetType returns AddCommitType event-type
type AddProposalBlockPartAction ¶
type AddProposalBlockPartAction struct {
// contains filtered or unexported fields
}
AddProposalBlockPartAction ... NOTE: block is not necessarily valid. Asynchronously triggers either enterPrevote (before we timeout of propose) or tryFinalizeCommit, once we have the full block.
func (*AddProposalBlockPartAction) Execute ¶
func (c *AddProposalBlockPartAction) Execute(ctx context.Context, stateEvent StateEvent) error
Execute ...
type AddProposalBlockPartEvent ¶
type AddProposalBlockPartEvent struct { Msg *BlockPartMessage PeerID types.NodeID FromReplay bool }
func (*AddProposalBlockPartEvent) GetType ¶
func (e *AddProposalBlockPartEvent) GetType() EventType
GetType returns AddProposalBlockPartType event-type
type AddVoteAction ¶
type AddVoteAction struct {
// contains filtered or unexported fields
}
AddVoteAction is the command to add a vote to the vote-set Attempt to add the vote. if its a duplicate signature, dupeout the validator
func (*AddVoteAction) Execute ¶
func (c *AddVoteAction) Execute(ctx context.Context, stateEvent StateEvent) error
Execute adds received vote to prevote or precommit set
type AddVoteEvent ¶
func (*AddVoteEvent) GetType ¶
func (e *AddVoteEvent) GetType() EventType
GetType returns AddVoteType event-type
type AddVoteFunc ¶
type AddVoteMiddlewareFunc ¶
type AddVoteMiddlewareFunc func(next AddVoteFunc) AddVoteFunc
type ApplyCommitAction ¶
type ApplyCommitAction struct {
// contains filtered or unexported fields
}
func (*ApplyCommitAction) Execute ¶
func (c *ApplyCommitAction) Execute(ctx context.Context, stateEvent StateEvent) error
func (*ApplyCommitAction) RecordMetrics ¶
type ApplyCommitEvent ¶
func (*ApplyCommitEvent) GetType ¶
func (e *ApplyCommitEvent) GetType() EventType
GetType returns ApplyCommitType event-type
type BaseWAL ¶
type BaseWAL struct { service.BaseService // contains filtered or unexported fields }
Write ahead logger writes msgs to disk before they are processed. Can be used for crash-recovery and deterministic replay. TODO: currently the wal is overwritten during replay catchup, give it a mode so it's either reading or appending - must read to end to start appending again.
func NewWAL ¶
func NewWAL(ctx context.Context, logger log.Logger, walFile string, groupOptions ...func(*auto.Group)) (*BaseWAL, error)
NewWAL returns a new write-ahead logger based on `baseWAL`, which implements WAL. It's flushed and synced to disk every 2s and once when stopped.
func (*BaseWAL) FlushAndSync ¶
FlushAndSync flushes and fsync's the underlying group's data to disk. See auto#FlushAndSync
func (*BaseWAL) OnStop ¶
func (wal *BaseWAL) OnStop()
Stop the underlying autofile group. Use Wait() to ensure it's finished shutting down before cleaning up files.
func (*BaseWAL) SearchForEndHeight ¶
func (wal *BaseWAL) SearchForEndHeight( height int64, options *WALSearchOptions) (rd io.ReadCloser, found bool, err error)
SearchForEndHeight searches for the EndHeightMessage with the given height and returns an auto.GroupReader, whenever it was found or not and an error. Group reader will be nil if found equals false.
CONTRACT: caller must close group reader.
func (*BaseWAL) SetFlushInterval ¶
SetFlushInterval allows us to override the periodic flush interval for the WAL.
func (*BaseWAL) Wait ¶
func (wal *BaseWAL) Wait()
Wait for the underlying autofile group to finish shutting down so it's safe to cleanup files.
func (*BaseWAL) Write ¶
func (wal *BaseWAL) Write(msg WALMessage) error
Write is called in newStep and for each receive on the peerMsgQueue and the timeoutTicker. NOTE: does not call fsync()
func (*BaseWAL) WriteSync ¶
func (wal *BaseWAL) WriteSync(msg WALMessage) error
WriteSync is called when we receive a msg from ourselves so that we write to disk before sending signed messages. NOTE: calls fsync()
type BlockPartMessage ¶
BlockPartMessage is sent when gossipping a piece of the proposed block.
func (*BlockPartMessage) String ¶
func (m *BlockPartMessage) String() string
String returns a string representation.
func (*BlockPartMessage) TypeTag ¶
func (*BlockPartMessage) TypeTag() string
func (*BlockPartMessage) ValidateBasic ¶
func (m *BlockPartMessage) ValidateBasic() error
ValidateBasic performs basic validation.
type BlockReplayer ¶
type BlockReplayer struct {
// contains filtered or unexported fields
}
BlockReplayer replays persisted blocks for ABCI application
func NewBlockReplayer ¶
func NewBlockReplayer( appClient abciclient.Client, stateStore sm.Store, store sm.BlockStore, genDoc *types.GenesisDoc, publisher types.BlockEventPublisher, blockExec *sm.BlockExecutor, opts ...func(r *BlockReplayer), ) *BlockReplayer
NewBlockReplayer creates and returns an instance of BlockReplayer
type BlockSyncReactor ¶
type BlockSyncReactor interface { SwitchToBlockSync(context.Context, sm.State) error GetMaxPeerBlockHeight() int64 // GetTotalSyncedTime returns the time duration since the blocksync starting. GetTotalSyncedTime() time.Duration // GetRemainingSyncTime returns the estimating time the node will be fully synced, // if will return 0 if the blocksync does not perform or the number of block synced is // too small (less than 100). GetRemainingSyncTime() time.Duration }
NOTE: Temporary interface for switching to block sync, we should get rid of v0. See: https://github.com/tendermint/tendermint/issues/4595
type CommitMessage ¶
CommitMessage is sent when commit is constructed after having 2/3rds of approving precommit messages for a proposal.
func (*CommitMessage) TypeTag ¶
func (*CommitMessage) TypeTag() string
func (*CommitMessage) ValidateBasic ¶
func (m *CommitMessage) ValidateBasic() error
ValidateBasic performs basic validation.
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is responsible for registering and dispatching an event to an action
func NewController ¶
func NewController(cs *State, wal *wrapWAL, statsQueue *chanQueue[msgInfo], propler cstypes.Proposaler) *Controller
NewController returns a new instance of a controller with a set of all possible transitions (actions)
func (*Controller) Dispatch ¶
func (c *Controller) Dispatch(ctx context.Context, event ActionEvent, stateData *StateData) error
Dispatch dispatches an event to a handler
func (*Controller) Get ¶
func (c *Controller) Get(eventType EventType) ActionHandler
Get returns an action handler by an event-type, if the action is not existed then returns nil
func (*Controller) Register ¶
func (c *Controller) Register(eventType EventType, handler ActionHandler)
Register adds or overrides a action handler for an event-type
type DataCorruptionError ¶
type DataCorruptionError struct {
// contains filtered or unexported fields
}
DataCorruptionError is an error that occures if data on disk was corrupted.
func (DataCorruptionError) Cause ¶
func (e DataCorruptionError) Cause() error
func (DataCorruptionError) Error ¶
func (e DataCorruptionError) Error() string
type EndHeightMessage ¶
type EndHeightMessage struct {
Height int64 `json:"height,string"`
}
EndHeightMessage marks the end of the given height inside WAL. @internal used by scripts/wal2json util.
func (EndHeightMessage) TypeTag ¶
func (EndHeightMessage) TypeTag() string
type EnterCommitAction ¶
type EnterCommitAction struct {
// contains filtered or unexported fields
}
EnterCommitAction ... Enter: +2/3 precommits for block
func (*EnterCommitAction) Execute ¶
func (c *EnterCommitAction) Execute(ctx context.Context, stateEvent StateEvent) error
Execute ...
type EnterCommitEvent ¶
func (*EnterCommitEvent) GetType ¶
func (e *EnterCommitEvent) GetType() EventType
GetType returns EnterCommitType event-type
type EnterNewRoundAction ¶
type EnterNewRoundAction struct {
// contains filtered or unexported fields
}
EnterNewRoundAction ... Enter: `timeoutNewHeight` by startTime (commitTime+timeoutCommit),
or, if SkipTimeoutCommit==true, after receiving all precommits from (height,round-1)
Enter: `timeoutPrecommits` after any +2/3 precommits from (height,round-1) Enter: +2/3 precommits for nil at (height,round-1) Enter: +2/3 prevotes any or +2/3 precommits for block or any from (height, round) Enter: A valid commit came in from a future round NOTE: cs.StartTime was already set for height.
func (*EnterNewRoundAction) Execute ¶
func (c *EnterNewRoundAction) Execute(ctx context.Context, stateEvent StateEvent) error
Execute ...
type EnterNewRoundEvent ¶
EnterNewRoundEvent ...
func (*EnterNewRoundEvent) GetType ¶
func (e *EnterNewRoundEvent) GetType() EventType
GetType returns EnterNewRoundType event-type
type EnterPrecommitAction ¶
type EnterPrecommitAction struct {
// contains filtered or unexported fields
}
EnterPrecommitAction ... Enter: `timeoutPrevote` after any +2/3 prevotes. Enter: `timeoutPrecommit` after any +2/3 precommits. Enter: +2/3 precomits for block or nil. Lock & precommit the ProposalBlock if we have enough prevotes for it (a POL in this round) else, precommit nil otherwise.
func (*EnterPrecommitAction) Execute ¶
func (c *EnterPrecommitAction) Execute(ctx context.Context, stateEvent StateEvent) error
Execute ... Enter: `timeoutPrevote` after any +2/3 prevotes. Enter: `timeoutPrecommit` after any +2/3 precommits. Enter: +2/3 precomits for block or nil. Lock & precommit the ProposalBlock if we have enough prevotes for it (a POL in this round) else, precommit nil otherwise.
type EnterPrecommitEvent ¶
func (*EnterPrecommitEvent) GetType ¶
func (e *EnterPrecommitEvent) GetType() EventType
GetType returns EnterPrecommitType event-type
type EnterPrecommitWaitAction ¶
type EnterPrecommitWaitAction struct {
// contains filtered or unexported fields
}
EnterPrecommitWaitAction ... Enter: any +2/3 precommits for next round.
func (*EnterPrecommitWaitAction) Execute ¶
func (c *EnterPrecommitWaitAction) Execute(_ context.Context, stateEvent StateEvent) error
Execute ... Enter: any +2/3 precommits for next round.
type EnterPrecommitWaitEvent ¶
func (*EnterPrecommitWaitEvent) GetType ¶
func (e *EnterPrecommitWaitEvent) GetType() EventType
GetType returns EnterPrecommitWaitType event-type
type EnterPrevoteAction ¶
type EnterPrevoteAction struct {
// contains filtered or unexported fields
}
EnterPrevoteAction ... Enter: `timeoutPropose` after entering Propose. Enter: proposal block and POL is ready. If we received a valid proposal within this round and we are not locked on a block, we will prevote for block. Otherwise, if we receive a valid proposal that matches the block we are locked on or matches a block that received a POL in a round later than our locked round, prevote for the proposal, otherwise vote nil.
func (*EnterPrevoteAction) Execute ¶
func (c *EnterPrevoteAction) Execute(ctx context.Context, statEvent StateEvent) error
Execute ...
type EnterPrevoteEvent ¶
func (*EnterPrevoteEvent) GetType ¶
func (e *EnterPrevoteEvent) GetType() EventType
GetType returns EnterPrevoteType event-type
type EnterPrevoteWaitAction ¶
type EnterPrevoteWaitAction struct {
// contains filtered or unexported fields
}
EnterPrevoteWaitAction ... Enter: any +2/3 prevotes at next round.
func (*EnterPrevoteWaitAction) Execute ¶
func (c *EnterPrevoteWaitAction) Execute(_ context.Context, stateEvent StateEvent) error
Execute ... Enter: any +2/3 prevotes at next round.
type EnterPrevoteWaitEvent ¶
func (*EnterPrevoteWaitEvent) GetType ¶
func (e *EnterPrevoteWaitEvent) GetType() EventType
GetType ...
type EnterProposeAction ¶
type EnterProposeAction struct {
// contains filtered or unexported fields
}
EnterProposeAction ... Enter (CreateEmptyBlocks): from enterNewRound(height,round) Enter (CreateEmptyBlocks, CreateEmptyBlocksInterval > 0 ): after enterNewRound(height,round), after timeout of CreateEmptyBlocksInterval Enter (!CreateEmptyBlocks) : after enterNewRound(height,round), once txs are in the mempool Caller should hold cs.mtx lock
func (*EnterProposeAction) Execute ¶
func (c *EnterProposeAction) Execute(ctx context.Context, stateEvent StateEvent) error
type EnterProposeEvent ¶
func (*EnterProposeEvent) GetType ¶
func (e *EnterProposeEvent) GetType() EventType
GetType returns EnterProposeType event-type
type EventPublisher ¶
type EventPublisher struct {
// contains filtered or unexported fields
}
EventPublisher is event message sender to event-bus and event-switch this component provides some methods for sending events event-bus is used to interact internally and between the modules event-switch is mostly used in tests
func (*EventPublisher) PublishCommitEvent ¶
func (p *EventPublisher) PublishCommitEvent(commit *types.Commit) error
PublishCommitEvent ...
func (*EventPublisher) PublishCompleteProposalEvent ¶
func (p *EventPublisher) PublishCompleteProposalEvent(event types.EventDataCompleteProposal)
func (*EventPublisher) PublishLockEvent ¶
func (p *EventPublisher) PublishLockEvent(rs cstypes.RoundState)
PublishLockEvent ...
func (*EventPublisher) PublishNewRoundEvent ¶
func (p *EventPublisher) PublishNewRoundEvent(event types.EventDataNewRound)
func (*EventPublisher) PublishNewRoundStepEvent ¶
func (p *EventPublisher) PublishNewRoundStepEvent(rs cstypes.RoundState)
func (*EventPublisher) PublishPolkaEvent ¶
func (p *EventPublisher) PublishPolkaEvent(rs cstypes.RoundState)
PublishPolkaEvent ...
func (*EventPublisher) PublishRelockEvent ¶
func (p *EventPublisher) PublishRelockEvent(rs cstypes.RoundState)
PublishRelockEvent ...
func (*EventPublisher) PublishValidBlockEvent ¶
func (p *EventPublisher) PublishValidBlockEvent(rs cstypes.RoundState)
PublishValidBlockEvent ...
func (*EventPublisher) PublishVoteEvent ¶
func (p *EventPublisher) PublishVoteEvent(vote *types.Vote) error
type EventType ¶
type EventType int
EventType is an integer representation of a transition event
const ( EnterNewRoundType EventType = iota EnterProposeType EnterPrevoteType EnterPrecommitType EnterCommitType TryAddCommitType AddCommitType TryFinalizeCommitType ApplyCommitType AddProposalBlockPartType ProposalCompletedType EnterPrevoteWaitType EnterPrecommitWaitType AddVoteType )
All possible event types
type Gossiper ¶
type Gossiper interface { GossipProposal(ctx context.Context, rs cstypes.RoundState, prs *cstypes.PeerRoundState) GossipProposalBlockParts(ctx context.Context, rs cstypes.RoundState, prs *cstypes.PeerRoundState) GossipBlockPartsForCatchup(ctx context.Context, rs cstypes.RoundState, prs *cstypes.PeerRoundState) GossipVote(ctx context.Context, rs cstypes.RoundState, prs *cstypes.PeerRoundState) GossipVoteSetMaj23(ctx context.Context, rs cstypes.RoundState, prs *cstypes.PeerRoundState) GossipCommit(ctx context.Context, rs cstypes.RoundState, prs *cstypes.PeerRoundState) }
Gossiper is the interface that wraps the methods needed to gossip a state between connected peers
type Handshaker ¶
type Handshaker struct {
// contains filtered or unexported fields
}
func NewHandshaker ¶
func NewHandshaker( blockReplayer *BlockReplayer, logger log.Logger, state sm.State, ) *Handshaker
func (*Handshaker) Handshake ¶
func (h *Handshaker) Handshake(ctx context.Context, appClient abciclient.Client) (uint64, error)
TODO: retry the handshake/replay if it fails ?
func (*Handshaker) NBlocks ¶
func (h *Handshaker) NBlocks() int
NBlocks returns the number of blocks applied to the state.
type HasCommitMessage ¶
HasCommitMessage is sent to indicate that a particular commit has been received.
func (*HasCommitMessage) String ¶
func (m *HasCommitMessage) String() string
String returns a string representation.
func (*HasCommitMessage) TypeTag ¶
func (*HasCommitMessage) TypeTag() string
func (*HasCommitMessage) ValidateBasic ¶
func (m *HasCommitMessage) ValidateBasic() error
ValidateBasic performs basic validation.
type HasVoteMessage ¶
type HasVoteMessage struct { Height int64 `json:",string"` Round int32 Type tmproto.SignedMsgType Index int32 }
HasVoteMessage is sent to indicate that a particular vote has been received.
func (*HasVoteMessage) String ¶
func (m *HasVoteMessage) String() string
String returns a string representation.
func (*HasVoteMessage) TypeTag ¶
func (*HasVoteMessage) TypeTag() string
func (*HasVoteMessage) ValidateBasic ¶
func (m *HasVoteMessage) ValidateBasic() error
ValidateBasic performs basic validation.
type Message ¶
Message defines an interface that the consensus domain types implement. When a proto message is received on a consensus p2p Channel, it is wrapped and then converted to a Message via MsgFromProtoMsg.
type Metrics ¶
type Metrics struct { // Height of the chain. Height metrics.Gauge // Last height signed by this validator if the node is a validator. ValidatorLastSignedHeight metrics.Gauge `metrics_labels:"validator_address"` // Number of rounds. Rounds metrics.Gauge // Histogram of round duration. RoundDuration metrics.Histogram `metrics_buckettype:"exprange" metrics_bucketsizes:"0.1, 100, 8"` // Number of validators. Validators metrics.Gauge // Total power of all validators. ValidatorsPower metrics.Gauge // Power of a validator. ValidatorPower metrics.Gauge `metrics_labels:"validator_address"` // Amount of blocks missed per validator. ValidatorMissedBlocks metrics.Gauge `metrics_labels:"validator_address"` // Number of validators who did not sign. MissingValidators metrics.Gauge // Total power of the missing validators. MissingValidatorsPower metrics.Gauge // Number of validators who tried to double sign. ByzantineValidators metrics.Gauge // Total power of the byzantine validators. ByzantineValidatorsPower metrics.Gauge // Time between this and the last block. BlockIntervalSeconds metrics.Histogram // Number of transactions. NumTxs metrics.Gauge // Size of the block. BlockSizeBytes metrics.Histogram // Total number of transactions. TotalTxs metrics.Gauge // The latest block height. CommittedHeight metrics.Gauge `metrics_name:"latest_block_height"` // Whether or not a node is block syncing. 1 if yes, 0 if no. BlockSyncing metrics.Gauge // Whether or not a node is state syncing. 1 if yes, 0 if no. StateSyncing metrics.Gauge // Number of block parts transmitted by each peer. BlockParts metrics.Counter `metrics_labels:"peer_id"` // Histogram of durations for each step in the consensus protocol. StepDuration metrics.Histogram `metrics_labels:"step" metrics_buckettype:"exprange" metrics_bucketsizes:"0.1, 100, 8"` // Histogram of time taken to receive a block in seconds, measured between when a new block is first // discovered to when the block is completed. BlockGossipReceiveLatency metrics.Histogram `metrics_buckettype:"exprange" metrics_bucketsizes:"0.1, 100, 8"` // Number of block parts received by the node, separated by whether the part // was relevant to the block the node is trying to gather or not. BlockGossipPartsReceived metrics.Counter `metrics_labels:"matches_current"` // QuroumPrevoteMessageDelay is the interval in seconds between the proposal // timestamp and the timestamp of the earliest prevote that achieved a quorum // during the prevote step. // // To compute it, sum the voting power over each prevote received, in increasing // order of timestamp. The timestamp of the first prevote to increase the sum to // be above 2/3 of the total voting power of the network defines the endpoint // the endpoint of the interval. Subtract the proposal timestamp from this endpoint // to obtain the quorum delay. //metrics:Interval in seconds between the proposal timestamp and the timestamp of the earliest prevote that achieved a quorum. QuorumPrevoteDelay metrics.Gauge `metrics_labels:"proposer_address"` // FullPrevoteDelay is the interval in seconds between the proposal // timestamp and the timestamp of the latest prevote in a round where 100% // of the voting power on the network issued prevotes. //metrics:Interval in seconds between the proposal timestamp and the timestamp of the latest prevote in a round where all validators voted. FullPrevoteDelay metrics.Gauge `metrics_labels:"proposer_address"` // ProposalTimestampDifference is the difference between the timestamp in // the proposal message and the local time of the validator at the time // that the validator received the message. //metrics:Difference between the timestamp in the proposal message and the local time of the validator at the time it received the message. ProposalTimestampDifference metrics.Histogram `metrics_labels:"is_timely" metrics_bucketsizes:"-10, -.5, -.025, 0, .1, .5, 1, 1.5, 2, 10"` // VoteExtensionReceiveCount is the number of vote extensions received by this // node. The metric is annotated by the status of the vote extension from the // application, either 'accepted' or 'rejected'. //metrics:Number of vote extensions received labeled by application response status. VoteExtensionReceiveCount metrics.Counter `metrics_labels:"status"` // ProposalReceiveCount is the total number of proposals received by this node // since process start. // The metric is annotated by the status of the proposal from the application, // either 'accepted' or 'rejected'. //metrics:Total number of proposals received by the node since process start labeled by application response status. ProposalReceiveCount metrics.Counter `metrics_labels:"status"` // ProposalCreationCount is the total number of proposals created by this node // since process start. //metrics:Total number of proposals created by the node since process start. ProposalCreateCount metrics.Counter // RoundVotingPowerPercent is the percentage of the total voting power received // with a round. The value begins at 0 for each round and approaches 1.0 as // additional voting power is observed. The metric is labeled by vote type. //metrics:A value between 0 and 1.0 representing the percentage of the total voting power per vote type received within a round. RoundVotingPowerPercent metrics.Gauge `metrics_labels:"vote_type"` // LateVotes stores the number of votes that were received by this node that // correspond to earlier heights and rounds than this node is currently // in. //metrics:Number of votes received by the node since process start that correspond to earlier heights and rounds than this node is currently in. LateVotes metrics.Counter `metrics_labels:"vote_type"` // contains filtered or unexported fields }
Metrics contains metrics exposed by this package.
func NopMetrics ¶
func NopMetrics() *Metrics
func PrometheusMetrics ¶
func (*Metrics) MarkBlockGossipComplete ¶
func (m *Metrics) MarkBlockGossipComplete()
func (*Metrics) MarkBlockGossipStarted ¶
func (m *Metrics) MarkBlockGossipStarted()
func (*Metrics) MarkLateVote ¶
func (m *Metrics) MarkLateVote(vt tmproto.SignedMsgType)
func (*Metrics) MarkProposalProcessed ¶
func (*Metrics) MarkStep ¶
func (m *Metrics) MarkStep(s cstypes.RoundStepType)
func (*Metrics) MarkVoteExtensionReceived ¶
func (*Metrics) MarkVoteReceived ¶
func (m *Metrics) MarkVoteReceived(vt tmproto.SignedMsgType, power, totalPower int64)
func (*Metrics) RecordConsMetrics ¶
RecordConsMetrics uses for recording the block related metrics during fast-sync.
type NewRoundStepMessage ¶
type NewRoundStepMessage struct { Height int64 `json:",string"` Round int32 Step cstypes.RoundStepType SecondsSinceStartTime int64 `json:",string"` LastCommitRound int32 }
NewRoundStepMessage is sent for every step taken in the ConsensusState. For every height/round/step transition
func (*NewRoundStepMessage) String ¶
func (m *NewRoundStepMessage) String() string
String returns a string representation.
func (*NewRoundStepMessage) TypeTag ¶
func (*NewRoundStepMessage) TypeTag() string
func (*NewRoundStepMessage) ValidateBasic ¶
func (m *NewRoundStepMessage) ValidateBasic() error
ValidateBasic performs basic validation.
func (*NewRoundStepMessage) ValidateHeight ¶
func (m *NewRoundStepMessage) ValidateHeight(initialHeight int64) error
ValidateHeight validates the height given the chain's initial height.
type NewValidBlockMessage ¶
type NewValidBlockMessage struct { Height int64 `json:",string"` Round int32 BlockPartSetHeader types.PartSetHeader BlockParts *bits.BitArray IsCommit bool }
NewValidBlockMessage is sent when a validator observes a valid block B in some round r, i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r. In case the block is also committed, then IsCommit flag is set to true.
func (*NewValidBlockMessage) String ¶
func (m *NewValidBlockMessage) String() string
String returns a string representation.
func (*NewValidBlockMessage) TypeTag ¶
func (*NewValidBlockMessage) TypeTag() string
func (*NewValidBlockMessage) ValidateBasic ¶
func (m *NewValidBlockMessage) ValidateBasic() error
ValidateBasic performs basic validation.
type PeerState ¶
type PeerState struct { PRS cstypes.PeerRoundState `json:"round_state"` Stats *peerStateStats `json:"stats"` // ProTxHash is accessible only for the validator ProTxHash types.ProTxHash // contains filtered or unexported fields }
PeerState contains the known state of a peer, including its connection and threadsafe access to its PeerRoundState. NOTE: THIS GETS DUMPED WITH rpc/core/consensus.go. Be mindful of what you Expose.
func NewPeerState ¶
NewPeerState returns a new PeerState for the given node ID.
func (*PeerState) ApplyHasCommitMessage ¶
func (ps *PeerState) ApplyHasCommitMessage(msg *HasCommitMessage)
ApplyHasCommitMessage updates the peer state for the new commit.
func (*PeerState) ApplyHasVoteMessage ¶
func (ps *PeerState) ApplyHasVoteMessage(msg *HasVoteMessage) error
ApplyHasVoteMessage updates the peer state for the new vote.
func (*PeerState) ApplyNewRoundStepMessage ¶
func (ps *PeerState) ApplyNewRoundStepMessage(msg *NewRoundStepMessage)
ApplyNewRoundStepMessage updates the peer state for the new round.
func (*PeerState) ApplyNewValidBlockMessage ¶
func (ps *PeerState) ApplyNewValidBlockMessage(msg *NewValidBlockMessage)
ApplyNewValidBlockMessage updates the peer state for the new valid block.
func (*PeerState) ApplyProposalPOLMessage ¶
func (ps *PeerState) ApplyProposalPOLMessage(msg *ProposalPOLMessage)
ApplyProposalPOLMessage updates the peer state for the new proposal POL.
func (*PeerState) ApplyVoteSetBitsMessage ¶
func (ps *PeerState) ApplyVoteSetBitsMessage(msg *VoteSetBitsMessage, ourVotes *bits.BitArray)
ApplyVoteSetBitsMessage updates the peer state for the bit-array of votes it claims to have for the corresponding BlockID. `ourVotes` is a BitArray of votes we have for msg.BlockID NOTE: if ourVotes is nil (e.g. msg.Height < rs.Height), we conservatively overwrite ps's votes w/ msg.Votes.
func (*PeerState) BlockPartsSent ¶
BlockPartsSent returns the number of useful block parts the peer has sent us.
func (*PeerState) CommitsSent ¶
CommitsSent safely returns a last value of a commit counter
func (*PeerState) EnsureVoteBitArrays ¶
EnsureVoteBitArrays ensures the bit-arrays have been allocated for tracking what votes this peer has received. NOTE: It's important to make sure that numValidators actually matches what the node sees as the number of validators for height.
func (*PeerState) GetHeight ¶
GetHeight returns an atomic snapshot of the PeerRoundState's height used by the mempool to ensure peers are caught up before broadcasting new txs.
func (*PeerState) GetProTxHash ¶
GetProTxHash returns a copy of peer's pro-tx-hash
func (*PeerState) GetRoundState ¶
func (ps *PeerState) GetRoundState() *cstypes.PeerRoundState
GetRoundState returns a shallow copy of the PeerRoundState. There's no point in mutating it since it won't change PeerState.
func (*PeerState) InitProposalBlockParts ¶
func (ps *PeerState) InitProposalBlockParts(partSetHeader types.PartSetHeader)
InitProposalBlockParts initializes the peer's proposal block parts header and bit array.
func (*PeerState) IsRunning ¶
IsRunning returns true if a PeerState is considered running where multiple broadcasting goroutines exist for the peer.
func (*PeerState) MarshalZerologObject ¶
MarshalZerologObject formats this object for logging purposes
func (*PeerState) PickVoteToSend ¶
PickVoteToSend picks a vote to send to the peer. It will return true if a vote was picked.
NOTE: `votes` must be the correct Size() for the Height().
func (*PeerState) RecordBlockPart ¶
RecordBlockPart increments internal block part related statistics for this peer. It returns the total number of added block parts.
func (*PeerState) RecordCommit ¶
RecordCommit safely increments the commit counter and returns the new value
func (*PeerState) RecordVote ¶
RecordVote increments internal votes related statistics for this peer. It returns the total number of added votes.
func (*PeerState) SetHasCommit ¶
SetHasCommit sets the given vote as known by the peer
func (*PeerState) SetHasProposal ¶
SetHasProposal sets the given proposal as known for the peer.
func (*PeerState) SetHasProposalBlockPart ¶
SetHasProposalBlockPart sets the given block part index as known for the peer.
func (*PeerState) SetHasVote ¶
SetHasVote sets the given vote as known by the peer
func (*PeerState) SetProTxHash ¶
func (*PeerState) SetRunning ¶
SetRunning sets the running state of the peer.
func (*PeerState) StringIndented ¶
StringIndented returns a string representation of the PeerState
func (*PeerState) UpdateProposalBlockParts ¶
UpdateProposalBlockParts updates peer-round-state with proposal block parts
func (*PeerState) UpdateRoundState ¶
func (ps *PeerState) UpdateRoundState(fn func(prs *cstypes.PeerRoundState))
UpdateRoundState ensures that the update function is called using the blocking mechanism
type ProposalCompletedAction ¶
type ProposalCompletedAction struct {
// contains filtered or unexported fields
}
func (*ProposalCompletedAction) Execute ¶
func (c *ProposalCompletedAction) Execute(ctx context.Context, stateEvent StateEvent) error
type ProposalCompletedEvent ¶
func (*ProposalCompletedEvent) GetType ¶
func (e *ProposalCompletedEvent) GetType() EventType
GetType ...
type ProposalMessage ¶
ProposalMessage is sent when a new block is proposed.
func (*ProposalMessage) String ¶
func (m *ProposalMessage) String() string
String returns a string representation.
func (*ProposalMessage) TypeTag ¶
func (*ProposalMessage) TypeTag() string
func (*ProposalMessage) ValidateBasic ¶
func (m *ProposalMessage) ValidateBasic() error
ValidateBasic performs basic validation.
type ProposalPOLMessage ¶
type ProposalPOLMessage struct { Height int64 `json:",string"` ProposalPOLRound int32 ProposalPOL *bits.BitArray }
ProposalPOLMessage is sent when a previous proposal is re-proposed.
func (*ProposalPOLMessage) String ¶
func (m *ProposalPOLMessage) String() string
String returns a string representation.
func (*ProposalPOLMessage) TypeTag ¶
func (*ProposalPOLMessage) TypeTag() string
func (*ProposalPOLMessage) ValidateBasic ¶
func (m *ProposalPOLMessage) ValidateBasic() error
ValidateBasic performs basic validation.
type Proposaler ¶
type Proposaler struct {
// contains filtered or unexported fields
}
Proposaler is used to set and create a proposal This structure must implement internal/consensus/types/Proposaler interface
func NewProposaler ¶
func NewProposaler( logger log.Logger, metrics *Metrics, privVal privValidator, queue *msgInfoQueue, blockExec *blockExecutor, ) *Proposaler
NewProposaler creates and returns a new Proposaler
func (*Proposaler) Create ¶
func (p *Proposaler) Create(ctx context.Context, height int64, round int32, rs *cstypes.RoundState) error
Create creates, sings and sends a created proposal to the queue
To create a proposal is used RoundState.ValidBlock if it isn't nil and valid, otherwise create a new one
func (*Proposaler) Set ¶
func (p *Proposaler) Set(proposal *types.Proposal, receivedAt time.Time, rs *cstypes.RoundState) error
Set updates Proposal, ProposalReceiveTime and ProposalBlockParts in RoundState if the passed proposal met conditions
func (*Proposaler) Subscribe ¶
func (p *Proposaler) Subscribe(emitter *eventemitter.EventEmitter)
type Reactor ¶
type Reactor struct { service.BaseService Metrics *Metrics // contains filtered or unexported fields }
Reactor defines a reactor for the consensus service.
func NewReactor ¶
func NewReactor( logger log.Logger, cs *State, channelCreator p2p.ChannelCreator, peerEvents p2p.PeerEventSubscriber, eventBus *eventbus.EventBus, waitSync bool, metrics *Metrics, ) *Reactor
NewReactor returns a reference to a new consensus reactor, which implements the service.Service interface. It accepts a logger, consensus state, references to relevant p2p Channels and a channel to listen for peer updates on. The reactor will close all p2p Channels when stopping.
func (*Reactor) GetConsensusState ¶
func (*Reactor) GetPeerState ¶
GetPeerState returns PeerState for a given NodeID.
func (*Reactor) OnStart ¶
OnStart starts separate go routines for each p2p Channel and listens for envelopes on each. In addition, it also listens for peer updates and handles messages on that p2p channel accordingly. The caller must be sure to execute OnStop to ensure the outbound p2p Channels are closed.
func (*Reactor) OnStop ¶
func (r *Reactor) OnStop()
OnStop stops the reactor by signaling to all spawned goroutines to exit and blocking until they all exit, as well as unsubscribing from events and stopping state.
func (*Reactor) SetBlockSyncingMetrics ¶
func (*Reactor) SetStateSyncingMetrics ¶
func (*Reactor) String ¶
String returns a string representation of the Reactor.
NOTE: For now, it is just a hard-coded string to avoid accessing unprotected shared variables.
TODO: improve!
func (*Reactor) SwitchToConsensus ¶
SwitchToConsensus switches from block-sync mode to consensus mode. It resets the state, turns off block-sync, and starts the consensus state-machine.
type State ¶
type State struct { service.BaseService // contains filtered or unexported fields }
State handles execution of the consensus algorithm. It processes votes and proposals, and upon reaching agreement, commits blocks to the chain and executes them against the application. The internal state machine receives input from peers, the internal validator, and from a timer.
func NewState ¶
func NewState( logger log.Logger, cfg *config.ConsensusConfig, store sm.Store, blockExec *sm.BlockExecutor, blockStore sm.BlockStore, txNotifier txNotifier, evpool evidencePool, eventBus *eventbus.EventBus, options ...StateOption, ) (*State, error)
NewState returns a new State.
func (*State) AddProposalBlockPart ¶
func (cs *State) AddProposalBlockPart(ctx context.Context, height int64, round int32, part *types.Part, peerID types.NodeID) error
AddProposalBlockPart inputs a part of the proposal block.
func (*State) CreateProposalBlock ¶
CreateProposalBlock safely creates a proposal block. Only used in tests.
func (*State) GetRoundState ¶
func (cs *State) GetRoundState() cstypes.RoundState
GetRoundState returns a shallow copy of the internal consensus state.
func (*State) GetRoundStateJSON ¶
GetRoundStateJSON returns a json of RoundState.
func (*State) GetRoundStateSimpleJSON ¶
GetRoundStateSimpleJSON returns a json of RoundStateSimple
func (*State) GetStateData ¶
func (*State) GetValidatorSet ¶
func (cs *State) GetValidatorSet() (int64, *types.ValidatorSet)
GetValidatorSet returns a copy of the current validator set.
func (*State) GetValidators ¶
GetValidators returns a copy of the current validators.
func (*State) OnStart ¶
OnStart loads the latest state via the WAL, and starts the timeout and receive routines.
func (*State) OpenWAL ¶
OpenWAL opens a file to log all consensus messages and timeouts for deterministic accountability.
func (*State) PrivValidator ¶
func (cs *State) PrivValidator() types.PrivValidator
PrivValidator returns safely a PrivValidator
func (*State) PublishCommitEvent ¶
PublishCommitEvent ...
func (*State) ReplayFile ¶
Replay msgs in file or start the console
func (*State) SetPrivValidator ¶
func (cs *State) SetPrivValidator(ctx context.Context, priv types.PrivValidator)
SetPrivValidator sets the private validator account for signing votes. It immediately requests pubkey and caches it.
func (*State) SetProposal ¶
func (cs *State) SetProposal(ctx context.Context, proposal *types.Proposal, peerID types.NodeID) error
SetProposal inputs a proposal.
func (*State) SetProposalAndBlock ¶
func (cs *State) SetProposalAndBlock( ctx context.Context, proposal *types.Proposal, parts *types.PartSet, peerID types.NodeID, ) error
SetProposalAndBlock inputs the proposal and all block parts.
func (*State) SetProposedAppVersion ¶
type StateData ¶
type StateData struct { cstypes.RoundState // contains filtered or unexported fields }
StateData is a copy of the current RoundState nad state.State stored in the store Along with data, StateData provides some methods to check or update data inside
func (*StateData) HeightVoteSet ¶
func (s *StateData) HeightVoteSet() (int64, *cstypes.HeightVoteSet)
func (*StateData) InitialHeight ¶
InitialHeight returns an initial height
type StateDataStore ¶
type StateDataStore struct {
// contains filtered or unexported fields
}
StateDataStore is a state-data store
func NewStateDataStore ¶
func NewStateDataStore( metrics *Metrics, logger log.Logger, cfg *config.ConsensusConfig, emitter *eventemitter.EventEmitter, ) *StateDataStore
NewStateDataStore creates and returns a new state-data store
func (*StateDataStore) Subscribe ¶
func (s *StateDataStore) Subscribe(evsw *eventemitter.EventEmitter)
func (*StateDataStore) Update ¶
func (s *StateDataStore) Update(candidate StateData) error
Update updates state-data with candidate
func (*StateDataStore) UpdateAndGet ¶
func (s *StateDataStore) UpdateAndGet(candidate StateData) (StateData, error)
UpdateAndGet updates state-data with a candidate and returns updated state-data
func (*StateDataStore) UpdateReplayMode ¶
func (s *StateDataStore) UpdateReplayMode(flag bool)
UpdateReplayMode safe updates replay-mode flag
type StateEvent ¶
type StateEvent struct { Ctrl *Controller EventType EventType StateData *StateData Data ActionEvent }
StateEvent uses to execute an action handler EventType and StateData are required for a call Data is optional
type StateOption ¶
type StateOption func(*State)
StateOption sets an optional parameter on the State.
type TimedWALMessage ¶
type TimedWALMessage struct { Time time.Time `json:"time"` Msg WALMessage `json:"msg"` }
TimedWALMessage wraps WALMessage and adds Time for debugging purposes.
type TimeoutTicker ¶
type TimeoutTicker interface { Start(context.Context) error Stop() IsRunning() bool Chan() <-chan timeoutInfo // on which to receive a timeout ScheduleTimeout(ti timeoutInfo) // reset the timer }
TimeoutTicker is a timer that schedules timeouts conditional on the height/round/step in the timeoutInfo. The timeoutInfo.Duration may be non-positive.
func NewTimeoutTicker ¶
func NewTimeoutTicker(logger log.Logger) TimeoutTicker
NewTimeoutTicker returns a new TimeoutTicker.
type TryAddCommitAction ¶
type TryAddCommitAction struct {
// contains filtered or unexported fields
}
TryAddCommitAction ... If we received a commit message from an external source try to add it then finalize it.
func (*TryAddCommitAction) Execute ¶
func (cs *TryAddCommitAction) Execute(ctx context.Context, stateEvent StateEvent) error
Execute ...
type TryAddCommitEvent ¶
func (*TryAddCommitEvent) GetType ¶
func (e *TryAddCommitEvent) GetType() EventType
GetType returns TryAddCommitType event-type
type TryFinalizeCommitAction ¶
type TryFinalizeCommitAction struct {
// contains filtered or unexported fields
}
TryFinalizeCommitAction ... If we have the block AND +2/3 commits for it, finalize.
func (*TryFinalizeCommitAction) Execute ¶
func (cs *TryFinalizeCommitAction) Execute(ctx context.Context, stateEvent StateEvent) error
Execute ...
type TryFinalizeCommitEvent ¶
type TryFinalizeCommitEvent struct {
Height int64
}
func (*TryFinalizeCommitEvent) GetType ¶
func (e *TryFinalizeCommitEvent) GetType() EventType
GetType returns TryFinalizeCommitType event-type
type VoteMessage ¶
VoteMessage is sent when voting for a proposal (or lack thereof).
func (*VoteMessage) String ¶
func (m *VoteMessage) String() string
String returns a string representation.
func (*VoteMessage) TypeTag ¶
func (*VoteMessage) TypeTag() string
func (*VoteMessage) ValidateBasic ¶
func (m *VoteMessage) ValidateBasic() error
ValidateBasic checks whether the vote within the message is well-formed.
type VoteSetBitsMessage ¶
type VoteSetBitsMessage struct { Height int64 `json:",string"` Round int32 Type tmproto.SignedMsgType BlockID types.BlockID Votes *bits.BitArray }
VoteSetBitsMessage is sent to communicate the bit-array of votes seen for the BlockID.
func (*VoteSetBitsMessage) String ¶
func (m *VoteSetBitsMessage) String() string
String returns a string representation.
func (*VoteSetBitsMessage) TypeTag ¶
func (*VoteSetBitsMessage) TypeTag() string
func (*VoteSetBitsMessage) ValidateBasic ¶
func (m *VoteSetBitsMessage) ValidateBasic() error
ValidateBasic performs basic validation.
type VoteSetMaj23Message ¶
type VoteSetMaj23Message struct { Height int64 `json:",string"` Round int32 Type tmproto.SignedMsgType BlockID types.BlockID }
VoteSetMaj23Message is sent to indicate that a given BlockID has seen +2/3 votes.
func (*VoteSetMaj23Message) String ¶
func (m *VoteSetMaj23Message) String() string
String returns a string representation.
func (*VoteSetMaj23Message) TypeTag ¶
func (*VoteSetMaj23Message) TypeTag() string
func (*VoteSetMaj23Message) ValidateBasic ¶
func (m *VoteSetMaj23Message) ValidateBasic() error
ValidateBasic performs basic validation.
type WAL ¶
type WAL interface { WALWriteFlusher WALSearcher // service methods Start(context.Context) error Stop() Wait() }
WAL is an interface for any write-ahead logger.
type WALDecoder ¶
type WALDecoder struct {
// contains filtered or unexported fields
}
A WALDecoder reads and decodes custom-encoded WAL messages from an input stream. See WALEncoder for the format used.
It will also compare the checksums and make sure data size is equal to the length from the header. If that is not the case, error will be returned.
func NewWALDecoder ¶
func NewWALDecoder(rd io.Reader) *WALDecoder
NewWALDecoder returns a new decoder that reads from rd.
func (*WALDecoder) Decode ¶
func (dec *WALDecoder) Decode() (*TimedWALMessage, error)
Decode reads the next custom-encoded value from its reader and returns it.
type WALEncoder ¶
type WALEncoder struct {
// contains filtered or unexported fields
}
A WALEncoder writes custom-encoded WAL messages to an output stream.
Format: 4 bytes CRC sum + 4 bytes length + arbitrary-length value
func NewWALEncoder ¶
func NewWALEncoder(wr io.Writer) *WALEncoder
NewWALEncoder returns a new encoder that writes to wr.
func (*WALEncoder) Encode ¶
func (enc *WALEncoder) Encode(v *TimedWALMessage) error
Encode writes the custom encoding of v to the stream. It returns an error if the encoded size of v is greater than 1MB. Any error encountered during the write is also returned.
type WALFlusher ¶
type WALFlusher interface {
FlushAndSync() error
}
type WALMessage ¶
type WALMessage interface{}
func WALFromProto ¶
func WALFromProto(msg *tmcons.WALMessage) (WALMessage, error)
WALFromProto takes a proto wal message and return a consensus walMessage and error.
type WALSearchOptions ¶
type WALSearchOptions struct { // IgnoreDataCorruptionErrors set to true will result in skipping data corruption errors. IgnoreDataCorruptionErrors bool }
WALSearchOptions are optional arguments to SearchForEndHeight.
type WALSearcher ¶
type WALSearcher interface {
SearchForEndHeight(height int64, options *WALSearchOptions) (rd io.ReadCloser, found bool, err error)
}
type WALWriteFlusher ¶
type WALWriteFlusher interface { WALWriter WALFlusher WriteSync(WALMessage) error }
type WALWriter ¶
type WALWriter interface {
Write(WALMessage) error
}
Source Files ¶
- block_executor.go
- context.go
- event_publisher.go
- gossip_handlers.go
- gossip_msg_sender.go
- gossip_peer_worker.go
- gossiper.go
- metrics.gen.go
- metrics.go
- msg_handlers.go
- msg_queue.go
- msgs.go
- peer_state.go
- proposal_updater.go
- reactor.go
- replay.go
- replay_file.go
- replay_stubs.go
- replayer.go
- round_scheduler.go
- state.go
- state_add_commit.go
- state_add_prop_block.go
- state_add_vote.go
- state_apply_commit.go
- state_controller.go
- state_data.go
- state_enter_commit.go
- state_enter_new_round.go
- state_enter_precommit.go
- state_enter_prevote.go
- state_enter_propose.go
- state_enter_wait.go
- state_prevoter.go
- state_proposaler.go
- state_try_add_commit.go
- state_try_finalize_commit.go
- ticker.go
- vote_signer.go
- wal.go
- wal_iter.go