From c330c4cf623b457d65510500889e7254d6ff61ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Thu, 30 May 2024 17:21:45 +0200 Subject: [PATCH 1/2] Add deprecation stanzas to ProtocolParameters and functions producing them --- .../internal/Cardano/Api/ProtocolParameters.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs index 767e08a613..573dcb94fc 100644 --- a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs +++ b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs @@ -175,8 +175,7 @@ instance IsShelleyBasedEra era => Eq (LedgerProtocolParameters era) where shelleyBasedEraConstraints (shelleyBasedEra @era) $ a == b --- TODO: Conway era - remove me when we begin relying on the JSON --- instances of Ledger.PParams +{-# DEPRECATED convertToLedgerProtocolParameters "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-} convertToLedgerProtocolParameters :: ShelleyBasedEra era -> ProtocolParameters @@ -465,6 +464,7 @@ createIntroducedInBabbagePParams w (IntroducedInBabbagePParams coinsPerUTxOByte) -- -- There are also parameters fixed in the Genesis file. See 'GenesisParameters'. -- +{-# DEPRECATED ProtocolParameters "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters" #-} data ProtocolParameters = ProtocolParameters { @@ -1669,6 +1669,7 @@ toConwayPParams = toBabbagePParams -- Conversion functions: protocol parameters from ledger types -- +{-# DEPRECATED fromLedgerPParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-} fromLedgerPParams :: ShelleyBasedEra era -> Ledger.PParams (ShelleyLedgerEra era) @@ -1681,6 +1682,7 @@ fromLedgerPParams ShelleyBasedEraBabbage = fromBabbagePParams fromLedgerPParams ShelleyBasedEraConway = fromConwayPParams +{-# DEPRECATED fromShelleyCommonPParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-} fromShelleyCommonPParams :: EraPParams ledgerera => PParams ledgerera -> ProtocolParameters @@ -1714,6 +1716,7 @@ fromShelleyCommonPParams pp = , protocolParamMinUTxOValue = Nothing -- Obsolete from Alonzo onwards } +{-# DEPRECATED fromShelleyPParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-} fromShelleyPParams :: ( EraPParams ledgerera , Ledger.AtMostEra Ledger.MaryEra ledgerera , Ledger.AtMostEra Ledger.AlonzoEra ledgerera @@ -1728,6 +1731,7 @@ fromShelleyPParams pp = } +{-# DEPRECATED fromAlonzoPParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-} fromAlonzoPParams :: AlonzoEraPParams ledgerera => PParams ledgerera -> ProtocolParameters @@ -1743,6 +1747,7 @@ fromAlonzoPParams pp = , protocolParamMaxCollateralInputs = Just $ pp ^. ppMaxCollateralInputsL } +{-# DEPRECATED fromExactlyAlonzoPParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-} fromExactlyAlonzoPParams :: (AlonzoEraPParams ledgerera, Ledger.ExactEra Ledger.AlonzoEra ledgerera) => PParams ledgerera -> ProtocolParameters @@ -1751,6 +1756,7 @@ fromExactlyAlonzoPParams pp = protocolParamUTxOCostPerByte = Just . unCoinPerWord $ pp ^. ppCoinsPerUTxOWordL } +{-# DEPRECATED fromBabbagePParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-} fromBabbagePParams :: BabbageEraPParams ledgerera => PParams ledgerera -> ProtocolParameters @@ -1760,11 +1766,13 @@ fromBabbagePParams pp = , protocolParamDecentralization = Nothing } +{-# DEPRECATED fromConwayPParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-} fromConwayPParams :: BabbageEraPParams ledgerera => PParams ledgerera -> ProtocolParameters fromConwayPParams = fromBabbagePParams +{-# DEPRECATED checkProtocolParameters "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters. PParams natively enforce these checks." #-} checkProtocolParameters :: () => ShelleyBasedEra era -> ProtocolParameters From 0481fd8979dfbf50f6b57ada6eab67a662b50cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Fri, 31 May 2024 11:02:07 +0200 Subject: [PATCH 2/2] Adapt tests --- .../Test/Golden/Cardano/Api/ProtocolParameters.hs | 3 +++ .../cardano-api-test/Test/Cardano/Api/ProtocolParameters.hs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/cardano-api/test/cardano-api-golden/Test/Golden/Cardano/Api/ProtocolParameters.hs b/cardano-api/test/cardano-api-golden/Test/Golden/Cardano/Api/ProtocolParameters.hs index 54f720b692..d2309136b1 100644 --- a/cardano-api/test/cardano-api-golden/Test/Golden/Cardano/Api/ProtocolParameters.hs +++ b/cardano-api/test/cardano-api-golden/Test/Golden/Cardano/Api/ProtocolParameters.hs @@ -3,6 +3,9 @@ {-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE ScopedTypeVariables #-} +-- TODO remove me when ProtocolParameters is deleted +{-# OPTIONS_GHC -Wno-deprecations #-} + module Test.Golden.Cardano.Api.ProtocolParameters ( test_golden_ProtocolParameters , test_golden_ProtocolParameters_to_PParams diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/ProtocolParameters.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/ProtocolParameters.hs index 8f566ce0a7..f93a1ec447 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/ProtocolParameters.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/ProtocolParameters.hs @@ -3,6 +3,9 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} +-- TODO remove me when ProtocolParameters is deleted +{-# OPTIONS_GHC -Wno-deprecations #-} + module Test.Cardano.Api.ProtocolParameters ( tests ) where