Skip to content

Commit

Permalink
Merge pull request #4832 from IntersectMBO/crocodile-dentist/og-genesis
Browse files Browse the repository at this point in the history
Big Ledger Peer Targets for Genesis
  • Loading branch information
crocodile-dentist authored Jul 24, 2024
2 parents 88bf776 + 2244210 commit 29899df
Show file tree
Hide file tree
Showing 18 changed files with 1,193 additions and 544 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ will make it easier for others to rebase on top of your committed changes). If
you need to rebase your branch we prefer to rebase over merge (since then the
actually merged changes are more explicit).

We also keep the convention that a source branch's name for a pull request
includes github user name of the contributor.

Since the code base of `ouroboros-network` is quite large, we don't require
that every commit is buildable across all included packages. You can update
upstream dependencies later in the commit history; although note that if you do
Expand Down
2 changes: 2 additions & 0 deletions ouroboros-network-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* Renamed:
* `accBigPoolStake` -> `accumulateBigLedgerStake`
and `reRelativeStake` -> `recomputeRelativeStake`
* Added `ConsensusMode` which must be passed to start diffusion in the
appropriate mode

* Added `Measure` and `BoundedMeasure` instances for `SizeInBytes`.

Expand Down
1 change: 1 addition & 0 deletions ouroboros-network-api/ouroboros-network-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ library
Ouroboros.Network.BlockFetch.ConsensusInterface

Ouroboros.Network.CodecCBORTerm
Ouroboros.Network.ConsensusMode
Ouroboros.Network.ControlMessage
Ouroboros.Network.Handshake
Ouroboros.Network.Handshake.Acceptable
Expand Down
29 changes: 29 additions & 0 deletions ouroboros-network-api/src/Ouroboros/Network/ConsensusMode.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}

module Ouroboros.Network.ConsensusMode where

import Data.Aeson
import GHC.Generics (Generic)

-- | Diffusion layer configuration parameter.
--
-- The two modes determine which `PeerSelectionTargets` basis is used
-- by churn and OG. The node's configuration sets this, and diffusion
-- is initiated and remains only in this mode.
--
data ConsensusMode =
GenesisMode
-- ^ When `LedgerStateJudgement` is `TooOld`, the targets basis is changed
-- from default to one specific for this mode, which uses more big ledger peers
-- until syncing is complete.

| PraosMode
-- ^ The legacy mode which depends on official relays and/or bootstrap peers
-- configuration. This mode uses only the default target basis irrespective
-- ledger state.
deriving (Eq, Show, Generic, FromJSON)


defaultConsensusMode :: ConsensusMode
defaultConsensusMode = PraosMode
13 changes: 13 additions & 0 deletions ouroboros-network/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
bootstrapping a node in Genesis consensus mode, or in general when
LedgerStateJudgement = TooOld, subject to conditions in
`LedgerPeers.ledgerPeersThread`.
* Diffusion run function in P2P mode has new paramaters:
* `daPeerTargets` - replaces daPeerSelectionTargets. `Configuration`
module provides an API. Used by peer selection & churn governors. Given
required arguments, it returns the correct target basis to use for churn
and peer selection governors.
* `daConsensusMode` - flag indicating whether diffusion should run in Praos
or Genesis mode, which influences what `PeerSelectionTargets` both
governors should use. Genesis may use two different sets of targets
depending on ledger state, while Praos uses only one set. Either set
once active is appropriately churned.

### Non-Breaking changes

Expand All @@ -27,6 +37,9 @@
* Added property tests checking if `LedgerPeerSnapshot` CBOR encoding is valid,
and decode/encode = id, as well as some property tests for calculating big ledger
peers
* Implemented separate configurable peer selection targets for Praos and
Genesis consensus modes. Genesis mode may use more big ledger peers when
a node is syncing up.

## 0.16.1.1 -- 2024-06-28

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ import Ouroboros.Network.Block (MaxSlotNo (..), maxSlotNoFromWithOrigin,
pointSlot)
import Ouroboros.Network.BlockFetch
import Ouroboros.Network.ConnectionManager.Types (DataFlow (..))
import Ouroboros.Network.ConsensusMode
import Ouroboros.Network.Diffusion qualified as Diff
import Ouroboros.Network.Diffusion.P2P qualified as Diff.P2P
import Ouroboros.Network.ExitPolicy (RepromoteDelay (..))
import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..))
import Ouroboros.Network.PeerSelection.Governor (PeerSelectionTargets (..),
PublicPeerSelectionState (..))
import Ouroboros.Network.PeerSelection.Governor (ConsensusModePeerTargets,
PeerSelectionTargets (..), PublicPeerSelectionState (..))
import Ouroboros.Network.PeerSelection.PeerMetric
(PeerMetricsConfiguration (..), newPeerMetric)
import Ouroboros.Network.Protocol.Handshake (HandshakeArguments (..))
Expand Down Expand Up @@ -141,13 +142,14 @@ data Arguments m = Arguments
, aShouldChainSyncExit :: BlockHeader -> m Bool
, aChainSyncEarlyExit :: Bool

, aPeerSelectionTargets :: PeerSelectionTargets
, aPeerTargets :: ConsensusModePeerTargets
, aReadLocalRootPeers :: STM m [( HotValency
, WarmValency
, Map RelayAccessPoint ( PeerAdvertise
, PeerTrustable))]
, aReadPublicRootPeers :: STM m (Map RelayAccessPoint PeerAdvertise)
, aReadUseBootstrapPeers :: Script UseBootstrapPeers
, aConsensusMode :: ConsensusMode
, aOwnPeerSharing :: PeerSharing
, aReadUseLedgerPeers :: STM m UseLedgerPeers
, aProtocolIdleTimeout :: DiffTime
Expand Down Expand Up @@ -390,7 +392,7 @@ run blockGeneratorArgs limits ni na tracersExtra tracerBlockFetch =
mkArgsExtra :: StrictTVar m (Script UseBootstrapPeers)
-> Diff.P2P.ArgumentsExtra m
mkArgsExtra ubpVar = Diff.P2P.ArgumentsExtra
{ Diff.P2P.daPeerSelectionTargets = aPeerSelectionTargets na
{ Diff.P2P.daPeerTargets = aPeerTargets na
, Diff.P2P.daReadLocalRootPeers = aReadLocalRootPeers na
, Diff.P2P.daReadPublicRootPeers = aReadPublicRootPeers na
, Diff.P2P.daReadUseBootstrapPeers = stepScriptSTM' ubpVar
Expand All @@ -401,6 +403,7 @@ run blockGeneratorArgs limits ni na tracersExtra tracerBlockFetch =
, Diff.P2P.daDeadlineChurnInterval = 3300
, Diff.P2P.daBulkChurnInterval = 300
, Diff.P2P.daReadLedgerPeerSnapshot = pure Nothing -- ^ tested independently
, Diff.P2P.daConsensusMode = aConsensusMode na
}

appArgs :: Node.AppArgs BlockHeader Block m
Expand Down
Loading

0 comments on commit 29899df

Please sign in to comment.