mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-21 18:37:26 +08:00
* wip: conversion of hotstuff from flow into Q-oriented model * bulk of tests * remaining non-integration tests * add integration test, adjust log interface, small tweaks * further adjustments, restore full pacemaker shape * add component lifecycle management+supervisor * further refinements * resolve timeout hanging * mostly finalized state for consensus * bulk of engine swap out * lifecycle-ify most types * wiring nearly complete, missing needed hooks for proposals * plugged in, vetting message validation paths * global consensus, plugged in and verified * app shard now wired in too * do not decode empty keys.yml (#456) * remove obsolete engine.maxFrames config parameter (#454) * default to Info log level unless debug is enabled (#453) * respect config's "logging" section params, remove obsolete single-file logging (#452) * Trivial code cleanup aiming to reduce Go compiler warnings (#451) * simplify range traversal * simplify channel read for single select case * delete rand.Seed() deprecated in Go 1.20 and no-op as of Go 1.24 * simplify range traversal * simplify channel read for single select case * remove redundant type from array * simplify range traversal * simplify channel read for single select case * RC slate * finalize 2.1.0.5 * Update comments in StrictMonotonicCounter Fix comment formatting and clarify description. --------- Co-authored-by: Black Swan <3999712+blacks1ne@users.noreply.github.com>
66 lines
2.5 KiB
Go
66 lines
2.5 KiB
Go
package consensus
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"source.quilibrium.com/quilibrium/monorepo/consensus/models"
|
|
)
|
|
|
|
// Pacemaker defines a standard set of methods for handling pacemaker behaviors
|
|
// in the consensus engine.
|
|
type Pacemaker interface {
|
|
ProposalDurationProvider
|
|
// CurrentRank returns the current rank
|
|
CurrentRank() uint64
|
|
// LatestQuorumCertificate returns the latest quorum certificate seen.
|
|
LatestQuorumCertificate() models.QuorumCertificate
|
|
// PriorRankTimeoutCertificate returns the prior rank's timeout certificate,
|
|
// if it exists.
|
|
PriorRankTimeoutCertificate() models.TimeoutCertificate
|
|
// ReceiveQuorumCertificate handles an incoming quorum certificate, advancing
|
|
// to a new rank if applicable.
|
|
ReceiveQuorumCertificate(
|
|
quorumCertificate models.QuorumCertificate,
|
|
) (*models.NextRank, error)
|
|
// ReceiveTimeoutCertificate handles an incoming timeout certificate,
|
|
// advancing to a new rank if applicable.
|
|
ReceiveTimeoutCertificate(
|
|
timeoutCertificate models.TimeoutCertificate,
|
|
) (*models.NextRank, error)
|
|
// TimeoutCh provides a channel for timing out on the current rank.
|
|
TimeoutCh() <-chan time.Time
|
|
// Start starts the pacemaker, takes a cancellable context.
|
|
Start(ctx context.Context)
|
|
}
|
|
|
|
// ProposalDurationProvider generates the target publication time for state
|
|
// proposals.
|
|
type ProposalDurationProvider interface {
|
|
|
|
// TargetPublicationTime is intended to be called by the EventHandler,
|
|
// whenever it wants to publish a new proposal. The event handler inputs
|
|
// - proposalRank: the rank it is proposing for,
|
|
// - timeRankEntered: the time when the EventHandler entered this rank
|
|
// - parentStateId: the ID of the parent state, which the EventHandler is
|
|
// building on
|
|
// TargetPublicationTime returns the time stamp when the new proposal should
|
|
// be broadcasted. For a given rank where we are the primary, suppose the
|
|
// actual time we are done building our proposal is P:
|
|
// - if P < TargetPublicationTime(..), then the EventHandler should wait
|
|
// until `TargetPublicationTime` to broadcast the proposal
|
|
// - if P >= TargetPublicationTime(..), then the EventHandler should
|
|
// immediately broadcast the proposal
|
|
//
|
|
// Note: Technically, our metrics capture the publication delay relative to
|
|
// this function's _latest_ call. Currently, the EventHandler is the only
|
|
// caller of this function, and only calls it once.
|
|
//
|
|
// Concurrency safe.
|
|
TargetPublicationTime(
|
|
proposalRank uint64,
|
|
timeRankEntered time.Time,
|
|
parentStateId models.Identity,
|
|
) time.Time
|
|
}
|