Documentation ¶
Index ¶
- Variables
- type BlockContainer
- type BlockQC
- type Forks
- func (f *Forks) AddProposal(proposal *model.Proposal) error
- func (f *Forks) FinalizedBlock() *model.Block
- func (f *Forks) FinalizedView() uint64
- func (f *Forks) GetProposal(blockID flow.Identifier) (*model.Proposal, bool)
- func (f *Forks) GetProposalsForView(view uint64) []*model.Proposal
- func (f *Forks) IsKnownBlock(block *model.Block) bool
- func (f *Forks) IsProcessingNeeded(block *model.Block) bool
- func (f *Forks) NewestView() uint64
- func (f *Forks) UnverifiedAddProposal(proposal *model.Proposal) error
- func (f *Forks) VerifyProposal(proposal *model.Proposal) error
Constants ¶
This section is empty.
Variables ¶
var ErrPrunedAncestry = errors.New("cannot resolve pruned ancestor")
ErrPrunedAncestry is a sentinel error: cannot resolve ancestry of block due to pruning
Functions ¶
This section is empty.
Types ¶
type BlockContainer ¶ added in v0.29.0
BlockContainer wraps a block proposal to implement forest.Vertex so the proposal can be stored in forest.LevelledForest
func (*BlockContainer) Level ¶ added in v0.29.0
func (b *BlockContainer) Level() uint64
func (*BlockContainer) Parent ¶ added in v0.29.0
func (b *BlockContainer) Parent() (flow.Identifier, uint64)
func (*BlockContainer) VertexID ¶ added in v0.29.0
func (b *BlockContainer) VertexID() flow.Identifier
type BlockQC ¶
type BlockQC struct { Block *model.Block QC *flow.QuorumCertificate }
BlockQC is a Block with a QC that pointing to it, meaning a Quorum Certified Block. This implies Block.View == QC.View && Block.BlockID == QC.BlockID
type Forks ¶
type Forks struct {
// contains filtered or unexported fields
}
Forks enforces structural validity of the consensus state and implements finalization rules as defined in Jolteon consensus https://arxiv.org/abs/2106.10362 The same approach has later been adopted by the Diem team resulting in DiemBFT v4: https://developers.diem.com/papers/diem-consensus-state-machine-replication-in-the-diem-blockchain/2021-08-17.pdf Forks is NOT safe for concurrent use by multiple goroutines.
func (*Forks) AddProposal ¶ added in v0.29.0
AddProposal adds proposal to the consensus state. Performs verification to make sure that we don't add invalid proposals into consensus state. We assume that all blocks are fully verified. A valid block must satisfy all consistency requirements; otherwise we have a bug in the compliance layer. Expected errors during normal operations:
- model.ByzantineThresholdExceededError - new block results in conflicting finalized blocks
func (*Forks) FinalizedBlock ¶
func (*Forks) FinalizedView ¶
func (*Forks) GetProposal ¶ added in v0.29.0
GetProposal returns block for given ID
func (*Forks) GetProposalsForView ¶ added in v0.29.0
GetProposalsForView returns all known proposals for the given view
func (*Forks) IsKnownBlock ¶ added in v0.29.0
IsKnownBlock checks whether block is known. UNVALIDATED: expects block to pass Forks.VerifyProposal(block)
func (*Forks) IsProcessingNeeded ¶ added in v0.29.0
IsProcessingNeeded performs basic checks to determine whether block needs processing, only considering the block's height and hash. Returns false if any of the following conditions applies
- block view is _below_ the most recently finalized block
- the block already exists in the consensus state
UNVALIDATED: expects block to pass Forks.VerifyProposal(block)
func (*Forks) NewestView ¶ added in v0.29.0
func (*Forks) UnverifiedAddProposal ¶ added in v0.29.0
UnverifiedAddProposal adds `proposal` to the consensus state and updates the latest finalized block, if possible. Calling this method with previously-processed blocks leaves the consensus state invariant (though, it will potentially cause some duplicate processing). UNVALIDATED: expects block to pass Forks.VerifyProposal(block) Error returns: * model.ByzantineThresholdExceededError if proposal's QC conflicts with an existing QC. * generic error in case of unexpected bug or internal state corruption
func (*Forks) VerifyProposal ¶ added in v0.29.0
VerifyProposal checks a block for internal consistency and consistency with the current forest state. See forest.VerifyVertex for more detail. We assume that all blocks are fully verified. A valid block must satisfy all consistency requirements; otherwise we have a bug in the compliance layer. Error returns:
- model.MissingBlockError if the parent of the input proposal does not exist in the forest (but is above the pruned view)
- generic error in case of unexpected bug or internal state corruption