Skip to content

Commit 15683b7

Browse files
committed
Updated ouroboros-{network,consensus}
1 parent 7c3a03a commit 15683b7

7 files changed

Lines changed: 94 additions & 86 deletions

File tree

cabal.project

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,14 @@ source-repository-package
8686
source-repository-package
8787
type: git
8888
location: https://github.com/IntersectMBO/ouroboros-consensus
89-
tag: 49351452ea456b6242fa50e5ba3724ea6b66117d
90-
--sha256: sha256-4ONSJnD5x89HAfhUk/Kt6/CePc1OL2i15J7d4wpsQ10=
91-
subdir:
92-
ouroboros-consensus-cardano
93-
ouroboros-consensus-diffusion
94-
sop-extras
95-
ouroboros-consensus-protocol
96-
ouroboros-consensus
89+
tag: 5a8a751c57a4f8c2b15ca8153dc2d7b67904eac8
90+
--sha256: sha256-E36B6r1LD9Yv1rimHxJKanwl/C0wrFQBly5nugy55l0=
9791

9892
source-repository-package
9993
type: git
10094
location: https://github.com/IntersectMBO/ouroboros-network
101-
tag: 6ac49ca0ac4899609af8808e898cca503d7eeeea
102-
--sha256: sha256-A+77cCaZAH/l1N6WKYhc7OxXWkQd7HSi8PtxjoodniI=
95+
tag: 88a44d3a5804c53681f9ba07fb751f9b712d91f0
96+
--sha256: sha256-chSZKljsoYosvaxfzxsvCP0Ja3sqRp/1/hBVaajtR48=
10397
subdir:
10498
acts-generic
10599
cardano-diffusion

dmq-node/dmq-node.cabal

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,11 @@ library
126126
network-mux ^>=0.10,
127127
nothunks,
128128
optparse-applicative >=0.18 && <0.20,
129-
ouroboros-consensus,
130-
ouroboros-consensus-cardano,
131-
ouroboros-consensus-diffusion,
129+
ouroboros-consensus:{ouroboros-consensus, cardano, diffusion},
132130
ouroboros-network:{ouroboros-network, api, framework, orphan-instances, protocols} ^>=0.24,
133131
quiet,
134132
random ^>=1.3,
135133
singletons,
136-
strict-sop-core,
137134
text >=1.2.4 && <2.2,
138135
time >=1.12 && <1.15,
139136
transformers,

dmq-node/src/DMQ/Diffusion/Arguments.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ diffusionArguments
5353
-> Tracer m (NtC.HandshakeTr ntcAddr)
5454
-> STM m [(PoolStake, NonEmpty LedgerRelayAccessPoint)]
5555
-> Diffusion.Arguments
56-
NoExtraState NoExtraDebugState NoExtraFlags NoExtraPeers
57-
NoExtraAPI NoExtraChurnArgs NoExtraCounters NoExtraTracer
56+
NoExtraState NoExtraDebugState NoExtraFlags (NoExtraPeers RemoteAddress)
57+
NoExtraAPI NoExtraChurnArgs
5858
IOException
5959
Resolver
6060
m
@@ -82,7 +82,7 @@ diffusionArguments handshakeNtNTracer
8282
, lpExtraAPI = NoExtraAPI
8383
}
8484
, Diffusion.daEmptyExtraState = NoExtraState
85-
, Diffusion.daEmptyExtraCounters = NoExtraCounters
85+
, Diffusion.daEmptyExtraCounters = Diffusion.NoExtraView
8686
, Diffusion.daExtraPeersAPI = nullPublicExtraPeersAPI
8787
, Diffusion.daInstallSigUSR1Handler = \_ _ -> pure ()
8888
, Diffusion.daPeerSelectionGovernorArgs =
@@ -101,8 +101,7 @@ diffusionArguments handshakeNtNTracer
101101
}
102102
, defaultExtraFlags = NoExtraFlags
103103
}
104-
, Diffusion.daPeerSelectionStateToExtraCounters = const NoExtraCounters
105-
, Diffusion.daToExtraPeers = const NoExtraPeers
104+
, Diffusion.daToExtraPeers = const Diffusion.NoExtraPeers
106105
, Diffusion.daRequestPublicRootPeers = Nothing
107106
, Diffusion.daPeerChurnGovernor = peerChurnGovernor
108107
, Diffusion.daExtraChurnArgs = NoExtraChurnArgs

dmq-node/src/DMQ/NodeToClient/LocalStateQueryClient.hs

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,20 @@ import Data.Functor ((<&>))
2222
import Data.List.NonEmpty qualified as NonEmpty
2323
import Data.Map.Strict qualified as Map
2424
import Data.Proxy
25-
import Data.SOP.Strict.NS (NS (..))
2625
import Data.Void
2726

2827
import Cardano.Chain.Slotting (EpochSlots (..))
2928
import Cardano.Ledger.Api.State.Query (StakeSnapshots (..))
3029
import Cardano.Network.NodeToClient
3130
import Cardano.Network.PeerSelection (LedgerPeerSnapshot (..),
32-
LedgerRelayAccessPoint (..))
31+
LedgerRelayAccessPoint (..), SingLedgerPeersKind (..))
3332
import Cardano.Slotting.EpochInfo.API
3433
import Cardano.Slotting.Slot (EpochNo)
3534
import Cardano.Slotting.Time
3635

3736
import DMQ.Diffusion.NodeKernel
3837
import Ouroboros.Consensus.Cardano.Block
3938
import Ouroboros.Consensus.Cardano.Node
40-
import Ouroboros.Consensus.HardFork.Combinator (EraIndex)
41-
import Ouroboros.Consensus.HardFork.Combinator.Abstract.SingleEraBlock
42-
(EraIndex (..))
4339
import Ouroboros.Consensus.HardFork.Combinator.Ledger.Query
4440
import Ouroboros.Consensus.HardFork.History.EpochInfo (interpreterToEpochInfo)
4541
import Ouroboros.Consensus.HardFork.History.Qry (PastHorizonException)
@@ -53,8 +49,8 @@ import Ouroboros.Network.Block
5349
import Ouroboros.Network.Magic
5450
import Ouroboros.Network.Mux qualified as Mx
5551
import Ouroboros.Network.PeerSelection.LedgerPeers (LedgerPeersKind (..),
56-
SomeLedgerPeerSnapshot (..), accumulateBigLedgerStake)
57-
import Ouroboros.Network.PeerSelection.LedgerPeers.Type (SomeHashableBlock)
52+
accumulateBigLedgerStake)
53+
import Ouroboros.Network.PeerSelection.LedgerPeers.Type (RawBlockHash)
5854
import Ouroboros.Network.Point (Block (..))
5955
import Ouroboros.Network.Protocol.LocalStateQuery.Client
6056
import Ouroboros.Network.Protocol.LocalStateQuery.Type
@@ -186,36 +182,30 @@ cardanoClient tracer ledgerPeers
186182
queryStakeSnapshots
187183
:: SystemStart
188184
-> UTCTime
189-
-> EraIndex idx
185+
-> EraIndex (CardanoEras crypto)
190186
-> m (ClientStAcquired
191187
(CardanoBlock crypto)
192188
(Point (CardanoBlock crypto))
193189
(Query (CardanoBlock crypto))
194190
m
195191
Void)
196192
queryStakeSnapshots systemStart nextEpoch era =
197-
case getEraIndex era of
198-
Z _ -> throwIO UnsupportedEra
199-
S Z{} -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentShelley (GetStakeSnapshots Nothing)))
200-
$ wrappingMismatch handleStakeSnapshots
201-
S (S Z{}) -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentAllegra (GetStakeSnapshots Nothing)))
202-
$ wrappingMismatch handleStakeSnapshots
203-
S (S (S Z{})) -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentMary (GetStakeSnapshots Nothing)))
204-
$ wrappingMismatch handleStakeSnapshots
205-
S (S (S (S Z{}))) -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentAlonzo (GetStakeSnapshots Nothing)))
206-
$ wrappingMismatch handleStakeSnapshots
207-
S (S (S (S (S Z{})))) -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentBabbage (GetStakeSnapshots Nothing)))
208-
$ wrappingMismatch handleStakeSnapshots
209-
S (S (S (S (S (S Z{}))))) -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentConway (GetStakeSnapshots Nothing)))
210-
$ wrappingMismatch handleStakeSnapshots
211-
S (S (S (S (S (S (S Z{})))))) -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentDijkstra (GetStakeSnapshots Nothing)))
212-
$ wrappingMismatch handleStakeSnapshots
213-
-- TODO: requires manual intervention when new era is introduced, it
214-
-- would be nice if `ouroboros-consensus` exposed its
215-
-- `TagByron..TagDjikstra` patterns and made them complete as all the
216-
-- other patterns are. Then we'd get an incomplete GHC warning when
217-
-- a new era is introduced.
218-
_ -> throwIO UnsupportedEra
193+
case era of
194+
EraByron{} -> throwIO UnsupportedEra
195+
EraShelley{} -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentShelley (GetStakeSnapshots Nothing)))
196+
$ wrappingMismatch handleStakeSnapshots
197+
EraAllegra{} -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentAllegra (GetStakeSnapshots Nothing)))
198+
$ wrappingMismatch handleStakeSnapshots
199+
EraMary{} -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentMary (GetStakeSnapshots Nothing)))
200+
$ wrappingMismatch handleStakeSnapshots
201+
EraAlonzo{} -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentAlonzo (GetStakeSnapshots Nothing)))
202+
$ wrappingMismatch handleStakeSnapshots
203+
EraBabbage{} -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentBabbage (GetStakeSnapshots Nothing)))
204+
$ wrappingMismatch handleStakeSnapshots
205+
EraConway{} -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentConway (GetStakeSnapshots Nothing)))
206+
$ wrappingMismatch handleStakeSnapshots
207+
EraDijkstra{} -> return $ SendMsgQuery (BlockQuery (QueryIfCurrentDijkstra (GetStakeSnapshots Nothing)))
208+
$ wrappingMismatch handleStakeSnapshots
219209
where
220210
handleStakeSnapshots
221211
:: StakeSnapshots
@@ -251,18 +241,18 @@ cardanoClient tracer ledgerPeers
251241
m
252242
Void
253243
queryLedgerPeers systemStart toNextEpoch =
254-
SendMsgQuery (BlockQuery . QueryIfCurrentConway $ GetLedgerPeerSnapshot AllLedgerPeers)
244+
SendMsgQuery (BlockQuery . QueryIfCurrentConway $ GetLedgerPeerSnapshot SingAllLedgerPeers)
255245
$ wrappingMismatch handleLedgerPeers
256246
where
257247
handleLedgerPeers
258-
:: SomeLedgerPeerSnapshot
248+
:: LedgerPeerSnapshot AllLedgerPeers
259249
-> m (ClientStAcquired
260250
(CardanoBlock crypto)
261251
(Point (CardanoBlock crypto))
262252
(Query (CardanoBlock crypto))
263253
m
264254
Void)
265-
handleLedgerPeers (SomeLedgerPeerSnapshot _ (LedgerAllPeerSnapshotV23 pt magic peers)) = do
255+
handleLedgerPeers (LedgerAllPeerSnapshotV23 pt magic peers) = do
266256
let bigSrvRelays = force
267257
[(accStake, (stake, NonEmpty.fromList relays'))
268258
| (accStake, (stake, relays)) <- accumulateBigLedgerStake peers
@@ -274,7 +264,7 @@ cardanoClient tracer ledgerPeers
274264
relays
275265
, not (null relays')
276266
]
277-
pt' :: Point SomeHashableBlock
267+
pt' :: Point RawBlockHash
278268
pt' = Point $ getPoint pt <&>
279269
\blk -> blk { blockPointSlot = maxBound }
280270
srvRelays = force
@@ -295,13 +285,6 @@ cardanoClient tracer ledgerPeers
295285

296286
pure $ release systemStart toNextEpoch
297287

298-
handleLedgerPeers (SomeLedgerPeerSnapshot _ LedgerBigPeerSnapshotV23 {}) = do
299-
pure $ release systemStart toNextEpoch
300-
301-
handleLedgerPeers (SomeLedgerPeerSnapshot _ LedgerPeerSnapshotV2 {}) = do
302-
traceWith tracer LedgerPeersNotAvailable
303-
pure $ release systemStart toNextEpoch
304-
305288

306289
-- release, continue the loop in `idle`
307290
release :: SystemStart

dmq-node/src/DMQ/Policy.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ sigDecisionPolicy = TxDecisionPolicy {
3535
maxNumTxIdsToRequest = maxSigsInflight,
3636
maxUnacknowledgedTxIds = 4 * maxSigsInflight,
3737
txsSizeInflightPerPeer = maxSigSize * fromIntegral maxSigsInflight,
38-
maxTxsSizeInflight = 250_000,
3938
txInflightMultiplicity = 1,
4039
bufferedTxsMinLifetime = 0,
4140
scoreRate = 0.1,

dmq-node/src/DMQ/Tracer.hs

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ import Data.Aeson.Encode.Pretty (encodePretty)
3131
import Data.Bool (bool)
3232
import Data.ByteString.Lazy.Char8 qualified as LBS.Char8
3333
import Data.Functor.Contravariant ((>$<))
34-
import Data.Set qualified as Set
3534
import Data.Text qualified as Text
3635

36+
import Ouroboros.Network.Diffusion (NoExtraPeers (..))
3737
import Ouroboros.Network.Diffusion qualified as Diffusion
3838
import Ouroboros.Network.OrphanInstances ()
3939
import Ouroboros.Network.PeerSelection (DebugPeerSelection (..))
@@ -79,17 +79,7 @@ dmqTracer pretty = contramapM
7979
instance ToJSON Term where
8080
toJSON term = String (Text.pack . show $ term)
8181

82-
data NoExtraPeers = NoExtraPeers
83-
instance Semigroup NoExtraPeers where
84-
_ <> _ = NoExtraPeers
85-
instance Monoid NoExtraPeers where
86-
mempty = NoExtraPeers
87-
88-
instance ToJSON NoExtraPeers where
89-
toJSON _ = Null
90-
omitField _ = True
91-
92-
instance ToJSON (PublicRootPeers NoExtraPeers RemoteAddress) where
82+
instance ToJSON (PublicRootPeers (NoExtraPeers RemoteAddress) RemoteAddress) where
9383
toJSON prp =
9484
object [ "kind" .= String "PublicRootPeers"
9585
, "ledgerPeers" .= PublicRootPeers.getLedgerPeers prp
@@ -145,18 +135,66 @@ instance ToJSON (Governor.PeerSelectionCounters NoExtraCounters) where
145135
, "activeNonRootPeersDemotions" .= numberOfActiveNonRootPeersDemotions
146136
]
147137

148-
instance ToJSON (DebugPeerSelection NoExtraState NoExtraFlags NoExtraPeers RemoteAddress) where
138+
instance ToJSON (DebugPeerSelection NoExtraState NoExtraFlags (NoExtraPeers RemoteAddress) RemoteAddress) where
149139
toJSON (TraceGovernorState blockedAt wakeupAfter st@Governor.PeerSelectionState { Governor.targets }) =
150140
object [ "kind" .= String "DebugPeerSelection"
151141
, "blockedAt" .= String (Text.pack . show $ blockedAt)
152142
, "wakeupAfter" .= String (Text.pack . show $ wakeupAfter)
153143
, "targets" .= targets
154-
, "counters" .= Governor.peerSelectionStateToCounters
155-
(const Set.empty)
156-
(const NoExtraCounters)
157-
st
144+
, "counters" .= Governor.peerSelectionStateToCounters st
158145
]
159146

147+
148+
instance ToJSON (Governor.ToExtraTrace (NoExtraPeers RemoteAddress)) where
149+
toJSON _ = Null
150+
omitField _ = True
151+
152+
instance ToJSON (Governor.PeerSelectionCounters (Governor.ViewExtraPeers (NoExtraPeers RemoteAddress))) where
153+
toJSON Governor.PeerSelectionCounters {..} =
154+
object [ "kind" .= String "PeerSelectionCounters"
155+
156+
, "rootPeers" .= numberOfRootPeers
157+
158+
, "knownPeers" .= numberOfKnownPeers
159+
, "availableToConnect" .= numberOfAvailableToConnectPeers
160+
, "coldPeersPromotions" .= numberOfColdPeersPromotions
161+
, "establishedPeers" .= numberOfEstablishedPeers
162+
, "warmPeersDemotions" .= numberOfWarmPeersDemotions
163+
, "warmPeersPromotions" .= numberOfWarmPeersPromotions
164+
, "activePeers" .= numberOfActivePeers
165+
, "activePeersDemotions" .= numberOfActivePeersDemotions
166+
167+
, "knownBigLedgerPeers" .= numberOfKnownBigLedgerPeers
168+
, "availableToConnectBigLegerPeers" .= numberOfAvailableToConnectBigLedgerPeers
169+
, "coldBigLedgerPeersPromotions" .= numberOfColdBigLedgerPeersPromotions
170+
, "establishedBigLedgerPeers" .= numberOfEstablishedBigLedgerPeers
171+
, "warmBigLedgerPeersDemotions" .= numberOfWarmBigLedgerPeersDemotions
172+
, "warmBigLedgerPeersPromotions" .= numberOfWarmBigLedgerPeersPromotions
173+
, "activeBigLedgerPeers" .= numberOfActiveBigLedgerPeers
174+
, "activeBigLedgerPeersDemotions" .= numberOfActiveBigLedgerPeersDemotions
175+
176+
, "knownLocalRootPeers" .= numberOfKnownLocalRootPeers
177+
, "availableToConnectLocalRootPeers" .= numberOfAvailableToConnectLocalRootPeers
178+
, "coldLocalRootPeersPromotions" .= numberOfColdLocalRootPeersPromotions
179+
, "establishedLocalRootPeers" .= numberOfEstablishedLocalRootPeers
180+
, "warmLocalRootPeersPromotions" .= numberOfWarmLocalRootPeersPromotions
181+
, "activeLocalRootPeers" .= numberOfActiveLocalRootPeers
182+
, "activeLocalRootPeersDemotions" .= numberOfActiveLocalRootPeersDemotions
183+
184+
, "knownNonRootPeers" .= numberOfKnownNonRootPeers
185+
, "coldNonRootPeersPromotions" .= numberOfColdNonRootPeersPromotions
186+
, "establishedNonRootPeers" .= numberOfEstablishedNonRootPeers
187+
, "warmNonRootPeersDemotions" .= numberOfWarmNonRootPeersDemotions
188+
, "warmNonRootPeersPromotions" .= numberOfWarmNonRootPeersPromotions
189+
, "activeNonRootPeers" .= numberOfActiveNonRootPeers
190+
, "activeNonRootPeersDemotions" .= numberOfActiveNonRootPeersDemotions
191+
192+
]
193+
194+
instance ToJSON (NoExtraPeers RemoteAddress) where
195+
toJSON _ = Null
196+
omitField _ = True
197+
160198
dmqDiffusionTracers
161199
:: forall m.
162200
Applicative m
@@ -167,9 +205,7 @@ dmqDiffusionTracers
167205
NoExtraState
168206
NoExtraDebugState
169207
NoExtraFlags
170-
NoExtraPeers
171-
NoExtraCounters
172-
NoExtraTracer
208+
(NoExtraPeers RemoteAddress)
173209
m
174210
dmqDiffusionTracers
175211
Configuration {

dmq-node/test/Test/DMQ/SigSubmission/App.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Prelude hiding (seq)
1515

1616
import Control.Concurrent.Class.MonadMVar.Strict
1717
import Control.Concurrent.Class.MonadSTM.Strict
18+
import Control.Concurrent.Class.MonadSTM qualified as LazySTM
1819
import Control.Monad.Class.MonadAsync
1920
import Control.Monad.Class.MonadFork
2021
import Control.Monad.Class.MonadSay
@@ -199,9 +200,7 @@ sigSubmissionSimulation (SigSubmissionState state sigDecisionPolicy) = do
199200
atomically (traverse_ (`writeTVar` Terminate) controlMessageVars)
200201
) \_ -> do
201202
let tracer :: forall a. (Show a, Typeable a) => Tracer (IOSim s) a
202-
tracer = verboseTracer
203-
<> debugTracer
204-
<> Tracer traceM
203+
tracer = dynamicTracer <> sayTracer
205204
runSigSubmissionV2 tracer tracer state'' sigDecisionPolicy
206205

207206

@@ -279,6 +278,7 @@ runSigSubmissionV2 tracer tracerSigLogic st0 sigDecisionPolicy = do
279278
sharedSigStateVar <- newSharedTxStateVar sigRng
280279
traceTVarIO sharedSigStateVar \_ -> return . TraceDynamic . SigStateTrace
281280
labelTVarIO sharedSigStateVar "shared-sig-state"
281+
duplicateSigsVar <- LazySTM.newTVarIO []
282282

283283
withAsync (decisionLogicThreads tracerSigLogic sayTracer
284284
sigDecisionPolicy sigChannelsVar sharedSigStateVar) $ \a -> do
@@ -307,12 +307,12 @@ runSigSubmissionV2 tracer tracerSigLogic st0 sigDecisionPolicy = do
307307
sigDecisionPolicy
308308
sharedSigStateVar
309309
(getMempoolReader inboundMempool)
310-
(getMempoolWriter inboundMempool)
310+
(getMempoolWriter duplicateSigsVar inboundMempool)
311311
getTxSize
312312
addr $ \(api :: PeerTxAPI m TxId (Tx TxId))-> do
313313
let inbound = sigSubmissionInbound
314314
verboseTracer
315-
(getMempoolWriter inboundMempool)
315+
(getMempoolWriter duplicateSigsVar inboundMempool)
316316
api
317317
ctrlMsgSTM
318318
runPipelinedPeerWithLimits

0 commit comments

Comments
 (0)