Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- data DensityBounds blk = DensityBounds {}
- data TraceGDDEvent peer blk = TraceGDDEvent {
- bounds ∷ Map peer (DensityBounds blk)
- curChain ∷ AnchoredFragment (Header blk)
- candidates ∷ Map peer (AnchoredFragment (Header blk))
- candidateSuffixes ∷ Map peer (AnchoredFragment (Header blk))
- losingPeers ∷ [peer]
- loeHead ∷ Anchor (Header blk)
- sgen ∷ GenesisWindow
- data UpdateLoEFrag m blk = UpdateLoEFrag {
- updateLoEFrag ∷ AnchoredFragment (Header blk) → ExtLedgerState blk → m (AnchoredFragment (Header blk))
- densityDisconnect ∷ (Ord peer, LedgerSupportsProtocol blk) ⇒ GenesisWindow → SecurityParam → Map peer (ChainSyncState blk) → Map peer (AnchoredFragment (Header blk)) → AnchoredFragment (Header blk) → ([peer], Map peer (DensityBounds blk))
- 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
- sharedCandidatePrefix ∷ GetHeader blk ⇒ AnchoredFragment (Header blk) → Map peer (AnchoredFragment (Header blk)) → (AnchoredFragment (Header blk), Map peer (AnchoredFragment (Header blk)))
- 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
- updateLoEFragStall ∷ MonadSTM m ⇒ GetHeader blk ⇒ STM m (Map peer (AnchoredFragment (Header blk))) → UpdateLoEFrag m blk
- updateLoEFragUnconditional ∷ MonadSTM m ⇒ UpdateLoEFrag m blk
Documentation
data DensityBounds blk Source #
data TraceGDDEvent peer blk Source #
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.
UpdateLoEFrag | |
|
Instances
Generic (UpdateLoEFrag m blk) Source # | |
Defined in Ouroboros.Consensus.Genesis.Governor type Rep (UpdateLoEFrag m blk) ∷ Type → Type # from ∷ UpdateLoEFrag m blk → Rep (UpdateLoEFrag m blk) x # to ∷ Rep (UpdateLoEFrag m blk) x → UpdateLoEFrag m blk # | |
NoThunks (UpdateLoEFrag m blk) Source # | |
Defined in Ouroboros.Consensus.Genesis.Governor | |
type Rep (UpdateLoEFrag m blk) Source # | |
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) ⇒ GenesisWindow → SecurityParam → Map 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.
sharedCandidatePrefix ∷ GetHeader 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.
updateLoEFragStall ∷ MonadSTM 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.
updateLoEFragUnconditional ∷ MonadSTM 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.