Skip to content

Commit

Permalink
Add a new GetFuturePParams query
Browse files Browse the repository at this point in the history
  • Loading branch information
dnadales committed Sep 17, 2024
1 parent f042d6b commit 1763348
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
+### Breaking
+
+- Add `GetFuturePParams` query.
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,23 @@ pattern CardanoNodeToClientVersion13 =
:* Nil
)

-- | The hard fork enabled, and the Shelley, Allegra, Mary, Alonzo and Babbage
-- and Conway eras enabled, using 'ShelleyNodeToClientVersion9' for the
-- Shelley-based eras.
pattern CardanoNodeToClientVersion14 :: BlockNodeToClientVersion (CardanoBlock c)
pattern CardanoNodeToClientVersion14 =
HardForkNodeToClientEnabled
HardForkSpecificNodeToClientVersion3
( EraNodeToClientEnabled ByronNodeToClientVersion1
:* EraNodeToClientEnabled ShelleyNodeToClientVersion10
:* EraNodeToClientEnabled ShelleyNodeToClientVersion10
:* EraNodeToClientEnabled ShelleyNodeToClientVersion10
:* EraNodeToClientEnabled ShelleyNodeToClientVersion10
:* EraNodeToClientEnabled ShelleyNodeToClientVersion10
:* EraNodeToClientEnabled ShelleyNodeToClientVersion10
:* Nil
)

instance CardanoHardForkConstraints c
=> SupportedNetworkProtocolVersion (CardanoBlock c) where
supportedNodeToNodeVersions _ = Map.fromList $
Expand All @@ -496,9 +513,10 @@ instance CardanoHardForkConstraints c
, (NodeToClientV_15, CardanoNodeToClientVersion11)
, (NodeToClientV_16, CardanoNodeToClientVersion12)
, (NodeToClientV_17, CardanoNodeToClientVersion13)
, (NodeToClientV_17, CardanoNodeToClientVersion14) -- FIXME: use NodeToClientV_18 once it's available in ouroboros-network
]

latestReleasedNodeVersion _prx = (Just NodeToNodeV_13, Just NodeToClientV_17)
latestReleasedNodeVersion _prx = (Just NodeToNodeV_13, Just NodeToClientV_17) -- FIXME: use NodeToClientV_18 once it's available in ouroboros-network

{-------------------------------------------------------------------------------
ProtocolInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ data ShelleyNodeToClientVersion =

-- | New queries introduced: GetProposals, GetRatifyState
| ShelleyNodeToClientVersion9

-- | New queries introduced: GetFuturePParams
| ShelleyNodeToClientVersion10
deriving (Show, Eq, Ord, Enum, Bounded)

instance HasNetworkProtocolVersion (ShelleyBlock proto era) where
Expand Down Expand Up @@ -67,6 +70,7 @@ instance SupportedNetworkProtocolVersion (ShelleyBlock proto era) where
, (NodeToClientV_15, ShelleyNodeToClientVersion7)
, (NodeToClientV_16, ShelleyNodeToClientVersion8)
, (NodeToClientV_17, ShelleyNodeToClientVersion9)
, (NodeToClientV_17, ShelleyNodeToClientVersion10) -- FIXME: use NodeToClientV_18 once it's available in ouroboros-network
]

latestReleasedNodeVersion = latestReleasedNodeVersionDefault
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ data instance BlockQuery (ShelleyBlock proto era) :: Type -> Type where
:: CG.ConwayEraGov era
=> BlockQuery (ShelleyBlock proto era) (CG.RatifyState era)

GetFuturePParams
:: CG.ConwayEraGov era
=> BlockQuery (ShelleyBlock proto era) (Maybe (LC.PParams era))

-- WARNING: please add new queries to the end of the list and stick to this
-- order in all other pattern matches on queries. This helps in particular
-- with the en/decoders, as we want the CBOR tags to be ordered.
Expand Down Expand Up @@ -468,6 +472,8 @@ instance (ShelleyCompatible proto era, ProtoCrypto proto ~ crypto)
SL.queryProposals st gids
GetRatifyState ->
SL.queryRatifyState st
GetFuturePParams ->
SL.queryFuturePParams st
where
lcfg = configLedger $ getExtLedgerCfg cfg
globals = shelleyLedgerGlobals lcfg
Expand Down Expand Up @@ -627,6 +633,8 @@ instance SameDepIndex (BlockQuery (ShelleyBlock proto era)) where
sameDepIndex GetProposals{} _ = Nothing
sameDepIndex GetRatifyState{} GetRatifyState{} = Just Refl
sameDepIndex GetRatifyState{} _ = Nothing
sameDepIndex GetFuturePParams{} GetFuturePParams{} = Just Refl
sameDepIndex GetFuturePParams{} _ = Nothing

deriving instance Eq (BlockQuery (ShelleyBlock proto era) result)
deriving instance Show (BlockQuery (ShelleyBlock proto era) result)
Expand Down Expand Up @@ -666,6 +674,7 @@ instance ShelleyCompatible proto era => ShowQuery (BlockQuery (ShelleyBlock prot
GetSPOStakeDistr {} -> show
GetProposals {} -> show
GetRatifyState {} -> show
GetFuturePParams {} -> show

-- | Is the given query supported by the given 'ShelleyNodeToClientVersion'?
querySupportedVersion :: BlockQuery (ShelleyBlock proto era) result -> ShelleyNodeToClientVersion -> Bool
Expand Down Expand Up @@ -703,18 +712,20 @@ querySupportedVersion = \case
GetSPOStakeDistr {} -> (>= v8)
GetProposals {} -> (>= v9)
GetRatifyState {} -> (>= v9)
GetFuturePParams {} -> (>= v10)
-- WARNING: when adding a new query, a new @ShelleyNodeToClientVersionX@
-- must be added. See #2830 for a template on how to do this.
where
v1 = ShelleyNodeToClientVersion1
v2 = ShelleyNodeToClientVersion2
v3 = ShelleyNodeToClientVersion3
v4 = ShelleyNodeToClientVersion4
v5 = ShelleyNodeToClientVersion5
v6 = ShelleyNodeToClientVersion6
v7 = ShelleyNodeToClientVersion7
v8 = ShelleyNodeToClientVersion8
v9 = ShelleyNodeToClientVersion9
v1 = ShelleyNodeToClientVersion1
v2 = ShelleyNodeToClientVersion2
v3 = ShelleyNodeToClientVersion3
v4 = ShelleyNodeToClientVersion4
v5 = ShelleyNodeToClientVersion5
v6 = ShelleyNodeToClientVersion6
v7 = ShelleyNodeToClientVersion7
v8 = ShelleyNodeToClientVersion8
v9 = ShelleyNodeToClientVersion9
v10 = ShelleyNodeToClientVersion10

{-------------------------------------------------------------------------------
Auxiliary
Expand Down Expand Up @@ -833,6 +844,8 @@ encodeShelleyQuery query = case query of
CBOR.encodeListLen 2 <> CBOR.encodeWord8 31 <> LC.toEraCBOR @era gids
GetRatifyState ->
CBOR.encodeListLen 1 <> CBOR.encodeWord8 32
GetFuturePParams ->
CBOR.encodeListLen 1 <> CBOR.encodeWord8 33

decodeShelleyQuery ::
forall era proto. ShelleyBasedEra era
Expand Down Expand Up @@ -893,6 +906,7 @@ decodeShelleyQuery = do
(2, 30) -> requireCG $ SomeSecond . GetSPOStakeDistr <$> LC.fromEraCBOR @era
(2, 31) -> requireCG $ SomeSecond . GetProposals <$> LC.fromEraCBOR @era
(1, 32) -> requireCG $ return $ SomeSecond GetRatifyState
(1, 33) -> requireCG $ return $ SomeSecond GetFuturePParams
_ -> failmsg "invalid"

encodeShelleyResult ::
Expand Down Expand Up @@ -933,6 +947,7 @@ encodeShelleyResult v query = case query of
GetSPOStakeDistr {} -> LC.toEraCBOR @era
GetProposals {} -> LC.toEraCBOR @era
GetRatifyState {} -> LC.toEraCBOR @era
GetFuturePParams {} -> LC.toEraCBOR @era

decodeShelleyResult ::
forall proto era result. ShelleyCompatible proto era
Expand Down Expand Up @@ -973,6 +988,7 @@ decodeShelleyResult v query = case query of
GetSPOStakeDistr {} -> LC.fromEraCBOR @era
GetProposals {} -> LC.fromEraCBOR @era
GetRatifyState {} -> LC.fromEraCBOR @era
GetFuturePParams {} -> LC.fromEraCBOR @era

currentPParamsEnDecoding ::
forall era s.
Expand Down

0 comments on commit 1763348

Please sign in to comment.