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

Fix building of Alonzo transaction in Babbage era. #4166

Merged
merged 1 commit into from
Jul 23, 2022
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
16 changes: 11 additions & 5 deletions cardano-api/src/Cardano/Api/ProtocolParameters.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
Expand Down Expand Up @@ -64,6 +65,7 @@ module Cardano.Api.ProtocolParameters (

import Prelude

import Control.Applicative ((<|>))
import Control.Monad
import Data.Aeson (FromJSON (..), ToJSON (..), object, withObject, (.!=), (.:), (.:?),
(.=))
Expand Down Expand Up @@ -106,8 +108,8 @@ import Text.PrettyBy.Default (display)
import Cardano.Api.Address
import Cardano.Api.Eras
import Cardano.Api.Error
import Cardano.Api.HasTypeProxy
import Cardano.Api.Hash
import Cardano.Api.HasTypeProxy
import Cardano.Api.KeysByron
import Cardano.Api.KeysShelley
import Cardano.Api.Script
Expand All @@ -120,7 +122,6 @@ import Cardano.Api.TxMetadata
import Cardano.Api.Utils
import Cardano.Api.Value


-- | The values of the set of /updatable/ protocol parameters. At any
-- particular point on the chain there is a current set of parameters in use.
--
Expand Down Expand Up @@ -1436,15 +1437,20 @@ toAlonzoPParams ProtocolParameters {
protocolParamPoolPledgeInfluence,
protocolParamMonetaryExpansion,
protocolParamTreasuryCut,
protocolParamUTxOCostPerWord = Just utxoCostPerWord,
protocolParamUTxOCostPerWord,
protocolParamCostModels,
protocolParamPrices = Just prices,
protocolParamMaxTxExUnits = Just maxTxExUnits,
protocolParamMaxBlockExUnits = Just maxBlockExUnits,
protocolParamMaxValueSize = Just maxValueSize,
protocolParamCollateralPercent = Just collateralPercentage,
protocolParamMaxCollateralInputs = Just maxCollateralInputs
protocolParamMaxCollateralInputs = Just maxCollateralInputs,
protocolParamUTxOCostPerByte
} =
let !coinsPerUTxOWord = fromMaybe
(error "toAlonzoPParams: must specify protocolParamUTxOCostPerWord or protocolParamUTxOCostPerByte") $
protocolParamUTxOCostPerWord <|> ((* 8) <$> protocolParamUTxOCostPerByte)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conversion occurs here.

in
Alonzo.PParams {
Alonzo._protocolVersion
= let (maj, minor) = protocolParamProtocolVersion
Expand Down Expand Up @@ -1483,7 +1489,7 @@ toAlonzoPParams ProtocolParameters {
(Ledger.boundRational protocolParamTreasuryCut)

-- New params in Alonzo:
, Alonzo._coinsPerUTxOWord = toShelleyLovelace utxoCostPerWord
, Alonzo._coinsPerUTxOWord = toShelleyLovelace coinsPerUTxOWord
, Alonzo._costmdls = either
(\e -> error $ "toAlonzoPParams: invalid cost models, error: " <> e)
id
Expand Down