forks

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: AGPL-3.0 Imports: 8 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

type BlockContainer struct {
	Proposal *model.Proposal
}

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 New

func New(trustedRoot *BlockQC, finalizationCallback module.Finalizer, notifier hotstuff.FinalizationConsumer) (*Forks, error)

func (*Forks) AddProposal added in v0.29.0

func (f *Forks) AddProposal(proposal *model.Proposal) error

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 (f *Forks) FinalizedBlock() *model.Block

func (*Forks) FinalizedView

func (f *Forks) FinalizedView() uint64

func (*Forks) GetProposal added in v0.29.0

func (f *Forks) GetProposal(blockID flow.Identifier) (*model.Proposal, bool)

GetProposal returns block for given ID

func (*Forks) GetProposalsForView added in v0.29.0

func (f *Forks) GetProposalsForView(view uint64) []*model.Proposal

GetProposalsForView returns all known proposals for the given view

func (*Forks) IsKnownBlock added in v0.29.0

func (f *Forks) IsKnownBlock(block *model.Block) bool

IsKnownBlock checks whether block is known. UNVALIDATED: expects block to pass Forks.VerifyProposal(block)

func (*Forks) IsProcessingNeeded added in v0.29.0

func (f *Forks) IsProcessingNeeded(block *model.Block) bool

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 (f *Forks) NewestView() uint64

func (*Forks) UnverifiedAddProposal added in v0.29.0

func (f *Forks) UnverifiedAddProposal(proposal *model.Proposal) error

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

func (f *Forks) VerifyProposal(proposal *model.Proposal) error

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

Jump to

Keyboard shortcuts

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