epochmgr

package
v0.32.9 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: AGPL-3.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

View Source
const DefaultStartupTimeout = time.Minute

DefaultStartupTimeout is the default time we wait when starting epoch components before giving up.

Variables

View Source
var ErrNotAuthorizedForEpoch = fmt.Errorf("we are not an authorized participant for the epoch")

ErrNotAuthorizedForEpoch is returned when we attempt to create epoch components for an epoch in which we are not an authorized network participant. This is the case for epochs during which this node is joining or leaving the network.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	events.Noop // satisfy protocol events consumer interface

	component.Component
	// contains filtered or unexported fields
}

Engine is the epoch manager, which coordinates the lifecycle of other modules and processes that are epoch-dependent. The manager is responsible for spinning up engines when a new epoch is about to start and spinning down engines for an epoch that has ended.

The `epochmgr.Engine` implements the `protocol.Consumer` interface. In particular, it ingests the following notifications from the protocol state:

  • EpochSetupPhaseStarted
  • EpochTransition

As part of the engine starting, it executes pending actions that should have been triggered by protocol events but those events were missed during a crash/restart. See respective consumer methods for further details.

func New

func New(
	log zerolog.Logger,
	me module.Local,
	state protocol.State,
	pools *epochpool.TransactionPools,
	voter module.ClusterRootQCVoter,
	factory EpochComponentsFactory,
	heightEvents events.Heights,
	clusterIDUpdateDistributor collection.ClusterEvents,
) (*Engine, error)

func (*Engine) Done

func (e *Engine) Done() <-chan struct{}

Done returns a done channel that is closed once the engine has fully stopped. This is true when the engine-scoped worker threads have stopped, and all presently running epoch components (max 2) have stopped.

func (*Engine) EpochSetupPhaseStarted

func (e *Engine) EpochSetupPhaseStarted(_ uint64, first *flow.Header)

EpochSetupPhaseStarted handles the epoch setup phase started protocol event. NOTE: Ready will check if we start up in the EpochSetup phase at initialization and trigger QC voting. This handles dropped protocol events and restarts interrupting QC voting.

func (*Engine) EpochTransition

func (e *Engine) EpochTransition(_ uint64, first *flow.Header)

EpochTransition handles the epoch transition protocol event. NOTE: epochmgr.Engine will not restart trailing cluster consensus instances from previous epoch, therefore no need to handle dropped protocol events here (see issue below). TODO gracefully handle restarts in first 600 blocks of epoch https://github.com/dapperlabs/flow-go/issues/5659

func (*Engine) Ready

func (e *Engine) Ready() <-chan struct{}

Ready returns a ready channel that is closed once the engine has fully started. This is true when the engine-scoped worker threads have started, and all presently running epoch components (max 2) have started.

func (*Engine) Start added in v0.29.0

func (e *Engine) Start(ctx irrecoverable.SignalerContext)

Start starts the engine.

type EpochComponents

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

EpochComponents represents all dependencies for running an epoch.

func NewEpochComponents added in v0.23.9

func NewEpochComponents(
	state cluster.State,
	comp component.Component,
	sync module.ReadyDoneAware,
	hotstuff module.HotStuff,
	voteAggregator hotstuff.VoteAggregator,
	timeoutAggregator hotstuff.TimeoutAggregator,
	messageHub component.Component,
) *EpochComponents

type EpochComponentsFactory

type EpochComponentsFactory interface {

	// Create sets up and instantiates all dependencies for the epoch. It may
	// be used either for an ongoing epoch (for example, after a restart) or
	// for an epoch that will start soon. It is safe to call multiple times for
	// a given epoch counter.
	//
	// Must return ErrNotAuthorizedForEpoch if this node is not authorized in the epoch.
	Create(epoch protocol.Epoch) (
		state cluster.State,
		proposal component.Component,
		sync module.ReadyDoneAware,
		hotstuff module.HotStuff,
		voteAggregator hotstuff.VoteAggregator,
		timeoutAggregator hotstuff.TimeoutAggregator,
		messageHub component.Component,
		err error,
	)
}

EpochComponentsFactory is responsible for creating epoch-scoped components managed by the epoch manager engine for the given epoch.

type RunningEpochComponents added in v0.29.0

type RunningEpochComponents struct {
	*EpochComponents
	// contains filtered or unexported fields
}

RunningEpochComponents contains all consensus-related components for an epoch and the cancel function to stop these components. All components must have been started when the RunningEpochComponents is constructed.

func NewRunningEpochComponents added in v0.29.0

func NewRunningEpochComponents(components *EpochComponents, cancel context.CancelFunc) *RunningEpochComponents

NewRunningEpochComponents returns a new RunningEpochComponents container for the given epoch components. The components must have already been started using some context, which the provided cancel function cancels (stopping the epoch components).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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