{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Cardano.Ledger.Alonzo.Translation where

import Cardano.Ledger.Alonzo.Core hiding (Tx)
import qualified Cardano.Ledger.Alonzo.Core as Core
import Cardano.Ledger.Alonzo.Era (AlonzoEra)
import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis (..))
import Cardano.Ledger.Alonzo.PParams ()
import Cardano.Ledger.Alonzo.Tx (AlonzoTx (..), IsValid (..))
import Cardano.Ledger.Binary (DecoderError)
import Cardano.Ledger.CertState (CommitteeState (..), PState (..), VState (..))
import Cardano.Ledger.Shelley.LedgerState (
  CertState (..),
  DState (..),
  EpochState (..),
  LedgerState (..),
  NewEpochState (..),
  UTxOState (..),
 )
import Cardano.Ledger.Shelley.PParams (ProposedPPUpdates (..))
import Cardano.Ledger.UTxO (UTxO (..))
import Data.Default (def)
import qualified Data.Map.Strict as Map
import Lens.Micro ((^.))

--------------------------------------------------------------------------------
-- Translation from Mary to Alonzo
--
-- The instances below are needed by the consensus layer. Do not remove any of
-- them without coordinating with consensus.
--
-- Please add auxiliary instances and other declarations at the bottom of this
-- module, not in the list below so that it remains clear which instances the
-- consensus layer needs.
--
-- WARNING: when a translation instance currently uses the default
-- 'TranslationError', i.e., 'Void', it means the consensus layer relies on it
-- being total. Do not change it!
--------------------------------------------------------------------------------

type instance TranslationContext AlonzoEra = AlonzoGenesis

instance TranslateEra AlonzoEra NewEpochState where
  translateEra :: TranslationContext AlonzoEra
-> NewEpochState (PreviousEra AlonzoEra)
-> Except
     (TranslationError AlonzoEra NewEpochState)
     (NewEpochState AlonzoEra)
translateEra TranslationContext AlonzoEra
ctxt NewEpochState (PreviousEra AlonzoEra)
nes =
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$
      NewEpochState
        { nesEL :: EpochNo
nesEL = forall era. NewEpochState era -> EpochNo
nesEL NewEpochState (PreviousEra AlonzoEra)
nes
        , nesBprev :: BlocksMade
nesBprev = forall era. NewEpochState era -> BlocksMade
nesBprev NewEpochState (PreviousEra AlonzoEra)
nes
        , nesBcur :: BlocksMade
nesBcur = forall era. NewEpochState era -> BlocksMade
nesBcur NewEpochState (PreviousEra AlonzoEra)
nes
        , nesEs :: EpochState AlonzoEra
nesEs = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. NewEpochState era -> EpochState era
nesEs NewEpochState (PreviousEra AlonzoEra)
nes
        , nesRu :: StrictMaybe PulsingRewUpdate
nesRu = forall era. NewEpochState era -> StrictMaybe PulsingRewUpdate
nesRu NewEpochState (PreviousEra AlonzoEra)
nes
        , nesPd :: PoolDistr
nesPd = forall era. NewEpochState era -> PoolDistr
nesPd NewEpochState (PreviousEra AlonzoEra)
nes
        , stashedAVVMAddresses :: StashedAVVMAddresses AlonzoEra
stashedAVVMAddresses = ()
        }

instance TranslateEra AlonzoEra PParams where
  translateEra :: TranslationContext AlonzoEra
-> PParams (PreviousEra AlonzoEra)
-> Except (TranslationError AlonzoEra PParams) (PParams AlonzoEra)
translateEra (AlonzoGenesisWrapper UpgradeAlonzoPParams Identity
upgradeArgs) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era.
(EraPParams era, EraPParams (PreviousEra era)) =>
UpgradePParams Identity era
-> PParams (PreviousEra era) -> PParams era
upgradePParams UpgradeAlonzoPParams Identity
upgradeArgs

instance TranslateEra AlonzoEra FuturePParams where
  translateEra :: TranslationContext AlonzoEra
-> FuturePParams (PreviousEra AlonzoEra)
-> Except
     (TranslationError AlonzoEra FuturePParams)
     (FuturePParams AlonzoEra)
translateEra TranslationContext AlonzoEra
ctxt = \case
    FuturePParams (PreviousEra AlonzoEra)
NoPParamsUpdate -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall era. FuturePParams era
NoPParamsUpdate
    DefinitePParamsUpdate PParams (PreviousEra AlonzoEra)
pp -> forall era. PParams era -> FuturePParams era
DefinitePParamsUpdate forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall era (f :: * -> *).
TranslateEra era f =>
TranslationContext era
-> f (PreviousEra era) -> Except (TranslationError era f) (f era)
translateEra TranslationContext AlonzoEra
ctxt PParams (PreviousEra AlonzoEra)
pp
    PotentialPParamsUpdate Maybe (PParams (PreviousEra AlonzoEra))
mpp -> forall era. Maybe (PParams era) -> FuturePParams era
PotentialPParamsUpdate forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall era (f :: * -> *).
TranslateEra era f =>
TranslationContext era
-> f (PreviousEra era) -> Except (TranslationError era f) (f era)
translateEra TranslationContext AlonzoEra
ctxt) Maybe (PParams (PreviousEra AlonzoEra))
mpp

newtype Tx era = Tx {forall era. Tx era -> Tx era
unTx :: Core.Tx era}

instance TranslateEra AlonzoEra Tx where
  type TranslationError AlonzoEra Tx = DecoderError
  translateEra :: TranslationContext AlonzoEra
-> Tx (PreviousEra AlonzoEra)
-> Except (TranslationError AlonzoEra Tx) (Tx AlonzoEra)
translateEra TranslationContext AlonzoEra
_ctxt (Tx Tx (PreviousEra AlonzoEra)
tx) = do
    -- Note that this does not preserve the hidden bytes field of the transaction.
    -- This is under the premise that this is irrelevant for TxInBlocks, which are
    -- not transmitted as contiguous chunks.
    AlonzoTxBody AlonzoEra
txBody <- forall era (ti :: * -> *) (to :: * -> *).
(Era era, ToCBOR (ti (PreviousEra era)),
 DecCBOR (Annotator (to era))) =>
Text -> ti (PreviousEra era) -> Except DecoderError (to era)
translateEraThroughCBOR Text
"TxBody" forall a b. (a -> b) -> a -> b
$ Tx (PreviousEra AlonzoEra)
tx forall s a. s -> Getting a s a -> a
^. forall era. EraTx era => Lens' (Tx era) (TxBody era)
bodyTxL
    AlonzoTxWits AlonzoEra
txWits <- forall era (ti :: * -> *) (to :: * -> *).
(Era era, ToCBOR (ti (PreviousEra era)),
 DecCBOR (Annotator (to era))) =>
Text -> ti (PreviousEra era) -> Except DecoderError (to era)
translateEraThroughCBOR Text
"TxWits" forall a b. (a -> b) -> a -> b
$ Tx (PreviousEra AlonzoEra)
tx forall s a. s -> Getting a s a -> a
^. forall era. EraTx era => Lens' (Tx era) (TxWits era)
witsTxL
    StrictMaybe (AlonzoTxAuxData AlonzoEra)
txAuxData <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall era (ti :: * -> *) (to :: * -> *).
(Era era, ToCBOR (ti (PreviousEra era)),
 DecCBOR (Annotator (to era))) =>
Text -> ti (PreviousEra era) -> Except DecoderError (to era)
translateEraThroughCBOR Text
"TxAuxData") (Tx (PreviousEra AlonzoEra)
tx forall s a. s -> Getting a s a -> a
^. forall era.
EraTx era =>
Lens' (Tx era) (StrictMaybe (TxAuxData era))
auxDataTxL)
    -- transactions from Mary era always pass script ("phase 2") validation
    let validating :: IsValid
validating = Bool -> IsValid
IsValid Bool
True
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall era. Tx era -> Tx era
Tx forall a b. (a -> b) -> a -> b
$ forall era.
TxBody era
-> TxWits era
-> IsValid
-> StrictMaybe (TxAuxData era)
-> AlonzoTx era
AlonzoTx AlonzoTxBody AlonzoEra
txBody AlonzoTxWits AlonzoEra
txWits IsValid
validating StrictMaybe (AlonzoTxAuxData AlonzoEra)
txAuxData

--------------------------------------------------------------------------------
-- Auxiliary instances and functions
--------------------------------------------------------------------------------

instance TranslateEra AlonzoEra EpochState where
  translateEra :: TranslationContext AlonzoEra
-> EpochState (PreviousEra AlonzoEra)
-> Except
     (TranslationError AlonzoEra EpochState) (EpochState AlonzoEra)
translateEra TranslationContext AlonzoEra
ctxt EpochState (PreviousEra AlonzoEra)
es =
    forall (m :: * -> *) a. Monad m => a -> m a
return
      EpochState
        { esAccountState :: AccountState
esAccountState = forall era. EpochState era -> AccountState
esAccountState EpochState (PreviousEra AlonzoEra)
es
        , esSnapshots :: SnapShots
esSnapshots = forall era. EpochState era -> SnapShots
esSnapshots EpochState (PreviousEra AlonzoEra)
es
        , esLState :: LedgerState AlonzoEra
esLState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. EpochState era -> LedgerState era
esLState EpochState (PreviousEra AlonzoEra)
es
        , esNonMyopic :: NonMyopic
esNonMyopic = forall era. EpochState era -> NonMyopic
esNonMyopic EpochState (PreviousEra AlonzoEra)
es
        }

instance TranslateEra AlonzoEra DState where
  translateEra :: TranslationContext AlonzoEra
-> DState (PreviousEra AlonzoEra)
-> Except (TranslationError AlonzoEra DState) (DState AlonzoEra)
translateEra TranslationContext AlonzoEra
_ DState {Map FutureGenDeleg GenDelegPair
InstantaneousRewards
UMap
GenDelegs
dsUnified :: forall era. DState era -> UMap
dsFutureGenDelegs :: forall era. DState era -> Map FutureGenDeleg GenDelegPair
dsGenDelegs :: forall era. DState era -> GenDelegs
dsIRewards :: forall era. DState era -> InstantaneousRewards
dsIRewards :: InstantaneousRewards
dsGenDelegs :: GenDelegs
dsFutureGenDelegs :: Map FutureGenDeleg GenDelegPair
dsUnified :: UMap
..} = forall (f :: * -> *) a. Applicative f => a -> f a
pure DState {Map FutureGenDeleg GenDelegPair
InstantaneousRewards
UMap
GenDelegs
dsUnified :: UMap
dsFutureGenDelegs :: Map FutureGenDeleg GenDelegPair
dsGenDelegs :: GenDelegs
dsIRewards :: InstantaneousRewards
dsIRewards :: InstantaneousRewards
dsGenDelegs :: GenDelegs
dsFutureGenDelegs :: Map FutureGenDeleg GenDelegPair
dsUnified :: UMap
..}

instance TranslateEra AlonzoEra CommitteeState where
  translateEra :: TranslationContext AlonzoEra
-> CommitteeState (PreviousEra AlonzoEra)
-> Except
     (TranslationError AlonzoEra CommitteeState)
     (CommitteeState AlonzoEra)
translateEra TranslationContext AlonzoEra
_ CommitteeState {Map (Credential 'ColdCommitteeRole) CommitteeAuthorization
csCommitteeCreds :: forall era.
CommitteeState era
-> Map (Credential 'ColdCommitteeRole) CommitteeAuthorization
csCommitteeCreds :: Map (Credential 'ColdCommitteeRole) CommitteeAuthorization
..} = forall (f :: * -> *) a. Applicative f => a -> f a
pure CommitteeState {Map (Credential 'ColdCommitteeRole) CommitteeAuthorization
csCommitteeCreds :: Map (Credential 'ColdCommitteeRole) CommitteeAuthorization
csCommitteeCreds :: Map (Credential 'ColdCommitteeRole) CommitteeAuthorization
..}

instance TranslateEra AlonzoEra VState where
  translateEra :: TranslationContext AlonzoEra
-> VState (PreviousEra AlonzoEra)
-> Except (TranslationError AlonzoEra VState) (VState AlonzoEra)
translateEra TranslationContext AlonzoEra
ctx VState {Map (Credential 'DRepRole) DRepState
CommitteeState (PreviousEra AlonzoEra)
EpochNo
vsDReps :: forall era. VState era -> Map (Credential 'DRepRole) DRepState
vsCommitteeState :: forall era. VState era -> CommitteeState era
vsNumDormantEpochs :: forall era. VState era -> EpochNo
vsNumDormantEpochs :: EpochNo
vsCommitteeState :: CommitteeState (PreviousEra AlonzoEra)
vsDReps :: Map (Credential 'DRepRole) DRepState
..} = do
    CommitteeState AlonzoEra
committeeState <- forall era (f :: * -> *).
TranslateEra era f =>
TranslationContext era
-> f (PreviousEra era) -> Except (TranslationError era f) (f era)
translateEra TranslationContext AlonzoEra
ctx CommitteeState (PreviousEra AlonzoEra)
vsCommitteeState
    forall (f :: * -> *) a. Applicative f => a -> f a
pure VState {vsCommitteeState :: CommitteeState AlonzoEra
vsCommitteeState = CommitteeState AlonzoEra
committeeState, Map (Credential 'DRepRole) DRepState
EpochNo
vsDReps :: Map (Credential 'DRepRole) DRepState
vsNumDormantEpochs :: EpochNo
vsNumDormantEpochs :: EpochNo
vsDReps :: Map (Credential 'DRepRole) DRepState
..}

instance TranslateEra AlonzoEra PState where
  translateEra :: TranslationContext AlonzoEra
-> PState (PreviousEra AlonzoEra)
-> Except (TranslationError AlonzoEra PState) (PState AlonzoEra)
translateEra TranslationContext AlonzoEra
_ PState {Map (KeyHash 'StakePool) PoolParams
Map (KeyHash 'StakePool) Coin
Map (KeyHash 'StakePool) EpochNo
psStakePoolParams :: forall era. PState era -> Map (KeyHash 'StakePool) PoolParams
psFutureStakePoolParams :: forall era. PState era -> Map (KeyHash 'StakePool) PoolParams
psRetiring :: forall era. PState era -> Map (KeyHash 'StakePool) EpochNo
psDeposits :: forall era. PState era -> Map (KeyHash 'StakePool) Coin
psDeposits :: Map (KeyHash 'StakePool) Coin
psRetiring :: Map (KeyHash 'StakePool) EpochNo
psFutureStakePoolParams :: Map (KeyHash 'StakePool) PoolParams
psStakePoolParams :: Map (KeyHash 'StakePool) PoolParams
..} = forall (f :: * -> *) a. Applicative f => a -> f a
pure PState {Map (KeyHash 'StakePool) PoolParams
Map (KeyHash 'StakePool) Coin
Map (KeyHash 'StakePool) EpochNo
psStakePoolParams :: Map (KeyHash 'StakePool) PoolParams
psFutureStakePoolParams :: Map (KeyHash 'StakePool) PoolParams
psRetiring :: Map (KeyHash 'StakePool) EpochNo
psDeposits :: Map (KeyHash 'StakePool) Coin
psDeposits :: Map (KeyHash 'StakePool) Coin
psRetiring :: Map (KeyHash 'StakePool) EpochNo
psFutureStakePoolParams :: Map (KeyHash 'StakePool) PoolParams
psStakePoolParams :: Map (KeyHash 'StakePool) PoolParams
..}

instance TranslateEra AlonzoEra CertState where
  translateEra :: TranslationContext AlonzoEra
-> CertState (PreviousEra AlonzoEra)
-> Except
     (TranslationError AlonzoEra CertState) (CertState AlonzoEra)
translateEra TranslationContext AlonzoEra
ctxt CertState (PreviousEra AlonzoEra)
ls =
    forall (f :: * -> *) a. Applicative f => a -> f a
pure
      CertState
        { certDState :: DState AlonzoEra
certDState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. CertState era -> DState era
certDState CertState (PreviousEra AlonzoEra)
ls
        , certPState :: PState AlonzoEra
certPState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. CertState era -> PState era
certPState CertState (PreviousEra AlonzoEra)
ls
        , certVState :: VState AlonzoEra
certVState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. CertState era -> VState era
certVState CertState (PreviousEra AlonzoEra)
ls
        }

instance TranslateEra AlonzoEra LedgerState where
  translateEra :: TranslationContext AlonzoEra
-> LedgerState (PreviousEra AlonzoEra)
-> Except
     (TranslationError AlonzoEra LedgerState) (LedgerState AlonzoEra)
translateEra TranslationContext AlonzoEra
ctxt LedgerState (PreviousEra AlonzoEra)
ls =
    forall (m :: * -> *) a. Monad m => a -> m a
return
      LedgerState
        { lsUTxOState :: UTxOState AlonzoEra
lsUTxOState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. LedgerState era -> UTxOState era
lsUTxOState LedgerState (PreviousEra AlonzoEra)
ls
        , lsCertState :: CertState AlonzoEra
lsCertState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. LedgerState era -> CertState era
lsCertState LedgerState (PreviousEra AlonzoEra)
ls
        }

instance TranslateEra AlonzoEra UTxOState where
  translateEra :: TranslationContext AlonzoEra
-> UTxOState (PreviousEra AlonzoEra)
-> Except
     (TranslationError AlonzoEra UTxOState) (UTxOState AlonzoEra)
translateEra TranslationContext AlonzoEra
ctxt UTxOState (PreviousEra AlonzoEra)
us =
    forall (m :: * -> *) a. Monad m => a -> m a
return
      UTxOState
        { utxosUtxo :: UTxO AlonzoEra
utxosUtxo = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. UTxOState era -> UTxO era
utxosUtxo UTxOState (PreviousEra AlonzoEra)
us
        , utxosDeposited :: Coin
utxosDeposited = forall era. UTxOState era -> Coin
utxosDeposited UTxOState (PreviousEra AlonzoEra)
us
        , utxosFees :: Coin
utxosFees = forall era. UTxOState era -> Coin
utxosFees UTxOState (PreviousEra AlonzoEra)
us
        , utxosGovState :: GovState AlonzoEra
utxosGovState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. UTxOState era -> GovState era
utxosGovState UTxOState (PreviousEra AlonzoEra)
us
        , utxosStakeDistr :: IncrementalStake
utxosStakeDistr = forall era. UTxOState era -> IncrementalStake
utxosStakeDistr UTxOState (PreviousEra AlonzoEra)
us
        , utxosDonation :: Coin
utxosDonation = forall era. UTxOState era -> Coin
utxosDonation UTxOState (PreviousEra AlonzoEra)
us
        }

instance TranslateEra AlonzoEra UTxO where
  translateEra :: TranslationContext AlonzoEra
-> UTxO (PreviousEra AlonzoEra)
-> Except (TranslationError AlonzoEra UTxO) (UTxO AlonzoEra)
translateEra TranslationContext AlonzoEra
_ctxt UTxO (PreviousEra AlonzoEra)
utxo =
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall era. Map TxIn (TxOut era) -> UTxO era
UTxO forall a b. (a -> b) -> a -> b
$ forall era.
(EraTxOut era, EraTxOut (PreviousEra era)) =>
TxOut (PreviousEra era) -> TxOut era
upgradeTxOut forall a b k. (a -> b) -> Map k a -> Map k b
`Map.map` forall era. UTxO era -> Map TxIn (TxOut era)
unUTxO UTxO (PreviousEra AlonzoEra)
utxo

instance TranslateEra AlonzoEra ShelleyGovState where
  translateEra :: TranslationContext AlonzoEra
-> ShelleyGovState (PreviousEra AlonzoEra)
-> Except
     (TranslationError AlonzoEra ShelleyGovState)
     (ShelleyGovState AlonzoEra)
translateEra TranslationContext AlonzoEra
ctxt ShelleyGovState (PreviousEra AlonzoEra)
ps =
    forall (m :: * -> *) a. Monad m => a -> m a
return
      ShelleyGovState
        { sgsCurProposals :: ProposedPPUpdates AlonzoEra
sgsCurProposals = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. ShelleyGovState era -> ProposedPPUpdates era
sgsCurProposals ShelleyGovState (PreviousEra AlonzoEra)
ps
        , sgsFutureProposals :: ProposedPPUpdates AlonzoEra
sgsFutureProposals = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. ShelleyGovState era -> ProposedPPUpdates era
sgsFutureProposals ShelleyGovState (PreviousEra AlonzoEra)
ps
        , sgsCurPParams :: PParams AlonzoEra
sgsCurPParams = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. ShelleyGovState era -> PParams era
sgsCurPParams ShelleyGovState (PreviousEra AlonzoEra)
ps
        , sgsPrevPParams :: PParams AlonzoEra
sgsPrevPParams = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. ShelleyGovState era -> PParams era
sgsPrevPParams ShelleyGovState (PreviousEra AlonzoEra)
ps
        , sgsFuturePParams :: FuturePParams AlonzoEra
sgsFuturePParams = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext AlonzoEra
ctxt forall a b. (a -> b) -> a -> b
$ forall era. ShelleyGovState era -> FuturePParams era
sgsFuturePParams ShelleyGovState (PreviousEra AlonzoEra)
ps
        }

instance TranslateEra AlonzoEra ProposedPPUpdates where
  translateEra :: TranslationContext AlonzoEra
-> ProposedPPUpdates (PreviousEra AlonzoEra)
-> Except
     (TranslationError AlonzoEra ProposedPPUpdates)
     (ProposedPPUpdates AlonzoEra)
translateEra TranslationContext AlonzoEra
_ctxt (ProposedPPUpdates Map (KeyHash 'Genesis) (PParamsUpdate (PreviousEra AlonzoEra))
ppup) =
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall era.
Map (KeyHash 'Genesis) (PParamsUpdate era) -> ProposedPPUpdates era
ProposedPPUpdates forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall era.
(EraPParams era, EraPParams (PreviousEra era)) =>
UpgradePParams StrictMaybe era
-> PParamsUpdate (PreviousEra era) -> PParamsUpdate era
upgradePParamsUpdate forall a. Default a => a
def) Map (KeyHash 'Genesis) (PParamsUpdate (PreviousEra AlonzoEra))
ppup