Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/PParams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ instance EraPParams AllegraEra where
upgradePParamsHKD () = coerce
downgradePParamsHKD () = coerce

hkdMinFeeACompactL = lens sppMinFeeA $ \pp x -> pp {sppMinFeeA = x}
hkdMinFeeBCompactL = lens sppMinFeeB $ \pp x -> pp {sppMinFeeB = x}
hkdTxFeePerByteL = lens sppTxFeePerByte $ \pp x -> pp {sppTxFeePerByte = x}
hkdTxFeeFixedCompactL = lens sppTxFeeFixed $ \pp x -> pp {sppTxFeeFixed = x}
hkdMaxBBSizeL = lens sppMaxBBSize $ \pp x -> pp {sppMaxBBSize = x}
hkdMaxTxSizeL = lens sppMaxTxSize $ \pp x -> pp {sppMaxTxSize = x}
hkdMaxBHSizeL = lens sppMaxBHSize $ \pp x -> pp {sppMaxBHSize = x}
Expand Down
5 changes: 4 additions & 1 deletion eras/alonzo/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

## 1.15.0.0

* Renamed:
- `appMinFeeA` -> `appTxFeePerByte`
- `appMinFeeB` -> `appTxFeeFixed`
* Changed type of `appMinFeeA` to `CoinPerByte`
* Change sets containing errors into `NonEmptySet` for `AlonzoUtxoPredFailure`, `AlonzoUtxowPredFailure`
* Change all lists into `NonEmpty` for `AlonzoUtxoPredFailure`, `AlonzoUtxosPredFailure`, `AlonzoUtxowPredFailure`
* Change `collectPlutusScriptsWithContext` to return a `NonEmpty` list of failures
* Changed the type of `dappMinUTxOValue` to `CompactForm Coin` in `DowngradeAlonzoPParams`
* Changed the type of the following fields to `CompactForm Coin` in `AlonzoPParams`:
- `appMinFeeA`
- `appMinFeeB`
- `appKeyDeposit`
- `appMinPoolCost`
Expand Down
42 changes: 27 additions & 15 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/PParams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ module Cardano.Ledger.Alonzo.PParams (
ppMaxTxExUnits,
ppMaxValSize,
ppPrices,

-- * Deprecated
appMinFeeA,
appMinFeeB,
) where

import Cardano.Ledger.Alonzo.Era (AlonzoEra)
Expand All @@ -86,7 +90,7 @@ import Cardano.Ledger.Binary (
encodePreEncoded,
serialize',
)
import Cardano.Ledger.Coin (Coin (..), CompactForm (..))
import Cardano.Ledger.Coin
import Cardano.Ledger.Core (EraPParams (..))
import Cardano.Ledger.HKD (HKDFunctor (..))
import Cardano.Ledger.Mary.Core
Expand Down Expand Up @@ -223,9 +227,9 @@ ppuMaxCollateralInputsL = ppuLensHKD . hkdMaxCollateralInputsL @era @StrictMaybe
-- | Protocol parameters.
-- Shelley parameters + additional ones
data AlonzoPParams f era = AlonzoPParams
{ appMinFeeA :: !(HKD f (CompactForm Coin))
{ appTxFeePerByte :: !(HKD f CoinPerByte)
-- ^ The linear factor for the minimum fee calculation
, appMinFeeB :: !(HKD f (CompactForm Coin))
, appTxFeeFixed :: !(HKD f (CompactForm Coin))
-- ^ The constant factor for the minimum fee calculation
, appMaxBBSize :: !(HKD f Word32)
-- ^ Maximal block body size
Expand Down Expand Up @@ -280,6 +284,14 @@ data AlonzoPParams f era = AlonzoPParams
}
deriving (Generic)

appMinFeeA :: forall era f. HKDFunctor f => AlonzoPParams f era -> HKD f Coin
appMinFeeA p = appTxFeePerByte p ^. hkdCoinPerByteL @f . hkdPartialCompactCoinL @f
{-# DEPRECATED appMinFeeA "In favor of `appTxFeePerByte`" #-}

appMinFeeB :: forall era f. HKDFunctor f => AlonzoPParams f era -> HKD f Coin
appMinFeeB p = appTxFeeFixed p ^. hkdPartialCompactCoinL @f
{-# DEPRECATED appMinFeeB "In favor of `appTxFeeFixed`" #-}

deriving instance Eq (AlonzoPParams Identity era)

deriving instance Ord (AlonzoPParams Identity era)
Expand Down Expand Up @@ -312,8 +324,8 @@ instance EraPParams AlonzoEra where
downgradePParamsHKD = downgradeAlonzoPParams
emptyUpgradePParamsUpdate = emptyAlonzoUpgradePParamsUpdate

hkdMinFeeACompactL = lens appMinFeeA $ \pp x -> pp {appMinFeeA = x}
hkdMinFeeBCompactL = lens appMinFeeB $ \pp x -> pp {appMinFeeB = x}
hkdTxFeePerByteL = lens appTxFeePerByte $ \pp x -> pp {appTxFeePerByte = x}
hkdTxFeeFixedCompactL = lens appTxFeeFixed $ \pp x -> pp {appTxFeeFixed = x}
hkdMaxBBSizeL = lens appMaxBBSize $ \pp x -> pp {appMaxBBSize = x}
hkdMaxTxSizeL = lens appMaxTxSize $ \pp x -> pp {appMaxTxSize = x}
hkdMaxBHSizeL = lens appMaxBHSize $ \pp x -> pp {appMaxBHSize = x}
Expand All @@ -331,8 +343,8 @@ instance EraPParams AlonzoEra where
hkdMinPoolCostCompactL = lens appMinPoolCost $ \pp x -> pp {appMinPoolCost = x}

eraPParams =
[ ppMinFeeA
, ppMinFeeB
[ ppTxFeePerByte
, ppTxFeeFixed
, ppMaxBBSize
, ppMaxTxSize
, ppMaxBHSize
Expand Down Expand Up @@ -470,8 +482,8 @@ instance NFData (DowngradeAlonzoPParams Identity)
emptyAlonzoPParams :: forall era. Era era => AlonzoPParams Identity era
emptyAlonzoPParams =
AlonzoPParams
{ appMinFeeA = CompactCoin 0
, appMinFeeB = CompactCoin 0
{ appTxFeePerByte = CoinPerByte $ CompactCoin 0
, appTxFeeFixed = CompactCoin 0
, appMaxBBSize = 0
, appMaxTxSize = 2048
, appMaxBHSize = 0
Expand Down Expand Up @@ -500,8 +512,8 @@ emptyAlonzoPParams =
emptyAlonzoPParamsUpdate :: AlonzoPParams StrictMaybe era
emptyAlonzoPParamsUpdate =
AlonzoPParams
{ appMinFeeA = SNothing
, appMinFeeB = SNothing
{ appTxFeePerByte = SNothing
, appTxFeeFixed = SNothing
, appMaxBBSize = SNothing
, appMaxTxSize = SNothing
, appMaxBHSize = SNothing
Expand Down Expand Up @@ -594,8 +606,8 @@ upgradeAlonzoPParams ::
AlonzoPParams f era2
upgradeAlonzoPParams UpgradeAlonzoPParams {..} ShelleyPParams {..} =
AlonzoPParams
{ appMinFeeA = sppMinFeeA
, appMinFeeB = sppMinFeeB
{ appTxFeePerByte = sppTxFeePerByte
, appTxFeeFixed = sppTxFeeFixed
, appMaxBBSize = sppMaxBBSize
, appMaxTxSize = sppMaxTxSize
, appMaxBHSize = sppMaxBHSize
Expand Down Expand Up @@ -625,8 +637,8 @@ upgradeAlonzoPParams UpgradeAlonzoPParams {..} ShelleyPParams {..} =
downgradeAlonzoPParams :: DowngradeAlonzoPParams f -> AlonzoPParams f era2 -> ShelleyPParams f era1
downgradeAlonzoPParams DowngradeAlonzoPParams {dappMinUTxOValue} AlonzoPParams {..} =
ShelleyPParams
{ sppMinFeeA = appMinFeeA
, sppMinFeeB = appMinFeeB
{ sppTxFeePerByte = appTxFeePerByte
, sppTxFeeFixed = appTxFeeFixed
, sppMaxBBSize = appMaxBBSize
, sppMaxTxSize = appMaxTxSize
, sppMaxBHSize = appMaxBHSize
Expand Down
5 changes: 3 additions & 2 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ import Cardano.Ledger.Binary (
)
import Cardano.Ledger.Binary.Coders
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Compactible (Compactible (fromCompact))
import Cardano.Ledger.Core
import Cardano.Ledger.Mary (Tx (..))
import Cardano.Ledger.MemoBytes (EqRaw (..))
Expand Down Expand Up @@ -369,8 +370,8 @@ alonzoMinFeeTx ::
Tx l era ->
Coin
alonzoMinFeeTx pp tx =
(tx ^. sizeTxF <×> pp ^. ppMinFeeAL)
<+> (pp ^. ppMinFeeBL)
(tx ^. sizeTxF <×> (fromCompact . unCoinPerByte) (pp ^. ppTxFeePerByteL))
<+> (pp ^. ppTxFeeFixedL)
<+> txscriptfee (pp ^. ppPricesL) allExunits
where
allExunits = totExUnits tx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import Cardano.Ledger.Alonzo.UTxO (AlonzoScriptsNeeded (..))
import Cardano.Ledger.BaseTypes
import Cardano.Ledger.Binary (EncCBOR)
import Cardano.Ledger.Coin (Coin (..), CompactForm (..))
import Cardano.Ledger.Compactible (Compactible (fromCompact))
import Cardano.Ledger.Credential (Credential (..))
import Cardano.Ledger.Mary (MaryEra)
import Cardano.Ledger.Mary.Value (
Expand Down Expand Up @@ -548,7 +549,7 @@ sumCollateral tx utxo =
sumCoinUTxO $ txInsFilter utxo $ tx ^. bodyTxL . collateralInputsTxBodyL

storageCost :: forall era t. (EraPParams era, EncCBOR t) => Integer -> PParams era -> t -> Coin
storageCost extra pp x = (extra + encodedLen @era x) <×> pp ^. ppMinFeeAL
storageCost extra pp x = (extra + encodedLen @era x) <×> fromCompact (unCoinPerByte $ pp ^. ppTxFeePerByteL)

addRedeemMap ::
(P.Data, Natural, Natural) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Cardano.Ledger.BaseTypes (SlotNo (..), StrictMaybe (..), boundRational)
import Cardano.Ledger.Binary (decCBOR, decodeFullAnnotator)
import Cardano.Ledger.Binary.Plain as Plain (serialize)
import Cardano.Ledger.Block (Block (Block))
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Coin (Coin (..), CompactForm (CompactCoin))
import Cardano.Ledger.Mary.Value (valueFromList)
import Cardano.Ledger.Plutus.CostModels (
CostModel,
Expand Down Expand Up @@ -298,8 +298,8 @@ goldenMinFee =
pricesParam = Prices priceMem priceSteps
pp =
emptyPParams
& ppMinFeeAL .~ Coin 44
& ppMinFeeBL .~ Coin 155381
& ppTxFeePerByteL .~ CoinPerByte (CompactCoin 44)
& ppTxFeeFixedL .~ Coin 155381
& ppPricesL .~ pricesParam

Coin 1006053 `shouldBe` alonzoMinFeeTx pp firstTx
Expand Down
7 changes: 6 additions & 1 deletion eras/babbage/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

## 1.13.0.0

* Renamed:
- `bppMinFeeA` -> `bppTxFeePerByte`
- `bppMinFeeB` -> `bppTxFeeFixed`
* Changed type of `bppMinFeeA` to `CoinPerByte`
* Moved `CoinPerByte` to `cardano-ledger-core`
* Change sets containing errors into `NonEmptySet` for `BabbageUtxowPredFailure`
* Change all lists into `NonEmpty` for `BabbageUtxoPredFailure`
* Add `babbageUtxoValidation`
* Add `babbageUtxoTests`
* Changed the type of the following fields to `CompactForm Coin` in `BabbagePParams`:
- `bppMinFeeA`
- `bppMinFeeB`
- `bppKeyDeposit`
- `bppMinPoolCost`
Expand Down Expand Up @@ -44,6 +48,7 @@

### `testlib`

* Moved `Arbitrary` and `ToExpr` instances of `CoinPerByte` to `cardano-ledger-core`
* Remove `huddle-cddl` and the `CDDL` modules.
* Add `plutus_v2_script` to CDDL exports
* Hide Shelley CDDL `protocol_version` and re-export a new one for Babbage
Expand Down
1 change: 0 additions & 1 deletion eras/babbage/impl/src/Cardano/Ledger/Babbage/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module Cardano.Ledger.Babbage.Core (
import Cardano.Ledger.Alonzo.Core
import Cardano.Ledger.Babbage.PParams (
BabbageEraPParams (..),
CoinPerByte (..),
ppCoinsPerUTxOByteL,
ppuCoinsPerUTxOByteL,
)
Expand Down
Loading