@@ -138,7 +138,14 @@ type Delegations = Map (SL.Credential 'SL.Staking) (SL.KeyHash 'SL.StakePool)
138
138
139
139
type VoteDelegatees = Map (SL. Credential 'SL.Staking ) SL. DRep
140
140
141
- {-# DEPRECATED GetProposedPParamsUpdates "Deprecated in ShelleyNodeToClientVersion12" #-}
141
+ {-# DEPRECATED
142
+ GetPoolDistr
143
+ "Deprecated in ShelleyNodeToClientVersion13. Implement the new alterative GetPoolDistr2"
144
+ #-}
145
+ {-# DEPRECATED
146
+ GetStakeDistribution
147
+ "Deprecated in ShelleyNodeToClientVersion13. Implement the new alterative GetStakeDistribution2"
148
+ #-}
142
149
143
150
data instance BlockQuery (ShelleyBlock proto era ) fp result where
144
151
GetLedgerTip :: BlockQuery (ShelleyBlock proto era ) QFNoTables (Point (ShelleyBlock proto era ))
@@ -150,8 +157,6 @@ data instance BlockQuery (ShelleyBlock proto era) fp result where
150
157
BlockQuery (ShelleyBlock proto era ) QFNoTables NonMyopicMemberRewards
151
158
GetCurrentPParams ::
152
159
BlockQuery (ShelleyBlock proto era ) QFNoTables (LC. PParams era )
153
- GetProposedPParamsUpdates ::
154
- BlockQuery (ShelleyBlock proto era ) QFNoTables (SL. ProposedPPUpdates era )
155
160
-- | This gets the stake distribution, but not in terms of _active_ stake
156
161
-- (which we need for the leader schedule), but rather in terms of _total_
157
162
-- stake, which is relevant for rewards. It is used by the wallet to show
@@ -338,6 +343,20 @@ data instance BlockQuery (ShelleyBlock proto era) fp result where
338
343
CG. ConwayEraGov era =>
339
344
KeyHash 'StakePool ->
340
345
BlockQuery (ShelleyBlock proto era ) QFNoTables CG. DefaultVote
346
+ GetPoolDistr2 ::
347
+ Maybe (Set (SL. KeyHash 'SL.StakePool )) ->
348
+ BlockQuery
349
+ (ShelleyBlock proto era )
350
+ QFNoTables
351
+ SL. PoolDistr
352
+ -- | This gets the stake distribution, but not in terms of _active_ stake
353
+ -- (which we need for the leader schedule), but rather in terms of _total_
354
+ -- stake, which is relevant for rewards. It is used by the wallet to show
355
+ -- saturation levels to the end user. We should consider refactoring this, to
356
+ -- an endpoint that provides all the information that the wallet wants about
357
+ -- pools, in an extensible fashion.
358
+ GetStakeDistribution2 ::
359
+ BlockQuery (ShelleyBlock proto era ) QFNoTables SL. PoolDistr
341
360
342
361
-- WARNING: please add new queries to the end of the list and stick to this
343
362
-- order in all other pattern matches on queries. This helps in particular
@@ -376,10 +395,8 @@ instance
376
395
SL. getNonMyopicMemberRewards globals st creds
377
396
GetCurrentPParams ->
378
397
getPParams st
379
- GetProposedPParamsUpdates ->
380
- SL. ProposedPPUpdates Map. empty
381
398
GetStakeDistribution ->
382
- fromLedgerPoolDistr $ SL. poolsByTotalStakeFraction globals st
399
+ fromLedgerPoolDistr $ answerPureBlockQuery cfg GetStakeDistribution2 ext
383
400
DebugEpochState ->
384
401
getEpochState st
385
402
GetCBOR query' ->
@@ -469,9 +486,7 @@ instance
469
486
, ssGoTotal = getAllStake ssStakeGo
470
487
}
471
488
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
489
+ fromLedgerPoolDistr $ answerPureBlockQuery cfg (GetPoolDistr2 mPoolIds) ext
475
490
GetStakeDelegDeposits stakeCreds ->
476
491
let lookupDeposit =
477
492
SL. lookupDepositDState (view SL. certDStateL $ SL. lsCertState $ SL. esLState $ SL. nesEs st)
@@ -509,6 +524,11 @@ instance
509
524
in LedgerPeerSnapshot (slot, bigLedgerPeers)
510
525
QueryStakePoolDefaultVote stakePool ->
511
526
SL. queryStakePoolDefaultVote st stakePool
527
+ GetPoolDistr2 mPoolIds ->
528
+ let stakeSet = SL. ssStakeSet . SL. esSnapshots $ getEpochState st
529
+ in SL. calculatePoolDistr' (maybe (const True ) (flip Set. member) mPoolIds) stakeSet
530
+ GetStakeDistribution2 ->
531
+ SL. poolsByTotalStakeFraction globals st
512
532
where
513
533
lcfg = configLedger $ getExtLedgerCfg cfg
514
534
globals = shelleyLedgerGlobals lcfg
@@ -533,8 +553,7 @@ instance
533
553
GetEpochNo -> const True
534
554
GetNonMyopicMemberRewards {} -> const True
535
555
GetCurrentPParams -> const True
536
- GetProposedPParamsUpdates -> (< v12)
537
- GetStakeDistribution -> const True
556
+ GetStakeDistribution -> (< v13)
538
557
GetUTxOByAddress {} -> const True
539
558
GetUTxOWhole -> const True
540
559
DebugEpochState -> const True
@@ -550,7 +569,7 @@ instance
550
569
GetRewardInfoPools -> const True
551
570
GetPoolState {} -> const True
552
571
GetStakeSnapshots {} -> const True
553
- GetPoolDistr {} -> const True
572
+ GetPoolDistr {} -> ( < v13)
554
573
GetStakeDelegDeposits {} -> const True
555
574
GetConstitution -> (>= v8)
556
575
GetGovState -> (>= v8)
@@ -565,6 +584,8 @@ instance
565
584
GetFuturePParams {} -> (>= v10)
566
585
GetBigLedgerPeerSnapshot -> (>= v11)
567
586
QueryStakePoolDefaultVote {} -> (>= v12)
587
+ GetPoolDistr2 {} -> (>= v13)
588
+ GetStakeDistribution2 {} -> (>= v13)
568
589
where
569
590
-- WARNING: when adding a new query, a new @ShelleyNodeToClientVersionX@
570
591
-- must be added. See #2830 for a template on how to do this.
@@ -574,6 +595,7 @@ instance
574
595
v10 = ShelleyNodeToClientVersion10
575
596
v11 = ShelleyNodeToClientVersion11
576
597
v12 = ShelleyNodeToClientVersion12
598
+ v13 = ShelleyNodeToClientVersion13
577
599
578
600
instance SameDepIndex2 (BlockQuery (ShelleyBlock proto era )) where
579
601
sameDepIndex2 GetLedgerTip GetLedgerTip =
@@ -595,10 +617,6 @@ instance SameDepIndex2 (BlockQuery (ShelleyBlock proto era)) where
595
617
Just Refl
596
618
sameDepIndex2 GetCurrentPParams _ =
597
619
Nothing
598
- sameDepIndex2 GetProposedPParamsUpdates GetProposedPParamsUpdates =
599
- Just Refl
600
- sameDepIndex2 GetProposedPParamsUpdates _ =
601
- Nothing
602
620
sameDepIndex2 GetStakeDistribution GetStakeDistribution =
603
621
Just Refl
604
622
sameDepIndex2 GetStakeDistribution _ =
@@ -727,6 +745,10 @@ instance SameDepIndex2 (BlockQuery (ShelleyBlock proto era)) where
727
745
sameDepIndex2 GetBigLedgerPeerSnapshot _ = Nothing
728
746
sameDepIndex2 QueryStakePoolDefaultVote {} QueryStakePoolDefaultVote {} = Just Refl
729
747
sameDepIndex2 QueryStakePoolDefaultVote {} _ = Nothing
748
+ sameDepIndex2 GetPoolDistr2 {} GetPoolDistr2 {} = Just Refl
749
+ sameDepIndex2 GetPoolDistr2 {} _ = Nothing
750
+ sameDepIndex2 GetStakeDistribution2 {} GetStakeDistribution2 {} = Just Refl
751
+ sameDepIndex2 GetStakeDistribution2 {} _ = Nothing
730
752
731
753
deriving instance Eq (BlockQuery (ShelleyBlock proto era ) fp result )
732
754
deriving instance Show (BlockQuery (ShelleyBlock proto era ) fp result )
@@ -737,7 +759,6 @@ instance ShelleyCompatible proto era => ShowQuery (BlockQuery (ShelleyBlock prot
737
759
GetEpochNo -> show
738
760
GetNonMyopicMemberRewards {} -> show
739
761
GetCurrentPParams -> show
740
- GetProposedPParamsUpdates -> show
741
762
GetStakeDistribution -> show
742
763
GetUTxOByAddress {} -> show
743
764
GetUTxOWhole -> show
@@ -769,6 +790,8 @@ instance ShelleyCompatible proto era => ShowQuery (BlockQuery (ShelleyBlock prot
769
790
GetFuturePParams {} -> show
770
791
GetBigLedgerPeerSnapshot -> show
771
792
QueryStakePoolDefaultVote {} -> show
793
+ GetPoolDistr2 {} -> show
794
+ GetStakeDistribution2 {} -> show
772
795
773
796
{- ------------------------------------------------------------------------------
774
797
Auxiliary
@@ -823,8 +846,6 @@ encodeShelleyQuery query = case query of
823
846
CBOR. encodeListLen 2 <> CBOR. encodeWord8 2 <> toCBOR creds
824
847
GetCurrentPParams ->
825
848
CBOR. encodeListLen 1 <> CBOR. encodeWord8 3
826
- GetProposedPParamsUpdates ->
827
- CBOR. encodeListLen 1 <> CBOR. encodeWord8 4
828
849
GetStakeDistribution ->
829
850
CBOR. encodeListLen 1 <> CBOR. encodeWord8 5
830
851
GetUTxOByAddress addrs ->
@@ -891,6 +912,10 @@ encodeShelleyQuery query = case query of
891
912
CBOR. encodeListLen 1 <> CBOR. encodeWord8 34
892
913
QueryStakePoolDefaultVote stakePoolKey ->
893
914
CBOR. encodeListLen 2 <> CBOR. encodeWord8 35 <> LC. toEraCBOR @ era stakePoolKey
915
+ GetPoolDistr2 poolids ->
916
+ CBOR. encodeListLen 2 <> CBOR. encodeWord8 36 <> toCBOR poolids
917
+ GetStakeDistribution2 ->
918
+ CBOR. encodeListLen 1 <> CBOR. encodeWord8 37
894
919
895
920
decodeShelleyQuery ::
896
921
forall era proto .
@@ -925,7 +950,6 @@ decodeShelleyQuery = do
925
950
(1 , 1 ) -> return $ SomeBlockQuery GetEpochNo
926
951
(2 , 2 ) -> SomeBlockQuery . GetNonMyopicMemberRewards <$> fromCBOR
927
952
(1 , 3 ) -> return $ SomeBlockQuery GetCurrentPParams
928
- (1 , 4 ) -> return $ SomeBlockQuery GetProposedPParamsUpdates
929
953
(1 , 5 ) -> return $ SomeBlockQuery GetStakeDistribution
930
954
(2 , 6 ) -> SomeBlockQuery . GetUTxOByAddress <$> LC. fromEraCBOR @ era
931
955
(1 , 7 ) -> return $ SomeBlockQuery GetUTxOWhole
@@ -962,6 +986,8 @@ decodeShelleyQuery = do
962
986
(1 , 33 ) -> requireCG $ return $ SomeBlockQuery GetFuturePParams
963
987
(1 , 34 ) -> return $ SomeBlockQuery GetBigLedgerPeerSnapshot
964
988
(2 , 35 ) -> requireCG $ SomeBlockQuery . QueryStakePoolDefaultVote <$> LC. fromEraCBOR @ era
989
+ (2 , 36 ) -> SomeBlockQuery . GetPoolDistr2 <$> fromCBOR
990
+ (1 , 37 ) -> return $ SomeBlockQuery GetStakeDistribution2
965
991
_ -> failmsg " invalid"
966
992
967
993
encodeShelleyResult ::
@@ -975,7 +1001,6 @@ encodeShelleyResult v query = case query of
975
1001
GetLedgerTip -> encodePoint encode
976
1002
GetEpochNo -> toCBOR
977
1003
GetNonMyopicMemberRewards {} -> toCBOR
978
- GetProposedPParamsUpdates -> toCBOR
979
1004
GetCurrentPParams -> fst $ currentPParamsEnDecoding v
980
1005
GetStakeDistribution -> LC. toEraCBOR @ era
981
1006
GetUTxOByAddress {} -> toCBOR
@@ -1008,6 +1033,8 @@ encodeShelleyResult v query = case query of
1008
1033
GetFuturePParams {} -> LC. toEraCBOR @ era
1009
1034
GetBigLedgerPeerSnapshot -> toCBOR
1010
1035
QueryStakePoolDefaultVote {} -> toCBOR
1036
+ GetPoolDistr2 {} -> LC. toEraCBOR @ era
1037
+ GetStakeDistribution2 {} -> LC. toEraCBOR @ era
1011
1038
1012
1039
decodeShelleyResult ::
1013
1040
forall proto era fp result .
@@ -1020,7 +1047,6 @@ decodeShelleyResult v query = case query of
1020
1047
GetLedgerTip -> decodePoint decode
1021
1048
GetEpochNo -> fromCBOR
1022
1049
GetNonMyopicMemberRewards {} -> fromCBOR
1023
- GetProposedPParamsUpdates -> fromCBOR
1024
1050
GetCurrentPParams -> snd $ currentPParamsEnDecoding v
1025
1051
GetStakeDistribution -> LC. fromEraCBOR @ era
1026
1052
GetUTxOByAddress {} -> fromCBOR
@@ -1053,6 +1079,8 @@ decodeShelleyResult v query = case query of
1053
1079
GetFuturePParams {} -> LC. fromEraCBOR @ era
1054
1080
GetBigLedgerPeerSnapshot -> fromCBOR
1055
1081
QueryStakePoolDefaultVote {} -> fromCBOR
1082
+ GetPoolDistr2 {} -> LC. fromEraCBOR @ era
1083
+ GetStakeDistribution2 -> LC. fromEraCBOR @ era
1056
1084
1057
1085
currentPParamsEnDecoding ::
1058
1086
forall era s .
0 commit comments