ouroboros-consensus-0.18.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Consensus.Genesis.Governor

Description

Implementation of the GDD governor

The GDD governor is the component responsible for identifying and disconnecting peers offering sparser chains than the best. This has the effect of unblocking the Limit on Eagerness, since removing disagreeing peers allows the current selection to advance.

The GDD governor, invoked with runGdd, is supposed to run in a background thread. It evaluates candidate chains whenever they change, or whenever a peer claims to have no more headers, or whenever a peer starts sending headers beyond the forecast horizon.

Whenever GDD disconnects peers, the chain selection is updated.

Synopsis

Documentation

data TraceGDDEvent peer blk Source #

Constructors

TraceGDDEvent 

data UpdateLoEFrag m blk Source #

An action representing an update to the LoE fragment, that determines which blocks can be selected in the ChainDB. With Ouroboros Genesis, this is implemented via the GDD governor, see updateLoEFragGenesis.

The callback is applied to the current chain and the current ledger state, and yields the new LoE fragment, which should be anchored in the immutable tip.

Constructors

UpdateLoEFrag 

Instances

Instances details
Generic (UpdateLoEFrag m blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Genesis.Governor

Associated Types

type Rep (UpdateLoEFrag m blk) ∷ TypeType #

Methods

fromUpdateLoEFrag m blk → Rep (UpdateLoEFrag m blk) x #

toRep (UpdateLoEFrag m blk) x → UpdateLoEFrag m blk #

NoThunks (UpdateLoEFrag m blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Genesis.Governor

type Rep (UpdateLoEFrag m blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Genesis.Governor

type Rep (UpdateLoEFrag m blk) = D1 ('MetaData "UpdateLoEFrag" "Ouroboros.Consensus.Genesis.Governor" "ouroboros-consensus-0.18.0.0-inplace" 'False) (C1 ('MetaCons "UpdateLoEFrag" 'PrefixI 'True) (S1 ('MetaSel ('Just "updateLoEFrag") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (AnchoredFragment (Header blk) → ExtLedgerState blk → m (AnchoredFragment (Header blk))))))

densityDisconnect ∷ (Ord peer, LedgerSupportsProtocol blk) ⇒ GenesisWindowSecurityParamMap peer (ChainSyncState blk) → Map peer (AnchoredFragment (Header blk)) → AnchoredFragment (Header blk) → ([peer], Map peer (DensityBounds blk)) Source #

densityDisconnect genWin k states candidateSuffixes loeFrag yields the list of peers which are known to lose the density comparison with any other peer, when looking at the genesis window after loeFrag.

The peers are taken from the keys of candidateSuffixes.

candidateSuffixes tells for every peer what is the fragment that the peer proposes to use after loeFrag.

states contains further information for every peer, such as the last ChainSync instruction the peer sent, and whether the peer is idling (i.e. it sent MsgAwaitReply).

loeFrag is the fragment from the immutable tip to the first intersection with a candidate fragment.

runGdd ∷ (Monoid a, Eq a, IOLike m, LedgerSupportsProtocol blk) ⇒ UpdateLoEFrag m blk → StrictTVar m (AnchoredFragment (Header blk)) → ChainDB m blk → STM m a → m Void Source #

A never ending computation that runs the GDD governor whenever the STM action getTrigger changes, writing the LoE fragment computed by loEUpdater to varLoEFrag, and then triggering ChainSel to reprocess all blocks that had previously been postponed by the LoE.

sharedCandidatePrefixGetHeader blk ⇒ AnchoredFragment (Header blk) → Map peer (AnchoredFragment (Header blk)) → (AnchoredFragment (Header blk), Map peer (AnchoredFragment (Header blk))) Source #

Compute the fragment loeFrag between the immutable tip and the earliest intersection between curChain and any of the candidates.

The immutable tip is the anchor of curChain.

The function also yields the suffixes of the intersection of loeFrag with every candidate fragment.

updateLoEFragGenesis ∷ ∀ m blk peer. (IOLike m, Ord peer, LedgerSupportsProtocol blk, HasHardForkHistory blk) ⇒ TopLevelConfig blk → Tracer m (TraceGDDEvent peer blk) → STM m (Map peer (ChainSyncClientHandle m blk)) → UpdateLoEFrag m blk Source #

Update the LoE fragment.

See UpdateLoEFrag for the definition of LoE fragment.

Additionally, disconnect the peers that lose density comparisons.

Disconnecting peers causes chain fragments to be removed, which causes the LoE fragment to be updated over and over until no more peers are disconnected.

getCandidates is the callback to obtain the candidate fragments

getHandles is the callback to get the handles that allow to disconnect from peers.

updateLoEFragStallMonadSTM m ⇒ GetHeader blk ⇒ STM m (Map peer (AnchoredFragment (Header blk))) → UpdateLoEFrag m blk Source #

This version of the LoE implements part of the intended Genesis approach. The fragment is set to the prefix of all candidates, ranging from the immutable tip to the earliest intersection of all peers.

Using this will cause ChainSel to stall indefinitely, or until a peer disconnects for unrelated reasons. In the future, the Genesis Density Disconnect Governor variant will extend this with an analysis that will always result in disconnections from peers to ensure the selection can advance.

updateLoEFragUnconditionalMonadSTM m ⇒ UpdateLoEFrag m blk Source #

A dummy version of the LoE that sets the LoE fragment to the current selection. This can be seen as emulating Praos behavior.