Skip to content

Commit 4c82185

Browse files
committed
Remove explicit EncCBOR, ToCBOR instances for AlonzoPParams
in favour of the ones defined in `EraPParams`
1 parent 46d4dbf commit 4c82185

File tree

1 file changed

+0
-89
lines changed
  • eras/alonzo/impl/src/Cardano/Ledger/Alonzo

1 file changed

+0
-89
lines changed

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/PParams.hs

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -76,35 +76,27 @@ import Cardano.Ledger.BaseTypes (
7676
Nonce (NeutralNonce),
7777
StrictMaybe (..),
7878
UnitInterval,
79-
isSNothing,
8079
)
8180
import qualified Cardano.Ledger.BaseTypes as BT (ProtVer (..))
8281
import Cardano.Ledger.Binary (
8382
DecCBOR (..),
8483
EncCBOR (..),
8584
Encoding,
8685
FromCBOR (..),
87-
ToCBOR (..),
8886
decodeRecordNamed,
8987
encodeFoldableAsDefLenList,
9088
encodeFoldableAsIndefLenList,
91-
encodeListLen,
9289
encodeMapLen,
9390
encodeNull,
9491
encodePreEncoded,
9592
serialize',
9693
)
9794
import Cardano.Ledger.Binary.Coders (
9895
Decode (..),
99-
Density (..),
100-
Encode (..),
10196
Field (..),
102-
Wrapped (..),
10397
decode,
104-
encode,
10598
field,
10699
invalidField,
107-
(!>),
108100
)
109101
import Cardano.Ledger.Coin (Coin (..))
110102
import Cardano.Ledger.Core (EraPParams (..))
@@ -414,35 +406,6 @@ instance EraGov AlonzoEra where
414406

415407
obligationGovState = const mempty
416408

417-
instance Era era => EncCBOR (AlonzoPParams Identity era) where
418-
encCBOR AlonzoPParams {..} =
419-
encodeListLen 24
420-
<> encCBOR appMinFeeA
421-
<> encCBOR appMinFeeB
422-
<> encCBOR appMaxBBSize
423-
<> encCBOR appMaxTxSize
424-
<> encCBOR appMaxBHSize
425-
<> encCBOR appKeyDeposit
426-
<> encCBOR appPoolDeposit
427-
<> encCBOR appEMax
428-
<> encCBOR appNOpt
429-
<> encCBOR appA0
430-
<> encCBOR appRho
431-
<> encCBOR appTau
432-
<> encCBOR appD
433-
<> encCBOR appExtraEntropy
434-
<> encCBOR appProtocolVersion
435-
<> encCBOR appMinPoolCost
436-
-- new/updated for alonzo
437-
<> encCBOR appCoinsPerUTxOWord
438-
<> encCBOR appCostModels
439-
<> encCBOR appPrices
440-
<> encCBOR appMaxTxExUnits
441-
<> encCBOR appMaxBlockExUnits
442-
<> encCBOR appMaxValSize
443-
<> encCBOR appCollateralPercentage
444-
<> encCBOR appMaxCollateralInputs
445-
446409
instance Era era => DecCBOR (AlonzoPParams Identity era) where
447410
decCBOR =
448411
decodeRecordNamed "PParams" (const 24) $ do
@@ -473,9 +436,6 @@ instance Era era => DecCBOR (AlonzoPParams Identity era) where
473436
appMaxCollateralInputs <- decCBOR
474437
pure AlonzoPParams {..}
475438

476-
instance Era era => ToCBOR (AlonzoPParams Identity era) where
477-
toCBOR = toEraCBOR @era
478-
479439
instance Era era => FromCBOR (AlonzoPParams Identity era) where
480440
fromCBOR = fromEraCBOR @era
481441

@@ -644,52 +604,6 @@ emptyAlonzoPParamsUpdate =
644604
, appMaxCollateralInputs = SNothing
645605
}
646606

647-
-- =======================================================
648-
-- A PParamsUpdate has StrictMaybe fields, we want to Sparse encode it, by
649-
-- writing only those fields where the field is (SJust x), that is the role of
650-
-- the local function (omitStrictMaybe key x)
651-
652-
encodePParamsUpdate ::
653-
AlonzoPParams StrictMaybe era ->
654-
Encode ('Closed 'Sparse) (AlonzoPParams StrictMaybe era)
655-
encodePParamsUpdate ppup =
656-
Keyed AlonzoPParams
657-
!> omitStrictMaybe 0 (appMinFeeA ppup) encCBOR
658-
!> omitStrictMaybe 1 (appMinFeeB ppup) encCBOR
659-
!> omitStrictMaybe 2 (appMaxBBSize ppup) encCBOR
660-
!> omitStrictMaybe 3 (appMaxTxSize ppup) encCBOR
661-
!> omitStrictMaybe 4 (appMaxBHSize ppup) encCBOR
662-
!> omitStrictMaybe 5 (appKeyDeposit ppup) encCBOR
663-
!> omitStrictMaybe 6 (appPoolDeposit ppup) encCBOR
664-
!> omitStrictMaybe 7 (appEMax ppup) encCBOR
665-
!> omitStrictMaybe 8 (appNOpt ppup) encCBOR
666-
!> omitStrictMaybe 9 (appA0 ppup) encCBOR
667-
!> omitStrictMaybe 10 (appRho ppup) encCBOR
668-
!> omitStrictMaybe 11 (appTau ppup) encCBOR
669-
!> omitStrictMaybe 12 (appD ppup) encCBOR
670-
!> omitStrictMaybe 13 (appExtraEntropy ppup) encCBOR
671-
!> omitStrictMaybe 14 (appProtocolVersion ppup) encCBOR
672-
!> omitStrictMaybe 16 (appMinPoolCost ppup) encCBOR
673-
!> omitStrictMaybe 17 (appCoinsPerUTxOWord ppup) encCBOR
674-
!> omitStrictMaybe 18 (appCostModels ppup) encCBOR
675-
!> omitStrictMaybe 19 (appPrices ppup) encCBOR
676-
!> omitStrictMaybe 20 (appMaxTxExUnits ppup) encCBOR
677-
!> omitStrictMaybe 21 (appMaxBlockExUnits ppup) encCBOR
678-
!> omitStrictMaybe 22 (appMaxValSize ppup) encCBOR
679-
!> omitStrictMaybe 23 (appCollateralPercentage ppup) encCBOR
680-
!> omitStrictMaybe 24 (appMaxCollateralInputs ppup) encCBOR
681-
where
682-
omitStrictMaybe ::
683-
Word -> StrictMaybe a -> (a -> Encoding) -> Encode ('Closed 'Sparse) (StrictMaybe a)
684-
omitStrictMaybe key x enc = Omit isSNothing (Key key (E (enc . fromSJust) x))
685-
686-
fromSJust :: StrictMaybe a -> a
687-
fromSJust (SJust x) = x
688-
fromSJust SNothing = error "SNothing in fromSJust. This should never happen, it is guarded by isSNothing."
689-
690-
instance Era era => EncCBOR (AlonzoPParams StrictMaybe era) where
691-
encCBOR ppup = encode (encodePParamsUpdate ppup)
692-
693607
updateField :: Word -> Field (AlonzoPParams StrictMaybe era)
694608
updateField = \case
695609
0 -> field (\x up -> up {appMinFeeA = SJust x}) From
@@ -722,9 +636,6 @@ instance Era era => DecCBOR (AlonzoPParams StrictMaybe era) where
722636
decCBOR =
723637
decode (SparseKeyed "PParamsUpdate" emptyAlonzoPParamsUpdate updateField [])
724638

725-
instance Era era => ToCBOR (AlonzoPParams StrictMaybe era) where
726-
toCBOR = toEraCBOR @era
727-
728639
instance Era era => FromCBOR (AlonzoPParams StrictMaybe era) where
729640
fromCBOR = fromEraCBOR @era
730641

0 commit comments

Comments
 (0)