Skip to content

Commit 29899df

Browse files
Merge pull request #4832 from IntersectMBO/crocodile-dentist/og-genesis
Big Ledger Peer Targets for Genesis
2 parents 88bf776 + 2244210 commit 29899df

File tree

18 files changed

+1193
-544
lines changed

18 files changed

+1193
-544
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ will make it easier for others to rebase on top of your committed changes). If
213213
you need to rebase your branch we prefer to rebase over merge (since then the
214214
actually merged changes are more explicit).
215215

216+
We also keep the convention that a source branch's name for a pull request
217+
includes github user name of the contributor.
218+
216219
Since the code base of `ouroboros-network` is quite large, we don't require
217220
that every commit is buildable across all included packages. You can update
218221
upstream dependencies later in the commit history; although note that if you do

ouroboros-network-api/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* Renamed:
1818
* `accBigPoolStake` -> `accumulateBigLedgerStake`
1919
and `reRelativeStake` -> `recomputeRelativeStake`
20+
* Added `ConsensusMode` which must be passed to start diffusion in the
21+
appropriate mode
2022

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

ouroboros-network-api/ouroboros-network-api.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ library
2929
Ouroboros.Network.BlockFetch.ConsensusInterface
3030

3131
Ouroboros.Network.CodecCBORTerm
32+
Ouroboros.Network.ConsensusMode
3233
Ouroboros.Network.ControlMessage
3334
Ouroboros.Network.Handshake
3435
Ouroboros.Network.Handshake.Acceptable
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{-# LANGUAGE DeriveAnyClass #-}
2+
{-# LANGUAGE DeriveGeneric #-}
3+
4+
module Ouroboros.Network.ConsensusMode where
5+
6+
import Data.Aeson
7+
import GHC.Generics (Generic)
8+
9+
-- | Diffusion layer configuration parameter.
10+
--
11+
-- The two modes determine which `PeerSelectionTargets` basis is used
12+
-- by churn and OG. The node's configuration sets this, and diffusion
13+
-- is initiated and remains only in this mode.
14+
--
15+
data ConsensusMode =
16+
GenesisMode
17+
-- ^ When `LedgerStateJudgement` is `TooOld`, the targets basis is changed
18+
-- from default to one specific for this mode, which uses more big ledger peers
19+
-- until syncing is complete.
20+
21+
| PraosMode
22+
-- ^ The legacy mode which depends on official relays and/or bootstrap peers
23+
-- configuration. This mode uses only the default target basis irrespective
24+
-- ledger state.
25+
deriving (Eq, Show, Generic, FromJSON)
26+
27+
28+
defaultConsensusMode :: ConsensusMode
29+
defaultConsensusMode = PraosMode

ouroboros-network/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
bootstrapping a node in Genesis consensus mode, or in general when
1414
LedgerStateJudgement = TooOld, subject to conditions in
1515
`LedgerPeers.ledgerPeersThread`.
16+
* Diffusion run function in P2P mode has new paramaters:
17+
* `daPeerTargets` - replaces daPeerSelectionTargets. `Configuration`
18+
module provides an API. Used by peer selection & churn governors. Given
19+
required arguments, it returns the correct target basis to use for churn
20+
and peer selection governors.
21+
* `daConsensusMode` - flag indicating whether diffusion should run in Praos
22+
or Genesis mode, which influences what `PeerSelectionTargets` both
23+
governors should use. Genesis may use two different sets of targets
24+
depending on ledger state, while Praos uses only one set. Either set
25+
once active is appropriately churned.
1626

1727
### Non-Breaking changes
1828

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

3144
## 0.16.1.1 -- 2024-06-28
3245

ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Diffusion/Node.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ import Ouroboros.Network.Block (MaxSlotNo (..), maxSlotNoFromWithOrigin,
6767
pointSlot)
6868
import Ouroboros.Network.BlockFetch
6969
import Ouroboros.Network.ConnectionManager.Types (DataFlow (..))
70+
import Ouroboros.Network.ConsensusMode
7071
import Ouroboros.Network.Diffusion qualified as Diff
7172
import Ouroboros.Network.Diffusion.P2P qualified as Diff.P2P
7273
import Ouroboros.Network.ExitPolicy (RepromoteDelay (..))
7374
import Ouroboros.Network.NodeToNode.Version (DiffusionMode (..))
74-
import Ouroboros.Network.PeerSelection.Governor (PeerSelectionTargets (..),
75-
PublicPeerSelectionState (..))
75+
import Ouroboros.Network.PeerSelection.Governor (ConsensusModePeerTargets,
76+
PeerSelectionTargets (..), PublicPeerSelectionState (..))
7677
import Ouroboros.Network.PeerSelection.PeerMetric
7778
(PeerMetricsConfiguration (..), newPeerMetric)
7879
import Ouroboros.Network.Protocol.Handshake (HandshakeArguments (..))
@@ -141,13 +142,14 @@ data Arguments m = Arguments
141142
, aShouldChainSyncExit :: BlockHeader -> m Bool
142143
, aChainSyncEarlyExit :: Bool
143144

144-
, aPeerSelectionTargets :: PeerSelectionTargets
145+
, aPeerTargets :: ConsensusModePeerTargets
145146
, aReadLocalRootPeers :: STM m [( HotValency
146147
, WarmValency
147148
, Map RelayAccessPoint ( PeerAdvertise
148149
, PeerTrustable))]
149150
, aReadPublicRootPeers :: STM m (Map RelayAccessPoint PeerAdvertise)
150151
, aReadUseBootstrapPeers :: Script UseBootstrapPeers
152+
, aConsensusMode :: ConsensusMode
151153
, aOwnPeerSharing :: PeerSharing
152154
, aReadUseLedgerPeers :: STM m UseLedgerPeers
153155
, aProtocolIdleTimeout :: DiffTime
@@ -390,7 +392,7 @@ run blockGeneratorArgs limits ni na tracersExtra tracerBlockFetch =
390392
mkArgsExtra :: StrictTVar m (Script UseBootstrapPeers)
391393
-> Diff.P2P.ArgumentsExtra m
392394
mkArgsExtra ubpVar = Diff.P2P.ArgumentsExtra
393-
{ Diff.P2P.daPeerSelectionTargets = aPeerSelectionTargets na
395+
{ Diff.P2P.daPeerTargets = aPeerTargets na
394396
, Diff.P2P.daReadLocalRootPeers = aReadLocalRootPeers na
395397
, Diff.P2P.daReadPublicRootPeers = aReadPublicRootPeers na
396398
, Diff.P2P.daReadUseBootstrapPeers = stepScriptSTM' ubpVar
@@ -401,6 +403,7 @@ run blockGeneratorArgs limits ni na tracersExtra tracerBlockFetch =
401403
, Diff.P2P.daDeadlineChurnInterval = 3300
402404
, Diff.P2P.daBulkChurnInterval = 300
403405
, Diff.P2P.daReadLedgerPeerSnapshot = pure Nothing -- ^ tested independently
406+
, Diff.P2P.daConsensusMode = aConsensusMode na
404407
}
405408

406409
appArgs :: Node.AppArgs BlockHeader Block m

0 commit comments

Comments
 (0)