types

package
v0.0.0-...-1abf0d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoundStepNewHeight     = RoundStepType(0x01) // Wait til CommitTime + timeoutCommit
	RoundStepNewRound      = RoundStepType(0x02) // Setup new round and go to RoundStepPropose
	RoundStepPropose       = RoundStepType(0x03) // Did propose, gossip proposal
	RoundStepPrevote       = RoundStepType(0x04) // Did prevote, gossip prevotes
	RoundStepPrevoteWait   = RoundStepType(0x05) // Did receive any +2/3 prevotes, start timeout
	RoundStepPrecommit     = RoundStepType(0x06) // Did precommit, gossip precommits
	RoundStepPrecommitWait = RoundStepType(0x07) // Did receive any +2/3 precommits, start timeout
	RoundStepCommit        = RoundStepType(0x08) // Entered commit state machine

)

RoundStepType

Variables

View Source
var (
	ErrGotVoteFromUnwantedRound = errors.New(
		"peer has sent a vote that does not match our round for more than one round",
	)
)

Functions

This section is empty.

Types

type HeightVoteSet

type HeightVoteSet struct {
	// contains filtered or unexported fields
}

Keeps track of all VoteSets from round 0 to round 'round'.

Also keeps track of up to one RoundVoteSet greater than 'round' from each peer, to facilitate catchup syncing of commits.

A commit is +2/3 precommits for a block at a round, but which round is not known in advance, so when a peer provides a precommit for a round greater than mtx.round, we create a new entry in roundVoteSets but also remember the peer to prevent abuse. We let each peer provide us with up to 2 unexpected "catchup" rounds. One for their LastCommit round, and another for the official commit round.

func NewExtendedHeightVoteSet

func NewExtendedHeightVoteSet(chainID string, height int64, valSet *types.ValidatorSet) *HeightVoteSet

func NewHeightVoteSet

func NewHeightVoteSet(chainID string, height int64, valSet *types.ValidatorSet) *HeightVoteSet

func (*HeightVoteSet) AddVote

func (hvs *HeightVoteSet) AddVote(vote *types.Vote, peerID types.NodeID) (added bool, err error)

Duplicate votes return added=false, err=nil. By convention, peerID is "" if origin is self.

func (*HeightVoteSet) Height

func (hvs *HeightVoteSet) Height() int64

func (*HeightVoteSet) MarshalJSON

func (hvs *HeightVoteSet) MarshalJSON() ([]byte, error)

func (*HeightVoteSet) POLInfo

func (hvs *HeightVoteSet) POLInfo() (polRound int32, polBlockID types.BlockID)

Last round and blockID that has +2/3 prevotes for a particular block or nil. Returns -1 if no such round exists.

func (*HeightVoteSet) Precommits

func (hvs *HeightVoteSet) Precommits(round int32) *types.VoteSet

func (*HeightVoteSet) Prevotes

func (hvs *HeightVoteSet) Prevotes(round int32) *types.VoteSet

func (*HeightVoteSet) Reset

func (hvs *HeightVoteSet) Reset(height int64, valSet *types.ValidatorSet)

func (*HeightVoteSet) Round

func (hvs *HeightVoteSet) Round() int32

func (*HeightVoteSet) SetPeerMaj23

func (hvs *HeightVoteSet) SetPeerMaj23(
	round int32,
	voteType tmproto.SignedMsgType,
	peerID types.NodeID,
	blockID types.BlockID) error

If a peer claims that it has 2/3 majority for given blockKey, call this. NOTE: if there are too many peers, or too much peer churn, this can cause memory issues. TODO: implement ability to remove peers too

func (*HeightVoteSet) SetRound

func (hvs *HeightVoteSet) SetRound(round int32)

Create more RoundVoteSets up to round.

func (*HeightVoteSet) String

func (hvs *HeightVoteSet) String() string

func (*HeightVoteSet) StringIndented

func (hvs *HeightVoteSet) StringIndented(indent string) string

type PeerRoundState

type PeerRoundState struct {
	Height int64         `json:"height,string"` // Height peer is at
	Round  int32         `json:"round"`         // Round peer is at, -1 if unknown.
	Step   RoundStepType `json:"step"`          // Step peer is at

	// Estimated start of round 0 at this height
	StartTime time.Time `json:"start_time"`

	// True if peer has proposal for this round
	Proposal                   bool                `json:"proposal"`
	ProposalBlockPartSetHeader types.PartSetHeader `json:"proposal_block_part_set_header"`
	ProposalBlockParts         *bits.BitArray      `json:"proposal_block_parts"`
	// Proposal's POL round. -1 if none.
	ProposalPOLRound int32 `json:"proposal_pol_round"`

	// nil until ProposalPOLMessage received.
	ProposalPOL     *bits.BitArray `json:"proposal_pol"`
	Prevotes        *bits.BitArray `json:"prevotes"`          // All votes peer has for this round
	Precommits      *bits.BitArray `json:"precommits"`        // All precommits peer has for this round
	LastCommitRound int32          `json:"last_commit_round"` // Round of commit for last height. -1 if none.
	LastCommit      *bits.BitArray `json:"last_commit"`       // All commit precommits of commit for last height.

	// Round that we have commit for. Not necessarily unique. -1 if none.
	CatchupCommitRound int32 `json:"catchup_commit_round"`

	// All commit precommits peer has for this height & CatchupCommitRound
	CatchupCommit *bits.BitArray `json:"catchup_commit"`
}

PeerRoundState contains the known state of a peer. NOTE: Read-only when returned by PeerState.GetRoundState().

func (PeerRoundState) Copy

func (prs PeerRoundState) Copy() PeerRoundState

Copy provides a deep copy operation. Because many of the fields in the PeerRound struct are pointers, we need an explicit deep copy operation to avoid a non-obvious shared data situation.

func (PeerRoundState) String

func (prs PeerRoundState) String() string

String returns a string representation of the PeerRoundState

func (PeerRoundState) StringIndented

func (prs PeerRoundState) StringIndented(indent string) string

StringIndented returns a string representation of the PeerRoundState

type RoundState

type RoundState struct {
	Height    int64         `json:"height,string"` // Height we are working on
	Round     int32         `json:"round"`
	Step      RoundStepType `json:"step"`
	StartTime time.Time     `json:"start_time"`

	// Subjective time when +2/3 precommits for Block at Round were found
	CommitTime          time.Time           `json:"commit_time"`
	Validators          *types.ValidatorSet `json:"validators"`
	Proposal            *types.Proposal     `json:"proposal"`
	ProposalReceiveTime time.Time           `json:"proposal_receive_time"`
	ProposalBlock       *types.Block        `json:"proposal_block"`
	ProposalBlockParts  *types.PartSet      `json:"proposal_block_parts"`
	LockedRound         int32               `json:"locked_round"`
	LockedBlock         *types.Block        `json:"locked_block"`
	LockedBlockParts    *types.PartSet      `json:"locked_block_parts"`

	// Last known round with POL for non-nil valid block.
	ValidRound int32        `json:"valid_round"`
	ValidBlock *types.Block `json:"valid_block"` // Last known block of POL mentioned above.

	// Last known block parts of POL mentioned above.
	ValidBlockParts           *types.PartSet      `json:"valid_block_parts"`
	Votes                     *HeightVoteSet      `json:"votes"`
	CommitRound               int32               `json:"commit_round"` //
	LastCommit                *types.VoteSet      `json:"last_commit"`  // Last precommits at Height-1
	LastValidators            *types.ValidatorSet `json:"last_validators"`
	TriggeredTimeoutPrecommit bool                `json:"triggered_timeout_precommit"`
}

RoundState defines the internal consensus state. NOTE: Not thread safe. Should only be manipulated by functions downstream of the cs.receiveRoutine

func (*RoundState) CompleteProposalEvent

func (rs *RoundState) CompleteProposalEvent() types.EventDataCompleteProposal

CompleteProposalEvent returns information about a proposed block as an event.

func (*RoundState) NewRoundEvent

func (rs *RoundState) NewRoundEvent() types.EventDataNewRound

NewRoundEvent returns the RoundState with proposer information as an event.

func (*RoundState) RoundStateEvent

func (rs *RoundState) RoundStateEvent() types.EventDataRoundState

RoundStateEvent returns the H/R/S of the RoundState as an event.

func (*RoundState) RoundStateSimple

func (rs *RoundState) RoundStateSimple() RoundStateSimple

Compress the RoundState to RoundStateSimple

func (*RoundState) String

func (rs *RoundState) String() string

String returns a string

func (*RoundState) StringIndented

func (rs *RoundState) StringIndented(indent string) string

StringIndented returns a string

func (*RoundState) StringShort

func (rs *RoundState) StringShort() string

StringShort returns a string

type RoundStateSimple

type RoundStateSimple struct {
	HeightRoundStep   string              `json:"height/round/step"`
	StartTime         time.Time           `json:"start_time"`
	ProposalBlockHash bytes.HexBytes      `json:"proposal_block_hash"`
	LockedBlockHash   bytes.HexBytes      `json:"locked_block_hash"`
	ValidBlockHash    bytes.HexBytes      `json:"valid_block_hash"`
	Votes             json.RawMessage     `json:"height_vote_set"`
	Proposer          types.ValidatorInfo `json:"proposer"`
}

Compressed version of the RoundState for use in RPC

type RoundStepType

type RoundStepType uint8 // These must be numeric, ordered.

RoundStepType enumerates the state of the consensus state machine

func (RoundStepType) IsValid

func (rs RoundStepType) IsValid() bool

IsValid returns true if the step is valid, false if unknown/undefined.

func (RoundStepType) String

func (rs RoundStepType) String() string

String returns a string

type RoundVoteSet

type RoundVoteSet struct {
	Prevotes   *types.VoteSet
	Precommits *types.VoteSet
}

type SafeRoundState

type SafeRoundState struct {
	// contains filtered or unexported fields
}

func (*SafeRoundState) CommitRound

func (s *SafeRoundState) CommitRound() int32

func (*SafeRoundState) CommitTime

func (s *SafeRoundState) CommitTime() time.Time

func (*SafeRoundState) CompleteProposalEvent

func (s *SafeRoundState) CompleteProposalEvent() types.EventDataCompleteProposal

func (*SafeRoundState) CopyInternal

func (s *SafeRoundState) CopyInternal() *RoundState

func (*SafeRoundState) GetInternalPointer

func (s *SafeRoundState) GetInternalPointer() *RoundState

func (*SafeRoundState) Height

func (s *SafeRoundState) Height() int64

func (*SafeRoundState) LastCommit

func (s *SafeRoundState) LastCommit() *types.VoteSet

func (*SafeRoundState) LastValidators

func (s *SafeRoundState) LastValidators() *types.ValidatorSet

func (*SafeRoundState) LockedBlock

func (s *SafeRoundState) LockedBlock() *types.Block

func (*SafeRoundState) LockedBlockParts

func (s *SafeRoundState) LockedBlockParts() *types.PartSet

func (*SafeRoundState) LockedRound

func (s *SafeRoundState) LockedRound() int32

func (*SafeRoundState) NewRoundEvent

func (s *SafeRoundState) NewRoundEvent() types.EventDataNewRound

func (*SafeRoundState) Proposal

func (s *SafeRoundState) Proposal() *types.Proposal

func (*SafeRoundState) ProposalBlock

func (s *SafeRoundState) ProposalBlock() *types.Block

func (*SafeRoundState) ProposalBlockParts

func (s *SafeRoundState) ProposalBlockParts() *types.PartSet

func (*SafeRoundState) ProposalReceiveTime

func (s *SafeRoundState) ProposalReceiveTime() time.Time

func (*SafeRoundState) Round

func (s *SafeRoundState) Round() int32

func (*SafeRoundState) RoundStateEvent

func (s *SafeRoundState) RoundStateEvent() types.EventDataRoundState

func (*SafeRoundState) SetCommitRound

func (s *SafeRoundState) SetCommitRound(r int32)

func (*SafeRoundState) SetCommitTime

func (s *SafeRoundState) SetCommitTime(t time.Time)

func (*SafeRoundState) SetHeight

func (s *SafeRoundState) SetHeight(h int64)

func (*SafeRoundState) SetLastCommit

func (s *SafeRoundState) SetLastCommit(c *types.VoteSet)

func (*SafeRoundState) SetLastValidators

func (s *SafeRoundState) SetLastValidators(p *types.ValidatorSet)

func (*SafeRoundState) SetLockedBlock

func (s *SafeRoundState) SetLockedBlock(p *types.Block)

func (*SafeRoundState) SetLockedBlockParts

func (s *SafeRoundState) SetLockedBlockParts(p *types.PartSet)

func (*SafeRoundState) SetLockedRound

func (s *SafeRoundState) SetLockedRound(p int32)

func (*SafeRoundState) SetProposal

func (s *SafeRoundState) SetProposal(p *types.Proposal)

func (*SafeRoundState) SetProposalBlock

func (s *SafeRoundState) SetProposalBlock(p *types.Block)

func (*SafeRoundState) SetProposalBlockParts

func (s *SafeRoundState) SetProposalBlockParts(p *types.PartSet)

func (*SafeRoundState) SetProposalReceiveTime

func (s *SafeRoundState) SetProposalReceiveTime(p time.Time)

func (*SafeRoundState) SetRound

func (s *SafeRoundState) SetRound(r int32)

func (*SafeRoundState) SetStartTime

func (s *SafeRoundState) SetStartTime(t time.Time)

func (*SafeRoundState) SetStep

func (s *SafeRoundState) SetStep(t RoundStepType)

func (*SafeRoundState) SetTriggeredTimeoutPrecommit

func (s *SafeRoundState) SetTriggeredTimeoutPrecommit(p bool)

func (*SafeRoundState) SetValidBlock

func (s *SafeRoundState) SetValidBlock(p *types.Block)

func (*SafeRoundState) SetValidBlockParts

func (s *SafeRoundState) SetValidBlockParts(p *types.PartSet)

func (*SafeRoundState) SetValidRound

func (s *SafeRoundState) SetValidRound(p int32)

func (*SafeRoundState) SetValidators

func (s *SafeRoundState) SetValidators(v *types.ValidatorSet)

func (*SafeRoundState) SetVotes

func (s *SafeRoundState) SetVotes(v *HeightVoteSet)

func (*SafeRoundState) StartTime

func (s *SafeRoundState) StartTime() time.Time

func (*SafeRoundState) Step

func (s *SafeRoundState) Step() RoundStepType

func (*SafeRoundState) TriggeredTimeoutPrecommit

func (s *SafeRoundState) TriggeredTimeoutPrecommit() bool

func (*SafeRoundState) ValidBlock

func (s *SafeRoundState) ValidBlock() *types.Block

func (*SafeRoundState) ValidBlockParts

func (s *SafeRoundState) ValidBlockParts() *types.PartSet

func (*SafeRoundState) ValidRound

func (s *SafeRoundState) ValidRound() int32

func (*SafeRoundState) Validators

func (s *SafeRoundState) Validators() *types.ValidatorSet

func (*SafeRoundState) Votes

func (s *SafeRoundState) Votes() *HeightVoteSet

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL