ouroboros-consensus-diffusion-0.18.0.0: Integration for the Ouroboros Network layer
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Consensus.Node.GSM

Description

The Genesis State Machine decides whether the node is caught-up or not.

Synopsis

Documentation

data CandidateVersusSelection Source #

Constructors

CandidateDoesNotIntersect

The GSM assumes that this is ephemeral

For example, the ChainSync client will either disconnect from the peer or update the candidate to one that is not stale. It's also technically possible that the selection is stale, which the ChainDB would also resolve as soon as possible.

WhetherCandidateIsBetter !Bool

Whether the candidate is better than the selection

data DurationFromNow Source #

Constructors

After !NominalDiffTime

INVARIANT positive

Already

This value represents all non-positive durations, ie events from the past

data GsmEntryPoints m Source #

The two proper GSM entrypoints.

See the BootstrapPeersIER.md document for documentation.

See initializationLedgerJudgement for the Initializing pseudo-state.

Constructors

GsmEntryPoints 

Fields

  • enterCaughtUp ∷ ∀ neverTerminates. m neverTerminates

    ASSUMPTION the marker file is present on disk, a la setCaughtUpPersistentMark True

    Thus this can be invoked at node start up after determining the marker file is present (and the tip is still not stale)

  • enterPreSyncing ∷ ∀ neverTerminates. m neverTerminates

    ASSUMPTION the marker file is absent on disk, a la setCaughtUpPersistentMark False

    Thus this can be invoked at node start up after determining the marker file is absent.

data GsmState Source #

Current state of the Genesis State Machine

Constructors

PreSyncing

We are syncing, and the Honest Availability Assumption is not satisfied.

Syncing

We are syncing, and the Honest Availability Assumption is satisfied.

CaughtUp

We are caught-up.

Instances

Instances details
Generic GsmState 
Instance details

Defined in Ouroboros.Consensus.Node.GsmState

Associated Types

type Rep GsmStateTypeType #

Methods

fromGsmStateRep GsmState x #

toRep GsmState x → GsmState #

Read GsmState 
Instance details

Defined in Ouroboros.Consensus.Node.GsmState

Show GsmState 
Instance details

Defined in Ouroboros.Consensus.Node.GsmState

Methods

showsPrecIntGsmStateShowS #

showGsmStateString #

showList ∷ [GsmState] → ShowS #

Eq GsmState 
Instance details

Defined in Ouroboros.Consensus.Node.GsmState

Methods

(==)GsmStateGsmStateBool #

(/=)GsmStateGsmStateBool #

NoThunks GsmState 
Instance details

Defined in Ouroboros.Consensus.Node.GsmState

type Rep GsmState 
Instance details

Defined in Ouroboros.Consensus.Node.GsmState

type Rep GsmState = D1 ('MetaData "GsmState" "Ouroboros.Consensus.Node.GsmState" "ouroboros-consensus-0.21.0.0-inplace" 'False) (C1 ('MetaCons "PreSyncing" 'PrefixI 'False) (U1TypeType) :+: (C1 ('MetaCons "Syncing" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "CaughtUp" 'PrefixI 'False) (U1TypeType)))

data GsmView m upstreamPeer selection chainSyncState Source #

Constructors

GsmView 

Fields

data MarkerFileView m Source #

A view on the GSM's Caught-Up persistent marker file

These comments constrain the result of realMarkerFile; mock views in testing are free to be different.

Constructors

MarkerFileView 

Fields

Auxiliaries

data TraceGsmEvent selection Source #

Constructors

GsmEventEnterCaughtUp !Int !selection

how many peers and the current selection

GsmEventLeaveCaughtUp !selection !DurationFromNow

the current selection and its age

GsmEventPreSyncingToSyncing

the Honest Availability Assumption is now satisfied

GsmEventSyncingToPreSyncing

the Honest Availability Assumption is no longer satisfied

Instances

Instances details
Show selection ⇒ Show (TraceGsmEvent selection) Source # 
Instance details

Defined in Ouroboros.Consensus.Node.GSM

Methods

showsPrecIntTraceGsmEvent selection → ShowS #

showTraceGsmEvent selection → String #

showList ∷ [TraceGsmEvent selection] → ShowS #

Eq selection ⇒ Eq (TraceGsmEvent selection) Source # 
Instance details

Defined in Ouroboros.Consensus.Node.GSM

Methods

(==)TraceGsmEvent selection → TraceGsmEvent selection → Bool #

(/=)TraceGsmEvent selection → TraceGsmEvent selection → Bool #

gsmStateToLedgerJudgementGsmStateLedgerStateJudgement Source #

For LedgerStateJudgement as used in the Diffusion layer, there is no difference between PreSyncing and Syncing.

initializationGsmState Source #

Arguments

∷ (GetTip (LedgerState blk), Monad m) 
⇒ m (LedgerState blk) 
Maybe (WrapDurationUntilTooOld m blk)

Nothing if blk has no age limit

MarkerFileView m 
→ m GsmState 

Determine the initial GsmState

Also initializes the persistent marker file.

Constructors

realDurationUntilTooOld Source #

Arguments

∷ (HasHardForkHistory blk, MonadSTM m) 
LedgerConfig blk 
STM m (LedgerState blk) 
NominalDiffTime

If the volatile tip is older than this, then the node will exit the CaughtUp state.

Eg llrnMaxCaughtUpAge

WARNING This function returns Already if the wall clock is beyond the current ledger state's translation horizon; that may be confusing if an unexpectedly large NominalDiffTime is given here (eg 1 one week).

SystemTime m 
→ m (WrapDurationUntilTooOld m blk) 

The real system's durationUntilTooOld

realGsmEntryPoints ∷ ∀ m upstreamPeer selection tracedSelection candidate. (MonadDelay m, MonadTimer m) ⇒ (selection → tracedSelection, Tracer m (TraceGsmEvent tracedSelection)) → GsmView m upstreamPeer selection candidate → GsmEntryPoints m Source #

The actual GSM logic for boot strap peers

See the BootstrapPeersIER.md document for the specification of most of this logic, except the transition rules between PreSyncing and Syncing, the two states OnlyBootstrap is split into:

  • PreSyncing ⟶ Syncing: The Honest Availability Assumption is satisfied.

realMarkerFileView Source #

Arguments

MonadThrow m 
ChainDB m blk 
HasFS m h

should be independent of other filesystems, eg gsm/

MarkerFileView m 

The real system's MarkerFileView

The strict ChainDB argument is unused, but its existence ensures there's only one process using this file system.

Re-exported