pacemaker

package
v0.33.12 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: AGPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithQCs added in v0.30.2

func WithQCs(qcs ...*flow.QuorumCertificate) recoveryInformation

WithQCs informs the PaceMaker about the given QCs. Old and nil QCs are accepted (no-op).

func WithTCs added in v0.30.2

func WithTCs(tcs ...*flow.TimeoutCertificate) recoveryInformation

WithTCs informs the PaceMaker about the given TCs. Old and nil TCs are accepted (no-op).

Types

type ActivePaceMaker added in v0.29.0

type ActivePaceMaker struct {
	hotstuff.ProposalDurationProvider
	// contains filtered or unexported fields
}

ActivePaceMaker implements the hotstuff.PaceMaker Conceptually, we use the Pacemaker algorithm first proposed in [1] (specifically Jolteon) and described in more detail in [2]. [1] https://arxiv.org/abs/2106.10362 [2] https://developers.diem.com/papers/diem-consensus-state-machine-replication-in-the-diem-blockchain/2021-08-17.pdf (aka DiemBFT v4)

To enter a new view `v`, the Pacemaker must observe a valid QC or TC for view `v-1`. The Pacemaker also controls when a node should locally time out for a given view. In contrast to the passive Pacemaker (previous implementation), locally timing a view does not cause a view change. A local timeout for a view `v` causes a node to: * never produce a vote for any proposal with view ≤ `v`, after the timeout * produce and broadcast a timeout object, which can form a part of the TC for the timed out view

Not concurrency safe.

func New

func New(
	timeoutController *timeout.Controller,
	proposalDurationProvider hotstuff.ProposalDurationProvider,
	notifier hotstuff.Consumer,
	persist hotstuff.Persister,
	recovery ...recoveryInformation,
) (*ActivePaceMaker, error)

New creates a new ActivePaceMaker instance

  • startView is the view for the pacemaker to start with.
  • timeoutController controls the timeout trigger.
  • notifier provides callbacks for pacemaker events.

Expected error conditions: * model.ConfigurationError if initial LivenessData is invalid

func (*ActivePaceMaker) CurView added in v0.29.0

func (p *ActivePaceMaker) CurView() uint64

CurView returns the current view

func (*ActivePaceMaker) LastViewTC added in v0.29.0

func (p *ActivePaceMaker) LastViewTC() *flow.TimeoutCertificate

LastViewTC returns TC for last view, this will be nil only if the current view was entered with a QC.

func (*ActivePaceMaker) NewestQC added in v0.29.0

func (p *ActivePaceMaker) NewestQC() *flow.QuorumCertificate

NewestQC returns QC with the highest view discovered by PaceMaker.

func (*ActivePaceMaker) ProcessQC added in v0.29.0

ProcessQC notifies the pacemaker with a new QC, which might allow pacemaker to fast-forward its view. In contrast to `ProcessTC`, this function does _not_ handle `nil` inputs. No errors are expected, any error should be treated as exception

func (*ActivePaceMaker) ProcessTC added in v0.29.0

ProcessTC notifies the Pacemaker of a new timeout certificate, which may allow Pacemaker to fast-forward its current view. A nil TC is an expected valid input, so that callers may pass in e.g. `Proposal.LastViewTC`, which may or may not have a value. No errors are expected, any error should be treated as exception

func (*ActivePaceMaker) Start added in v0.29.0

func (p *ActivePaceMaker) Start(ctx context.Context)

Start starts the pacemaker by starting the initial timer for the current view. Start should only be called once - subsequent calls are a no-op. CAUTION: ActivePaceMaker is not concurrency safe. The Start method must be executed by the same goroutine that also calls the other business logic methods, or concurrency safety has to be implemented externally.

func (*ActivePaceMaker) TimeoutChannel added in v0.29.0

func (p *ActivePaceMaker) TimeoutChannel() <-chan time.Time

TimeoutChannel returns the timeout channel for current active timeout. Note the returned timeout channel returns only one timeout, which is the current timeout. To get the timeout for the next timeout, you need to call TimeoutChannel() again.

type StaticProposalDurationProvider added in v0.31.0

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

StaticProposalDurationProvider is a hotstuff.ProposalDurationProvider which provides a static ProposalDuration. The constant dur represents the time to produce and broadcast the proposal (ProposalDuration), NOT the time for the entire view (ViewDuration).

func NewStaticProposalDurationProvider added in v0.31.0

func NewStaticProposalDurationProvider(dur time.Duration) StaticProposalDurationProvider

func NoProposalDelay added in v0.31.0

func NoProposalDelay() StaticProposalDurationProvider

func (StaticProposalDurationProvider) TargetPublicationTime added in v0.31.0

func (p StaticProposalDurationProvider) TargetPublicationTime(_ uint64, timeViewEntered time.Time, _ flow.Identifier) time.Time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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