Skip to content

Commit 3c89d58

Browse files
committed
add support for new ledger state query for drep delegations.
1 parent 374ef15 commit 3c89d58

File tree

4 files changed

+44
-1
lines changed
  • ouroboros-consensus-cardano/src
  • ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Ledger/Query

4 files changed

+44
-1
lines changed

ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/Node.hs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ module Ouroboros.Consensus.Cardano.Node
4444
, pattern CardanoNodeToClientVersion16
4545
, pattern CardanoNodeToClientVersion17
4646
, pattern CardanoNodeToClientVersion18
47+
, pattern CardanoNodeToClientVersion19
4748
, pattern CardanoNodeToNodeVersion1
4849
, pattern CardanoNodeToNodeVersion2
4950
) where
@@ -422,6 +423,21 @@ pattern CardanoNodeToClientVersion18 =
422423
:* Nil
423424
)
424425

426+
pattern CardanoNodeToClientVersion19 :: BlockNodeToClientVersion (CardanoBlock c)
427+
pattern CardanoNodeToClientVersion19 =
428+
HardForkNodeToClientEnabled
429+
HardForkSpecificNodeToClientVersion3
430+
( EraNodeToClientEnabled ByronNodeToClientVersion1
431+
:* EraNodeToClientEnabled ShelleyNodeToClientVersion15
432+
:* EraNodeToClientEnabled ShelleyNodeToClientVersion15
433+
:* EraNodeToClientEnabled ShelleyNodeToClientVersion15
434+
:* EraNodeToClientEnabled ShelleyNodeToClientVersion15
435+
:* EraNodeToClientEnabled ShelleyNodeToClientVersion15
436+
:* EraNodeToClientEnabled ShelleyNodeToClientVersion15
437+
:* EraNodeToClientEnabled ShelleyNodeToClientVersion15
438+
:* Nil
439+
)
440+
425441
instance
426442
CardanoHardForkConstraints c =>
427443
SupportedNetworkProtocolVersion (CardanoBlock c)
@@ -441,9 +457,10 @@ instance
441457
, (NodeToClientV_20, CardanoNodeToClientVersion16)
442458
, (NodeToClientV_21, CardanoNodeToClientVersion17)
443459
, (NodeToClientV_22, CardanoNodeToClientVersion18)
460+
, (NodeToClientV_23, CardanoNodeToClientVersion19)
444461
]
445462

446-
latestReleasedNodeVersion _prx = (Just NodeToNodeV_15, Just NodeToClientV_22)
463+
latestReleasedNodeVersion _prx = (Just NodeToNodeV_15, Just NodeToClientV_23)
447464

448465
{-------------------------------------------------------------------------------
449466
ProtocolInfo

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/NetworkProtocolVersion.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ data ShelleyNodeToClientVersion
3131
ShelleyNodeToClientVersion13
3232
| -- | Support SRV in GetBigLedgerPeerSnapshot
3333
ShelleyNodeToClientVersion14
34+
-- | New queries introduced: QueryDRepsDelegations
35+
| ShelleyNodeToClientVersion15
3436
deriving (Show, Eq, Ord, Enum, Bounded)
3537

3638
ledgerPeerSnapshotSupportsSRV :: ShelleyNodeToClientVersion -> LedgerPeerSnapshotSRVSupport
@@ -58,6 +60,7 @@ instance SupportedNetworkProtocolVersion (ShelleyBlock proto era) where
5860
, (NodeToClientV_20, ShelleyNodeToClientVersion12)
5961
, (NodeToClientV_21, ShelleyNodeToClientVersion13)
6062
, (NodeToClientV_22, ShelleyNodeToClientVersion14)
63+
, (NodeToClientV_23, ShelleyNodeToClientVersion15)
6164
]
6265

6366
latestReleasedNodeVersion = latestReleasedNodeVersionDefault

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,12 @@ data instance BlockQuery (ShelleyBlock proto era) fp result where
365365
BlockQuery (ShelleyBlock proto era) QFNoTables SL.PoolDistr
366366
GetMaxMajorProtocolVersion ::
367367
BlockQuery (ShelleyBlock proto era) QFNoTables MaxMajorProtVer
368+
GetDRepDelegations ::
369+
Set SL.DRep ->
370+
BlockQuery
371+
(ShelleyBlock proto era)
372+
QFNoTables
373+
(Map SL.DRep (Set (SL.Credential 'SL.Staking)))
368374

369375
-- WARNING: please add new queries to the end of the list and stick to this
370376
-- order in all other pattern matches on queries. This helps in particular
@@ -533,6 +539,8 @@ instance
533539
. configConsensus
534540
. getExtLedgerCfg
535541
$ cfg
542+
GetDRepDelegations dreps ->
543+
SL.queryDRepDelegations st dreps
536544
where
537545
lcfg = configLedger $ getExtLedgerCfg cfg
538546
globals = shelleyLedgerGlobals lcfg
@@ -592,6 +600,7 @@ instance
592600
GetPoolDistr2{} -> (>= v13)
593601
GetStakeDistribution2{} -> (>= v13)
594602
GetMaxMajorProtocolVersion -> (>= v13)
603+
GetDRepDelegations {} -> (>= v14)
595604
where
596605
-- WARNING: when adding a new query, a new @ShelleyNodeToClientVersionX@
597606
-- must be added. See #2830 for a template on how to do this.
@@ -602,6 +611,7 @@ instance
602611
v11 = ShelleyNodeToClientVersion11
603612
v12 = ShelleyNodeToClientVersion12
604613
v13 = ShelleyNodeToClientVersion13
614+
v14 = ShelleyNodeToClientVersion14
605615

606616
instance SameDepIndex2 (BlockQuery (ShelleyBlock proto era)) where
607617
sameDepIndex2 GetLedgerTip GetLedgerTip =
@@ -761,6 +771,12 @@ instance SameDepIndex2 (BlockQuery (ShelleyBlock proto era)) where
761771
sameDepIndex2 GetStakeDistribution2{} _ = Nothing
762772
sameDepIndex2 GetMaxMajorProtocolVersion{} GetMaxMajorProtocolVersion{} = Just Refl
763773
sameDepIndex2 GetMaxMajorProtocolVersion{} _ = Nothing
774+
sameDepIndex2 (GetDRepDelegations dreps) (GetDRepDelegations dreps')
775+
| dreps == dreps' =
776+
Just Refl
777+
| otherwise =
778+
Nothing
779+
sameDepIndex2 GetDRepDelegations{} _ = Nothing
764780

765781
deriving instance Eq (BlockQuery (ShelleyBlock proto era) fp result)
766782
deriving instance Show (BlockQuery (ShelleyBlock proto era) fp result)
@@ -806,6 +822,7 @@ instance ShelleyCompatible proto era => ShowQuery (BlockQuery (ShelleyBlock prot
806822
GetPoolDistr2{} -> show
807823
GetStakeDistribution2{} -> show
808824
GetMaxMajorProtocolVersion{} -> show
825+
GetDRepDelegations {} -> show
809826

810827
{-------------------------------------------------------------------------------
811828
Auxiliary
@@ -930,6 +947,8 @@ encodeShelleyQuery query = case query of
930947
CBOR.encodeListLen 1 <> CBOR.encodeWord8 37
931948
GetMaxMajorProtocolVersion ->
932949
CBOR.encodeListLen 1 <> CBOR.encodeWord8 38
950+
GetDRepDelegations dreps ->
951+
CBOR.encodeListLen 2 <> CBOR.encodeWord8 39 <> LC.toEraCBOR @era dreps
933952

934953
decodeShelleyQuery ::
935954
forall era proto.
@@ -1004,6 +1023,7 @@ decodeShelleyQuery = do
10041023
(2, 36) -> SomeBlockQuery . GetPoolDistr2 <$> fromCBOR
10051024
(1, 37) -> return $ SomeBlockQuery GetStakeDistribution2
10061025
(1, 38) -> return $ SomeBlockQuery GetMaxMajorProtocolVersion
1026+
(2, 39) -> SomeBlockQuery . GetDRepDelegations <$> LC.fromEraCBOR @era
10071027
_ -> failmsg "invalid"
10081028

10091029
encodeShelleyResult ::
@@ -1053,6 +1073,7 @@ encodeShelleyResult v query = case query of
10531073
GetPoolDistr2{} -> LC.toEraCBOR @era
10541074
GetStakeDistribution2{} -> LC.toEraCBOR @era
10551075
GetMaxMajorProtocolVersion -> toCBOR
1076+
GetDRepDelegations {} -> LC.toEraCBOR @era
10561077

10571078
decodeShelleyResult ::
10581079
forall proto era fp result.
@@ -1101,6 +1122,7 @@ decodeShelleyResult v query = case query of
11011122
GetPoolDistr2{} -> LC.fromEraCBOR @era
11021123
GetStakeDistribution2 -> LC.fromEraCBOR @era
11031124
GetMaxMajorProtocolVersion -> fromCBOR
1125+
GetDRepDelegations {} -> LC.fromEraCBOR @era
11041126

11051127
currentPParamsEnDecoding ::
11061128
forall era s.

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Ledger/Query/Version.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ nodeToClientVersionToQueryVersion x = case x of
2828
NodeToClientV_20 -> QueryVersion3
2929
NodeToClientV_21 -> QueryVersion3
3030
NodeToClientV_22 -> QueryVersion3
31+
NodeToClientV_23 -> QueryVersion3

0 commit comments

Comments
 (0)