diff --git a/cabal.project b/cabal.project index 80c8cb73e98..c460b3e4d7b 100644 --- a/cabal.project +++ b/cabal.project @@ -197,7 +197,7 @@ source-repository-package source-repository-package type: git location: https://github.com/input-output-hk/cardano-ledger - tag: 0913292b13963ae4b60136eddb8d18b137f96a21 + tag: 65292694de72f137e6b90c5f361ae7646b48775f --sha256: 19rrnvvplvg8v989bcv6vpjwvblfa0m65izxkcp8dclf0a914qq3 subdir: eras/alonzo/impl diff --git a/cardano-api/gen/Gen/Cardano/Api/Typed.hs b/cardano-api/gen/Gen/Cardano/Api/Typed.hs index 49a0dd9cf16..ed91c879218 100644 --- a/cardano-api/gen/Gen/Cardano/Api/Typed.hs +++ b/cardano-api/gen/Gen/Cardano/Api/Typed.hs @@ -765,6 +765,7 @@ genProtocolParameters = <*> Gen.maybe genNat <*> Gen.maybe genNat <*> Gen.maybe genNat + <*> Gen.maybe genLovelace genProtocolParametersUpdate :: Gen ProtocolParametersUpdate genProtocolParametersUpdate = do @@ -785,7 +786,7 @@ genProtocolParametersUpdate = do protocolUpdatePoolPledgeInfluence <- Gen.maybe genRationalInt64 protocolUpdateMonetaryExpansion <- Gen.maybe genRational protocolUpdateTreasuryCut <- Gen.maybe genRational - protocolUpdateUTxOCostPerByte <- Gen.maybe genLovelace + protocolUpdateUTxOCostPerWord <- Gen.maybe genLovelace let protocolUpdateCostModels = mempty -- genCostModels --TODO: Babbage figure out how to deal with -- asymmetric cost model JSON instances @@ -795,6 +796,7 @@ genProtocolParametersUpdate = do protocolUpdateMaxValueSize <- Gen.maybe genNat protocolUpdateCollateralPercent <- Gen.maybe genNat protocolUpdateMaxCollateralInputs <- Gen.maybe genNat + protocolUpdateUTxOCostPerByte <- Gen.maybe genLovelace pure ProtocolParametersUpdate{..} diff --git a/cardano-api/src/Cardano/Api/Fees.hs b/cardano-api/src/Cardano/Api/Fees.hs index 6b9d4492a77..13b0e84fb0f 100644 --- a/cardano-api/src/Cardano/Api/Fees.hs +++ b/cardano-api/src/Cardano/Api/Fees.hs @@ -795,6 +795,10 @@ data TxBodyErrorAutoBalance = -- | The 'ProtocolParameters' must provide the value for the cost per -- word parameter, for eras that use this parameter. + | TxBodyErrorMissingParamCostPerWord + + -- | The 'ProtocolParameters' must provide the value for the cost per + -- byte parameter, for eras that use this parameter. | TxBodyErrorMissingParamCostPerByte -- | The transaction validity interval is too far into the future. @@ -856,6 +860,9 @@ instance Error TxBodyErrorAutoBalance where displayError TxBodyErrorMissingParamMinUTxO = "The minUTxOValue protocol parameter is required but missing" + displayError TxBodyErrorMissingParamCostPerWord = + "The utxoCostPerWord protocol parameter is required but missing" + displayError TxBodyErrorMissingParamCostPerByte = "The utxoCostPerByte protocol parameter is required but missing" @@ -1259,6 +1266,7 @@ calculateMinimumUTxO era txout@(TxOut _ v _ _) pparams' = data MinimumUTxOError = PParamsMinUTxOMissing + | PParamsUTxOCostPerWordMissing | PParamsUTxOCostPerByteMissing deriving Show @@ -1266,6 +1274,9 @@ instance Error MinimumUTxOError where displayError PParamsMinUTxOMissing = "\"minUtxoValue\" field not present in protocol parameters when \ \trying to calculate minimum UTxO value." + displayError PParamsUTxOCostPerWordMissing = + "\"utxoCostPerWord\" field not present in protocol parameters when \ + \trying to calculate minimum UTxO value." displayError PParamsUTxOCostPerByteMissing = "\"utxoCostPerByte\" field not present in protocol parameters when \ \trying to calculate minimum UTxO value." diff --git a/cardano-api/src/Cardano/Api/ProtocolParameters.hs b/cardano-api/src/Cardano/Api/ProtocolParameters.hs index 7ec817413f0..4dbef3733b3 100644 --- a/cardano-api/src/Cardano/Api/ProtocolParameters.hs +++ b/cardano-api/src/Cardano/Api/ProtocolParameters.hs @@ -100,7 +100,6 @@ import qualified Cardano.Ledger.Alonzo.PParams as Alonzo import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo import qualified Cardano.Ledger.Babbage.PParams as Babbage -import Cardano.Ledger.Babbage.Translation (coinsPerUTxOWordToCoinsPerUTxOByte) import Text.PrettyBy.Default (display) @@ -249,8 +248,8 @@ data ProtocolParameters = -- | Cost in ada per byte of UTxO storage. -- - -- /Introduced in Babbage/ - protocolParamUTxOCostPerByte :: Maybe Lovelace, + -- /Introduced in Alonzo/ + protocolParamUTxOCostPerWord :: Maybe Lovelace, -- | Cost models for script languages that use them. -- @@ -286,7 +285,13 @@ data ProtocolParameters = -- | The maximum number of collateral inputs allowed in a transaction. -- -- /Introduced in Alonzo/ - protocolParamMaxCollateralInputs :: Maybe Natural + protocolParamMaxCollateralInputs :: Maybe Natural, + + -- | Cost in ada per byte of UTxO storage. + -- + -- /Introduced in Babbage/ + protocolParamUTxOCostPerByte :: Maybe Lovelace + } deriving (Eq, Generic, Show) @@ -312,7 +317,7 @@ instance FromJSON ProtocolParameters where <*> o .: "poolPledgeInfluence" <*> o .: "monetaryExpansion" <*> o .: "treasuryCut" - <*> o .:? "utxoCostPerBytes" + <*> o .:? "utxoCostPerWord" <*> o .:? "costModels" .!= Map.empty <*> o .:? "executionUnitPrices" <*> o .:? "maxTxExecutionUnits" @@ -320,6 +325,7 @@ instance FromJSON ProtocolParameters where <*> o .:? "maxValueSize" <*> o .:? "collateralPercentage" <*> o .:? "maxCollateralInputs" + <*> o .:? "utxoCostPerByte" instance ToJSON ProtocolParameters where toJSON ProtocolParameters{..} = @@ -343,6 +349,7 @@ instance ToJSON ProtocolParameters where , "txFeeFixed" .= protocolParamTxFeeFixed , "txFeePerByte" .= protocolParamTxFeePerByte -- Alonzo era: + , "utxoCostPerWord" .= protocolParamUTxOCostPerWord , "costModels" .= protocolParamCostModels , "executionUnitPrices" .= protocolParamPrices , "maxTxExecutionUnits" .= protocolParamMaxTxExUnits @@ -474,12 +481,12 @@ data ProtocolParametersUpdate = -- protocolUpdateTreasuryCut :: Maybe Rational, - -- Introduced in Babbage, + -- Introduced in Alonzo, -- | Cost in ada per byte of UTxO storage. -- - -- /Introduced in Babbage/ - protocolUpdateUTxOCostPerByte :: Maybe Lovelace, + -- /Introduced in Alonzo, obsoleted in Babbage by 'protocolUpdateUTxOCostPerByte'/ + protocolUpdateUTxOCostPerWord :: Maybe Lovelace, -- Introduced in Alonzo, @@ -517,7 +524,12 @@ data ProtocolParametersUpdate = -- | The maximum number of collateral inputs allowed in a transaction. -- -- /Introduced in Alonzo/ - protocolUpdateMaxCollateralInputs :: Maybe Natural + protocolUpdateMaxCollateralInputs :: Maybe Natural, + + -- | Cost in ada per byte of UTxO storage. + -- + -- /Introduced in Babbage. Supercedes 'protocolUpdateUTxOCostPerWord'/ + protocolUpdateUTxOCostPerByte :: Maybe Lovelace } deriving (Eq, Show) @@ -541,9 +553,8 @@ instance Semigroup ProtocolParametersUpdate where , protocolUpdatePoolPledgeInfluence = merge protocolUpdatePoolPledgeInfluence , protocolUpdateMonetaryExpansion = merge protocolUpdateMonetaryExpansion , protocolUpdateTreasuryCut = merge protocolUpdateTreasuryCut - -- Introduced in Babbage below. - , protocolUpdateUTxOCostPerByte = merge protocolUpdateUTxOCostPerByte -- Introduced in Alonzo below. + , protocolUpdateUTxOCostPerWord = merge protocolUpdateUTxOCostPerWord , protocolUpdateCostModels = mergeMap protocolUpdateCostModels , protocolUpdatePrices = merge protocolUpdatePrices , protocolUpdateMaxTxExUnits = merge protocolUpdateMaxTxExUnits @@ -551,6 +562,8 @@ instance Semigroup ProtocolParametersUpdate where , protocolUpdateMaxValueSize = merge protocolUpdateMaxValueSize , protocolUpdateCollateralPercent = merge protocolUpdateCollateralPercent , protocolUpdateMaxCollateralInputs = merge protocolUpdateMaxCollateralInputs + -- Introduced in Babbage below. + , protocolUpdateUTxOCostPerByte = merge protocolUpdateUTxOCostPerByte } where -- prefer the right hand side: @@ -581,7 +594,7 @@ instance Monoid ProtocolParametersUpdate where , protocolUpdatePoolPledgeInfluence = Nothing , protocolUpdateMonetaryExpansion = Nothing , protocolUpdateTreasuryCut = Nothing - , protocolUpdateUTxOCostPerByte = Nothing + , protocolUpdateUTxOCostPerWord = Nothing , protocolUpdateCostModels = mempty , protocolUpdatePrices = Nothing , protocolUpdateMaxTxExUnits = Nothing @@ -589,11 +602,12 @@ instance Monoid ProtocolParametersUpdate where , protocolUpdateMaxValueSize = Nothing , protocolUpdateCollateralPercent = Nothing , protocolUpdateMaxCollateralInputs = Nothing + , protocolUpdateUTxOCostPerByte = Nothing } instance ToCBOR ProtocolParametersUpdate where toCBOR ProtocolParametersUpdate{..} = - CBOR.encodeListLen 25 + CBOR.encodeListLen 26 <> toCBOR protocolUpdateProtocolVersion <> toCBOR protocolUpdateDecentralization <> toCBOR protocolUpdateExtraPraosEntropy @@ -622,7 +636,7 @@ instance ToCBOR ProtocolParametersUpdate where instance FromCBOR ProtocolParametersUpdate where fromCBOR = do - CBOR.enforceSize "ProtocolParametersUpdate" 25 + CBOR.enforceSize "ProtocolParametersUpdate" 26 ProtocolParametersUpdate <$> fromCBOR <*> fromCBOR @@ -649,6 +663,7 @@ instance FromCBOR ProtocolParametersUpdate where <*> fromCBOR <*> fromCBOR <*> fromCBOR + <*> fromCBOR -- ---------------------------------------------------------------------------- @@ -1171,7 +1186,7 @@ fromShelleyPParamsUpdate strictMaybeToMaybe _rho , protocolUpdateTreasuryCut = Ledger.unboundRational <$> strictMaybeToMaybe _tau - , protocolUpdateUTxOCostPerByte = Nothing -- Babbage + , protocolUpdateUTxOCostPerWord = Nothing , protocolUpdateCostModels = mempty , protocolUpdatePrices = Nothing , protocolUpdateMaxTxExUnits = Nothing @@ -1179,6 +1194,8 @@ fromShelleyPParamsUpdate , protocolUpdateMaxValueSize = Nothing , protocolUpdateCollateralPercent = Nothing , protocolUpdateMaxCollateralInputs = Nothing + + , protocolUpdateUTxOCostPerByte = Nothing } fromAlonzoPParamsUpdate :: Alonzo.PParamsUpdate ledgerera @@ -1237,7 +1254,7 @@ fromAlonzoPParamsUpdate strictMaybeToMaybe _rho , protocolUpdateTreasuryCut = Ledger.unboundRational <$> strictMaybeToMaybe _tau - , protocolUpdateUTxOCostPerByte = fromShelleyLovelace . coinsPerUTxOWordToCoinsPerUTxOByte <$> + , protocolUpdateUTxOCostPerWord = fromShelleyLovelace <$> strictMaybeToMaybe _coinsPerUTxOWord , protocolUpdateCostModels = maybe mempty fromAlonzoCostModels (strictMaybeToMaybe _costmdls) @@ -1250,6 +1267,7 @@ fromAlonzoPParamsUpdate , protocolUpdateMaxValueSize = strictMaybeToMaybe _maxValSize , protocolUpdateCollateralPercent = strictMaybeToMaybe _collateralPercentage , protocolUpdateMaxCollateralInputs = strictMaybeToMaybe _maxCollateralInputs + , protocolUpdateUTxOCostPerByte = Nothing } @@ -1305,8 +1323,7 @@ fromBabbagePParamsUpdate strictMaybeToMaybe _rho , protocolUpdateTreasuryCut = Ledger.unboundRational <$> strictMaybeToMaybe _tau - , protocolUpdateUTxOCostPerByte = fromShelleyLovelace <$> - strictMaybeToMaybe _coinsPerUTxOByte + , protocolUpdateUTxOCostPerWord = Nothing , protocolUpdateCostModels = maybe mempty fromAlonzoCostModels (strictMaybeToMaybe _costmdls) , protocolUpdatePrices = fromAlonzoPrices <$> @@ -1318,6 +1335,8 @@ fromBabbagePParamsUpdate , protocolUpdateMaxValueSize = strictMaybeToMaybe _maxValSize , protocolUpdateCollateralPercent = strictMaybeToMaybe _collateralPercentage , protocolUpdateMaxCollateralInputs = strictMaybeToMaybe _maxCollateralInputs + , protocolUpdateUTxOCostPerByte = fromShelleyLovelace <$> + strictMaybeToMaybe _coinsPerUTxOByte } @@ -1631,7 +1650,7 @@ fromShelleyPParams , protocolParamPoolPledgeInfluence = Ledger.unboundRational _a0 , protocolParamMonetaryExpansion = Ledger.unboundRational _rho , protocolParamTreasuryCut = Ledger.unboundRational _tau - , protocolParamUTxOCostPerByte = Nothing + , protocolParamUTxOCostPerWord = Nothing , protocolParamCostModels = Map.empty , protocolParamPrices = Nothing , protocolParamMaxTxExUnits = Nothing @@ -1639,6 +1658,7 @@ fromShelleyPParams , protocolParamMaxValueSize = Nothing , protocolParamCollateralPercent = Nothing , protocolParamMaxCollateralInputs = Nothing + , protocolParamUTxOCostPerByte = Nothing } @@ -1689,8 +1709,7 @@ fromAlonzoPParams , protocolParamPoolPledgeInfluence = Ledger.unboundRational _a0 , protocolParamMonetaryExpansion = Ledger.unboundRational _rho , protocolParamTreasuryCut = Ledger.unboundRational _tau - , protocolParamUTxOCostPerByte = -- adapted from alonzo protocol parameter field - Just (fromShelleyLovelace (coinsPerUTxOWordToCoinsPerUTxOByte _coinsPerUTxOWord)) + , protocolParamUTxOCostPerWord = Just (fromShelleyLovelace _coinsPerUTxOWord) , protocolParamCostModels = fromAlonzoCostModels _costmdls , protocolParamPrices = Just (fromAlonzoPrices _prices) , protocolParamMaxTxExUnits = Just (fromAlonzoExUnits _maxTxExUnits) @@ -1698,6 +1717,7 @@ fromAlonzoPParams , protocolParamMaxValueSize = Just _maxValSize , protocolParamCollateralPercent = Just _collateralPercentage , protocolParamMaxCollateralInputs = Just _maxCollateralInputs + , protocolParamUTxOCostPerByte = Nothing } fromBabbagePParams :: Babbage.PParams ledgerera -> ProtocolParameters @@ -1745,7 +1765,7 @@ fromBabbagePParams , protocolParamPoolPledgeInfluence = Ledger.unboundRational _a0 , protocolParamMonetaryExpansion = Ledger.unboundRational _rho , protocolParamTreasuryCut = Ledger.unboundRational _tau - , protocolParamUTxOCostPerByte = Just (fromShelleyLovelace _coinsPerUTxOByte) + , protocolParamUTxOCostPerWord = Nothing , protocolParamCostModels = fromAlonzoCostModels _costmdls , protocolParamPrices = Just (fromAlonzoPrices _prices) , protocolParamMaxTxExUnits = Just (fromAlonzoExUnits _maxTxExUnits) @@ -1753,6 +1773,7 @@ fromBabbagePParams , protocolParamMaxValueSize = Just _maxValSize , protocolParamCollateralPercent = Just _collateralPercentage , protocolParamMaxCollateralInputs = Just _maxCollateralInputs + , protocolParamUTxOCostPerByte = Just (fromShelleyLovelace _coinsPerUTxOByte) } data ProtocolParametersError = diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs b/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs index b5e0a8a7864..aa17c3bce0d 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs @@ -2895,7 +2895,7 @@ pProtocolParametersUpdate = <*> optional pPoolInfluence <*> optional pMonetaryExpansion <*> optional pTreasuryExpansion - <*> optional pUTxOCostPerByte + <*> optional pUTxOCostPerWord <*> pure mempty <*> optional pExecutionUnitPrices <*> optional pMaxTxExecutionUnits @@ -2903,6 +2903,7 @@ pProtocolParametersUpdate = <*> optional pMaxValueSize <*> optional pCollateralPercent <*> optional pMaxCollateralInputs + <*> optional pUTxOCostPerByte pCostModels :: Parser FilePath pCostModels = @@ -3054,6 +3055,14 @@ pExtraEntropy = . B16.decode . BSC.pack =<< some Parsec.hexDigit +pUTxOCostPerWord :: Parser Lovelace +pUTxOCostPerWord = + Opt.option (readerFromParsecParser parseLovelace) + ( Opt.long "utxo-cost-per-word" + <> Opt.metavar "LOVELACE" + <> Opt.help "Cost in lovelace per unit of UTxO storage (from Alonzo era)." + ) + pUTxOCostPerByte :: Parser Lovelace pUTxOCostPerByte = Opt.option (readerFromParsecParser parseLovelace) diff --git a/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs b/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs index 6bbc4d7d927..03a63ee60f6 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs @@ -434,7 +434,7 @@ instance ( ShelleyBasedEra era mconcat [ "kind" .= String "InvalidWitnessesUTXOW" , "invalidWitnesses" .= map textShow wits' ] - forMachine _dtal (MissingVKeyWitnessesUTXOW (WitHashes wits')) = + forMachine _dtal (MissingVKeyWitnessesUTXOW wits') = mconcat [ "kind" .= String "MissingVKeyWitnessesUTXOW" , "missingWitnesses" .= wits' ] diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs index 986f2c20233..e2ce44b2086 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs @@ -372,7 +372,7 @@ instance ( ShelleyBasedEra era mconcat [ "kind" .= String "InvalidWitnessesUTXOW" , "invalidWitnesses" .= map textShow wits' ] - toObject _verb (MissingVKeyWitnessesUTXOW (WitHashes wits')) = + toObject _verb (MissingVKeyWitnessesUTXOW wits') = mconcat [ "kind" .= String "MissingVKeyWitnessesUTXOW" , "missingWitnesses" .= wits' ]