@@ -139,6 +139,14 @@ type Delegations = Map (SL.Credential 'SL.Staking) (SL.KeyHash 'SL.StakePool)
139
139
type VoteDelegatees = Map (SL. Credential 'SL.Staking ) SL. DRep
140
140
141
141
{-# DEPRECATED GetProposedPParamsUpdates "Deprecated in ShelleyNodeToClientVersion12" #-}
142
+ {-# DEPRECATED
143
+ GetPoolDistr
144
+ "Deprecated in ShelleyNodeToClientVersion13. Implement the new alterative GetPoolDistr2"
145
+ #-}
146
+ {-# DEPRECATED
147
+ GetStakeDistribution
148
+ "Deprecated in ShelleyNodeToClientVersion13. Implement the new alterative GetStakeDistribution2"
149
+ #-}
142
150
143
151
data instance BlockQuery (ShelleyBlock proto era ) fp result where
144
152
GetLedgerTip :: BlockQuery (ShelleyBlock proto era ) QFNoTables (Point (ShelleyBlock proto era ))
@@ -338,6 +346,20 @@ data instance BlockQuery (ShelleyBlock proto era) fp result where
338
346
CG. ConwayEraGov era =>
339
347
KeyHash 'StakePool ->
340
348
BlockQuery (ShelleyBlock proto era ) QFNoTables CG. DefaultVote
349
+ GetPoolDistr2 ::
350
+ Maybe (Set (SL. KeyHash 'SL.StakePool )) ->
351
+ BlockQuery
352
+ (ShelleyBlock proto era )
353
+ QFNoTables
354
+ SL. PoolDistr
355
+ -- | This gets the stake distribution, but not in terms of _active_ stake
356
+ -- (which we need for the leader schedule), but rather in terms of _total_
357
+ -- stake, which is relevant for rewards. It is used by the wallet to show
358
+ -- saturation levels to the end user. We should consider refactoring this, to
359
+ -- an endpoint that provides all the information that the wallet wants about
360
+ -- pools, in an extensible fashion.
361
+ GetStakeDistribution2 ::
362
+ BlockQuery (ShelleyBlock proto era ) QFNoTables SL. PoolDistr
341
363
342
364
-- WARNING: please add new queries to the end of the list and stick to this
343
365
-- order in all other pattern matches on queries. This helps in particular
@@ -379,7 +401,7 @@ instance
379
401
GetProposedPParamsUpdates ->
380
402
SL. ProposedPPUpdates Map. empty
381
403
GetStakeDistribution ->
382
- fromLedgerPoolDistr $ SL. poolsByTotalStakeFraction globals st
404
+ fromLedgerPoolDistr $ answerPureBlockQuery cfg GetStakeDistribution2 ext
383
405
DebugEpochState ->
384
406
getEpochState st
385
407
GetCBOR query' ->
@@ -469,9 +491,7 @@ instance
469
491
, ssGoTotal = getAllStake ssStakeGo
470
492
}
471
493
GetPoolDistr mPoolIds ->
472
- let stakeSet = SL. ssStakeSet . SL. esSnapshots $ getEpochState st
473
- in fromLedgerPoolDistr $
474
- SL. calculatePoolDistr' (maybe (const True ) (flip Set. member) mPoolIds) stakeSet
494
+ fromLedgerPoolDistr $ answerPureBlockQuery cfg (GetPoolDistr2 mPoolIds) ext
475
495
GetStakeDelegDeposits stakeCreds ->
476
496
let lookupDeposit =
477
497
SL. lookupDepositDState (view SL. certDStateL $ SL. lsCertState $ SL. esLState $ SL. nesEs st)
@@ -509,6 +529,11 @@ instance
509
529
in LedgerPeerSnapshot (slot, bigLedgerPeers)
510
530
QueryStakePoolDefaultVote stakePool ->
511
531
SL. queryStakePoolDefaultVote st stakePool
532
+ GetPoolDistr2 mPoolIds ->
533
+ let stakeSet = SL. ssStakeSet . SL. esSnapshots $ getEpochState st
534
+ in SL. calculatePoolDistr' (maybe (const True ) (flip Set. member) mPoolIds) stakeSet
535
+ GetStakeDistribution2 ->
536
+ SL. poolsByTotalStakeFraction globals st
512
537
where
513
538
lcfg = configLedger $ getExtLedgerCfg cfg
514
539
globals = shelleyLedgerGlobals lcfg
@@ -534,7 +559,7 @@ instance
534
559
GetNonMyopicMemberRewards {} -> const True
535
560
GetCurrentPParams -> const True
536
561
GetProposedPParamsUpdates -> (< v12)
537
- GetStakeDistribution -> const True
562
+ GetStakeDistribution -> ( < v13)
538
563
GetUTxOByAddress {} -> const True
539
564
GetUTxOWhole -> const True
540
565
DebugEpochState -> const True
@@ -550,7 +575,7 @@ instance
550
575
GetRewardInfoPools -> const True
551
576
GetPoolState {} -> const True
552
577
GetStakeSnapshots {} -> const True
553
- GetPoolDistr {} -> const True
578
+ GetPoolDistr {} -> ( < v13)
554
579
GetStakeDelegDeposits {} -> const True
555
580
GetConstitution -> (>= v8)
556
581
GetGovState -> (>= v8)
@@ -565,6 +590,8 @@ instance
565
590
GetFuturePParams {} -> (>= v10)
566
591
GetBigLedgerPeerSnapshot -> (>= v11)
567
592
QueryStakePoolDefaultVote {} -> (>= v12)
593
+ GetPoolDistr2 {} -> (>= v13)
594
+ GetStakeDistribution2 {} -> (>= v13)
568
595
where
569
596
-- WARNING: when adding a new query, a new @ShelleyNodeToClientVersionX@
570
597
-- must be added. See #2830 for a template on how to do this.
@@ -574,6 +601,7 @@ instance
574
601
v10 = ShelleyNodeToClientVersion10
575
602
v11 = ShelleyNodeToClientVersion11
576
603
v12 = ShelleyNodeToClientVersion12
604
+ v13 = ShelleyNodeToClientVersion13
577
605
578
606
instance SameDepIndex2 (BlockQuery (ShelleyBlock proto era )) where
579
607
sameDepIndex2 GetLedgerTip GetLedgerTip =
@@ -727,6 +755,10 @@ instance SameDepIndex2 (BlockQuery (ShelleyBlock proto era)) where
727
755
sameDepIndex2 GetBigLedgerPeerSnapshot _ = Nothing
728
756
sameDepIndex2 QueryStakePoolDefaultVote {} QueryStakePoolDefaultVote {} = Just Refl
729
757
sameDepIndex2 QueryStakePoolDefaultVote {} _ = Nothing
758
+ sameDepIndex2 GetPoolDistr2 {} GetPoolDistr2 {} = Just Refl
759
+ sameDepIndex2 GetPoolDistr2 {} _ = Nothing
760
+ sameDepIndex2 GetStakeDistribution2 {} GetStakeDistribution2 {} = Just Refl
761
+ sameDepIndex2 GetStakeDistribution2 {} _ = Nothing
730
762
731
763
deriving instance Eq (BlockQuery (ShelleyBlock proto era ) fp result )
732
764
deriving instance Show (BlockQuery (ShelleyBlock proto era ) fp result )
@@ -769,6 +801,8 @@ instance ShelleyCompatible proto era => ShowQuery (BlockQuery (ShelleyBlock prot
769
801
GetFuturePParams {} -> show
770
802
GetBigLedgerPeerSnapshot -> show
771
803
QueryStakePoolDefaultVote {} -> show
804
+ GetPoolDistr2 {} -> show
805
+ GetStakeDistribution2 {} -> show
772
806
773
807
{- ------------------------------------------------------------------------------
774
808
Auxiliary
@@ -891,6 +925,10 @@ encodeShelleyQuery query = case query of
891
925
CBOR. encodeListLen 1 <> CBOR. encodeWord8 34
892
926
QueryStakePoolDefaultVote stakePoolKey ->
893
927
CBOR. encodeListLen 2 <> CBOR. encodeWord8 35 <> LC. toEraCBOR @ era stakePoolKey
928
+ GetPoolDistr2 poolids ->
929
+ CBOR. encodeListLen 2 <> CBOR. encodeWord8 36 <> toCBOR poolids
930
+ GetStakeDistribution2 ->
931
+ CBOR. encodeListLen 1 <> CBOR. encodeWord8 37
894
932
895
933
decodeShelleyQuery ::
896
934
forall era proto .
@@ -962,6 +1000,8 @@ decodeShelleyQuery = do
962
1000
(1 , 33 ) -> requireCG $ return $ SomeBlockQuery GetFuturePParams
963
1001
(1 , 34 ) -> return $ SomeBlockQuery GetBigLedgerPeerSnapshot
964
1002
(2 , 35 ) -> requireCG $ SomeBlockQuery . QueryStakePoolDefaultVote <$> LC. fromEraCBOR @ era
1003
+ (2 , 36 ) -> SomeBlockQuery . GetPoolDistr2 <$> fromCBOR
1004
+ (1 , 37 ) -> return $ SomeBlockQuery GetStakeDistribution2
965
1005
_ -> failmsg " invalid"
966
1006
967
1007
encodeShelleyResult ::
@@ -975,8 +1015,8 @@ encodeShelleyResult v query = case query of
975
1015
GetLedgerTip -> encodePoint encode
976
1016
GetEpochNo -> toCBOR
977
1017
GetNonMyopicMemberRewards {} -> toCBOR
978
- GetProposedPParamsUpdates -> toCBOR
979
1018
GetCurrentPParams -> fst $ currentPParamsEnDecoding v
1019
+ GetProposedPParamsUpdates -> toCBOR
980
1020
GetStakeDistribution -> LC. toEraCBOR @ era
981
1021
GetUTxOByAddress {} -> toCBOR
982
1022
GetUTxOWhole -> toCBOR
@@ -1008,6 +1048,8 @@ encodeShelleyResult v query = case query of
1008
1048
GetFuturePParams {} -> LC. toEraCBOR @ era
1009
1049
GetBigLedgerPeerSnapshot -> toCBOR
1010
1050
QueryStakePoolDefaultVote {} -> toCBOR
1051
+ GetPoolDistr2 {} -> LC. toEraCBOR @ era
1052
+ GetStakeDistribution2 {} -> LC. toEraCBOR @ era
1011
1053
1012
1054
decodeShelleyResult ::
1013
1055
forall proto era fp result .
@@ -1020,8 +1062,8 @@ decodeShelleyResult v query = case query of
1020
1062
GetLedgerTip -> decodePoint decode
1021
1063
GetEpochNo -> fromCBOR
1022
1064
GetNonMyopicMemberRewards {} -> fromCBOR
1023
- GetProposedPParamsUpdates -> fromCBOR
1024
1065
GetCurrentPParams -> snd $ currentPParamsEnDecoding v
1066
+ GetProposedPParamsUpdates -> fromCBOR
1025
1067
GetStakeDistribution -> LC. fromEraCBOR @ era
1026
1068
GetUTxOByAddress {} -> fromCBOR
1027
1069
GetUTxOWhole -> fromCBOR
@@ -1053,6 +1095,8 @@ decodeShelleyResult v query = case query of
1053
1095
GetFuturePParams {} -> LC. fromEraCBOR @ era
1054
1096
GetBigLedgerPeerSnapshot -> fromCBOR
1055
1097
QueryStakePoolDefaultVote {} -> fromCBOR
1098
+ GetPoolDistr2 {} -> LC. fromEraCBOR @ era
1099
+ GetStakeDistribution2 -> LC. fromEraCBOR @ era
1056
1100
1057
1101
currentPParamsEnDecoding ::
1058
1102
forall era s .
0 commit comments