diff --git a/ouroboros-consensus-cardano/changelog.d/20240917_143437_damian.nadales.md b/ouroboros-consensus-cardano/changelog.d/20240917_143437_damian.nadales.md new file mode 100644 index 0000000000..fc973af7a1 --- /dev/null +++ b/ouroboros-consensus-cardano/changelog.d/20240917_143437_damian.nadales.md @@ -0,0 +1,3 @@ +### Breaking + +- Add `GetFuturePParams` query. diff --git a/ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/Node.hs b/ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/Node.hs index f4665d9851..f6aa673e42 100644 --- a/ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/Node.hs +++ b/ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/Node.hs @@ -45,6 +45,7 @@ module Ouroboros.Consensus.Cardano.Node ( , pattern CardanoNodeToClientVersion11 , pattern CardanoNodeToClientVersion12 , pattern CardanoNodeToClientVersion13 + , pattern CardanoNodeToClientVersion14 , pattern CardanoNodeToClientVersion2 , pattern CardanoNodeToClientVersion3 , pattern CardanoNodeToClientVersion4 @@ -474,6 +475,23 @@ pattern CardanoNodeToClientVersion13 = :* Nil ) +-- | The hard fork enabled, and the Shelley, Allegra, Mary, Alonzo and Babbage +-- and Conway eras enabled, using 'ShelleyNodeToClientVersion10' 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 $ @@ -496,9 +514,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 diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/NetworkProtocolVersion.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/NetworkProtocolVersion.hs index c9b08fd4cb..d7a5898212 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/NetworkProtocolVersion.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/NetworkProtocolVersion.hs @@ -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 @@ -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 diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs index 87de176f78..d244152ef3 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs @@ -308,6 +308,9 @@ data instance BlockQuery (ShelleyBlock proto era) :: Type -> Type where :: CG.ConwayEraGov era => BlockQuery (ShelleyBlock proto era) (CG.RatifyState era) + GetFuturePParams + :: 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. @@ -468,6 +471,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 @@ -627,6 +632,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) @@ -666,6 +673,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 @@ -703,18 +711,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 @@ -833,6 +843,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 @@ -893,6 +905,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 :: @@ -933,6 +946,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 @@ -973,6 +987,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. diff --git a/ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano/Golden.hs b/ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano/Golden.hs index c1bbd91802..30f5204a16 100644 --- a/ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano/Golden.hs +++ b/ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano/Golden.hs @@ -45,4 +45,5 @@ instance CardanoHardForkConstraints c CardanoNodeToClientVersion11 -> "CardanoNodeToClientVersion11" CardanoNodeToClientVersion12 -> "CardanoNodeToClientVersion12" CardanoNodeToClientVersion13 -> "CardanoNodeToClientVersion13" + CardanoNodeToClientVersion14 -> "CardanoNodeToClientVersion14" _ -> error $ "Unknown version: " <> show blockVersion