Documentation
¶
Overview ¶
Package consensus defines the node-wide consensus provider contract.
Index ¶
Constants ¶
const ( // PraosProviderName is the provider name used by existing networks and // databases. PraosProviderName = "praos" // PraosIdentity versions persisted and network-visible Praos semantics. PraosIdentity = "praos/v1" // TachysProviderName is the built-in CIP-0177 provider. TachysProviderName = "tachys" // TachysIdentity binds network, database, and schedule state to the // supported CIP-0177 semantics. TachysIdentity = "tachys/cip177/" + gconsensus.TachysSpecificationRevision // DatabaseIdentitySyncKey is the sync-state key that binds a database to // the DatabaseIdentity of the provider that created it. It must outlive // any bulk sync-state cleanup: a database that loses it is read as an // unmarked Praos database on the next start. DatabaseIdentitySyncKey = "consensus_provider_identity" )
Variables ¶
This section is empty.
Functions ¶
func NetworkMagic ¶ added in v0.89.0
NetworkMagic derives the node-to-node network identity for a consensus provider while preserving Cardano's magic for Praos interoperability.
func RegisterProvider ¶
RegisterProvider registers the built-in Praos and Tachys providers on host.
Types ¶
type HeaderVerifier ¶
type HeaderVerifier interface {
ValidatePraosHeader(
context.Context,
ledgerpkg.Block,
bool,
bool,
) error
ValidateTachysHeader(
context.Context,
ledgerpkg.Block,
bool,
bool,
) error
}
HeaderVerifier exposes the ledger-owned Praos header checks to a provider. The provider chooses the algorithm; the ledger retains all state access.
type LeaderScheduleKind ¶ added in v0.89.0
type LeaderScheduleKind uint8
LeaderScheduleKind identifies the algorithm used to construct a production schedule. Providers pass it through composition so one selected provider governs both incoming authorization and local forging.
const ( LeaderSchedulePraos LeaderScheduleKind = iota LeaderScheduleTachys )
type LeaderScheduler ¶
type LeaderScheduler interface {
Start(context.Context) error
Stop() error
ConsensusStateRestored()
ShouldProduceBlock(uint64) bool
NextLeaderSlot(uint64) (uint64, bool)
}
LeaderScheduler is the production schedule selected by a Provider.
type LeaderSchedulerFactory ¶
type LeaderSchedulerFactory func( scheduleIdentity string, kind LeaderScheduleKind, ) (LeaderScheduler, error)
LeaderSchedulerFactory lets application composition construct the concrete scheduler chosen by a provider without making the provider contract depend on ledger implementation packages.
type Provider ¶
type Provider interface {
Name() string
NetworkIdentity() string
DatabaseIdentity() string
ScheduleIdentity() string
ValidateHeader(
context.Context,
HeaderVerifier,
ledgerpkg.Block,
bool,
bool,
) error
CompareTips(
ochainsync.Tip,
ochainsync.Tip,
praos.PraosTiebreakerView,
praos.PraosTiebreakerView,
) praos.ChainComparisonResult
NewLeaderScheduler(LeaderSchedulerFactory) (LeaderScheduler, error)
}
Provider makes every consensus decision for one node instance.
func NewPraosProvider ¶
func NewPraosProvider() Provider
NewPraosProvider returns the built-in Praos provider.
func NewTachysProvider ¶ added in v0.89.0
func NewTachysProvider() Provider
NewTachysProvider returns the built-in CIP-0177 provider.
type TachysDistribution ¶ added in v0.89.0
type TachysDistribution struct {
// contains filtered or unexported fields
}
TachysDistribution is an immutable, canonically ordered election snapshot. It carries the whole pool distribution because a local stake fraction is not enough to reproduce a CIP-0177 schedule.
func NewTachysDistribution ¶ added in v0.89.0
func NewTachysDistribution( pools []gconsensus.TachysPool, totalStake uint64, ) (*TachysDistribution, error)
NewTachysDistribution validates and copies a full election distribution.
func (*TachysDistribution) Commitment ¶ added in v0.89.0
func (d *TachysDistribution) Commitment() common.Blake2b256
Commitment returns the full-distribution commitment used by persisted schedules.
func (*TachysDistribution) Pools ¶ added in v0.89.0
func (d *TachysDistribution) Pools() []gconsensus.TachysPool
Pools returns a copy of the canonical pool distribution.
func (*TachysDistribution) Selector ¶ added in v0.89.0
func (d *TachysDistribution) Selector() (*gconsensus.TachysLeaderSelector, error)
Selector returns the shared immutable exact-integer selector for this snapshot.
func (*TachysDistribution) TotalStake ¶ added in v0.89.0
func (d *TachysDistribution) TotalStake() uint64
TotalStake returns the exact sum of the pool distribution.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package peras is the home for Dingo's Ouroboros Peras (CIP-0140) consensus support.
|
Package peras is the home for Dingo's Ouroboros Peras (CIP-0140) consensus support. |
|
Package praos contains pure Praos chain-selection primitives: the select view projected from a Shelley-family block header, VRF output extraction, and the equal-length tiebreaker comparison functions that mirror ouroboros-consensus' PraosTiebreakerView and preferCandidate logic.
|
Package praos contains pure Praos chain-selection primitives: the select view projected from a Shelley-family block header, VRF output extraction, and the equal-length tiebreaker comparison functions that mirror ouroboros-consensus' PraosTiebreakerView and preferCandidate logic. |