Skip to content

Commit

Permalink
Merge pull request #358 from input-output-hk/smelc/conway-protocol-ve…
Browse files Browse the repository at this point in the history
…rsion-change-not-common-anymore

Protocol version change is not common to all versions anymore
  • Loading branch information
smelc authored Nov 6, 2023
2 parents be8142d + ad103a1 commit 914c7f3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
35 changes: 22 additions & 13 deletions cardano-api/internal/Cardano/Api/ProtocolParameters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module Cardano.Api.ProtocolParameters (
EraBasedProtocolParametersUpdate(..),
AlonzoOnwardsPParams(..),
CommonProtocolParametersUpdate(..),
DeprecatedAfterBabbagePParams(..),
DeprecatedAfterMaryPParams(..),
ShelleyToAlonzoPParams(..),
IntroducedInBabbagePParams(..),
Expand Down Expand Up @@ -194,30 +195,35 @@ data EraBasedProtocolParametersUpdate era where
ShelleyEraBasedProtocolParametersUpdate
:: CommonProtocolParametersUpdate
-> DeprecatedAfterMaryPParams ShelleyEra
-> DeprecatedAfterBabbagePParams ShelleyEra
-> ShelleyToAlonzoPParams ShelleyEra
-> EraBasedProtocolParametersUpdate ShelleyEra

AllegraEraBasedProtocolParametersUpdate
:: CommonProtocolParametersUpdate
-> DeprecatedAfterMaryPParams AllegraEra
-> ShelleyToAlonzoPParams AllegraEra
-> DeprecatedAfterBabbagePParams ShelleyEra
-> EraBasedProtocolParametersUpdate AllegraEra

MaryEraBasedProtocolParametersUpdate
:: CommonProtocolParametersUpdate
-> DeprecatedAfterMaryPParams MaryEra
-> ShelleyToAlonzoPParams MaryEra
-> DeprecatedAfterBabbagePParams ShelleyEra
-> EraBasedProtocolParametersUpdate MaryEra

AlonzoEraBasedProtocolParametersUpdate
:: CommonProtocolParametersUpdate
-> ShelleyToAlonzoPParams AlonzoEra
-> AlonzoOnwardsPParams AlonzoEra
-> DeprecatedAfterBabbagePParams ShelleyEra
-> EraBasedProtocolParametersUpdate AlonzoEra

BabbageEraBasedProtocolParametersUpdate
:: CommonProtocolParametersUpdate
-> AlonzoOnwardsPParams BabbageEra
-> DeprecatedAfterBabbagePParams ShelleyEra
-> IntroducedInBabbagePParams BabbageEra
-> EraBasedProtocolParametersUpdate BabbageEra

Expand Down Expand Up @@ -266,37 +272,37 @@ createEraBasedProtocolParamUpdate
-> Ledger.PParamsUpdate (ShelleyLedgerEra era)
createEraBasedProtocolParamUpdate sbe eraPParamsUpdate =
case eraPParamsUpdate of
ShelleyEraBasedProtocolParametersUpdate c depAfterMary depAfterAlonzo ->
ShelleyEraBasedProtocolParametersUpdate c depAfterMary depAfterBabbage depAfterAlonzo ->
let Ledger.PParamsUpdate common = createCommonPParamsUpdate c
Ledger.PParamsUpdate withProtVer = createPreConwayProtocolVersionUpdate c
Ledger.PParamsUpdate withProtVer = createPreConwayProtocolVersionUpdate depAfterBabbage
Ledger.PParamsUpdate depAfterMary' = createDeprecatedAfterMaryPParams sbe depAfterMary
Ledger.PParamsUpdate depAfterAlonzo' = createDeprecatedAfterAlonzoPParams sbe depAfterAlonzo
in Ledger.PParamsUpdate $ common <> withProtVer <> depAfterMary' <> depAfterAlonzo'

AllegraEraBasedProtocolParametersUpdate c depAfterMary depAfterAlonzo ->
AllegraEraBasedProtocolParametersUpdate c depAfterMary depAfterAlonzo depAfterBabbage ->
let Ledger.PParamsUpdate common = createCommonPParamsUpdate c
Ledger.PParamsUpdate withProtVer = createPreConwayProtocolVersionUpdate c
Ledger.PParamsUpdate withProtVer = createPreConwayProtocolVersionUpdate depAfterBabbage
Ledger.PParamsUpdate depAfterMary' = createDeprecatedAfterMaryPParams sbe depAfterMary
Ledger.PParamsUpdate depAfterAlonzo' = createDeprecatedAfterAlonzoPParams sbe depAfterAlonzo
in Ledger.PParamsUpdate $ common <> withProtVer <> depAfterMary' <> depAfterAlonzo'

MaryEraBasedProtocolParametersUpdate c depAfterMary depAfterAlonzo ->
MaryEraBasedProtocolParametersUpdate c depAfterMary depAfterAlonzo depAfterBabbage ->
let Ledger.PParamsUpdate common = createCommonPParamsUpdate c
Ledger.PParamsUpdate withProtVer = createPreConwayProtocolVersionUpdate c
Ledger.PParamsUpdate withProtVer = createPreConwayProtocolVersionUpdate depAfterBabbage
Ledger.PParamsUpdate depAfterMary' = createDeprecatedAfterMaryPParams sbe depAfterMary
Ledger.PParamsUpdate depAfterAlonzo' = createDeprecatedAfterAlonzoPParams sbe depAfterAlonzo
in Ledger.PParamsUpdate $ common <> withProtVer <> depAfterMary' <> depAfterAlonzo'

AlonzoEraBasedProtocolParametersUpdate c depAfterAlonzoA introInAlon ->
AlonzoEraBasedProtocolParametersUpdate c depAfterAlonzoA introInAlon depAfterBabbage ->
let Ledger.PParamsUpdate common = createCommonPParamsUpdate c
Ledger.PParamsUpdate withProtVer = createPreConwayProtocolVersionUpdate c
Ledger.PParamsUpdate withProtVer = createPreConwayProtocolVersionUpdate depAfterBabbage
Ledger.PParamsUpdate preAl' = createPParamsUpdateIntroducedInAlonzo AlonzoEraOnwardsAlonzo introInAlon
Ledger.PParamsUpdate depAfterAlonzoA' = createDeprecatedAfterAlonzoPParams sbe depAfterAlonzoA
in Ledger.PParamsUpdate $ common <> withProtVer <> preAl' <> depAfterAlonzoA'

BabbageEraBasedProtocolParametersUpdate c introInAlonzo introInBabbage ->
BabbageEraBasedProtocolParametersUpdate c introInAlonzo depAfterBabbage introInBabbage ->
let Ledger.PParamsUpdate common = createCommonPParamsUpdate c
Ledger.PParamsUpdate withProtVer = createPreConwayProtocolVersionUpdate c
Ledger.PParamsUpdate withProtVer = createPreConwayProtocolVersionUpdate depAfterBabbage
Ledger.PParamsUpdate inAlonzoPParams = createPParamsUpdateIntroducedInAlonzo AlonzoEraOnwardsBabbage introInAlonzo
Ledger.PParamsUpdate inBAb = createIntroducedInBabbagePParams BabbageEraOnwardsBabbage introInBabbage
in Ledger.PParamsUpdate $ common <> withProtVer <> inAlonzoPParams <> inBAb
Expand Down Expand Up @@ -325,7 +331,6 @@ data CommonProtocolParametersUpdate
, cppPoolPledgeInfluence :: StrictMaybe Ledger.NonNegativeInterval
, cppTreasuryExpansion :: StrictMaybe Ledger.UnitInterval
, cppMonetaryExpansion :: StrictMaybe Ledger.UnitInterval
, cppProtocolVersion :: StrictMaybe Ledger.ProtVer
, cppMinPoolCost :: StrictMaybe Ledger.Coin
} deriving Show

Expand Down Expand Up @@ -356,15 +361,19 @@ createCommonPParamsUpdate CommonProtocolParametersUpdate{..} =
-- when creating `Ledger.PParamsUpdate` within `createEraBasedProtocolParamUpdate`.
createPreConwayProtocolVersionUpdate
:: (EraPParams ledgerera, Ledger.ProtVerAtMost ledgerera 8)
=> CommonProtocolParametersUpdate
=> DeprecatedAfterBabbagePParams cppProtocolVersion
-> Ledger.PParamsUpdate ledgerera
createPreConwayProtocolVersionUpdate CommonProtocolParametersUpdate {cppProtocolVersion} =
createPreConwayProtocolVersionUpdate (DeprecatedAfterBabbagePParams cppProtocolVersion) =
Ledger.emptyPParamsUpdate & Ledger.ppuProtocolVersionL .~ cppProtocolVersion

newtype DeprecatedAfterMaryPParams ledgerera
= DeprecatedAfterMaryPParams (StrictMaybe Ledger.Coin) -- Minimum UTxO value
deriving Show

newtype DeprecatedAfterBabbagePParams ledgerera
= DeprecatedAfterBabbagePParams (StrictMaybe Ledger.ProtVer)
deriving Show

type MaxMaryEra ledgerera = Ledger.ProtVerAtMost ledgerera 4

createDeprecatedAfterMaryPParams
Expand Down
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ module Cardano.Api.Shelley
EraBasedProtocolParametersUpdate(..),
CommonProtocolParametersUpdate(..),
AlonzoOnwardsPParams(..),
DeprecatedAfterBabbagePParams(..),
DeprecatedAfterMaryPParams(..),
ShelleyToAlonzoPParams(..),
IntroducedInBabbagePParams(..),
Expand Down

0 comments on commit 914c7f3

Please sign in to comment.