dkg

package
v0.37.16 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: AGPL-3.0 Imports: 24 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultPollStep = 10

DefaultPollStep specifies the default number of views that separate two calls to the DKG smart-contract to read broadcast messages.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessagingEngine

type MessagingEngine struct {
	component.Component
	// contains filtered or unexported fields
}

MessagingEngine is an engine which sends and receives all DKG private messages. The same engine instance is used for the lifetime of a node and will be used for different DKG instances. The ReactorEngine is responsible for the lifecycle of components which are scoped one DKG instance, for example the DKGController. The dkg.BrokerTunnel handles routing messages to/from the current DKG instance.

func NewMessagingEngine

func NewMessagingEngine(
	log zerolog.Logger,
	net network.EngineRegistry,
	me module.Local,
	tunnel *dkg.BrokerTunnel,
	collector module.MempoolMetrics,
	config MessagingEngineConfig,
) (*MessagingEngine, error)

NewMessagingEngine returns a new MessagingEngine.

func (*MessagingEngine) Process

func (e *MessagingEngine) Process(channel channels.Channel, originID flow.Identifier, message any) error

Process processes messages from the networking layer. No errors are expected during normal operation.

type MessagingEngineConfig added in v0.31.0

type MessagingEngineConfig struct {
	// RetryMax is the maximum number of times the engine will attempt to send
	// an outbound message before permanently giving up.
	RetryMax uint64
	// RetryBaseWait is the duration to wait between the two first send attempts.
	RetryBaseWait time.Duration
	// RetryJitterPercent is the percent jitter to add to each inter-retry wait.
	RetryJitterPercent uint64
}

MessagingEngineConfig configures outbound message submission.

func DefaultMessagingEngineConfig added in v0.31.0

func DefaultMessagingEngineConfig() MessagingEngineConfig

DefaultMessagingEngineConfig returns the config defaults. With 9 attempts and exponential backoff, this will retry for about 8m before giving up.

type ReactorEngine

type ReactorEngine struct {
	events.Noop

	State protocol.State
	// contains filtered or unexported fields
}

ReactorEngine is an engine that reacts to chain events to start new DKG runs, and manage subsequent phase transitions. Any unexpected error triggers a panic as it would undermine the security of the protocol. TODO replace engine.Unit with component.Component

func NewReactorEngine

func NewReactorEngine(
	log zerolog.Logger,
	me module.Local,
	state protocol.State,
	dkgState storage.DKGState,
	controllerFactory module.DKGControllerFactory,
	viewEvents events.Views,
) *ReactorEngine

NewReactorEngine return a new ReactorEngine.

func (*ReactorEngine) Done

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

Done implements the module ReadyDoneAware interface. It returns a channel that will close when the engine has successfully stopped.

func (*ReactorEngine) EpochCommittedPhaseStarted

func (e *ReactorEngine) EpochCommittedPhaseStarted(currentEpochCounter uint64, first *flow.Header)

EpochCommittedPhaseStarted handles the EpochCommittedPhaseStarted protocol event by checking the consistency of our locally computed key share. NOTE: ReactorEngine will not recover from mid-DKG crashes, therefore we do not need to handle dropped protocol events here.

func (*ReactorEngine) EpochSetupPhaseStarted

func (e *ReactorEngine) EpochSetupPhaseStarted(currentEpochCounter uint64, first *flow.Header)

EpochSetupPhaseStarted handles the EpochSetupPhaseStarted protocol event by starting the DKG process. NOTE: ReactorEngine will not recover from mid-DKG crashes, therefore we do not need to handle dropped protocol events here.

func (*ReactorEngine) Ready

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

Ready implements the module ReadyDoneAware interface. It returns a channel that will close when the engine has successfully started.

Jump to

Keyboard shortcuts

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