diff --git a/eras/alonzo/impl/CHANGELOG.md b/eras/alonzo/impl/CHANGELOG.md index 09cf2099d4a..750666fcfd3 100644 --- a/eras/alonzo/impl/CHANGELOG.md +++ b/eras/alonzo/impl/CHANGELOG.md @@ -12,6 +12,10 @@ * Remove `witsVKeyNeeded`, in favor of the one from `cardano-ledger-shelley` * Fix an issue where `TotalDeposits` didn't appear on Alonzo era +## 1.2.1.0 + +* Fix `PParams AlonzoEra` serialization. [#3440](https://github.com/input-output-hk/cardano-ledger/pull/3440) + ## 1.2.0.0 * Replace `DPState c` with `CertState era` diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/PParams.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/PParams.hs index cb7301fcd34..2dee59a37cf 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/PParams.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/PParams.hs @@ -84,11 +84,16 @@ import Cardano.Ledger.Binary ( Encoding, FromCBOR (..), ToCBOR (..), + decCBORGroup, + decodeRecordNamed, + encCBORGroup, encodeFoldableAsDefLenList, encodeFoldableAsIndefLenList, + encodeListLen, encodeMapLen, encodeNull, encodePreEncoded, + listLen, serialize', ) import Cardano.Ledger.Binary.Coders ( @@ -101,7 +106,6 @@ import Cardano.Ledger.Binary.Coders ( encode, field, (!>), - ( EraGovernance (AlonzoEra c) where getProposedPPUpdates = Just . proposals instance Era era => EncCBOR (AlonzoPParams Identity era) where - encCBOR - AlonzoPParams - { appMinFeeA - , appMinFeeB - , appMaxBBSize - , appMaxTxSize - , appMaxBHSize - , appKeyDeposit - , appPoolDeposit - , appEMax - , appNOpt - , appA0 - , appRho - , appTau - , appD - , appExtraEntropy - , appProtocolVersion - , appMinPoolCost - , appCoinsPerUTxOWord - , appCostModels - , appPrices - , appMaxTxExUnits - , appMaxBlockExUnits - , appMaxValSize - , appCollateralPercentage - , appMaxCollateralInputs - } = - encode $ - Rec (AlonzoPParams @Identity) - !> To appMinFeeA - !> To appMinFeeB - !> To appMaxBBSize - !> To appMaxTxSize - !> To appMaxBHSize - !> To appKeyDeposit - !> To appPoolDeposit - !> To appEMax - !> To appNOpt - !> To appA0 - !> To appRho - !> To appTau - !> To appD - !> To appExtraEntropy - !> To appProtocolVersion - !> To appMinPoolCost - -- new/updated for alonzo - !> To appCoinsPerUTxOWord - !> To appCostModels - !> To appPrices - !> To appMaxTxExUnits - !> To appMaxBlockExUnits - !> To appMaxValSize - !> To appCollateralPercentage - !> To appMaxCollateralInputs + encCBOR AlonzoPParams {..} = + encodeListLen (23 + listLen appProtocolVersion) + <> encCBOR appMinFeeA + <> encCBOR appMinFeeB + <> encCBOR appMaxBBSize + <> encCBOR appMaxTxSize + <> encCBOR appMaxBHSize + <> encCBOR appKeyDeposit + <> encCBOR appPoolDeposit + <> encCBOR appEMax + <> encCBOR appNOpt + <> encCBOR appA0 + <> encCBOR appRho + <> encCBOR appTau + <> encCBOR appD + <> encCBOR appExtraEntropy + <> encCBORGroup appProtocolVersion + <> encCBOR appMinPoolCost + -- new/updated for alonzo + <> encCBOR appCoinsPerUTxOWord + <> encCBOR appCostModels + <> encCBOR appPrices + <> encCBOR appMaxTxExUnits + <> encCBOR appMaxBlockExUnits + <> encCBOR appMaxValSize + <> encCBOR appCollateralPercentage + <> encCBOR appMaxCollateralInputs instance Era era => DecCBOR (AlonzoPParams Identity era) where decCBOR = - decode $ - RecD AlonzoPParams - 23 + fromIntegral (listLen (appProtocolVersion pp))) $ do + appMinFeeA <- decCBOR + appMinFeeB <- decCBOR + appMaxBBSize <- decCBOR + appMaxTxSize <- decCBOR + appMaxBHSize <- decCBOR + appKeyDeposit <- decCBOR + appPoolDeposit <- decCBOR + appEMax <- decCBOR + appNOpt <- decCBOR + appA0 <- decCBOR + appRho <- decCBOR + appTau <- decCBOR + appD <- decCBOR + appExtraEntropy <- decCBOR + appProtocolVersion <- decCBORGroup + appMinPoolCost <- decCBOR + -- new/updated for alonzo + appCoinsPerUTxOWord <- decCBOR + appCostModels <- decCBOR + appPrices <- decCBOR + appMaxTxExUnits <- decCBOR + appMaxBlockExUnits <- decCBOR + appMaxValSize <- decCBOR + appCollateralPercentage <- decCBOR + appMaxCollateralInputs <- decCBOR + pure AlonzoPParams {..} instance Era era => ToCBOR (AlonzoPParams Identity era) where toCBOR = toEraCBOR @era diff --git a/eras/alonzo/test-suite/golden/translations.cbor b/eras/alonzo/test-suite/golden/translations.cbor index b00dfa132b7..4c9951d6e09 100644 Binary files a/eras/alonzo/test-suite/golden/translations.cbor and b/eras/alonzo/test-suite/golden/translations.cbor differ diff --git a/eras/babbage/impl/CHANGELOG.md b/eras/babbage/impl/CHANGELOG.md index ddfede1ab52..b57a7c76165 100644 --- a/eras/babbage/impl/CHANGELOG.md +++ b/eras/babbage/impl/CHANGELOG.md @@ -8,6 +8,10 @@ * Add `EraPlutusContext 'PlutusV2` instance to `BabbageEra` * Fix an issue where `TotalDeposits` didn't appear on Babbage era +## 1.2.1.0 + +* Fix `PParams BabbageEra` serialization. [#3440](https://github.com/input-output-hk/cardano-ledger/pull/3440) + ## 1.2.0.0 * Replace `DPState c` with `CertState era` diff --git a/eras/babbage/impl/src/Cardano/Ledger/Babbage/PParams.hs b/eras/babbage/impl/src/Cardano/Ledger/Babbage/PParams.hs index 53ae8043889..4738aeecba1 100644 --- a/eras/babbage/impl/src/Cardano/Ledger/Babbage/PParams.hs +++ b/eras/babbage/impl/src/Cardano/Ledger/Babbage/PParams.hs @@ -60,6 +60,11 @@ import Cardano.Ledger.Binary ( Encoding, FromCBOR (..), ToCBOR (..), + decCBORGroup, + decodeRecordNamed, + encCBORGroup, + encodeListLen, + listLen, ) import Cardano.Ledger.Binary.Coders ( Decode (..), @@ -71,7 +76,6 @@ import Cardano.Ledger.Binary.Coders ( encode, field, (!>), - ( EraGovernance (BabbageEra c) where instance Era era => EncCBOR (BabbagePParams Identity era) where encCBOR BabbagePParams {..} = - encode - ( Rec (BabbagePParams @Identity) - !> To bppMinFeeA - !> To bppMinFeeB - !> To bppMaxBBSize - !> To bppMaxTxSize - !> To bppMaxBHSize - !> To bppKeyDeposit - !> To bppPoolDeposit - !> To bppEMax - !> To bppNOpt - !> To bppA0 - !> To bppRho - !> To bppTau - !> To bppProtocolVersion - !> To bppMinPoolCost - !> To bppCoinsPerUTxOByte - !> To bppCostModels - !> To bppPrices - !> To bppMaxTxExUnits - !> To bppMaxBlockExUnits - !> To bppMaxValSize - !> To bppCollateralPercentage - !> To bppMaxCollateralInputs - ) + encodeListLen (21 + listLen bppProtocolVersion) + <> encCBOR bppMinFeeA + <> encCBOR bppMinFeeB + <> encCBOR bppMaxBBSize + <> encCBOR bppMaxTxSize + <> encCBOR bppMaxBHSize + <> encCBOR bppKeyDeposit + <> encCBOR bppPoolDeposit + <> encCBOR bppEMax + <> encCBOR bppNOpt + <> encCBOR bppA0 + <> encCBOR bppRho + <> encCBOR bppTau + <> encCBORGroup bppProtocolVersion + <> encCBOR bppMinPoolCost + <> encCBOR bppCoinsPerUTxOByte + <> encCBOR bppCostModels + <> encCBOR bppPrices + <> encCBOR bppMaxTxExUnits + <> encCBOR bppMaxBlockExUnits + <> encCBOR bppMaxValSize + <> encCBOR bppCollateralPercentage + <> encCBOR bppMaxCollateralInputs instance Era era => ToCBOR (BabbagePParams Identity era) where toCBOR = toEraCBOR @era instance Era era => DecCBOR (BabbagePParams Identity era) where decCBOR = - decode $ - RecD BabbagePParams - 21 + fromIntegral (listLen (bppProtocolVersion pp))) $ do + bppMinFeeA <- decCBOR + bppMinFeeB <- decCBOR + bppMaxBBSize <- decCBOR + bppMaxTxSize <- decCBOR + bppMaxBHSize <- decCBOR + bppKeyDeposit <- decCBOR + bppPoolDeposit <- decCBOR + bppEMax <- decCBOR + bppNOpt <- decCBOR + bppA0 <- decCBOR + bppRho <- decCBOR + bppTau <- decCBOR + bppProtocolVersion <- decCBORGroup + bppMinPoolCost <- decCBOR + bppCoinsPerUTxOByte <- decCBOR + bppCostModels <- decCBOR + bppPrices <- decCBOR + bppMaxTxExUnits <- decCBOR + bppMaxBlockExUnits <- decCBOR + bppMaxValSize <- decCBOR + bppCollateralPercentage <- decCBOR + bppMaxCollateralInputs <- decCBOR + pure BabbagePParams {..} instance Era era => FromCBOR (BabbagePParams Identity era) where fromCBOR = fromEraCBOR @era diff --git a/eras/babbage/test-suite/golden/translations.cbor b/eras/babbage/test-suite/golden/translations.cbor index 4cf4a1014d9..574d1cdeca2 100644 Binary files a/eras/babbage/test-suite/golden/translations.cbor and b/eras/babbage/test-suite/golden/translations.cbor differ diff --git a/libs/cardano-ledger-binary/src/Cardano/Ledger/Binary/Decoding/Decoder.hs b/libs/cardano-ledger-binary/src/Cardano/Ledger/Binary/Decoding/Decoder.hs index 1e07810b7c6..4624d8c3cd6 100644 --- a/libs/cardano-ledger-binary/src/Cardano/Ledger/Binary/Decoding/Decoder.hs +++ b/libs/cardano-ledger-binary/src/Cardano/Ledger/Binary/Decoding/Decoder.hs @@ -3,7 +3,6 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-}