Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not require decentralization parameter in protocol parameters #4051

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions cardano-api/src/Cardano/Api/ProtocolParameters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ data ProtocolParameters =
--
-- This is the \"d\" parameter from the design document.
--
-- /Deprecated in Babbage/
protocolParamDecentralization :: Maybe Rational,

-- | Extra entropy for the Praos per-epoch nonce.
Expand Down Expand Up @@ -295,7 +296,7 @@ instance FromJSON ProtocolParameters where
v <- o .: "protocolVersion"
ProtocolParameters
<$> ((,) <$> v .: "major" <*> v .: "minor")
<*> o .: "decentralization"
<*> o .:? "decentralization"
<*> o .: "extraPraosEntropy"
<*> o .: "maxBlockHeaderSize"
<*> o .: "maxBlockBodySize"
Expand Down Expand Up @@ -1358,7 +1359,13 @@ toShelleyPParams ProtocolParameters {
= let (maj, minor) = protocolParamProtocolVersion
in Ledger.ProtVer maj minor
, Shelley._d = case protocolParamDecentralization of
Nothing -> error "toAlonzoPParams: Decentralization value required in Shelley era"
-- The decentralization parameter is deprecated in Babbage
-- so we default to 0 if no dentralization parameter is found
-- in the api's 'ProtocolParameter' type. If we don't do this
-- we won't be able to construct an Alonzo tx using the Babbage
-- era's protocol parameter because our only other option is to
-- error.
Nothing -> minBound
Just pDecentral ->
fromMaybe
(error "toAlonzoPParams: invalid Decentralization value")
Expand Down Expand Up @@ -1420,7 +1427,13 @@ toAlonzoPParams ProtocolParameters {
= let (maj, minor) = protocolParamProtocolVersion
in Ledger.ProtVer maj minor
, Alonzo._d = case protocolParamDecentralization of
Nothing -> error "toAlonzoPParams: Decentralization value required in Alonzo era"
-- The decentralization parameter is deprecated in Babbage
-- so we default to 0 if no dentralization parameter is found
-- in the api's 'ProtocolParameter' type. If we don't do this
-- we won't be able to construct an Alonzo tx using the Babbage
-- era's protocol parameter because our only other option is to
-- error.
Nothing -> minBound
Just pDecentral ->
fromMaybe
(error "toAlonzoPParams: invalid Decentralization value")
Expand Down Expand Up @@ -1557,6 +1570,7 @@ toBabbagePParams ProtocolParameters { protocolParamCollateralPercent = Nothing }
error "toBabbagePParams: must specify protocolParamCollateralPercent"
toBabbagePParams ProtocolParameters { protocolParamMaxCollateralInputs = Nothing } =
error "toBabbagePParams: must specify protocolParamMaxCollateralInputs"

-- ----------------------------------------------------------------------------
-- Conversion functions: protocol parameters from ledger types
--
Expand Down