follower

package
v0.30.3-fix-read-leaf-... Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: AGPL-3.0 Imports: 24 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertifiedBlocks added in v0.30.0

type CertifiedBlocks []flow.CertifiedBlock

CertifiedBlocks is a connected list of certified blocks, in ascending height order.

type ComplianceCore added in v0.30.0

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

ComplianceCore implements main processing logic for follower engine. Generally is NOT concurrency safe but some functions can be used in concurrent setup.

func NewComplianceCore added in v0.30.0

func NewComplianceCore(log zerolog.Logger,
	mempoolMetrics module.MempoolMetrics,
	heroCacheCollector module.HeroCacheMetrics,
	finalizationConsumer hotstuff.FinalizationConsumer,
	state protocol.FollowerState,
	follower module.HotStuffFollower,
	validator hotstuff.Validator,
	sync module.BlockRequester,
	tracer module.Tracer,
) (*ComplianceCore, error)

NewComplianceCore creates new instance of ComplianceCore. No errors expected during normal operations.

func (*ComplianceCore) OnBlockRange added in v0.30.0

func (c *ComplianceCore) OnBlockRange(originID flow.Identifier, batch []*flow.Block) error

OnBlockRange processes a range of connected blocks. It validates the incoming batch, adds it to cache of pending blocks and schedules certified blocks for further processing. The input list must be sequentially ordered forming a chain, i.e. connectedRange[i] is the parent of connectedRange[i+1]. Submitting a disconnected batch results in an `ErrDisconnectedBatch` error and the batch is dropped (no-op). This method is safe to use in concurrent environment. Caution: method might block if internally too many certified blocks are queued in the channel `certifiedRangesChan`. Expected errors during normal operations:

  • cache.ErrDisconnectedBatch

func (*ComplianceCore) OnFinalizedBlock added in v0.30.0

func (c *ComplianceCore) OnFinalizedBlock(final *flow.Header)

OnFinalizedBlock updates local state of pendingCache tree using received finalized block and queues finalized block to be processed by internal goroutine. This function is safe to use in concurrent environment. CAUTION: this function blocks and hence is not compliant with the `FinalizationConsumer.OnFinalizedBlock` interface.

type ComplianceEngine added in v0.30.0

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

ComplianceEngine is the highest level structure that consumes events from other components. It's an entry point to the follower engine which follows and maintains the local copy of the protocol state. It is a passive (read-only) version of the compliance engine. The compliance engine is employed by consensus nodes (active consensus participants) where the Follower engine is employed by all other node roles. ComplianceEngine is responsible for:

  1. Consuming events from external sources such as sync engine.
  2. Splitting incoming batches in batches of connected blocks.
  3. Providing worker goroutines for concurrent processing of batches of connected blocks.
  4. Handling of finalization events.

See interface `complianceCore` (this package) for detailed documentation of the algorithm. Implements consensus.Compliance interface.

func NewComplianceLayer added in v0.30.0

func NewComplianceLayer(
	log zerolog.Logger,
	net network.Network,
	me module.Local,
	engMetrics module.EngineMetrics,
	headers storage.Headers,
	finalized *flow.Header,
	core complianceCore,
	opts ...EngineOption,
) (*ComplianceEngine, error)

NewComplianceLayer instantiates th compliance layer for the consensus follower. See interface `complianceCore` (this package) for detailed documentation of the algorithm.

func (*ComplianceEngine) OnBlockProposal added in v0.30.0

func (e *ComplianceEngine) OnBlockProposal(proposal flow.Slashable[*messages.BlockProposal])

OnBlockProposal queues *untrusted* proposals for further processing and notifies the Engine's internal workers. This method is intended for fresh proposals received directly from leaders. It can ingest synced blocks as well, but is less performant compared to method `OnSyncedBlocks`.

func (*ComplianceEngine) OnFinalizedBlock added in v0.30.0

func (e *ComplianceEngine) OnFinalizedBlock(block *model.Block)

OnFinalizedBlock informs the compliance layer about finalization of a new block. It does not block and asynchronously executes the internal pruning logic. We accept inputs out of order, and only act on inputs with strictly monotonously increasing views.

Implements the `OnFinalizedBlock` callback from the `hotstuff.FinalizationConsumer` 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 (*ComplianceEngine) OnSyncedBlocks added in v0.30.0

func (e *ComplianceEngine) OnSyncedBlocks(blocks flow.Slashable[[]*messages.BlockProposal])

OnSyncedBlocks is an optimized consumer for *untrusted* synced blocks. It is specifically efficient for batches of continuously connected blocks (honest nodes supply finalized blocks in suitable sequences where possible). Nevertheless, the method tolerates blocks in arbitrary order (less efficient), making it robust against byzantine nodes.

func (*ComplianceEngine) Process added in v0.30.0

func (e *ComplianceEngine) Process(channel channels.Channel, originID flow.Identifier, message interface{}) error

Process processes the given event from the node with the given origin ID in a blocking manner. It returns the potential processing error when done. This method is intended to be used as a callback by the networking layer, notifying us about fresh proposals directly from the consensus leaders.

type EngineOption added in v0.30.0

type EngineOption func(*ComplianceEngine)

func WithChannel added in v0.27.0

func WithChannel(channel channels.Channel) EngineOption

WithChannel sets the channel the follower engine will use to receive blocks.

func WithComplianceConfigOpt added in v0.30.0

func WithComplianceConfigOpt(opt compliance.Opt) EngineOption

WithComplianceConfigOpt applies compliance config opt to internal config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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