voteaggregator

package
v0.31.9-compress-badge... Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: AGPL-3.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NewCollectorFactoryMethod added in v0.23.9

type NewCollectorFactoryMethod = func(view uint64, workers hotstuff.Workers) (hotstuff.VoteCollector, error)

NewCollectorFactoryMethod is a factory method to generate a VoteCollector for concrete view

type PendingStatus

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

PendingStatus keeps track of pending votes for the same block

func NewPendingStatus

func NewPendingStatus() *PendingStatus

NewPendingStatus creates a PendingStatus instance

func (*PendingStatus) AddVote

func (ps *PendingStatus) AddVote(vote *model.Vote) bool

AddVote adds a vote as a pending vote returns false if it has been added before returns true otherwise

type PendingVotes

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

PendingVotes stores all the pending votes for different block proposals

func NewPendingVotes

func NewPendingVotes() *PendingVotes

NewPendingVotes creates a PendingVotes instance

func (*PendingVotes) AddVote

func (pv *PendingVotes) AddVote(vote *model.Vote) bool

AddVote adds a vote as a pending vote returns true if it can be added to a PendingStatus successfully returns false otherwise

type VoteAggregator

type VoteAggregator struct {
	*component.ComponentManager
	// contains filtered or unexported fields
}

VoteAggregator stores the votes and aggregates them into a QC when enough votes have been collected VoteAggregator is designed in a way that it can aggregate votes for collection & consensus clusters that is why implementation relies on dependency injection.

func NewVoteAggregator added in v0.23.9

func NewVoteAggregator(
	log zerolog.Logger,
	hotstuffMetrics module.HotstuffMetrics,
	engineMetrics module.EngineMetrics,
	mempoolMetrics module.MempoolMetrics,
	notifier hotstuff.VoteAggregationViolationConsumer,
	lowestRetainedView uint64,
	collectors hotstuff.VoteCollectors,
) (*VoteAggregator, error)

NewVoteAggregator creates an instance of vote aggregator Note: verifyingProcessorFactory is injected. Thereby, the code is agnostic to the different voting formats of main Consensus vs Collector consensus.

func (*VoteAggregator) AddBlock added in v0.23.9

func (va *VoteAggregator) AddBlock(block *model.Proposal)

AddBlock notifies the VoteAggregator that it should start processing votes for the given block. The input block is queued internally within the `VoteAggregator` and processed _asynchronously_ by the VoteAggregator's internal worker routines. CAUTION: we expect that the input block's validity has been confirmed prior to calling AddBlock, including the proposer's signature. Otherwise, VoteAggregator might crash or exhibit undefined behaviour.

func (*VoteAggregator) AddVote added in v0.23.9

func (va *VoteAggregator) AddVote(vote *model.Vote)

AddVote checks if vote is stale and appends vote into processing queue actual vote processing will be called in other dispatching goroutine.

func (*VoteAggregator) InvalidBlock added in v0.23.9

func (va *VoteAggregator) InvalidBlock(proposal *model.Proposal) error

InvalidBlock notifies the VoteAggregator about an invalid proposal, so that it can process votes for the invalid block and slash the voters. No errors are expected during normal operations

func (*VoteAggregator) OnFinalizedBlock added in v0.25.0

func (va *VoteAggregator) OnFinalizedBlock(block *model.Block)

OnFinalizedBlock implements the `OnFinalizedBlock` callback from the `hotstuff.FinalizationConsumer` It informs sealing.Core about finalization of respective block.

CAUTION: the input to this callback is treated as trusted; precautions should be taken that messages from external nodes cannot be considered as inputs to this function

func (*VoteAggregator) PruneUpToView added in v0.23.9

func (va *VoteAggregator) PruneUpToView(lowestRetainedView uint64)

PruneUpToView deletes all votes _below_ to the given view, as well as related indices. We only retain and process whose view is equal or larger than `lowestRetainedView`. If `lowestRetainedView` is smaller than the previous value, the previous value is kept and the method call is a NoOp.

type VoteCollectors added in v0.23.9

type VoteCollectors struct {
	*component.ComponentManager
	// contains filtered or unexported fields
}

VoteCollectors implements management of multiple vote collectors indexed by view. Implements hotstuff.VoteCollectors interface. Creating a VoteCollector for a particular view is lazy (instances are created on demand). This structure is concurrently safe.

func NewVoteCollectors added in v0.23.9

func NewVoteCollectors(logger zerolog.Logger, lowestRetainedView uint64, workerPool hotstuff.Workerpool, factoryMethod NewCollectorFactoryMethod) *VoteCollectors

func (*VoteCollectors) GetOrCreateCollector added in v0.23.9

func (v *VoteCollectors) GetOrCreateCollector(view uint64) (hotstuff.VoteCollector, bool, error)

GetOrCreateCollector retrieves the hotstuff.VoteCollector for the specified view or creates one if none exists.

  • (collector, true, nil) if no collector can be found by the view, and a new collector was created.
  • (collector, false, nil) if the collector can be found by the view
  • (nil, false, error) if running into any exception creating the vote collector state machine

Expected error returns during normal operations:

  • mempool.BelowPrunedThresholdError - in case view is lower than lowestRetainedView

func (*VoteCollectors) PruneUpToView added in v0.23.9

func (v *VoteCollectors) PruneUpToView(lowestRetainedView uint64)

PruneUpToView prunes the vote collectors with views _below_ the given value, i.e. we only retain and process whose view is equal or larger than `lowestRetainedView`. If `lowestRetainedView` is smaller than the previous value, the previous value is kept and the method call is a NoOp.

Jump to

Keyboard shortcuts

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