{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Cardano.Ledger.Shelley.PParams (
emptyShelleyPParams,
emptyShelleyPParamsUpdate,
ShelleyPParams (..),
emptyPParams,
HKD,
PPUpdateEnv (..),
ProposedPPUpdates (..),
emptyPPPUpdates,
Update (..),
upgradeUpdate,
pvCanFollow,
hasLegalProtVerUpdate,
shelleyCommonPParamsHKDPairs,
shelleyCommonPParamsHKDPairsV6,
shelleyCommonPParamsHKDPairsV8,
)
where
import Cardano.Ledger.BaseTypes (
EpochInterval (..),
NonNegativeInterval,
Nonce (NeutralNonce),
ProtVer (..),
StrictMaybe (..),
UnitInterval,
invalidKey,
strictMaybeToMaybe,
succVersion,
)
import Cardano.Ledger.Binary (
DecCBOR (..),
DecCBORGroup (..),
EncCBOR (..),
EncCBORGroup (..),
FromCBOR (..),
ToCBOR (..),
decodeMapContents,
decodeRecordNamed,
decodeWord,
encodeListLen,
encodeMapLen,
encodeWord,
)
import Cardano.Ledger.Binary.Coders (Decode (From, RecD), decode, (<!))
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Core
import Cardano.Ledger.HKD (HKD, HKDFunctor (..))
import Cardano.Ledger.Hashes (GenDelegs)
import Cardano.Ledger.Orphans ()
import Cardano.Ledger.Shelley.Era (ShelleyEra)
import Cardano.Ledger.Slot (EpochNo (..), SlotNo (..))
import Control.DeepSeq (NFData)
import Control.Monad (unless)
import Data.Aeson (
FromJSON (..),
Key,
KeyValue,
ToJSON (..),
object,
pairs,
(.!=),
(.:),
(.:?),
(.=),
)
import qualified Data.Aeson as Aeson
import Data.Foldable (fold)
import Data.Functor.Identity (Identity)
import Data.List (nub)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe (mapMaybe)
import Data.Proxy
import Data.Void
import Data.Word (Word16, Word32)
import GHC.Generics (Generic)
import Lens.Micro (lens, (^.))
import NoThunks.Class (NoThunks (..))
data ShelleyPParams f era = ShelleyPParams
{ forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinFeeA :: !(HKD f Coin)
, forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinFeeB :: !(HKD f Coin)
, forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word32
sppMaxBBSize :: !(HKD f Word32)
, forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word32
sppMaxTxSize :: !(HKD f Word32)
, forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word16
sppMaxBHSize :: !(HKD f Word16)
, forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppKeyDeposit :: !(HKD f Coin)
, forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppPoolDeposit :: !(HKD f Coin)
, forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f EpochInterval
sppEMax :: !(HKD f EpochInterval)
, forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word16
sppNOpt :: !(HKD f Word16)
, forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f NonNegativeInterval
sppA0 :: !(HKD f NonNegativeInterval)
, forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f UnitInterval
sppRho :: !(HKD f UnitInterval)
, forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f UnitInterval
sppTau :: !(HKD f UnitInterval)
, forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f UnitInterval
sppD :: !(HKD f UnitInterval)
, :: !(HKD f Nonce)
, forall (f :: * -> *) era. ShelleyPParams f era -> HKD f ProtVer
sppProtocolVersion :: !(HKD f ProtVer)
, forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinUTxOValue :: !(HKD f Coin)
, forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinPoolCost :: !(HKD f Coin)
}
deriving (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (f :: * -> *) era x.
Rep (ShelleyPParams f era) x -> ShelleyPParams f era
forall (f :: * -> *) era x.
ShelleyPParams f era -> Rep (ShelleyPParams f era) x
$cto :: forall (f :: * -> *) era x.
Rep (ShelleyPParams f era) x -> ShelleyPParams f era
$cfrom :: forall (f :: * -> *) era x.
ShelleyPParams f era -> Rep (ShelleyPParams f era) x
Generic)
deriving instance Eq (ShelleyPParams Identity era)
deriving instance Ord (ShelleyPParams Identity era)
deriving instance Show (ShelleyPParams Identity era)
instance NoThunks (ShelleyPParams Identity era)
instance NFData (ShelleyPParams Identity era)
deriving instance Eq (ShelleyPParams StrictMaybe era)
deriving instance Ord (ShelleyPParams StrictMaybe era)
deriving instance Show (ShelleyPParams StrictMaybe era)
instance NoThunks (ShelleyPParams StrictMaybe era)
instance NFData (ShelleyPParams StrictMaybe era)
instance EraPParams ShelleyEra where
type PParamsHKD f ShelleyEra = ShelleyPParams f ShelleyEra
type UpgradePParams f ShelleyEra = Void
type DowngradePParams f ShelleyEra = Void
emptyPParamsIdentity :: PParamsHKD Identity ShelleyEra
emptyPParamsIdentity = forall era. Era era => ShelleyPParams Identity era
emptyShelleyPParams
emptyPParamsStrictMaybe :: PParamsHKD StrictMaybe ShelleyEra
emptyPParamsStrictMaybe = forall era. ShelleyPParams StrictMaybe era
emptyShelleyPParamsUpdate
upgradePParamsHKD :: forall (f :: * -> *).
(HKDApplicative f, EraPParams (PreviousEra ShelleyEra)) =>
UpgradePParams f ShelleyEra
-> PParamsHKD f (PreviousEra ShelleyEra) -> PParamsHKD f ShelleyEra
upgradePParamsHKD = forall a. HasCallStack => String -> a
error String
"IMPOSSIBLE! There cannot be PParams that can be upgraded to Shelley"
downgradePParamsHKD :: forall (f :: * -> *).
(HKDFunctor f, EraPParams (PreviousEra ShelleyEra)) =>
DowngradePParams f ShelleyEra
-> PParamsHKD f ShelleyEra -> PParamsHKD f (PreviousEra ShelleyEra)
downgradePParamsHKD = forall a. HasCallStack => String -> a
error String
"IMPOSSIBLE! There cannot be PParams that can be downgraded from Shelley"
hkdMinFeeAL :: forall (f :: * -> *).
HKDFunctor f =>
Lens' (PParamsHKD f ShelleyEra) (HKD f Coin)
hkdMinFeeAL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinFeeA forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f Coin
x -> PParamsHKD f ShelleyEra
pp {sppMinFeeA :: HKD f Coin
sppMinFeeA = HKD f Coin
x}
hkdMinFeeBL :: forall (f :: * -> *).
HKDFunctor f =>
Lens' (PParamsHKD f ShelleyEra) (HKD f Coin)
hkdMinFeeBL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinFeeB forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f Coin
x -> PParamsHKD f ShelleyEra
pp {sppMinFeeB :: HKD f Coin
sppMinFeeB = HKD f Coin
x}
hkdMaxBBSizeL :: forall (f :: * -> *).
HKDFunctor f =>
Lens' (PParamsHKD f ShelleyEra) (HKD f Word32)
hkdMaxBBSizeL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word32
sppMaxBBSize forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f Word32
x -> PParamsHKD f ShelleyEra
pp {sppMaxBBSize :: HKD f Word32
sppMaxBBSize = HKD f Word32
x}
hkdMaxTxSizeL :: forall (f :: * -> *).
HKDFunctor f =>
Lens' (PParamsHKD f ShelleyEra) (HKD f Word32)
hkdMaxTxSizeL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word32
sppMaxTxSize forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f Word32
x -> PParamsHKD f ShelleyEra
pp {sppMaxTxSize :: HKD f Word32
sppMaxTxSize = HKD f Word32
x}
hkdMaxBHSizeL :: forall (f :: * -> *).
HKDFunctor f =>
Lens' (PParamsHKD f ShelleyEra) (HKD f Word16)
hkdMaxBHSizeL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word16
sppMaxBHSize forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f Word16
x -> PParamsHKD f ShelleyEra
pp {sppMaxBHSize :: HKD f Word16
sppMaxBHSize = HKD f Word16
x}
hkdKeyDepositL :: forall (f :: * -> *).
HKDFunctor f =>
Lens' (PParamsHKD f ShelleyEra) (HKD f Coin)
hkdKeyDepositL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppKeyDeposit forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f Coin
x -> PParamsHKD f ShelleyEra
pp {sppKeyDeposit :: HKD f Coin
sppKeyDeposit = HKD f Coin
x}
hkdPoolDepositL :: forall (f :: * -> *).
HKDFunctor f =>
Lens' (PParamsHKD f ShelleyEra) (HKD f Coin)
hkdPoolDepositL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppPoolDeposit forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f Coin
x -> PParamsHKD f ShelleyEra
pp {sppPoolDeposit :: HKD f Coin
sppPoolDeposit = HKD f Coin
x}
hkdEMaxL :: forall (f :: * -> *).
HKDFunctor f =>
Lens' (PParamsHKD f ShelleyEra) (HKD f EpochInterval)
hkdEMaxL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f EpochInterval
sppEMax forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f EpochInterval
x -> PParamsHKD f ShelleyEra
pp {sppEMax :: HKD f EpochInterval
sppEMax = HKD f EpochInterval
x}
hkdNOptL :: forall (f :: * -> *).
HKDFunctor f =>
Lens' (PParamsHKD f ShelleyEra) (HKD f Word16)
hkdNOptL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word16
sppNOpt forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f Word16
x -> PParamsHKD f ShelleyEra
pp {sppNOpt :: HKD f Word16
sppNOpt = HKD f Word16
x}
hkdA0L :: forall (f :: * -> *).
HKDFunctor f =>
Lens' (PParamsHKD f ShelleyEra) (HKD f NonNegativeInterval)
hkdA0L = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f NonNegativeInterval
sppA0 forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f NonNegativeInterval
x -> PParamsHKD f ShelleyEra
pp {sppA0 :: HKD f NonNegativeInterval
sppA0 = HKD f NonNegativeInterval
x}
hkdRhoL :: forall (f :: * -> *).
HKDFunctor f =>
Lens' (PParamsHKD f ShelleyEra) (HKD f UnitInterval)
hkdRhoL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f UnitInterval
sppRho forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f UnitInterval
x -> PParamsHKD f ShelleyEra
pp {sppRho :: HKD f UnitInterval
sppRho = HKD f UnitInterval
x}
hkdTauL :: forall (f :: * -> *).
HKDFunctor f =>
Lens' (PParamsHKD f ShelleyEra) (HKD f UnitInterval)
hkdTauL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f UnitInterval
sppTau forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f UnitInterval
x -> PParamsHKD f ShelleyEra
pp {sppTau :: HKD f UnitInterval
sppTau = HKD f UnitInterval
x}
hkdDL :: forall (f :: * -> *).
(HKDFunctor f, ProtVerAtMost ShelleyEra 6) =>
Lens' (PParamsHKD f ShelleyEra) (HKD f UnitInterval)
hkdDL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f UnitInterval
sppD forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f UnitInterval
x -> PParamsHKD f ShelleyEra
pp {sppD :: HKD f UnitInterval
sppD = HKD f UnitInterval
x}
hkdExtraEntropyL :: forall (f :: * -> *).
(HKDFunctor f, ProtVerAtMost ShelleyEra 6) =>
Lens' (PParamsHKD f ShelleyEra) (HKD f Nonce)
hkdExtraEntropyL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Nonce
sppExtraEntropy forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f Nonce
x -> PParamsHKD f ShelleyEra
pp {sppExtraEntropy :: HKD f Nonce
sppExtraEntropy = HKD f Nonce
x}
hkdProtocolVersionL :: forall (f :: * -> *).
(HKDFunctor f, ProtVerAtMost ShelleyEra 8) =>
Lens' (PParamsHKD f ShelleyEra) (HKD f ProtVer)
hkdProtocolVersionL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era. ShelleyPParams f era -> HKD f ProtVer
sppProtocolVersion forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f ProtVer
x -> PParamsHKD f ShelleyEra
pp {sppProtocolVersion :: HKD f ProtVer
sppProtocolVersion = HKD f ProtVer
x}
hkdMinUTxOValueL :: forall (f :: * -> *).
(HKDFunctor f, ProtVerAtMost ShelleyEra 4) =>
Lens' (PParamsHKD f ShelleyEra) (HKD f Coin)
hkdMinUTxOValueL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinUTxOValue forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f Coin
x -> PParamsHKD f ShelleyEra
pp {sppMinUTxOValue :: HKD f Coin
sppMinUTxOValue = HKD f Coin
x}
hkdMinPoolCostL :: forall (f :: * -> *).
HKDFunctor f =>
Lens' (PParamsHKD f ShelleyEra) (HKD f Coin)
hkdMinPoolCostL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinPoolCost forall a b. (a -> b) -> a -> b
$ \PParamsHKD f ShelleyEra
pp HKD f Coin
x -> PParamsHKD f ShelleyEra
pp {sppMinPoolCost :: HKD f Coin
sppMinPoolCost = HKD f Coin
x}
instance Era era => EncCBOR (ShelleyPParams Identity era) where
encCBOR :: ShelleyPParams Identity era -> Encoding
encCBOR
ShelleyPParams {HKD Identity Word16
HKD Identity Word32
HKD Identity Coin
HKD Identity ProtVer
HKD Identity NonNegativeInterval
HKD Identity UnitInterval
HKD Identity Nonce
HKD Identity EpochInterval
sppMinPoolCost :: HKD Identity Coin
sppMinUTxOValue :: HKD Identity Coin
sppProtocolVersion :: HKD Identity ProtVer
sppExtraEntropy :: HKD Identity Nonce
sppD :: HKD Identity UnitInterval
sppTau :: HKD Identity UnitInterval
sppRho :: HKD Identity UnitInterval
sppA0 :: HKD Identity NonNegativeInterval
sppNOpt :: HKD Identity Word16
sppEMax :: HKD Identity EpochInterval
sppPoolDeposit :: HKD Identity Coin
sppKeyDeposit :: HKD Identity Coin
sppMaxBHSize :: HKD Identity Word16
sppMaxTxSize :: HKD Identity Word32
sppMaxBBSize :: HKD Identity Word32
sppMinFeeB :: HKD Identity Coin
sppMinFeeA :: HKD Identity Coin
sppMinPoolCost :: forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinUTxOValue :: forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppProtocolVersion :: forall (f :: * -> *) era. ShelleyPParams f era -> HKD f ProtVer
sppExtraEntropy :: forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Nonce
sppD :: forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f UnitInterval
sppTau :: forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f UnitInterval
sppRho :: forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f UnitInterval
sppA0 :: forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f NonNegativeInterval
sppNOpt :: forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word16
sppEMax :: forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f EpochInterval
sppPoolDeposit :: forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppKeyDeposit :: forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMaxBHSize :: forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word16
sppMaxTxSize :: forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word32
sppMaxBBSize :: forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word32
sppMinFeeB :: forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinFeeA :: forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
..} =
Word -> Encoding
encodeListLen Word
18
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity Coin
sppMinFeeA
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity Coin
sppMinFeeB
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity Word32
sppMaxBBSize
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity Word32
sppMaxTxSize
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity Word16
sppMaxBHSize
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity Coin
sppKeyDeposit
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity Coin
sppPoolDeposit
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity EpochInterval
sppEMax
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity Word16
sppNOpt
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity NonNegativeInterval
sppA0
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity UnitInterval
sppRho
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity UnitInterval
sppTau
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity UnitInterval
sppD
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity Nonce
sppExtraEntropy
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBORGroup a => a -> Encoding
encCBORGroup HKD Identity ProtVer
sppProtocolVersion
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity Coin
sppMinUTxOValue
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR HKD Identity Coin
sppMinPoolCost
instance Era era => DecCBOR (ShelleyPParams Identity era) where
decCBOR :: forall s. Decoder s (ShelleyPParams Identity era)
decCBOR = do
forall a s. Text -> (a -> Int) -> Decoder s a -> Decoder s a
decodeRecordNamed Text
"ShelleyPParams" (forall a b. a -> b -> a
const Int
18) forall a b. (a -> b) -> a -> b
$
forall (f :: * -> *) era.
HKD f Coin
-> HKD f Coin
-> HKD f Word32
-> HKD f Word32
-> HKD f Word16
-> HKD f Coin
-> HKD f Coin
-> HKD f EpochInterval
-> HKD f Word16
-> HKD f NonNegativeInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f Nonce
-> HKD f ProtVer
-> HKD f Coin
-> HKD f Coin
-> ShelleyPParams f era
ShelleyPParams @Identity
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBORGroup a => Decoder s a
decCBORGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a s. DecCBOR a => Decoder s a
decCBOR
instance Era era => ToCBOR (ShelleyPParams Identity era) where
toCBOR :: ShelleyPParams Identity era -> Encoding
toCBOR = forall era t. (Era era, EncCBOR t) => t -> Encoding
toEraCBOR @era
instance Era era => FromCBOR (ShelleyPParams Identity era) where
fromCBOR :: forall s. Decoder s (ShelleyPParams Identity era)
fromCBOR = forall era t s. (Era era, DecCBOR t) => Decoder s t
fromEraCBOR @era
instance
( EraPParams era
, PParamsHKD Identity era ~ ShelleyPParams Identity era
, ProtVerAtMost era 4
, ProtVerAtMost era 6
, ProtVerAtMost era 8
) =>
ToJSON (ShelleyPParams Identity era)
where
toJSON :: ShelleyPParams Identity era -> Value
toJSON = [Pair] -> Value
object forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era a e.
(EraPParams era, ProtVerAtMost era 4, ProtVerAtMost era 6,
ProtVerAtMost era 8, KeyValue e a) =>
PParamsHKD Identity era -> [a]
shelleyPParamsPairs
toEncoding :: ShelleyPParams Identity era -> Encoding
toEncoding = Series -> Encoding
pairs forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Monoid a => [a] -> a
mconcat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era a e.
(EraPParams era, ProtVerAtMost era 4, ProtVerAtMost era 6,
ProtVerAtMost era 8, KeyValue e a) =>
PParamsHKD Identity era -> [a]
shelleyPParamsPairs
shelleyPParamsPairs ::
forall era a e.
(EraPParams era, ProtVerAtMost era 4, ProtVerAtMost era 6, ProtVerAtMost era 8, KeyValue e a) =>
PParamsHKD Identity era ->
[a]
shelleyPParamsPairs :: forall era a e.
(EraPParams era, ProtVerAtMost era 4, ProtVerAtMost era 6,
ProtVerAtMost era 8, KeyValue e a) =>
PParamsHKD Identity era -> [a]
shelleyPParamsPairs PParamsHKD Identity era
pp =
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
(.=)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) era.
(HKDFunctor f, EraPParams era, ProtVerAtMost era 4,
ProtVerAtMost era 6, ProtVerAtMost era 8) =>
Proxy f -> PParamsHKD f era -> [(Key, HKD f Value)]
shelleyPParamsHKDPairs (forall {k} (t :: k). Proxy t
Proxy @Identity) PParamsHKD Identity era
pp
instance FromJSON (ShelleyPParams Identity era) where
parseJSON :: Value -> Parser (ShelleyPParams Identity era)
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"ShelleyPParams" forall a b. (a -> b) -> a -> b
$ \Object
obj -> do
forall (f :: * -> *) era.
HKD f Coin
-> HKD f Coin
-> HKD f Word32
-> HKD f Word32
-> HKD f Word16
-> HKD f Coin
-> HKD f Coin
-> HKD f EpochInterval
-> HKD f Word16
-> HKD f NonNegativeInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f Nonce
-> HKD f ProtVer
-> HKD f Coin
-> HKD f Coin
-> ShelleyPParams f era
ShelleyPParams
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"txFeePerByte"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"txFeeFixed"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"maxBlockBodySize"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"maxTxSize"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"maxBlockHeaderSize"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"stakeAddressDeposit"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"stakePoolDeposit"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"poolRetireMaxEpoch"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"stakePoolTargetNum"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"poolPledgeInfluence"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"monetaryExpansion"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"treasuryCut"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"decentralization"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"extraPraosEntropy"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"protocolVersion"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"minUTxOValue" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Monoid a => a
mempty
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"minPoolCost" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Monoid a => a
mempty
emptyShelleyPParams :: forall era. Era era => ShelleyPParams Identity era
emptyShelleyPParams :: forall era. Era era => ShelleyPParams Identity era
emptyShelleyPParams =
ShelleyPParams
{ sppMinFeeA :: HKD Identity Coin
sppMinFeeA = Integer -> Coin
Coin Integer
0
, sppMinFeeB :: HKD Identity Coin
sppMinFeeB = Integer -> Coin
Coin Integer
0
, sppMaxBBSize :: HKD Identity Word32
sppMaxBBSize = Word32
0
, sppMaxTxSize :: HKD Identity Word32
sppMaxTxSize = Word32
2048
, sppMaxBHSize :: HKD Identity Word16
sppMaxBHSize = Word16
0
, sppKeyDeposit :: HKD Identity Coin
sppKeyDeposit = Integer -> Coin
Coin Integer
0
, sppPoolDeposit :: HKD Identity Coin
sppPoolDeposit = Integer -> Coin
Coin Integer
0
, sppEMax :: HKD Identity EpochInterval
sppEMax = Word32 -> EpochInterval
EpochInterval Word32
0
, sppNOpt :: HKD Identity Word16
sppNOpt = Word16
100
, sppA0 :: HKD Identity NonNegativeInterval
sppA0 = forall a. Bounded a => a
minBound
, sppRho :: HKD Identity UnitInterval
sppRho = forall a. Bounded a => a
minBound
, sppTau :: HKD Identity UnitInterval
sppTau = forall a. Bounded a => a
minBound
, sppD :: HKD Identity UnitInterval
sppD = forall a. Bounded a => a
minBound
, sppExtraEntropy :: HKD Identity Nonce
sppExtraEntropy = Nonce
NeutralNonce
, sppProtocolVersion :: HKD Identity ProtVer
sppProtocolVersion = Version -> Natural -> ProtVer
ProtVer (forall era. Era era => Version
eraProtVerLow @era) Natural
0
, sppMinUTxOValue :: HKD Identity Coin
sppMinUTxOValue = forall a. Monoid a => a
mempty
, sppMinPoolCost :: HKD Identity Coin
sppMinPoolCost = forall a. Monoid a => a
mempty
}
emptyShelleyPParamsUpdate :: ShelleyPParams StrictMaybe era
emptyShelleyPParamsUpdate :: forall era. ShelleyPParams StrictMaybe era
emptyShelleyPParamsUpdate =
ShelleyPParams
{ sppMinFeeA :: HKD StrictMaybe Coin
sppMinFeeA = forall a. StrictMaybe a
SNothing
, sppMinFeeB :: HKD StrictMaybe Coin
sppMinFeeB = forall a. StrictMaybe a
SNothing
, sppMaxBBSize :: HKD StrictMaybe Word32
sppMaxBBSize = forall a. StrictMaybe a
SNothing
, sppMaxTxSize :: HKD StrictMaybe Word32
sppMaxTxSize = forall a. StrictMaybe a
SNothing
, sppMaxBHSize :: HKD StrictMaybe Word16
sppMaxBHSize = forall a. StrictMaybe a
SNothing
, sppKeyDeposit :: HKD StrictMaybe Coin
sppKeyDeposit = forall a. StrictMaybe a
SNothing
, sppPoolDeposit :: HKD StrictMaybe Coin
sppPoolDeposit = forall a. StrictMaybe a
SNothing
, sppEMax :: HKD StrictMaybe EpochInterval
sppEMax = forall a. StrictMaybe a
SNothing
, sppNOpt :: HKD StrictMaybe Word16
sppNOpt = forall a. StrictMaybe a
SNothing
, sppA0 :: HKD StrictMaybe NonNegativeInterval
sppA0 = forall a. StrictMaybe a
SNothing
, sppRho :: HKD StrictMaybe UnitInterval
sppRho = forall a. StrictMaybe a
SNothing
, sppTau :: HKD StrictMaybe UnitInterval
sppTau = forall a. StrictMaybe a
SNothing
, sppD :: HKD StrictMaybe UnitInterval
sppD = forall a. StrictMaybe a
SNothing
, sppExtraEntropy :: HKD StrictMaybe Nonce
sppExtraEntropy = forall a. StrictMaybe a
SNothing
, sppProtocolVersion :: HKD StrictMaybe ProtVer
sppProtocolVersion = forall a. StrictMaybe a
SNothing
, sppMinUTxOValue :: HKD StrictMaybe Coin
sppMinUTxOValue = forall a. StrictMaybe a
SNothing
, sppMinPoolCost :: HKD StrictMaybe Coin
sppMinPoolCost = forall a. StrictMaybe a
SNothing
}
data Update era
= Update !(ProposedPPUpdates era) !EpochNo
deriving (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x. Rep (Update era) x -> Update era
forall era x. Update era -> Rep (Update era) x
$cto :: forall era x. Rep (Update era) x -> Update era
$cfrom :: forall era x. Update era -> Rep (Update era) x
Generic)
deriving instance Eq (PParamsUpdate era) => Eq (Update era)
instance NFData (PParamsUpdate era) => NFData (Update era)
deriving instance Show (PParamsUpdate era) => Show (Update era)
instance NoThunks (PParamsUpdate era) => NoThunks (Update era)
instance (Era era, EncCBOR (PParamsUpdate era)) => EncCBOR (Update era) where
encCBOR :: Update era -> Encoding
encCBOR (Update ProposedPPUpdates era
ppUpdate EpochNo
e) =
Word -> Encoding
encodeListLen Word
2 forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR ProposedPPUpdates era
ppUpdate forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> Encoding
encCBOR EpochNo
e
instance
(Era era, DecCBOR (PParamsUpdate era)) =>
DecCBOR (Update era)
where
decCBOR :: forall s. Decoder s (Update era)
decCBOR = forall (w :: Wrapped) t s. Decode w t -> Decoder s t
decode forall a b. (a -> b) -> a -> b
$ forall t. t -> Decode ('Closed 'Dense) t
RecD forall era. ProposedPPUpdates era -> EpochNo -> Update era
Update forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
data PPUpdateEnv = PPUpdateEnv SlotNo GenDelegs
deriving (Int -> PPUpdateEnv -> ShowS
[PPUpdateEnv] -> ShowS
PPUpdateEnv -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PPUpdateEnv] -> ShowS
$cshowList :: [PPUpdateEnv] -> ShowS
show :: PPUpdateEnv -> String
$cshow :: PPUpdateEnv -> String
showsPrec :: Int -> PPUpdateEnv -> ShowS
$cshowsPrec :: Int -> PPUpdateEnv -> ShowS
Show, PPUpdateEnv -> PPUpdateEnv -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PPUpdateEnv -> PPUpdateEnv -> Bool
$c/= :: PPUpdateEnv -> PPUpdateEnv -> Bool
== :: PPUpdateEnv -> PPUpdateEnv -> Bool
$c== :: PPUpdateEnv -> PPUpdateEnv -> Bool
Eq, forall x. Rep PPUpdateEnv x -> PPUpdateEnv
forall x. PPUpdateEnv -> Rep PPUpdateEnv x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PPUpdateEnv x -> PPUpdateEnv
$cfrom :: forall x. PPUpdateEnv -> Rep PPUpdateEnv x
Generic)
instance NoThunks PPUpdateEnv
{-# DEPRECATED PPUpdateEnv "As unused" #-}
instance Era era => EncCBOR (ShelleyPParams StrictMaybe era) where
encCBOR :: ShelleyPParams StrictMaybe era -> Encoding
encCBOR ShelleyPParams StrictMaybe era
ppup =
let l :: [Encoding]
l =
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe
[ forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
0 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinFeeA ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
1 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinFeeB ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
2 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word32
sppMaxBBSize ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
3 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word32
sppMaxTxSize ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
4 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word16
sppMaxBHSize ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
5 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppKeyDeposit ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
6 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppPoolDeposit ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
7 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f EpochInterval
sppEMax ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
8 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Word16
sppNOpt ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
9 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f NonNegativeInterval
sppA0 ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
10 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f UnitInterval
sppRho ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
11 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f UnitInterval
sppTau ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
12 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era.
ShelleyPParams f era -> HKD f UnitInterval
sppD ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
13 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Nonce
sppExtraEntropy ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
14 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era. ShelleyPParams f era -> HKD f ProtVer
sppProtocolVersion ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
15 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinUTxOValue ShelleyPParams StrictMaybe era
ppup
, forall {t}. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
16 forall a. EncCBOR a => a -> Encoding
encCBOR forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (f :: * -> *) era. ShelleyPParams f era -> HKD f Coin
sppMinPoolCost ShelleyPParams StrictMaybe era
ppup
]
n :: Word
n = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t a -> Int
length [Encoding]
l
in Word -> Encoding
encodeMapLen Word
n forall a. Semigroup a => a -> a -> a
<> forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold [Encoding]
l
where
encodeMapElement :: Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
i t -> Encoding
encoder t
x = forall a. a -> StrictMaybe a
SJust (Word -> Encoding
encodeWord Word
i forall a. Semigroup a => a -> a -> a
<> t -> Encoding
encoder t
x)
instance Era era => DecCBOR (ShelleyPParams StrictMaybe era) where
decCBOR :: forall s. Decoder s (ShelleyPParams StrictMaybe era)
decCBOR = do
[(Int,
ShelleyPParams StrictMaybe era -> ShelleyPParams StrictMaybe era)]
mapParts <-
forall s a. Decoder s a -> Decoder s [a]
decodeMapContents forall a b. (a -> b) -> a -> b
$
forall s. Decoder s Word
decodeWord forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Word
0 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Coin
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
0, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppMinFeeA :: HKD StrictMaybe Coin
sppMinFeeA = forall a. a -> StrictMaybe a
SJust Coin
x})
Word
1 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Coin
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
1, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppMinFeeB :: HKD StrictMaybe Coin
sppMinFeeB = forall a. a -> StrictMaybe a
SJust Coin
x})
Word
2 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Word32
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
2, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppMaxBBSize :: HKD StrictMaybe Word32
sppMaxBBSize = forall a. a -> StrictMaybe a
SJust Word32
x})
Word
3 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Word32
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
3, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppMaxTxSize :: HKD StrictMaybe Word32
sppMaxTxSize = forall a. a -> StrictMaybe a
SJust Word32
x})
Word
4 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Word16
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
4, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppMaxBHSize :: HKD StrictMaybe Word16
sppMaxBHSize = forall a. a -> StrictMaybe a
SJust Word16
x})
Word
5 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Coin
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
5, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppKeyDeposit :: HKD StrictMaybe Coin
sppKeyDeposit = forall a. a -> StrictMaybe a
SJust Coin
x})
Word
6 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Coin
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
6, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppPoolDeposit :: HKD StrictMaybe Coin
sppPoolDeposit = forall a. a -> StrictMaybe a
SJust Coin
x})
Word
7 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \EpochInterval
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
7, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppEMax :: HKD StrictMaybe EpochInterval
sppEMax = forall a. a -> StrictMaybe a
SJust EpochInterval
x})
Word
8 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Word16
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
8, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppNOpt :: HKD StrictMaybe Word16
sppNOpt = forall a. a -> StrictMaybe a
SJust Word16
x})
Word
9 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \NonNegativeInterval
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
9, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppA0 :: HKD StrictMaybe NonNegativeInterval
sppA0 = forall a. a -> StrictMaybe a
SJust NonNegativeInterval
x})
Word
10 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \UnitInterval
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
10, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppRho :: HKD StrictMaybe UnitInterval
sppRho = forall a. a -> StrictMaybe a
SJust UnitInterval
x})
Word
11 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \UnitInterval
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
11, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppTau :: HKD StrictMaybe UnitInterval
sppTau = forall a. a -> StrictMaybe a
SJust UnitInterval
x})
Word
12 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \UnitInterval
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
12, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppD :: HKD StrictMaybe UnitInterval
sppD = forall a. a -> StrictMaybe a
SJust UnitInterval
x})
Word
13 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Nonce
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
13, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppExtraEntropy :: HKD StrictMaybe Nonce
sppExtraEntropy = forall a. a -> StrictMaybe a
SJust Nonce
x})
Word
14 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ProtVer
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
14, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppProtocolVersion :: HKD StrictMaybe ProtVer
sppProtocolVersion = forall a. a -> StrictMaybe a
SJust ProtVer
x})
Word
15 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Coin
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
15, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppMinUTxOValue :: HKD StrictMaybe Coin
sppMinUTxOValue = forall a. a -> StrictMaybe a
SJust Coin
x})
Word
16 -> forall a s. DecCBOR a => Decoder s a
decCBOR forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Coin
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
16, \ShelleyPParams StrictMaybe era
up -> ShelleyPParams StrictMaybe era
up {sppMinPoolCost :: HKD StrictMaybe Coin
sppMinPoolCost = forall a. a -> StrictMaybe a
SJust Coin
x})
Word
k -> forall (m :: * -> *) a. MonadFail m => Word -> m a
invalidKey Word
k
let fields :: [Int]
fields = forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Int,
ShelleyPParams StrictMaybe era -> ShelleyPParams StrictMaybe era)]
mapParts :: [Int]
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless
(forall a. Eq a => [a] -> [a]
nub [Int]
fields forall a. Eq a => a -> a -> Bool
== [Int]
fields)
(forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"duplicate keys: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show [Int]
fields)
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr forall a b. (a -> b) -> a -> b
($) forall era. ShelleyPParams StrictMaybe era
emptyShelleyPParamsUpdate (forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Int,
ShelleyPParams StrictMaybe era -> ShelleyPParams StrictMaybe era)]
mapParts)
instance Era era => ToCBOR (ShelleyPParams StrictMaybe era) where
toCBOR :: ShelleyPParams StrictMaybe era -> Encoding
toCBOR = forall era t. (Era era, EncCBOR t) => t -> Encoding
toEraCBOR @era
instance Era era => FromCBOR (ShelleyPParams StrictMaybe era) where
fromCBOR :: forall s. Decoder s (ShelleyPParams StrictMaybe era)
fromCBOR = forall era t s. (Era era, DecCBOR t) => Decoder s t
fromEraCBOR @era
instance
( EraPParams era
, PParamsHKD StrictMaybe era ~ ShelleyPParams StrictMaybe era
, ProtVerAtMost era 4
, ProtVerAtMost era 6
, ProtVerAtMost era 8
) =>
ToJSON (ShelleyPParams StrictMaybe era)
where
toJSON :: ShelleyPParams StrictMaybe era -> Value
toJSON = [Pair] -> Value
object forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era a e.
(EraPParams era, ProtVerAtMost era 4, ProtVerAtMost era 6,
ProtVerAtMost era 8, KeyValue e a) =>
PParamsHKD StrictMaybe era -> [a]
shelleyPParamsUpdatePairs
toEncoding :: ShelleyPParams StrictMaybe era -> Encoding
toEncoding = Series -> Encoding
pairs forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Monoid a => [a] -> a
mconcat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era a e.
(EraPParams era, ProtVerAtMost era 4, ProtVerAtMost era 6,
ProtVerAtMost era 8, KeyValue e a) =>
PParamsHKD StrictMaybe era -> [a]
shelleyPParamsUpdatePairs
shelleyPParamsUpdatePairs ::
forall era a e.
(EraPParams era, ProtVerAtMost era 4, ProtVerAtMost era 6, ProtVerAtMost era 8, KeyValue e a) =>
PParamsHKD StrictMaybe era ->
[a]
shelleyPParamsUpdatePairs :: forall era a e.
(EraPParams era, ProtVerAtMost era 4, ProtVerAtMost era 6,
ProtVerAtMost era 8, KeyValue e a) =>
PParamsHKD StrictMaybe era -> [a]
shelleyPParamsUpdatePairs PParamsHKD StrictMaybe era
pp =
[ Key
k forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Value
v
| (Key
k, SJust Value
v) <- forall (f :: * -> *) era.
(HKDFunctor f, EraPParams era, ProtVerAtMost era 4,
ProtVerAtMost era 6, ProtVerAtMost era 8) =>
Proxy f -> PParamsHKD f era -> [(Key, HKD f Value)]
shelleyPParamsHKDPairs (forall {k} (t :: k). Proxy t
Proxy @StrictMaybe) PParamsHKD StrictMaybe era
pp
]
shelleyPParamsHKDPairs ::
forall f era.
(HKDFunctor f, EraPParams era, ProtVerAtMost era 4, ProtVerAtMost era 6, ProtVerAtMost era 8) =>
Proxy f ->
PParamsHKD f era ->
[(Key, HKD f Aeson.Value)]
shelleyPParamsHKDPairs :: forall (f :: * -> *) era.
(HKDFunctor f, EraPParams era, ProtVerAtMost era 4,
ProtVerAtMost era 6, ProtVerAtMost era 8) =>
Proxy f -> PParamsHKD f era -> [(Key, HKD f Value)]
shelleyPParamsHKDPairs Proxy f
px PParamsHKD f era
pp =
forall (f :: * -> *) era.
(HKDFunctor f, EraPParams era) =>
Proxy f -> PParamsHKD f era -> [(Key, HKD f Value)]
shelleyCommonPParamsHKDPairs Proxy f
px PParamsHKD f era
pp
forall a. [a] -> [a] -> [a]
++ forall (f :: * -> *) era.
(HKDFunctor f, EraPParams era, ProtVerAtMost era 6) =>
Proxy f -> PParamsHKD f era -> [(Key, HKD f Value)]
shelleyCommonPParamsHKDPairsV6 Proxy f
px PParamsHKD f era
pp
forall a. [a] -> [a] -> [a]
++ forall (f :: * -> *) era.
(HKDFunctor f, EraPParams era, ProtVerAtMost era 8) =>
Proxy f -> PParamsHKD f era -> [(Key, HKD f Value)]
shelleyCommonPParamsHKDPairsV8 Proxy f
px PParamsHKD f era
pp
forall a. [a] -> [a] -> [a]
++ [(Key
"minUTxOValue", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @Coin) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f, ProtVerAtMost era 4) =>
Lens' (PParamsHKD f era) (HKD f Coin)
hkdMinUTxOValueL @era @f))]
shelleyCommonPParamsHKDPairsV6 ::
forall f era.
(HKDFunctor f, EraPParams era, ProtVerAtMost era 6) =>
Proxy f ->
PParamsHKD f era ->
[(Key, HKD f Aeson.Value)]
shelleyCommonPParamsHKDPairsV6 :: forall (f :: * -> *) era.
(HKDFunctor f, EraPParams era, ProtVerAtMost era 6) =>
Proxy f -> PParamsHKD f era -> [(Key, HKD f Value)]
shelleyCommonPParamsHKDPairsV6 Proxy f
px PParamsHKD f era
pp =
[ (Key
"decentralization", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @UnitInterval) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f, ProtVerAtMost era 6) =>
Lens' (PParamsHKD f era) (HKD f UnitInterval)
hkdDL @era @f))
, (Key
"extraPraosEntropy", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @Nonce) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f, ProtVerAtMost era 6) =>
Lens' (PParamsHKD f era) (HKD f Nonce)
hkdExtraEntropyL @era @f))
]
shelleyCommonPParamsHKDPairsV8 ::
forall f era.
(HKDFunctor f, EraPParams era, ProtVerAtMost era 8) =>
Proxy f ->
PParamsHKD f era ->
[(Key, HKD f Aeson.Value)]
shelleyCommonPParamsHKDPairsV8 :: forall (f :: * -> *) era.
(HKDFunctor f, EraPParams era, ProtVerAtMost era 8) =>
Proxy f -> PParamsHKD f era -> [(Key, HKD f Value)]
shelleyCommonPParamsHKDPairsV8 Proxy f
px PParamsHKD f era
pp =
[ (Key
"protocolVersion", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @ProtVer) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f, ProtVerAtMost era 8) =>
Lens' (PParamsHKD f era) (HKD f ProtVer)
hkdProtocolVersionL @era @f))
]
shelleyCommonPParamsHKDPairs ::
forall f era.
(HKDFunctor f, EraPParams era) =>
Proxy f ->
PParamsHKD f era ->
[(Key, HKD f Aeson.Value)]
shelleyCommonPParamsHKDPairs :: forall (f :: * -> *) era.
(HKDFunctor f, EraPParams era) =>
Proxy f -> PParamsHKD f era -> [(Key, HKD f Value)]
shelleyCommonPParamsHKDPairs Proxy f
px PParamsHKD f era
pp =
[ (Key
"txFeePerByte", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @Coin) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Coin)
hkdMinFeeAL @_ @f :: HKD f Coin))
, (Key
"txFeeFixed", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @Coin) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Coin)
hkdMinFeeBL @era @f))
, (Key
"maxBlockBodySize", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @Word32) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Word32)
hkdMaxBBSizeL @era @f))
, (Key
"maxTxSize", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @Word32) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Word32)
hkdMaxTxSizeL @era @f))
, (Key
"maxBlockHeaderSize", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @Word16) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Word16)
hkdMaxBHSizeL @era @f))
, (Key
"stakeAddressDeposit", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @Coin) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Coin)
hkdKeyDepositL @era @f))
, (Key
"stakePoolDeposit", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @Coin) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Coin)
hkdPoolDepositL @era @f))
, (Key
"poolRetireMaxEpoch", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @EpochInterval) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f EpochInterval)
hkdEMaxL @era @f))
, (Key
"stakePoolTargetNum", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @Word16) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Word16)
hkdNOptL @era @f))
, (Key
"poolPledgeInfluence", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @NonNegativeInterval) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f NonNegativeInterval)
hkdA0L @era @f))
, (Key
"monetaryExpansion", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @UnitInterval) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f UnitInterval)
hkdRhoL @era @f))
, (Key
"treasuryCut", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @UnitInterval) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f UnitInterval)
hkdTauL @era @f))
, (Key
"minPoolCost", forall (f :: * -> *) (proxy :: (* -> *) -> *) a b.
HKDFunctor f =>
proxy f -> (a -> b) -> HKD f a -> HKD f b
hkdMap Proxy f
px (forall a. ToJSON a => a -> Value
toJSON @Coin) (PParamsHKD f era
pp forall s a. s -> Getting a s a -> a
^. forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Coin)
hkdMinPoolCostL @era @f))
]
newtype ProposedPPUpdates era
= ProposedPPUpdates (Map (KeyHash 'Genesis) (PParamsUpdate era))
deriving (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x.
Rep (ProposedPPUpdates era) x -> ProposedPPUpdates era
forall era x.
ProposedPPUpdates era -> Rep (ProposedPPUpdates era) x
$cto :: forall era x.
Rep (ProposedPPUpdates era) x -> ProposedPPUpdates era
$cfrom :: forall era x.
ProposedPPUpdates era -> Rep (ProposedPPUpdates era) x
Generic, NonEmpty (ProposedPPUpdates era) -> ProposedPPUpdates era
ProposedPPUpdates era
-> ProposedPPUpdates era -> ProposedPPUpdates era
forall b.
Integral b =>
b -> ProposedPPUpdates era -> ProposedPPUpdates era
forall era.
NonEmpty (ProposedPPUpdates era) -> ProposedPPUpdates era
forall era.
ProposedPPUpdates era
-> ProposedPPUpdates era -> ProposedPPUpdates era
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall era b.
Integral b =>
b -> ProposedPPUpdates era -> ProposedPPUpdates era
stimes :: forall b.
Integral b =>
b -> ProposedPPUpdates era -> ProposedPPUpdates era
$cstimes :: forall era b.
Integral b =>
b -> ProposedPPUpdates era -> ProposedPPUpdates era
sconcat :: NonEmpty (ProposedPPUpdates era) -> ProposedPPUpdates era
$csconcat :: forall era.
NonEmpty (ProposedPPUpdates era) -> ProposedPPUpdates era
<> :: ProposedPPUpdates era
-> ProposedPPUpdates era -> ProposedPPUpdates era
$c<> :: forall era.
ProposedPPUpdates era
-> ProposedPPUpdates era -> ProposedPPUpdates era
Semigroup, ProposedPPUpdates era
[ProposedPPUpdates era] -> ProposedPPUpdates era
ProposedPPUpdates era
-> ProposedPPUpdates era -> ProposedPPUpdates era
forall era. Semigroup (ProposedPPUpdates era)
forall era. ProposedPPUpdates era
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall era. [ProposedPPUpdates era] -> ProposedPPUpdates era
forall era.
ProposedPPUpdates era
-> ProposedPPUpdates era -> ProposedPPUpdates era
mconcat :: [ProposedPPUpdates era] -> ProposedPPUpdates era
$cmconcat :: forall era. [ProposedPPUpdates era] -> ProposedPPUpdates era
mappend :: ProposedPPUpdates era
-> ProposedPPUpdates era -> ProposedPPUpdates era
$cmappend :: forall era.
ProposedPPUpdates era
-> ProposedPPUpdates era -> ProposedPPUpdates era
mempty :: ProposedPPUpdates era
$cmempty :: forall era. ProposedPPUpdates era
Monoid)
deriving instance Eq (PParamsUpdate era) => Eq (ProposedPPUpdates era)
deriving instance NFData (PParamsUpdate era) => NFData (ProposedPPUpdates era)
deriving instance Show (PParamsUpdate era) => Show (ProposedPPUpdates era)
instance NoThunks (PParamsUpdate era) => NoThunks (ProposedPPUpdates era)
deriving instance (Era era, ToCBOR (PParamsUpdate era)) => ToCBOR (ProposedPPUpdates era)
deriving instance (Era era, FromCBOR (PParamsUpdate era)) => FromCBOR (ProposedPPUpdates era)
deriving instance (Era era, EncCBOR (PParamsUpdate era)) => EncCBOR (ProposedPPUpdates era)
deriving instance (Era era, DecCBOR (PParamsUpdate era)) => DecCBOR (ProposedPPUpdates era)
instance EraPParams era => ToJSON (ProposedPPUpdates era) where
toJSON :: ProposedPPUpdates era -> Value
toJSON (ProposedPPUpdates Map (KeyHash 'Genesis) (PParamsUpdate era)
ppUpdates) = forall a. ToJSON a => a -> Value
toJSON forall a b. (a -> b) -> a -> b
$ forall k a. Map k a -> [(k, a)]
Map.toList Map (KeyHash 'Genesis) (PParamsUpdate era)
ppUpdates
toEncoding :: ProposedPPUpdates era -> Encoding
toEncoding (ProposedPPUpdates Map (KeyHash 'Genesis) (PParamsUpdate era)
ppUpdates) = forall a. ToJSON a => a -> Encoding
toEncoding forall a b. (a -> b) -> a -> b
$ forall k a. Map k a -> [(k, a)]
Map.toList Map (KeyHash 'Genesis) (PParamsUpdate era)
ppUpdates
emptyPPPUpdates :: ProposedPPUpdates era
emptyPPPUpdates :: forall era. ProposedPPUpdates era
emptyPPPUpdates = forall era.
Map (KeyHash 'Genesis) (PParamsUpdate era) -> ProposedPPUpdates era
ProposedPPUpdates forall k a. Map k a
Map.empty
pvCanFollow ::
ProtVer ->
ProtVer ->
Bool
pvCanFollow :: ProtVer -> ProtVer -> Bool
pvCanFollow (ProtVer Version
curMajor Natural
curMinor) (ProtVer Version
newMajor Natural
newMinor) =
(forall (m :: * -> *). MonadFail m => Version -> m Version
succVersion Version
curMajor, Natural
0) forall a. Eq a => a -> a -> Bool
== (forall a. a -> Maybe a
Just Version
newMajor, Natural
newMinor)
Bool -> Bool -> Bool
|| (Version
curMajor, Natural
curMinor forall a. Num a => a -> a -> a
+ Natural
1) forall a. Eq a => a -> a -> Bool
== (Version
newMajor, Natural
newMinor)
hasLegalProtVerUpdate ::
(ProtVerAtMost era 8, EraPParams era) => PParams era -> PParamsUpdate era -> Bool
hasLegalProtVerUpdate :: forall era.
(ProtVerAtMost era 8, EraPParams era) =>
PParams era -> PParamsUpdate era -> Bool
hasLegalProtVerUpdate PParams era
pp PParamsUpdate era
ppu =
case PParamsUpdate era
ppu forall s a. s -> Getting a s a -> a
^. forall era.
(EraPParams era, ProtVerAtMost era 8) =>
Lens' (PParamsUpdate era) (StrictMaybe ProtVer)
ppuProtocolVersionL of
StrictMaybe ProtVer
SNothing -> Bool
True
SJust ProtVer
newProtVer -> ProtVer -> ProtVer -> Bool
pvCanFollow (PParams era
pp forall s a. s -> Getting a s a -> a
^. forall era. EraPParams era => Lens' (PParams era) ProtVer
ppProtocolVersionL) ProtVer
newProtVer
upgradeUpdate ::
forall era.
( EraPParams era
, EraPParams (PreviousEra era)
) =>
UpgradePParams StrictMaybe era ->
Update (PreviousEra era) ->
Update era
upgradeUpdate :: forall era.
(EraPParams era, EraPParams (PreviousEra era)) =>
UpgradePParams StrictMaybe era
-> Update (PreviousEra era) -> Update era
upgradeUpdate UpgradePParams StrictMaybe era
args (Update ProposedPPUpdates (PreviousEra era)
pp EpochNo
epoch) = forall era. ProposedPPUpdates era -> EpochNo -> Update era
Update (forall era.
(EraPParams era, EraPParams (PreviousEra era)) =>
UpgradePParams StrictMaybe era
-> ProposedPPUpdates (PreviousEra era) -> ProposedPPUpdates era
upgradeProposedPPUpdates @era UpgradePParams StrictMaybe era
args ProposedPPUpdates (PreviousEra era)
pp) EpochNo
epoch
upgradeProposedPPUpdates ::
( EraPParams era
, EraPParams (PreviousEra era)
) =>
UpgradePParams StrictMaybe era ->
ProposedPPUpdates (PreviousEra era) ->
ProposedPPUpdates era
upgradeProposedPPUpdates :: forall era.
(EraPParams era, EraPParams (PreviousEra era)) =>
UpgradePParams StrictMaybe era
-> ProposedPPUpdates (PreviousEra era) -> ProposedPPUpdates era
upgradeProposedPPUpdates UpgradePParams StrictMaybe era
args (ProposedPPUpdates Map (KeyHash 'Genesis) (PParamsUpdate (PreviousEra era))
ppus) =
forall era.
Map (KeyHash 'Genesis) (PParamsUpdate era) -> ProposedPPUpdates era
ProposedPPUpdates forall a b. (a -> b) -> a -> b
$ forall era.
(EraPParams era, EraPParams (PreviousEra era)) =>
UpgradePParams StrictMaybe era
-> PParamsUpdate (PreviousEra era) -> PParamsUpdate era
upgradePParamsUpdate UpgradePParams StrictMaybe era
args forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map (KeyHash 'Genesis) (PParamsUpdate (PreviousEra era))
ppus