@@ -22,24 +22,20 @@ import Data.Functor ((<&>))
2222import Data.List.NonEmpty qualified as NonEmpty
2323import Data.Map.Strict qualified as Map
2424import Data.Proxy
25- import Data.SOP.Strict.NS (NS (.. ))
2625import Data.Void
2726
2827import Cardano.Chain.Slotting (EpochSlots (.. ))
2928import Cardano.Ledger.Api.State.Query (StakeSnapshots (.. ))
3029import Cardano.Network.NodeToClient
3130import Cardano.Network.PeerSelection (LedgerPeerSnapshot (.. ),
32- LedgerRelayAccessPoint (.. ))
31+ LedgerRelayAccessPoint (.. ), SingLedgerPeersKind ( .. ) )
3332import Cardano.Slotting.EpochInfo.API
3433import Cardano.Slotting.Slot (EpochNo )
3534import Cardano.Slotting.Time
3635
3736import DMQ.Diffusion.NodeKernel
3837import Ouroboros.Consensus.Cardano.Block
3938import Ouroboros.Consensus.Cardano.Node
40- import Ouroboros.Consensus.HardFork.Combinator (EraIndex )
41- import Ouroboros.Consensus.HardFork.Combinator.Abstract.SingleEraBlock
42- (EraIndex (.. ))
4339import Ouroboros.Consensus.HardFork.Combinator.Ledger.Query
4440import Ouroboros.Consensus.HardFork.History.EpochInfo (interpreterToEpochInfo )
4541import Ouroboros.Consensus.HardFork.History.Qry (PastHorizonException )
@@ -53,8 +49,8 @@ import Ouroboros.Network.Block
5349import Ouroboros.Network.Magic
5450import Ouroboros.Network.Mux qualified as Mx
5551import 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 )
5854import Ouroboros.Network.Point (Block (.. ))
5955import Ouroboros.Network.Protocol.LocalStateQuery.Client
6056import 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
0 commit comments