{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Ouroboros.Consensus.Cardano.CanHardFork (
TriggerHardFork (..)
, ByronPartialLedgerConfig (..)
, ShelleyPartialLedgerConfig (..)
, CardanoHardForkConstraints
) where
import Control.Monad
import Control.Monad.Except (Except, throwError)
import qualified Data.Map.Strict as Map
import Data.Maybe (listToMaybe, mapMaybe)
import Data.Proxy
import Data.SOP.Strict ((:.:) (..), NP (..))
import Data.Void (Void)
import Data.Word
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)
import Cardano.Crypto.DSIGN (Ed25519DSIGN)
import Cardano.Crypto.Hash.Blake2b (Blake2b_224, Blake2b_256)
import qualified Cardano.Chain.Common as CC
import qualified Cardano.Chain.Genesis as CC.Genesis
import qualified Cardano.Chain.Update as CC.Update
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.Forecast
import Ouroboros.Consensus.HardFork.History (Bound (boundSlot),
addSlots)
import Ouroboros.Consensus.Ledger.Abstract
import Ouroboros.Consensus.TypeFamilyWrappers
import Ouroboros.Consensus.Util.RedundantConstraints
import Ouroboros.Consensus.HardFork.Combinator
import Ouroboros.Consensus.HardFork.Combinator.State.Types
import Ouroboros.Consensus.HardFork.Combinator.Util.InPairs
(RequiringBoth (..), ignoringBoth)
import Ouroboros.Consensus.HardFork.Combinator.Util.Tails (Tails (..))
import Ouroboros.Consensus.Byron.Ledger
import qualified Ouroboros.Consensus.Byron.Ledger.Inspect as Byron.Inspect
import Ouroboros.Consensus.Byron.Node ()
import Ouroboros.Consensus.Protocol.PBFT (PBft, PBftCrypto)
import Ouroboros.Consensus.Protocol.PBFT.State (PBftState)
import qualified Ouroboros.Consensus.Protocol.PBFT.State as PBftState
import Ouroboros.Consensus.Shelley.Ledger
import qualified Ouroboros.Consensus.Shelley.Ledger.Inspect as Shelley.Inspect
import Ouroboros.Consensus.Shelley.Node ()
import Ouroboros.Consensus.Shelley.Protocol
import Cardano.Ledger.Allegra.Translation ()
import Cardano.Ledger.Crypto (ADDRHASH, DSIGN, HASH)
import qualified Cardano.Ledger.Era as SL
import Cardano.Ledger.Mary.Translation ()
import qualified Shelley.Spec.Ledger.API as SL
import Ouroboros.Consensus.Cardano.Block
byronTransition :: PartialLedgerConfig ByronBlock
-> Word16
-> LedgerState ByronBlock
-> Maybe EpochNo
byronTransition :: PartialLedgerConfig ByronBlock
-> Word16 -> LedgerState ByronBlock -> Maybe EpochNo
byronTransition ByronPartialLedgerConfig{..} Word16
shelleyMajorVersion LedgerState ByronBlock
state =
[EpochNo] -> Maybe EpochNo
forall a. [a] -> Maybe a
takeAny
([EpochNo] -> Maybe EpochNo)
-> (LedgerState ByronBlock -> [EpochNo])
-> LedgerState ByronBlock
-> Maybe EpochNo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ProtocolUpdate -> Maybe EpochNo) -> [ProtocolUpdate] -> [EpochNo]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe ProtocolUpdate -> Maybe EpochNo
isTransitionToShelley
([ProtocolUpdate] -> [EpochNo])
-> (LedgerState ByronBlock -> [ProtocolUpdate])
-> LedgerState ByronBlock
-> [EpochNo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LedgerConfig ByronBlock
-> LedgerState ByronBlock -> [ProtocolUpdate]
Byron.Inspect.protocolUpdates LedgerConfig ByronBlock
byronLedgerConfig
(LedgerState ByronBlock -> Maybe EpochNo)
-> LedgerState ByronBlock -> Maybe EpochNo
forall a b. (a -> b) -> a -> b
$ LedgerState ByronBlock
state
where
ByronTransitionInfo Map ProtocolVersion BlockNo
transitionInfo = LedgerState ByronBlock -> ByronTransition
byronLedgerTransition LedgerState ByronBlock
state
genesis :: LedgerConfig ByronBlock
genesis = LedgerConfig ByronBlock
byronLedgerConfig
k :: BlockCount
k = GenesisData -> BlockCount
CC.Genesis.gdK (GenesisData -> BlockCount) -> GenesisData -> BlockCount
forall a b. (a -> b) -> a -> b
$ Config -> GenesisData
CC.Genesis.configGenesisData Config
LedgerConfig ByronBlock
genesis
isTransitionToShelley :: Byron.Inspect.ProtocolUpdate -> Maybe EpochNo
isTransitionToShelley :: ProtocolUpdate -> Maybe EpochNo
isTransitionToShelley ProtocolUpdate
update = do
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Maybe ()) -> Bool -> Maybe ()
forall a b. (a -> b) -> a -> b
$ ProtocolVersion -> Word16
CC.Update.pvMajor ProtocolVersion
version Word16 -> Word16 -> Bool
forall a. Eq a => a -> a -> Bool
== Word16
shelleyMajorVersion
case ProtocolUpdate -> UpdateState
Byron.Inspect.protocolUpdateState ProtocolUpdate
update of
Byron.Inspect.UpdateCandidate SlotNo
_becameCandidateSlotNo EpochNo
adoptedIn -> do
BlockNo
becameCandidateBlockNo <- ProtocolVersion -> Map ProtocolVersion BlockNo -> Maybe BlockNo
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup ProtocolVersion
version Map ProtocolVersion BlockNo
transitionInfo
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Maybe ()) -> Bool -> Maybe ()
forall a b. (a -> b) -> a -> b
$ BlockNo -> Bool
isReallyStable BlockNo
becameCandidateBlockNo
EpochNo -> Maybe EpochNo
forall (m :: * -> *) a. Monad m => a -> m a
return EpochNo
adoptedIn
Byron.Inspect.UpdateStableCandidate EpochNo
adoptedIn ->
EpochNo -> Maybe EpochNo
forall (m :: * -> *) a. Monad m => a -> m a
return EpochNo
adoptedIn
UpdateState
_otherwise ->
Maybe EpochNo
forall (m :: * -> *) a. MonadPlus m => m a
mzero
where
version :: CC.Update.ProtocolVersion
version :: ProtocolVersion
version = ProtocolUpdate -> ProtocolVersion
Byron.Inspect.protocolUpdateVersion ProtocolUpdate
update
isReallyStable :: BlockNo -> Bool
isReallyStable :: BlockNo -> Bool
isReallyStable (BlockNo Word64
bno) = Word64
distance Word64 -> Word64 -> Bool
forall a. Ord a => a -> a -> Bool
>= BlockCount -> Word64
CC.unBlockCount BlockCount
k
where
distance :: Word64
distance :: Word64
distance = case LedgerState ByronBlock -> WithOrigin BlockNo
byronLedgerTipBlockNo LedgerState ByronBlock
state of
WithOrigin BlockNo
Origin -> Word64
bno Word64 -> Word64 -> Word64
forall a. Num a => a -> a -> a
+ Word64
1
NotOrigin (BlockNo Word64
tip) -> Word64
tip Word64 -> Word64 -> Word64
forall a. Num a => a -> a -> a
- Word64
bno
takeAny :: [a] -> Maybe a
takeAny :: [a] -> Maybe a
takeAny = [a] -> Maybe a
forall a. [a] -> Maybe a
listToMaybe
shelleyTransition ::
forall era.
PartialLedgerConfig (ShelleyBlock era)
-> Word16
-> LedgerState (ShelleyBlock era)
-> Maybe EpochNo
shelleyTransition :: PartialLedgerConfig (ShelleyBlock era)
-> Word16 -> LedgerState (ShelleyBlock era) -> Maybe EpochNo
shelleyTransition ShelleyPartialLedgerConfig{..}
Word16
transitionMajorVersion
LedgerState (ShelleyBlock era)
state =
[EpochNo] -> Maybe EpochNo
forall a. [a] -> Maybe a
takeAny
([EpochNo] -> Maybe EpochNo)
-> (LedgerState (ShelleyBlock era) -> [EpochNo])
-> LedgerState (ShelleyBlock era)
-> Maybe EpochNo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ProtocolUpdate era -> Maybe EpochNo)
-> [ProtocolUpdate era] -> [EpochNo]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe ProtocolUpdate era -> Maybe EpochNo
isTransition
([ProtocolUpdate era] -> [EpochNo])
-> (LedgerState (ShelleyBlock era) -> [ProtocolUpdate era])
-> LedgerState (ShelleyBlock era)
-> [EpochNo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyGenesis era
-> LedgerState (ShelleyBlock era) -> [ProtocolUpdate era]
forall era.
ShelleyGenesis era
-> LedgerState (ShelleyBlock era) -> [ProtocolUpdate era]
Shelley.Inspect.protocolUpdates ShelleyGenesis era
genesis
(LedgerState (ShelleyBlock era) -> Maybe EpochNo)
-> LedgerState (ShelleyBlock era) -> Maybe EpochNo
forall a b. (a -> b) -> a -> b
$ LedgerState (ShelleyBlock era)
state
where
ShelleyTransitionInfo{Word32
shelleyAfterVoting :: ShelleyTransition -> Word32
shelleyAfterVoting :: Word32
..} = LedgerState (ShelleyBlock era) -> ShelleyTransition
forall era. LedgerState (ShelleyBlock era) -> ShelleyTransition
shelleyLedgerTransition LedgerState (ShelleyBlock era)
state
genesis :: SL.ShelleyGenesis era
genesis :: ShelleyGenesis era
genesis = ShelleyLedgerConfig era -> ShelleyGenesis era
forall era. ShelleyLedgerConfig era -> ShelleyGenesis era
shelleyLedgerGenesis ShelleyLedgerConfig era
shelleyLedgerConfig
k :: Word64
k :: Word64
k = ShelleyGenesis era -> Word64
forall era. ShelleyGenesis era -> Word64
SL.sgSecurityParam ShelleyGenesis era
genesis
isTransition :: Shelley.Inspect.ProtocolUpdate era -> Maybe EpochNo
isTransition :: ProtocolUpdate era -> Maybe EpochNo
isTransition Shelley.Inspect.ProtocolUpdate{UpdateProposal era
UpdateState (EraCrypto era)
protocolUpdateProposal :: forall era. ProtocolUpdate era -> UpdateProposal era
protocolUpdateState :: forall era. ProtocolUpdate era -> UpdateState (EraCrypto era)
protocolUpdateState :: UpdateState (EraCrypto era)
protocolUpdateProposal :: UpdateProposal era
..} = do
SL.ProtVer Natural
major Natural
_minor <- Maybe ProtVer
proposalVersion
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Maybe ()) -> Bool -> Maybe ()
forall a b. (a -> b) -> a -> b
$ Natural -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
major Word16 -> Word16 -> Bool
forall a. Eq a => a -> a -> Bool
== Word16
transitionMajorVersion
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Maybe ()) -> Bool -> Maybe ()
forall a b. (a -> b) -> a -> b
$ Bool
proposalReachedQuorum
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Maybe ()) -> Bool -> Maybe ()
forall a b. (a -> b) -> a -> b
$ Word32
shelleyAfterVoting Word32 -> Word32 -> Bool
forall a. Ord a => a -> a -> Bool
>= Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
k
EpochNo -> Maybe EpochNo
forall (m :: * -> *) a. Monad m => a -> m a
return EpochNo
proposalEpoch
where
Shelley.Inspect.UpdateProposal{Maybe ProtVer
EpochNo
PParamsUpdate era
proposalParams :: forall era. UpdateProposal era -> PParamsUpdate era
proposalVersion :: forall era. UpdateProposal era -> Maybe ProtVer
proposalEpoch :: forall era. UpdateProposal era -> EpochNo
proposalParams :: PParamsUpdate era
proposalEpoch :: EpochNo
proposalVersion :: Maybe ProtVer
..} = UpdateProposal era
protocolUpdateProposal
Shelley.Inspect.UpdateState{Bool
[KeyHash 'Genesis (EraCrypto era)]
proposalVotes :: forall c. UpdateState c -> [KeyHash 'Genesis c]
proposalReachedQuorum :: forall c. UpdateState c -> Bool
proposalVotes :: [KeyHash 'Genesis (EraCrypto era)]
proposalReachedQuorum :: Bool
..} = UpdateState (EraCrypto era)
protocolUpdateState
takeAny :: [a] -> Maybe a
takeAny :: [a] -> Maybe a
takeAny = [a] -> Maybe a
forall a. [a] -> Maybe a
listToMaybe
instance SingleEraBlock ByronBlock where
singleEraTransition :: PartialLedgerConfig ByronBlock
-> EraParams -> Bound -> LedgerState ByronBlock -> Maybe EpochNo
singleEraTransition PartialLedgerConfig ByronBlock
pcfg EraParams
_eraParams Bound
_eraStart LedgerState ByronBlock
ledgerState =
case ByronPartialLedgerConfig -> TriggerHardFork
byronTriggerHardFork PartialLedgerConfig ByronBlock
ByronPartialLedgerConfig
pcfg of
TriggerHardFork
TriggerHardForkNever -> Maybe EpochNo
forall a. Maybe a
Nothing
TriggerHardForkAtEpoch EpochNo
epoch -> EpochNo -> Maybe EpochNo
forall a. a -> Maybe a
Just EpochNo
epoch
TriggerHardForkAtVersion Word16
shelleyMajorVersion ->
PartialLedgerConfig ByronBlock
-> Word16 -> LedgerState ByronBlock -> Maybe EpochNo
byronTransition
PartialLedgerConfig ByronBlock
pcfg
Word16
shelleyMajorVersion
LedgerState ByronBlock
ledgerState
singleEraInfo :: proxy ByronBlock -> SingleEraInfo ByronBlock
singleEraInfo proxy ByronBlock
_ = SingleEraInfo :: forall blk. Text -> SingleEraInfo blk
SingleEraInfo {
singleEraName :: Text
singleEraName = Text
"Byron"
}
instance PBftCrypto bc => HasPartialConsensusConfig (PBft bc)
data TriggerHardFork =
TriggerHardForkAtVersion !Word16
| TriggerHardForkAtEpoch !EpochNo
| TriggerHardForkNever
deriving (Int -> TriggerHardFork -> ShowS
[TriggerHardFork] -> ShowS
TriggerHardFork -> String
(Int -> TriggerHardFork -> ShowS)
-> (TriggerHardFork -> String)
-> ([TriggerHardFork] -> ShowS)
-> Show TriggerHardFork
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TriggerHardFork] -> ShowS
$cshowList :: [TriggerHardFork] -> ShowS
show :: TriggerHardFork -> String
$cshow :: TriggerHardFork -> String
showsPrec :: Int -> TriggerHardFork -> ShowS
$cshowsPrec :: Int -> TriggerHardFork -> ShowS
Show, (forall x. TriggerHardFork -> Rep TriggerHardFork x)
-> (forall x. Rep TriggerHardFork x -> TriggerHardFork)
-> Generic TriggerHardFork
forall x. Rep TriggerHardFork x -> TriggerHardFork
forall x. TriggerHardFork -> Rep TriggerHardFork x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TriggerHardFork x -> TriggerHardFork
$cfrom :: forall x. TriggerHardFork -> Rep TriggerHardFork x
Generic, Context -> TriggerHardFork -> IO (Maybe ThunkInfo)
Proxy TriggerHardFork -> String
(Context -> TriggerHardFork -> IO (Maybe ThunkInfo))
-> (Context -> TriggerHardFork -> IO (Maybe ThunkInfo))
-> (Proxy TriggerHardFork -> String)
-> NoThunks TriggerHardFork
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy TriggerHardFork -> String
$cshowTypeOf :: Proxy TriggerHardFork -> String
wNoThunks :: Context -> TriggerHardFork -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> TriggerHardFork -> IO (Maybe ThunkInfo)
noThunks :: Context -> TriggerHardFork -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> TriggerHardFork -> IO (Maybe ThunkInfo)
NoThunks)
data ByronPartialLedgerConfig = ByronPartialLedgerConfig {
ByronPartialLedgerConfig -> LedgerConfig ByronBlock
byronLedgerConfig :: !(LedgerConfig ByronBlock)
, ByronPartialLedgerConfig -> TriggerHardFork
byronTriggerHardFork :: !TriggerHardFork
}
deriving ((forall x.
ByronPartialLedgerConfig -> Rep ByronPartialLedgerConfig x)
-> (forall x.
Rep ByronPartialLedgerConfig x -> ByronPartialLedgerConfig)
-> Generic ByronPartialLedgerConfig
forall x.
Rep ByronPartialLedgerConfig x -> ByronPartialLedgerConfig
forall x.
ByronPartialLedgerConfig -> Rep ByronPartialLedgerConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ByronPartialLedgerConfig x -> ByronPartialLedgerConfig
$cfrom :: forall x.
ByronPartialLedgerConfig -> Rep ByronPartialLedgerConfig x
Generic, Context -> ByronPartialLedgerConfig -> IO (Maybe ThunkInfo)
Proxy ByronPartialLedgerConfig -> String
(Context -> ByronPartialLedgerConfig -> IO (Maybe ThunkInfo))
-> (Context -> ByronPartialLedgerConfig -> IO (Maybe ThunkInfo))
-> (Proxy ByronPartialLedgerConfig -> String)
-> NoThunks ByronPartialLedgerConfig
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy ByronPartialLedgerConfig -> String
$cshowTypeOf :: Proxy ByronPartialLedgerConfig -> String
wNoThunks :: Context -> ByronPartialLedgerConfig -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> ByronPartialLedgerConfig -> IO (Maybe ThunkInfo)
noThunks :: Context -> ByronPartialLedgerConfig -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> ByronPartialLedgerConfig -> IO (Maybe ThunkInfo)
NoThunks)
instance HasPartialLedgerConfig ByronBlock where
type PartialLedgerConfig ByronBlock = ByronPartialLedgerConfig
completeLedgerConfig :: proxy ByronBlock
-> EpochInfo Identity
-> PartialLedgerConfig ByronBlock
-> LedgerConfig ByronBlock
completeLedgerConfig proxy ByronBlock
_ EpochInfo Identity
_ = PartialLedgerConfig ByronBlock -> LedgerConfig ByronBlock
ByronPartialLedgerConfig -> LedgerConfig ByronBlock
byronLedgerConfig
instance ShelleyBasedEra era => SingleEraBlock (ShelleyBlock era) where
singleEraTransition :: PartialLedgerConfig (ShelleyBlock era)
-> EraParams
-> Bound
-> LedgerState (ShelleyBlock era)
-> Maybe EpochNo
singleEraTransition PartialLedgerConfig (ShelleyBlock era)
pcfg EraParams
_eraParams Bound
_eraStart LedgerState (ShelleyBlock era)
ledgerState =
case ShelleyPartialLedgerConfig era -> TriggerHardFork
forall era. ShelleyPartialLedgerConfig era -> TriggerHardFork
shelleyTriggerHardFork PartialLedgerConfig (ShelleyBlock era)
ShelleyPartialLedgerConfig era
pcfg of
TriggerHardFork
TriggerHardForkNever -> Maybe EpochNo
forall a. Maybe a
Nothing
TriggerHardForkAtEpoch EpochNo
epoch -> EpochNo -> Maybe EpochNo
forall a. a -> Maybe a
Just EpochNo
epoch
TriggerHardForkAtVersion Word16
shelleyMajorVersion ->
PartialLedgerConfig (ShelleyBlock era)
-> Word16 -> LedgerState (ShelleyBlock era) -> Maybe EpochNo
forall era.
PartialLedgerConfig (ShelleyBlock era)
-> Word16 -> LedgerState (ShelleyBlock era) -> Maybe EpochNo
shelleyTransition
PartialLedgerConfig (ShelleyBlock era)
pcfg
Word16
shelleyMajorVersion
LedgerState (ShelleyBlock era)
ledgerState
singleEraInfo :: proxy (ShelleyBlock era) -> SingleEraInfo (ShelleyBlock era)
singleEraInfo proxy (ShelleyBlock era)
_ = SingleEraInfo :: forall blk. Text -> SingleEraInfo blk
SingleEraInfo {
singleEraName :: Text
singleEraName = Text
"Shelley"
}
instance PraosCrypto c => HasPartialConsensusConfig (TPraos c) where
type PartialConsensusConfig (TPraos c) = TPraosParams
completeConsensusConfig :: proxy (TPraos c)
-> EpochInfo Identity
-> PartialConsensusConfig (TPraos c)
-> ConsensusConfig (TPraos c)
completeConsensusConfig proxy (TPraos c)
_ EpochInfo Identity
tpraosEpochInfo PartialConsensusConfig (TPraos c)
tpraosParams = TPraosConfig :: forall c.
TPraosParams -> EpochInfo Identity -> ConsensusConfig (TPraos c)
TPraosConfig {EpochInfo Identity
PartialConsensusConfig (TPraos c)
TPraosParams
tpraosParams :: TPraosParams
tpraosEpochInfo :: EpochInfo Identity
tpraosParams :: PartialConsensusConfig (TPraos c)
tpraosEpochInfo :: EpochInfo Identity
..}
partialChainSelConfig :: proxy (TPraos c)
-> PartialConsensusConfig (TPraos c) -> ChainSelConfig (TPraos c)
partialChainSelConfig proxy (TPraos c)
_ PartialConsensusConfig (TPraos c)
_ = ()
data ShelleyPartialLedgerConfig era = ShelleyPartialLedgerConfig {
ShelleyPartialLedgerConfig era -> ShelleyLedgerConfig era
shelleyLedgerConfig :: !(ShelleyLedgerConfig era)
, ShelleyPartialLedgerConfig era -> TriggerHardFork
shelleyTriggerHardFork :: !TriggerHardFork
}
deriving ((forall x.
ShelleyPartialLedgerConfig era
-> Rep (ShelleyPartialLedgerConfig era) x)
-> (forall x.
Rep (ShelleyPartialLedgerConfig era) x
-> ShelleyPartialLedgerConfig era)
-> Generic (ShelleyPartialLedgerConfig era)
forall x.
Rep (ShelleyPartialLedgerConfig era) x
-> ShelleyPartialLedgerConfig era
forall x.
ShelleyPartialLedgerConfig era
-> Rep (ShelleyPartialLedgerConfig era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x.
Rep (ShelleyPartialLedgerConfig era) x
-> ShelleyPartialLedgerConfig era
forall era x.
ShelleyPartialLedgerConfig era
-> Rep (ShelleyPartialLedgerConfig era) x
$cto :: forall era x.
Rep (ShelleyPartialLedgerConfig era) x
-> ShelleyPartialLedgerConfig era
$cfrom :: forall era x.
ShelleyPartialLedgerConfig era
-> Rep (ShelleyPartialLedgerConfig era) x
Generic, Context -> ShelleyPartialLedgerConfig era -> IO (Maybe ThunkInfo)
Proxy (ShelleyPartialLedgerConfig era) -> String
(Context -> ShelleyPartialLedgerConfig era -> IO (Maybe ThunkInfo))
-> (Context
-> ShelleyPartialLedgerConfig era -> IO (Maybe ThunkInfo))
-> (Proxy (ShelleyPartialLedgerConfig era) -> String)
-> NoThunks (ShelleyPartialLedgerConfig era)
forall era.
ShelleyBasedEra era =>
Context -> ShelleyPartialLedgerConfig era -> IO (Maybe ThunkInfo)
forall era.
ShelleyBasedEra era =>
Proxy (ShelleyPartialLedgerConfig era) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy (ShelleyPartialLedgerConfig era) -> String
$cshowTypeOf :: forall era.
ShelleyBasedEra era =>
Proxy (ShelleyPartialLedgerConfig era) -> String
wNoThunks :: Context -> ShelleyPartialLedgerConfig era -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall era.
ShelleyBasedEra era =>
Context -> ShelleyPartialLedgerConfig era -> IO (Maybe ThunkInfo)
noThunks :: Context -> ShelleyPartialLedgerConfig era -> IO (Maybe ThunkInfo)
$cnoThunks :: forall era.
ShelleyBasedEra era =>
Context -> ShelleyPartialLedgerConfig era -> IO (Maybe ThunkInfo)
NoThunks)
instance ShelleyBasedEra era => HasPartialLedgerConfig (ShelleyBlock era) where
type PartialLedgerConfig (ShelleyBlock era) = ShelleyPartialLedgerConfig era
completeLedgerConfig :: proxy (ShelleyBlock era)
-> EpochInfo Identity
-> PartialLedgerConfig (ShelleyBlock era)
-> LedgerConfig (ShelleyBlock era)
completeLedgerConfig proxy (ShelleyBlock era)
_ EpochInfo Identity
epochInfo (ShelleyPartialLedgerConfig cfg _) =
ShelleyLedgerConfig era
cfg {
shelleyLedgerGlobals :: Globals
shelleyLedgerGlobals = (ShelleyLedgerConfig era -> Globals
forall era. ShelleyLedgerConfig era -> Globals
shelleyLedgerGlobals ShelleyLedgerConfig era
cfg) {
epochInfo :: EpochInfo Identity
SL.epochInfo = EpochInfo Identity
epochInfo
}
}
type CardanoHardForkConstraints c =
( PraosCrypto c
, ShelleyBasedEra (ShelleyEra c)
, ShelleyBasedEra (AllegraEra c)
, ShelleyBasedEra (MaryEra c)
, HASH c ~ Blake2b_256
, ADDRHASH c ~ Blake2b_224
, DSIGN c ~ Ed25519DSIGN
)
instance CardanoHardForkConstraints c => CanHardFork (CardanoEras c) where
hardForkEraTranslation :: EraTranslation (CardanoEras c)
hardForkEraTranslation = EraTranslation :: forall (xs :: [*]).
InPairs (RequiringBoth WrapLedgerConfig (Translate LedgerState)) xs
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
xs
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
xs
-> EraTranslation xs
EraTranslation {
translateLedgerState :: InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
(CardanoEras c)
translateLedgerState =
RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
(CardanoEras c)
forall k (f :: k -> k -> *) (x :: k) (y :: k) (zs :: [k]).
f x y -> InPairs f (y : zs) -> InPairs f (x : y : zs)
PCons RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
forall c.
(ShelleyBasedEra (ShelleyEra c), HASH c ~ Blake2b_256,
ADDRHASH c ~ Blake2b_224) =>
RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
translateLedgerStateByronToShelleyWrapper
(InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
(CardanoEras c))
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
(CardanoEras c)
forall a b. (a -> b) -> a -> b
$ RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k) (y :: k) (zs :: [k]).
f x y -> InPairs f (y : zs) -> InPairs f (x : y : zs)
PCons RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
forall c.
RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
translateLedgerStateShelleyToAllegraWrapper
(InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)])
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
forall a b. (a -> b) -> a -> b
$ RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k) (y :: k) (zs :: [k]).
f x y -> InPairs f (y : zs) -> InPairs f (x : y : zs)
PCons RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
forall c.
RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
translateLedgerStateAllegraToMaryWrapper
(InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)])
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
forall a b. (a -> b) -> a -> b
$ InPairs
(RequiringBoth WrapLedgerConfig (Translate LedgerState))
'[ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k). InPairs f '[x]
PNil
, translateChainDepState :: InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
(CardanoEras c)
translateChainDepState =
RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
(CardanoEras c)
forall k (f :: k -> k -> *) (x :: k) (y :: k) (zs :: [k]).
f x y -> InPairs f (y : zs) -> InPairs f (x : y : zs)
PCons RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
forall c.
RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
translateChainDepStateByronToShelleyWrapper
(InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
(CardanoEras c))
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
(CardanoEras c)
forall a b. (a -> b) -> a -> b
$ RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k) (y :: k) (zs :: [k]).
f x y -> InPairs f (y : zs) -> InPairs f (x : y : zs)
PCons RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
forall eraFrom eraTo.
(EraCrypto eraFrom ~ EraCrypto eraTo) =>
RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
translateChainDepStateAcrossShelley
(InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)])
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
forall a b. (a -> b) -> a -> b
$ RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k) (y :: k) (zs :: [k]).
f x y -> InPairs f (y : zs) -> InPairs f (x : y : zs)
PCons RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
forall eraFrom eraTo.
(EraCrypto eraFrom ~ EraCrypto eraTo) =>
RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
translateChainDepStateAcrossShelley
(InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)])
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
forall a b. (a -> b) -> a -> b
$ InPairs
(RequiringBoth WrapConsensusConfig (Translate WrapChainDepState))
'[ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k). InPairs f '[x]
PNil
, translateLedgerView :: InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
(CardanoEras c)
translateLedgerView =
RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
ByronBlock
(ShelleyBlock (ShelleyEra c))
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
(CardanoEras c)
forall k (f :: k -> k -> *) (x :: k) (y :: k) (zs :: [k]).
f x y -> InPairs f (y : zs) -> InPairs f (x : y : zs)
PCons RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
ByronBlock
(ShelleyBlock (ShelleyEra c))
forall c.
RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
ByronBlock
(ShelleyBlock (ShelleyEra c))
translateLedgerViewByronToShelleyWrapper
(InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
(CardanoEras c))
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
(CardanoEras c)
forall a b. (a -> b) -> a -> b
$ RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k) (y :: k) (zs :: [k]).
f x y -> InPairs f (y : zs) -> InPairs f (x : y : zs)
PCons RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
forall eraFrom eraTo.
(EraCrypto eraFrom ~ EraCrypto eraTo, ShelleyBasedEra eraFrom) =>
RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
translateLedgerViewAcrossShelley
(InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)])
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
forall a b. (a -> b) -> a -> b
$ RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k) (y :: k) (zs :: [k]).
f x y -> InPairs f (y : zs) -> InPairs f (x : y : zs)
PCons RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
forall eraFrom eraTo.
(EraCrypto eraFrom ~ EraCrypto eraTo, ShelleyBasedEra eraFrom) =>
RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
translateLedgerViewAcrossShelley
(InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)])
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
forall a b. (a -> b) -> a -> b
$ InPairs
(RequiringBoth
WrapLedgerConfig (TranslateForecast LedgerState WrapLedgerView))
'[ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k). InPairs f '[x]
PNil
}
hardForkChainSel :: Tails AcrossEraSelection (CardanoEras c)
hardForkChainSel =
NP
(AcrossEraSelection ByronBlock)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> Tails
AcrossEraSelection
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> Tails AcrossEraSelection (CardanoEras c)
forall k (f :: k -> k -> *) (x :: k) (xs1 :: [k]).
NP (f x) xs1 -> Tails f xs1 -> Tails f (x : xs1)
TCons (AcrossEraSelection ByronBlock (ShelleyBlock (ShelleyEra c))
forall a b. AcrossEraSelection a b
CompareBlockNo AcrossEraSelection ByronBlock (ShelleyBlock (ShelleyEra c))
-> NP
(AcrossEraSelection ByronBlock)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> NP
(AcrossEraSelection ByronBlock)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* AcrossEraSelection ByronBlock (ShelleyBlock (ShelleyEra c))
forall a b. AcrossEraSelection a b
CompareBlockNo AcrossEraSelection ByronBlock (ShelleyBlock (ShelleyEra c))
-> NP
(AcrossEraSelection ByronBlock) '[ShelleyBlock (ShelleyEra c)]
-> NP
(AcrossEraSelection ByronBlock)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* AcrossEraSelection ByronBlock (ShelleyBlock (ShelleyEra c))
forall a b. AcrossEraSelection a b
CompareBlockNo AcrossEraSelection ByronBlock (ShelleyBlock (ShelleyEra c))
-> NP (AcrossEraSelection ByronBlock) '[]
-> NP
(AcrossEraSelection ByronBlock) '[ShelleyBlock (ShelleyEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* NP (AcrossEraSelection ByronBlock) '[]
forall k (a :: k -> *). NP a '[]
Nil)
(Tails
AcrossEraSelection
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> Tails AcrossEraSelection (CardanoEras c))
-> Tails
AcrossEraSelection
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> Tails AcrossEraSelection (CardanoEras c)
forall a b. (a -> b) -> a -> b
$ NP
(AcrossEraSelection (ShelleyBlock (ShelleyEra c)))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> Tails
AcrossEraSelection
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> Tails
AcrossEraSelection
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k) (xs1 :: [k]).
NP (f x) xs1 -> Tails f xs1 -> Tails f (x : xs1)
TCons (AcrossEraSelection
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
forall a b.
(BlockProtocol a ~ BlockProtocol b) =>
AcrossEraSelection a b
SelectSameProtocol AcrossEraSelection
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
-> NP
(AcrossEraSelection (ShelleyBlock (ShelleyEra c)))
'[ShelleyBlock (ShelleyEra c)]
-> NP
(AcrossEraSelection (ShelleyBlock (ShelleyEra c)))
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* AcrossEraSelection
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
forall a b.
(BlockProtocol a ~ BlockProtocol b) =>
AcrossEraSelection a b
SelectSameProtocol AcrossEraSelection
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
-> NP (AcrossEraSelection (ShelleyBlock (ShelleyEra c))) '[]
-> NP
(AcrossEraSelection (ShelleyBlock (ShelleyEra c)))
'[ShelleyBlock (ShelleyEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* NP (AcrossEraSelection (ShelleyBlock (ShelleyEra c))) '[]
forall k (a :: k -> *). NP a '[]
Nil)
(Tails
AcrossEraSelection
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> Tails
AcrossEraSelection
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)])
-> Tails
AcrossEraSelection
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> Tails
AcrossEraSelection
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
forall a b. (a -> b) -> a -> b
$ NP
(AcrossEraSelection (ShelleyBlock (ShelleyEra c)))
'[ShelleyBlock (ShelleyEra c)]
-> Tails AcrossEraSelection '[ShelleyBlock (ShelleyEra c)]
-> Tails
AcrossEraSelection
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k) (xs1 :: [k]).
NP (f x) xs1 -> Tails f xs1 -> Tails f (x : xs1)
TCons (AcrossEraSelection
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
forall a b.
(BlockProtocol a ~ BlockProtocol b) =>
AcrossEraSelection a b
SelectSameProtocol AcrossEraSelection
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
-> NP (AcrossEraSelection (ShelleyBlock (ShelleyEra c))) '[]
-> NP
(AcrossEraSelection (ShelleyBlock (ShelleyEra c)))
'[ShelleyBlock (ShelleyEra c)]
forall k (a :: k -> *) (x :: k) (xs :: [k]).
a x -> NP a xs -> NP a (x : xs)
:* NP (AcrossEraSelection (ShelleyBlock (ShelleyEra c))) '[]
forall k (a :: k -> *). NP a '[]
Nil)
(Tails AcrossEraSelection '[ShelleyBlock (ShelleyEra c)]
-> Tails
AcrossEraSelection
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)])
-> Tails AcrossEraSelection '[ShelleyBlock (ShelleyEra c)]
-> Tails
AcrossEraSelection
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
forall a b. (a -> b) -> a -> b
$ NP (AcrossEraSelection (ShelleyBlock (ShelleyEra c))) '[]
-> Tails AcrossEraSelection '[]
-> Tails AcrossEraSelection '[ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k) (xs1 :: [k]).
NP (f x) xs1 -> Tails f xs1 -> Tails f (x : xs1)
TCons NP (AcrossEraSelection (ShelleyBlock (ShelleyEra c))) '[]
forall k (a :: k -> *). NP a '[]
Nil
(Tails AcrossEraSelection '[]
-> Tails AcrossEraSelection '[ShelleyBlock (ShelleyEra c)])
-> Tails AcrossEraSelection '[]
-> Tails AcrossEraSelection '[ShelleyBlock (ShelleyEra c)]
forall a b. (a -> b) -> a -> b
$ Tails AcrossEraSelection '[]
forall k (f :: k -> k -> *). Tails f '[]
TNil
hardForkInjectTxs :: InPairs (RequiringBoth WrapLedgerConfig InjectTx) (CardanoEras c)
hardForkInjectTxs =
RequiringBoth
WrapLedgerConfig InjectTx ByronBlock (ShelleyBlock (ShelleyEra c))
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx) (CardanoEras c)
forall k (f :: k -> k -> *) (x :: k) (y :: k) (zs :: [k]).
f x y -> InPairs f (y : zs) -> InPairs f (x : y : zs)
PCons (InjectTx ByronBlock (ShelleyBlock (ShelleyEra c))
-> RequiringBoth
WrapLedgerConfig InjectTx ByronBlock (ShelleyBlock (ShelleyEra c))
forall k (f :: k -> k -> *) (x :: k) (y :: k) (h :: k -> *).
f x y -> RequiringBoth h f x y
ignoringBoth InjectTx ByronBlock (ShelleyBlock (ShelleyEra c))
forall blk blk'. InjectTx blk blk'
cannotInjectTx)
(InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx) (CardanoEras c))
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx) (CardanoEras c)
forall a b. (a -> b) -> a -> b
$ RequiringBoth
WrapLedgerConfig
InjectTx
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k) (y :: k) (zs :: [k]).
f x y -> InPairs f (y : zs) -> InPairs f (x : y : zs)
PCons (InjectTx
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
-> RequiringBoth
WrapLedgerConfig
InjectTx
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
forall k (f :: k -> k -> *) (x :: k) (y :: k) (h :: k -> *).
f x y -> RequiringBoth h f x y
ignoringBoth InjectTx
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
forall c.
InjectTx
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
translateTxShelleyToAllegraWrapper)
(InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)])
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c),
ShelleyBlock (ShelleyEra c)]
forall a b. (a -> b) -> a -> b
$ RequiringBoth
WrapLedgerConfig
InjectTx
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k) (y :: k) (zs :: [k]).
f x y -> InPairs f (y : zs) -> InPairs f (x : y : zs)
PCons (InjectTx
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
-> RequiringBoth
WrapLedgerConfig
InjectTx
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
forall k (f :: k -> k -> *) (x :: k) (y :: k) (h :: k -> *).
f x y -> RequiringBoth h f x y
ignoringBoth InjectTx
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
forall c.
InjectTx
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
translateTxAllegraToMaryWrapper)
(InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)])
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c)]
-> InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c), ShelleyBlock (ShelleyEra c)]
forall a b. (a -> b) -> a -> b
$ InPairs
(RequiringBoth WrapLedgerConfig InjectTx)
'[ShelleyBlock (ShelleyEra c)]
forall k (f :: k -> k -> *) (x :: k). InPairs f '[x]
PNil
translateHeaderHashByronToShelley ::
forall c.
( ShelleyBasedEra (ShelleyEra c)
, HASH c ~ Blake2b_256
)
=> HeaderHash ByronBlock
-> HeaderHash (ShelleyBlock (ShelleyEra c))
=
Proxy (ShelleyBlock (ShelleyEra c))
-> ShortByteString -> HeaderHash (ShelleyBlock (ShelleyEra c))
forall blk (proxy :: * -> *).
ConvertRawHash blk =>
proxy blk -> ShortByteString -> HeaderHash blk
fromShortRawHash (Proxy (ShelleyBlock (ShelleyEra c))
forall k (t :: k). Proxy t
Proxy @(ShelleyBlock (ShelleyEra c)))
(ShortByteString -> ShelleyHash c)
-> (ByronHash -> ShortByteString) -> ByronHash -> ShelleyHash c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy ByronBlock -> HeaderHash ByronBlock -> ShortByteString
forall blk (proxy :: * -> *).
ConvertRawHash blk =>
proxy blk -> HeaderHash blk -> ShortByteString
toShortRawHash (Proxy ByronBlock
forall k (t :: k). Proxy t
Proxy @ByronBlock)
where
()
_ = Proxy (HASH c ~ Blake2b_256) -> ()
forall (c :: Constraint) (proxy :: Constraint -> *).
c =>
proxy c -> ()
keepRedundantConstraint (Proxy (HASH c ~ Blake2b_256)
forall k (t :: k). Proxy t
Proxy @(HASH c ~ Blake2b_256))
translatePointByronToShelley ::
( ShelleyBasedEra (ShelleyEra c)
, HASH c ~ Blake2b_256
)
=> Point ByronBlock
-> WithOrigin BlockNo
-> WithOrigin (ShelleyTip (ShelleyEra c))
translatePointByronToShelley :: Point ByronBlock
-> WithOrigin BlockNo -> WithOrigin (ShelleyTip (ShelleyEra c))
translatePointByronToShelley Point ByronBlock
point WithOrigin BlockNo
bNo =
case (Point ByronBlock
point, WithOrigin BlockNo
bNo) of
(Point ByronBlock
GenesisPoint, WithOrigin BlockNo
Origin) ->
WithOrigin (ShelleyTip (ShelleyEra c))
forall t. WithOrigin t
Origin
(BlockPoint SlotNo
s HeaderHash ByronBlock
h, NotOrigin BlockNo
n) -> ShelleyTip (ShelleyEra c) -> WithOrigin (ShelleyTip (ShelleyEra c))
forall t. t -> WithOrigin t
NotOrigin ShelleyTip :: forall era.
SlotNo
-> BlockNo -> HeaderHash (ShelleyBlock era) -> ShelleyTip era
ShelleyTip {
shelleyTipSlotNo :: SlotNo
shelleyTipSlotNo = SlotNo
s
, shelleyTipBlockNo :: BlockNo
shelleyTipBlockNo = BlockNo
n
, shelleyTipHash :: HeaderHash (ShelleyBlock (ShelleyEra c))
shelleyTipHash = HeaderHash ByronBlock -> HeaderHash (ShelleyBlock (ShelleyEra c))
forall c.
(ShelleyBasedEra (ShelleyEra c), HASH c ~ Blake2b_256) =>
HeaderHash ByronBlock -> HeaderHash (ShelleyBlock (ShelleyEra c))
translateHeaderHashByronToShelley HeaderHash ByronBlock
h
}
(Point ByronBlock, WithOrigin BlockNo)
_otherwise ->
String -> WithOrigin (ShelleyTip (ShelleyEra c))
forall a. HasCallStack => String -> a
error String
"translatePointByronToShelley: invalid Byron state"
translateLedgerStateByronToShelleyWrapper ::
( ShelleyBasedEra (ShelleyEra c)
, HASH c ~ Blake2b_256
, ADDRHASH c ~ Blake2b_224
)
=> RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
translateLedgerStateByronToShelleyWrapper :: RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
translateLedgerStateByronToShelleyWrapper =
(WrapLedgerConfig ByronBlock
-> WrapLedgerConfig (ShelleyBlock (ShelleyEra c))
-> Translate LedgerState ByronBlock (ShelleyBlock (ShelleyEra c)))
-> RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
forall k (h :: k -> *) (f :: k -> k -> *) (x :: k) (y :: k).
(h x -> h y -> f x y) -> RequiringBoth h f x y
RequireBoth ((WrapLedgerConfig ByronBlock
-> WrapLedgerConfig (ShelleyBlock (ShelleyEra c))
-> Translate LedgerState ByronBlock (ShelleyBlock (ShelleyEra c)))
-> RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
ByronBlock
(ShelleyBlock (ShelleyEra c)))
-> (WrapLedgerConfig ByronBlock
-> WrapLedgerConfig (ShelleyBlock (ShelleyEra c))
-> Translate LedgerState ByronBlock (ShelleyBlock (ShelleyEra c)))
-> RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
forall a b. (a -> b) -> a -> b
$ \WrapLedgerConfig ByronBlock
_ (WrapLedgerConfig LedgerConfig (ShelleyBlock (ShelleyEra c))
cfgShelley) ->
(EpochNo
-> LedgerState ByronBlock
-> LedgerState (ShelleyBlock (ShelleyEra c)))
-> Translate LedgerState ByronBlock (ShelleyBlock (ShelleyEra c))
forall (f :: * -> *) x y.
(EpochNo -> f x -> f y) -> Translate f x y
Translate ((EpochNo
-> LedgerState ByronBlock
-> LedgerState (ShelleyBlock (ShelleyEra c)))
-> Translate LedgerState ByronBlock (ShelleyBlock (ShelleyEra c)))
-> (EpochNo
-> LedgerState ByronBlock
-> LedgerState (ShelleyBlock (ShelleyEra c)))
-> Translate LedgerState ByronBlock (ShelleyBlock (ShelleyEra c))
forall a b. (a -> b) -> a -> b
$ \EpochNo
epochNo LedgerState ByronBlock
ledgerByron ->
ShelleyLedgerState :: forall era.
WithOrigin (ShelleyTip era)
-> NewEpochState era
-> ShelleyTransition
-> LedgerState (ShelleyBlock era)
ShelleyLedgerState {
shelleyLedgerTip :: WithOrigin (ShelleyTip (ShelleyEra c))
shelleyLedgerTip =
Point ByronBlock
-> WithOrigin BlockNo -> WithOrigin (ShelleyTip (ShelleyEra c))
forall c.
(ShelleyBasedEra (ShelleyEra c), HASH c ~ Blake2b_256) =>
Point ByronBlock
-> WithOrigin BlockNo -> WithOrigin (ShelleyTip (ShelleyEra c))
translatePointByronToShelley
(Proxy ByronBlock -> LedgerState ByronBlock -> Point ByronBlock
forall blk.
UpdateLedger blk =>
Proxy blk -> LedgerState blk -> Point blk
ledgerTipPoint (Proxy ByronBlock
forall k (t :: k). Proxy t
Proxy @ByronBlock) LedgerState ByronBlock
ledgerByron)
(LedgerState ByronBlock -> WithOrigin BlockNo
byronLedgerTipBlockNo LedgerState ByronBlock
ledgerByron)
, shelleyLedgerState :: NewEpochState (ShelleyEra c)
shelleyLedgerState =
ShelleyGenesis (ShelleyEra c)
-> EpochNo -> ChainValidationState -> NewEpochState (ShelleyEra c)
forall c.
(Crypto c, ADDRHASH c ~ Blake2b_224) =>
ShelleyGenesis (ShelleyEra c)
-> EpochNo -> ChainValidationState -> NewEpochState (ShelleyEra c)
SL.translateToShelleyLedgerState
(ShelleyLedgerConfig (ShelleyEra c) -> ShelleyGenesis (ShelleyEra c)
forall era. ShelleyLedgerConfig era -> ShelleyGenesis era
shelleyLedgerGenesis LedgerConfig (ShelleyBlock (ShelleyEra c))
ShelleyLedgerConfig (ShelleyEra c)
cfgShelley)
EpochNo
epochNo
(LedgerState ByronBlock -> ChainValidationState
byronLedgerState LedgerState ByronBlock
ledgerByron)
, shelleyLedgerTransition :: ShelleyTransition
shelleyLedgerTransition =
ShelleyTransitionInfo :: Word32 -> ShelleyTransition
ShelleyTransitionInfo{shelleyAfterVoting :: Word32
shelleyAfterVoting = Word32
0}
}
translateChainDepStateByronToShelleyWrapper ::
RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
translateChainDepStateByronToShelleyWrapper :: RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
translateChainDepStateByronToShelleyWrapper =
(WrapConsensusConfig ByronBlock
-> WrapConsensusConfig (ShelleyBlock (ShelleyEra c))
-> Translate
WrapChainDepState ByronBlock (ShelleyBlock (ShelleyEra c)))
-> RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
forall k (h :: k -> *) (f :: k -> k -> *) (x :: k) (y :: k).
(h x -> h y -> f x y) -> RequiringBoth h f x y
RequireBoth ((WrapConsensusConfig ByronBlock
-> WrapConsensusConfig (ShelleyBlock (ShelleyEra c))
-> Translate
WrapChainDepState ByronBlock (ShelleyBlock (ShelleyEra c)))
-> RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
ByronBlock
(ShelleyBlock (ShelleyEra c)))
-> (WrapConsensusConfig ByronBlock
-> WrapConsensusConfig (ShelleyBlock (ShelleyEra c))
-> Translate
WrapChainDepState ByronBlock (ShelleyBlock (ShelleyEra c)))
-> RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
ByronBlock
(ShelleyBlock (ShelleyEra c))
forall a b. (a -> b) -> a -> b
$ \WrapConsensusConfig ByronBlock
_ (WrapConsensusConfig ConsensusConfig (BlockProtocol (ShelleyBlock (ShelleyEra c)))
cfgShelley) ->
(EpochNo
-> WrapChainDepState ByronBlock
-> WrapChainDepState (ShelleyBlock (ShelleyEra c)))
-> Translate
WrapChainDepState ByronBlock (ShelleyBlock (ShelleyEra c))
forall (f :: * -> *) x y.
(EpochNo -> f x -> f y) -> Translate f x y
Translate ((EpochNo
-> WrapChainDepState ByronBlock
-> WrapChainDepState (ShelleyBlock (ShelleyEra c)))
-> Translate
WrapChainDepState ByronBlock (ShelleyBlock (ShelleyEra c)))
-> (EpochNo
-> WrapChainDepState ByronBlock
-> WrapChainDepState (ShelleyBlock (ShelleyEra c)))
-> Translate
WrapChainDepState ByronBlock (ShelleyBlock (ShelleyEra c))
forall a b. (a -> b) -> a -> b
$ \EpochNo
_ (WrapChainDepState ChainDepState (BlockProtocol ByronBlock)
pbftState) ->
ChainDepState (BlockProtocol (ShelleyBlock (ShelleyEra c)))
-> WrapChainDepState (ShelleyBlock (ShelleyEra c))
forall blk.
ChainDepState (BlockProtocol blk) -> WrapChainDepState blk
WrapChainDepState (ChainDepState (BlockProtocol (ShelleyBlock (ShelleyEra c)))
-> WrapChainDepState (ShelleyBlock (ShelleyEra c)))
-> ChainDepState (BlockProtocol (ShelleyBlock (ShelleyEra c)))
-> WrapChainDepState (ShelleyBlock (ShelleyEra c))
forall a b. (a -> b) -> a -> b
$
ConsensusConfig (TPraos c)
-> PBftState PBftByronCrypto -> TPraosState c
forall bc c.
ConsensusConfig (TPraos c) -> PBftState bc -> TPraosState c
translateChainDepStateByronToShelley ConsensusConfig (BlockProtocol (ShelleyBlock (ShelleyEra c)))
ConsensusConfig (TPraos c)
cfgShelley PBftState PBftByronCrypto
ChainDepState (BlockProtocol ByronBlock)
pbftState
translateChainDepStateByronToShelley ::
forall bc c.
ConsensusConfig (TPraos c)
-> PBftState bc
-> TPraosState c
translateChainDepStateByronToShelley :: ConsensusConfig (TPraos c) -> PBftState bc -> TPraosState c
translateChainDepStateByronToShelley TPraosConfig { tpraosParams } PBftState bc
pbftState =
WithOrigin SlotNo -> ChainDepState c -> TPraosState c
forall c. WithOrigin SlotNo -> ChainDepState c -> TPraosState c
TPraosState (PBftState bc -> WithOrigin SlotNo
forall c. PBftState c -> WithOrigin SlotNo
PBftState.lastSignedSlot PBftState bc
pbftState) (ChainDepState c -> TPraosState c)
-> ChainDepState c -> TPraosState c
forall a b. (a -> b) -> a -> b
$
ChainDepState :: forall crypto.
PrtclState crypto -> TicknState -> Nonce -> ChainDepState crypto
SL.ChainDepState
{ csProtocol :: PrtclState c
SL.csProtocol = Map (KeyHash 'BlockIssuer c) Word64
-> Nonce -> Nonce -> PrtclState c
forall crypto.
Map (KeyHash 'BlockIssuer crypto) Word64
-> Nonce -> Nonce -> PrtclState crypto
SL.PrtclState Map (KeyHash 'BlockIssuer c) Word64
forall k a. Map k a
Map.empty Nonce
nonce Nonce
nonce
, csTickn :: TicknState
SL.csTickn = TicknState :: Nonce -> Nonce -> TicknState
SL.TicknState {
ticknStateEpochNonce :: Nonce
ticknStateEpochNonce = Nonce
nonce
, ticknStatePrevHashNonce :: Nonce
ticknStatePrevHashNonce = Nonce
SL.NeutralNonce
}
, csLabNonce :: Nonce
SL.csLabNonce = Nonce
SL.NeutralNonce
}
where
nonce :: Nonce
nonce = TPraosParams -> Nonce
tpraosInitialNonce TPraosParams
tpraosParams
translateLedgerViewByronToShelleyWrapper ::
forall c.
RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
ByronBlock
(ShelleyBlock (ShelleyEra c))
translateLedgerViewByronToShelleyWrapper :: RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
ByronBlock
(ShelleyBlock (ShelleyEra c))
translateLedgerViewByronToShelleyWrapper =
(WrapLedgerConfig ByronBlock
-> WrapLedgerConfig (ShelleyBlock (ShelleyEra c))
-> TranslateForecast
LedgerState
WrapLedgerView
ByronBlock
(ShelleyBlock (ShelleyEra c)))
-> RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
ByronBlock
(ShelleyBlock (ShelleyEra c))
forall k (h :: k -> *) (f :: k -> k -> *) (x :: k) (y :: k).
(h x -> h y -> f x y) -> RequiringBoth h f x y
RequireBoth ((WrapLedgerConfig ByronBlock
-> WrapLedgerConfig (ShelleyBlock (ShelleyEra c))
-> TranslateForecast
LedgerState
WrapLedgerView
ByronBlock
(ShelleyBlock (ShelleyEra c)))
-> RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
ByronBlock
(ShelleyBlock (ShelleyEra c)))
-> (WrapLedgerConfig ByronBlock
-> WrapLedgerConfig (ShelleyBlock (ShelleyEra c))
-> TranslateForecast
LedgerState
WrapLedgerView
ByronBlock
(ShelleyBlock (ShelleyEra c)))
-> RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
ByronBlock
(ShelleyBlock (ShelleyEra c))
forall a b. (a -> b) -> a -> b
$ \WrapLedgerConfig ByronBlock
_ (WrapLedgerConfig LedgerConfig (ShelleyBlock (ShelleyEra c))
cfgShelley) ->
(Bound
-> SlotNo
-> LedgerState ByronBlock
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c)))))
-> TranslateForecast
LedgerState WrapLedgerView ByronBlock (ShelleyBlock (ShelleyEra c))
forall (f :: * -> *) (g :: * -> *) x y.
(Bound
-> SlotNo -> f x -> Except OutsideForecastRange (Ticked (g y)))
-> TranslateForecast f g x y
TranslateForecast (ShelleyLedgerConfig (ShelleyEra c)
-> Bound
-> SlotNo
-> LedgerState ByronBlock
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c))))
forecast LedgerConfig (ShelleyBlock (ShelleyEra c))
ShelleyLedgerConfig (ShelleyEra c)
cfgShelley)
where
forecast ::
ShelleyLedgerConfig (ShelleyEra c)
-> Bound
-> SlotNo
-> LedgerState ByronBlock
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c))))
forecast :: ShelleyLedgerConfig (ShelleyEra c)
-> Bound
-> SlotNo
-> LedgerState ByronBlock
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c))))
forecast ShelleyLedgerConfig (ShelleyEra c)
cfgShelley Bound
bound SlotNo
forecastFor LedgerState ByronBlock
currentByronState
| SlotNo
forecastFor SlotNo -> SlotNo -> Bool
forall a. Ord a => a -> a -> Bool
< SlotNo
maxFor
= Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c)))
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c))))
forall (m :: * -> *) a. Monad m => a -> m a
return (Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c)))
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c)))))
-> Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c)))
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c))))
forall a b. (a -> b) -> a -> b
$
Ticked (LedgerView (BlockProtocol (ShelleyBlock (ShelleyEra c))))
-> Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c)))
forall blk.
Ticked (LedgerView (BlockProtocol blk))
-> Ticked (WrapLedgerView blk)
WrapTickedLedgerView (Ticked (LedgerView (BlockProtocol (ShelleyBlock (ShelleyEra c))))
-> Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c))))
-> Ticked
(LedgerView (BlockProtocol (ShelleyBlock (ShelleyEra c))))
-> Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c)))
forall a b. (a -> b) -> a -> b
$ LedgerView c -> Ticked (LedgerView c)
forall c. LedgerView c -> Ticked (LedgerView c)
TickedPraosLedgerView (LedgerView c -> Ticked (LedgerView c))
-> LedgerView c -> Ticked (LedgerView c)
forall a b. (a -> b) -> a -> b
$
ShelleyGenesis (ShelleyEra c) -> LedgerView c
forall c. ShelleyGenesis (ShelleyEra c) -> LedgerView c
SL.mkInitialShelleyLedgerView
(ShelleyLedgerConfig (ShelleyEra c) -> ShelleyGenesis (ShelleyEra c)
forall era. ShelleyLedgerConfig era -> ShelleyGenesis era
shelleyLedgerGenesis ShelleyLedgerConfig (ShelleyEra c)
cfgShelley)
| Bool
otherwise
= OutsideForecastRange
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c))))
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (OutsideForecastRange
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c)))))
-> OutsideForecastRange
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock (ShelleyEra c))))
forall a b. (a -> b) -> a -> b
$ OutsideForecastRange :: WithOrigin SlotNo -> SlotNo -> SlotNo -> OutsideForecastRange
OutsideForecastRange {
outsideForecastAt :: WithOrigin SlotNo
outsideForecastAt = LedgerState ByronBlock -> WithOrigin SlotNo
forall blk.
UpdateLedger blk =>
LedgerState blk -> WithOrigin SlotNo
ledgerTipSlot LedgerState ByronBlock
currentByronState
, outsideForecastMaxFor :: SlotNo
outsideForecastMaxFor = SlotNo
maxFor
, outsideForecastFor :: SlotNo
outsideForecastFor = SlotNo
forecastFor
}
where
globals :: Globals
globals = ShelleyLedgerConfig (ShelleyEra c) -> Globals
forall era. ShelleyLedgerConfig era -> Globals
shelleyLedgerGlobals ShelleyLedgerConfig (ShelleyEra c)
cfgShelley
swindow :: Word64
swindow = Globals -> Word64
SL.stabilityWindow Globals
globals
maxFor :: SlotNo
maxFor :: SlotNo
maxFor = Word64 -> SlotNo -> SlotNo
addSlots Word64
swindow (Bound -> SlotNo
boundSlot Bound
bound)
instance ( ShelleyBasedEra era
, ShelleyBasedEra (SL.PreviousEra era)
, EraCrypto (SL.PreviousEra era) ~ EraCrypto era
) => SL.TranslateEra era ShelleyTip where
translateEra :: TranslationContext era
-> ShelleyTip (PreviousEra era)
-> Except (TranslationError era ShelleyTip) (ShelleyTip era)
translateEra TranslationContext era
_ (ShelleyTip SlotNo
sno BlockNo
bno (ShelleyHash hash)) =
ShelleyTip era -> ExceptT Void Identity (ShelleyTip era)
forall (m :: * -> *) a. Monad m => a -> m a
return (ShelleyTip era -> ExceptT Void Identity (ShelleyTip era))
-> ShelleyTip era -> ExceptT Void Identity (ShelleyTip era)
forall a b. (a -> b) -> a -> b
$ SlotNo
-> BlockNo -> HeaderHash (ShelleyBlock era) -> ShelleyTip era
forall era.
SlotNo
-> BlockNo -> HeaderHash (ShelleyBlock era) -> ShelleyTip era
ShelleyTip SlotNo
sno BlockNo
bno (HashHeader (EraCrypto era) -> ShelleyHash (EraCrypto era)
forall c. HashHeader c -> ShelleyHash c
ShelleyHash HashHeader (EraCrypto era)
hash)
instance ( ShelleyBasedEra era
, SL.TranslateEra era ShelleyTip
, SL.TranslateEra era SL.NewEpochState
, SL.TranslationError era SL.NewEpochState ~ Void
) => SL.TranslateEra era (LedgerState :.: ShelleyBlock) where
translateEra :: TranslationContext era
-> (:.:) LedgerState ShelleyBlock (PreviousEra era)
-> Except
(TranslationError era (LedgerState :.: ShelleyBlock))
((:.:) LedgerState ShelleyBlock era)
translateEra TranslationContext era
ctxt (Comp (ShelleyLedgerState tip state _transition)) = do
WithOrigin (ShelleyTip era)
tip' <- (ShelleyTip (PreviousEra era)
-> ExceptT Void Identity (ShelleyTip era))
-> WithOrigin (ShelleyTip (PreviousEra era))
-> ExceptT Void Identity (WithOrigin (ShelleyTip era))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (TranslationContext era
-> ShelleyTip (PreviousEra era)
-> Except (TranslationError era ShelleyTip) (ShelleyTip era)
forall era (f :: * -> *).
TranslateEra era f =>
TranslationContext era
-> f (PreviousEra era) -> Except (TranslationError era f) (f era)
SL.translateEra TranslationContext era
ctxt) WithOrigin (ShelleyTip (PreviousEra era))
tip
NewEpochState era
state' <- TranslationContext era
-> NewEpochState (PreviousEra era)
-> Except (TranslationError era NewEpochState) (NewEpochState era)
forall era (f :: * -> *).
TranslateEra era f =>
TranslationContext era
-> f (PreviousEra era) -> Except (TranslationError era f) (f era)
SL.translateEra TranslationContext era
ctxt NewEpochState (PreviousEra era)
state
(:.:) LedgerState ShelleyBlock era
-> ExceptT Void Identity ((:.:) LedgerState ShelleyBlock era)
forall (m :: * -> *) a. Monad m => a -> m a
return ((:.:) LedgerState ShelleyBlock era
-> ExceptT Void Identity ((:.:) LedgerState ShelleyBlock era))
-> (:.:) LedgerState ShelleyBlock era
-> ExceptT Void Identity ((:.:) LedgerState ShelleyBlock era)
forall a b. (a -> b) -> a -> b
$ LedgerState (ShelleyBlock era)
-> (:.:) LedgerState ShelleyBlock era
forall l k (f :: l -> *) (g :: k -> l) (p :: k).
f (g p) -> (:.:) f g p
Comp (LedgerState (ShelleyBlock era)
-> (:.:) LedgerState ShelleyBlock era)
-> LedgerState (ShelleyBlock era)
-> (:.:) LedgerState ShelleyBlock era
forall a b. (a -> b) -> a -> b
$ ShelleyLedgerState :: forall era.
WithOrigin (ShelleyTip era)
-> NewEpochState era
-> ShelleyTransition
-> LedgerState (ShelleyBlock era)
ShelleyLedgerState {
shelleyLedgerTip :: WithOrigin (ShelleyTip era)
shelleyLedgerTip = WithOrigin (ShelleyTip era)
tip'
, shelleyLedgerState :: NewEpochState era
shelleyLedgerState = NewEpochState era
state'
, shelleyLedgerTransition :: ShelleyTransition
shelleyLedgerTransition = Word32 -> ShelleyTransition
ShelleyTransitionInfo Word32
0
}
instance ( ShelleyBasedEra era
, SL.TranslateEra era SL.Tx
) => SL.TranslateEra era (GenTx :.: ShelleyBlock) where
type TranslationError era (GenTx :.: ShelleyBlock) = SL.TranslationError era SL.Tx
translateEra :: TranslationContext era
-> (:.:) GenTx ShelleyBlock (PreviousEra era)
-> Except
(TranslationError era (GenTx :.: ShelleyBlock))
((:.:) GenTx ShelleyBlock era)
translateEra TranslationContext era
ctxt (Comp (ShelleyTx _txId tx)) =
GenTx (ShelleyBlock era) -> (:.:) GenTx ShelleyBlock era
forall l k (f :: l -> *) (g :: k -> l) (p :: k).
f (g p) -> (:.:) f g p
Comp (GenTx (ShelleyBlock era) -> (:.:) GenTx ShelleyBlock era)
-> (Tx era -> GenTx (ShelleyBlock era))
-> Tx era
-> (:.:) GenTx ShelleyBlock era
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tx era -> GenTx (ShelleyBlock era)
forall era.
ShelleyBasedEra era =>
Tx era -> GenTx (ShelleyBlock era)
mkShelleyTx (Tx era -> (:.:) GenTx ShelleyBlock era)
-> ExceptT (TranslationError era Tx) Identity (Tx era)
-> ExceptT
(TranslationError era Tx) Identity ((:.:) GenTx ShelleyBlock era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TranslationContext era
-> Tx (PreviousEra era)
-> ExceptT (TranslationError era Tx) Identity (Tx era)
forall era (f :: * -> *).
TranslateEra era f =>
TranslationContext era
-> f (PreviousEra era) -> Except (TranslationError era f) (f era)
SL.translateEra TranslationContext era
ctxt Tx (PreviousEra era)
tx
forecastAcrossShelley ::
forall eraFrom eraTo.
( EraCrypto eraFrom ~ EraCrypto eraTo
, ShelleyBasedEra eraFrom
)
=> ShelleyLedgerConfig eraFrom
-> ShelleyLedgerConfig eraTo
-> Bound
-> SlotNo
-> LedgerState (ShelleyBlock eraFrom)
-> Except OutsideForecastRange (Ticked (WrapLedgerView (ShelleyBlock eraTo)))
forecastAcrossShelley :: ShelleyLedgerConfig eraFrom
-> ShelleyLedgerConfig eraTo
-> Bound
-> SlotNo
-> LedgerState (ShelleyBlock eraFrom)
-> Except
OutsideForecastRange (Ticked (WrapLedgerView (ShelleyBlock eraTo)))
forecastAcrossShelley ShelleyLedgerConfig eraFrom
cfgFrom ShelleyLedgerConfig eraTo
cfgTo Bound
transition SlotNo
forecastFor LedgerState (ShelleyBlock eraFrom)
ledgerStateFrom
| SlotNo
forecastFor SlotNo -> SlotNo -> Bool
forall a. Ord a => a -> a -> Bool
< SlotNo
maxFor
= Ticked (WrapLedgerView (ShelleyBlock eraTo))
-> Except
OutsideForecastRange (Ticked (WrapLedgerView (ShelleyBlock eraTo)))
forall (m :: * -> *) a. Monad m => a -> m a
return (Ticked (WrapLedgerView (ShelleyBlock eraTo))
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock eraTo))))
-> Ticked (WrapLedgerView (ShelleyBlock eraTo))
-> Except
OutsideForecastRange (Ticked (WrapLedgerView (ShelleyBlock eraTo)))
forall a b. (a -> b) -> a -> b
$ SlotNo -> Ticked (WrapLedgerView (ShelleyBlock eraTo))
futureLedgerView SlotNo
forecastFor
| Bool
otherwise
= OutsideForecastRange
-> Except
OutsideForecastRange (Ticked (WrapLedgerView (ShelleyBlock eraTo)))
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (OutsideForecastRange
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock eraTo))))
-> OutsideForecastRange
-> Except
OutsideForecastRange (Ticked (WrapLedgerView (ShelleyBlock eraTo)))
forall a b. (a -> b) -> a -> b
$ OutsideForecastRange :: WithOrigin SlotNo -> SlotNo -> SlotNo -> OutsideForecastRange
OutsideForecastRange {
outsideForecastAt :: WithOrigin SlotNo
outsideForecastAt = LedgerState (ShelleyBlock eraFrom) -> WithOrigin SlotNo
forall blk.
UpdateLedger blk =>
LedgerState blk -> WithOrigin SlotNo
ledgerTipSlot LedgerState (ShelleyBlock eraFrom)
ledgerStateFrom
, outsideForecastMaxFor :: SlotNo
outsideForecastMaxFor = SlotNo
maxFor
, outsideForecastFor :: SlotNo
outsideForecastFor = SlotNo
forecastFor
}
where
futureLedgerView :: SlotNo -> Ticked (WrapLedgerView (ShelleyBlock eraTo))
futureLedgerView :: SlotNo -> Ticked (WrapLedgerView (ShelleyBlock eraTo))
futureLedgerView =
Ticked (LedgerView (Crypto eraTo))
-> Ticked (WrapLedgerView (ShelleyBlock eraTo))
forall blk.
Ticked (LedgerView (BlockProtocol blk))
-> Ticked (WrapLedgerView blk)
WrapTickedLedgerView
(Ticked (LedgerView (Crypto eraTo))
-> Ticked (WrapLedgerView (ShelleyBlock eraTo)))
-> (SlotNo -> Ticked (LedgerView (Crypto eraTo)))
-> SlotNo
-> Ticked (WrapLedgerView (ShelleyBlock eraTo))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LedgerView (Crypto eraTo) -> Ticked (LedgerView (Crypto eraTo))
forall c. LedgerView c -> Ticked (LedgerView c)
TickedPraosLedgerView
(LedgerView (Crypto eraTo) -> Ticked (LedgerView (Crypto eraTo)))
-> (SlotNo -> LedgerView (Crypto eraTo))
-> SlotNo
-> Ticked (LedgerView (Crypto eraTo))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FutureLedgerViewError eraFrom -> LedgerView (Crypto eraTo))
-> (LedgerView (Crypto eraTo) -> LedgerView (Crypto eraTo))
-> Either
(FutureLedgerViewError eraFrom) (LedgerView (Crypto eraTo))
-> LedgerView (Crypto eraTo)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either
(\FutureLedgerViewError eraFrom
e -> String -> LedgerView (Crypto eraTo)
forall a. HasCallStack => String -> a
error (String
"futureLedgerView failed: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> FutureLedgerViewError eraFrom -> String
forall a. Show a => a -> String
show FutureLedgerViewError eraFrom
e))
LedgerView (Crypto eraTo) -> LedgerView (Crypto eraTo)
forall a. a -> a
id
(Either (FutureLedgerViewError eraFrom) (LedgerView (Crypto eraTo))
-> LedgerView (Crypto eraTo))
-> (SlotNo
-> Either
(FutureLedgerViewError eraFrom) (LedgerView (Crypto eraTo)))
-> SlotNo
-> LedgerView (Crypto eraTo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Globals
-> NewEpochState eraFrom
-> SlotNo
-> Either
(FutureLedgerViewError eraFrom) (LedgerView (Crypto eraFrom))
forall era (m :: * -> *).
(GetLedgerView era, MonadError (FutureLedgerViewError era) m) =>
Globals
-> NewEpochState era -> SlotNo -> m (LedgerView (Crypto era))
SL.futureLedgerView
(ShelleyLedgerConfig eraFrom -> Globals
forall era. ShelleyLedgerConfig era -> Globals
shelleyLedgerGlobals ShelleyLedgerConfig eraFrom
cfgFrom)
(LedgerState (ShelleyBlock eraFrom) -> NewEpochState eraFrom
forall era. LedgerState (ShelleyBlock era) -> NewEpochState era
shelleyLedgerState LedgerState (ShelleyBlock eraFrom)
ledgerStateFrom)
maxFor :: SlotNo
maxFor :: SlotNo
maxFor = WithOrigin SlotNo -> SlotNo -> Word64 -> Word64 -> SlotNo
crossEraForecastBound
(LedgerState (ShelleyBlock eraFrom) -> WithOrigin SlotNo
forall blk.
UpdateLedger blk =>
LedgerState blk -> WithOrigin SlotNo
ledgerTipSlot LedgerState (ShelleyBlock eraFrom)
ledgerStateFrom)
(Bound -> SlotNo
boundSlot Bound
transition)
(Globals -> Word64
SL.stabilityWindow (ShelleyLedgerConfig eraFrom -> Globals
forall era. ShelleyLedgerConfig era -> Globals
shelleyLedgerGlobals ShelleyLedgerConfig eraFrom
cfgFrom))
(Globals -> Word64
SL.stabilityWindow (ShelleyLedgerConfig eraTo -> Globals
forall era. ShelleyLedgerConfig era -> Globals
shelleyLedgerGlobals ShelleyLedgerConfig eraTo
cfgTo))
translateChainDepStateAcrossShelley ::
forall eraFrom eraTo.
EraCrypto eraFrom ~ EraCrypto eraTo
=> RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
translateChainDepStateAcrossShelley :: RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
translateChainDepStateAcrossShelley =
Translate
WrapChainDepState (ShelleyBlock eraFrom) (ShelleyBlock eraTo)
-> RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
forall k (f :: k -> k -> *) (x :: k) (y :: k) (h :: k -> *).
f x y -> RequiringBoth h f x y
ignoringBoth (Translate
WrapChainDepState (ShelleyBlock eraFrom) (ShelleyBlock eraTo)
-> RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo))
-> Translate
WrapChainDepState (ShelleyBlock eraFrom) (ShelleyBlock eraTo)
-> RequiringBoth
WrapConsensusConfig
(Translate WrapChainDepState)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
forall a b. (a -> b) -> a -> b
$
(EpochNo
-> WrapChainDepState (ShelleyBlock eraFrom)
-> WrapChainDepState (ShelleyBlock eraTo))
-> Translate
WrapChainDepState (ShelleyBlock eraFrom) (ShelleyBlock eraTo)
forall (f :: * -> *) x y.
(EpochNo -> f x -> f y) -> Translate f x y
Translate ((EpochNo
-> WrapChainDepState (ShelleyBlock eraFrom)
-> WrapChainDepState (ShelleyBlock eraTo))
-> Translate
WrapChainDepState (ShelleyBlock eraFrom) (ShelleyBlock eraTo))
-> (EpochNo
-> WrapChainDepState (ShelleyBlock eraFrom)
-> WrapChainDepState (ShelleyBlock eraTo))
-> Translate
WrapChainDepState (ShelleyBlock eraFrom) (ShelleyBlock eraTo)
forall a b. (a -> b) -> a -> b
$ \EpochNo
_epochNo (WrapChainDepState ChainDepState (BlockProtocol (ShelleyBlock eraFrom))
chainDepState) ->
ChainDepState (BlockProtocol (ShelleyBlock eraTo))
-> WrapChainDepState (ShelleyBlock eraTo)
forall blk.
ChainDepState (BlockProtocol blk) -> WrapChainDepState blk
WrapChainDepState ChainDepState (BlockProtocol (ShelleyBlock eraFrom))
ChainDepState (BlockProtocol (ShelleyBlock eraTo))
chainDepState
translateLedgerViewAcrossShelley ::
forall eraFrom eraTo.
( EraCrypto eraFrom ~ EraCrypto eraTo
, ShelleyBasedEra eraFrom
)
=> RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
translateLedgerViewAcrossShelley :: RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
translateLedgerViewAcrossShelley =
(WrapLedgerConfig (ShelleyBlock eraFrom)
-> WrapLedgerConfig (ShelleyBlock eraTo)
-> TranslateForecast
LedgerState
WrapLedgerView
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo))
-> RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
forall k (h :: k -> *) (f :: k -> k -> *) (x :: k) (y :: k).
(h x -> h y -> f x y) -> RequiringBoth h f x y
RequireBoth ((WrapLedgerConfig (ShelleyBlock eraFrom)
-> WrapLedgerConfig (ShelleyBlock eraTo)
-> TranslateForecast
LedgerState
WrapLedgerView
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo))
-> RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo))
-> (WrapLedgerConfig (ShelleyBlock eraFrom)
-> WrapLedgerConfig (ShelleyBlock eraTo)
-> TranslateForecast
LedgerState
WrapLedgerView
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo))
-> RequiringBoth
WrapLedgerConfig
(TranslateForecast LedgerState WrapLedgerView)
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
forall a b. (a -> b) -> a -> b
$ \(WrapLedgerConfig LedgerConfig (ShelleyBlock eraFrom)
cfgFrom)
(WrapLedgerConfig LedgerConfig (ShelleyBlock eraTo)
cfgTo) ->
(Bound
-> SlotNo
-> LedgerState (ShelleyBlock eraFrom)
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock eraTo))))
-> TranslateForecast
LedgerState
WrapLedgerView
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
forall (f :: * -> *) (g :: * -> *) x y.
(Bound
-> SlotNo -> f x -> Except OutsideForecastRange (Ticked (g y)))
-> TranslateForecast f g x y
TranslateForecast ((Bound
-> SlotNo
-> LedgerState (ShelleyBlock eraFrom)
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock eraTo))))
-> TranslateForecast
LedgerState
WrapLedgerView
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo))
-> (Bound
-> SlotNo
-> LedgerState (ShelleyBlock eraFrom)
-> Except
OutsideForecastRange
(Ticked (WrapLedgerView (ShelleyBlock eraTo))))
-> TranslateForecast
LedgerState
WrapLedgerView
(ShelleyBlock eraFrom)
(ShelleyBlock eraTo)
forall a b. (a -> b) -> a -> b
$ ShelleyLedgerConfig eraFrom
-> ShelleyLedgerConfig eraTo
-> Bound
-> SlotNo
-> LedgerState (ShelleyBlock eraFrom)
-> Except
OutsideForecastRange (Ticked (WrapLedgerView (ShelleyBlock eraTo)))
forall eraFrom eraTo.
(EraCrypto eraFrom ~ EraCrypto eraTo, ShelleyBasedEra eraFrom) =>
ShelleyLedgerConfig eraFrom
-> ShelleyLedgerConfig eraTo
-> Bound
-> SlotNo
-> LedgerState (ShelleyBlock eraFrom)
-> Except
OutsideForecastRange (Ticked (WrapLedgerView (ShelleyBlock eraTo)))
forecastAcrossShelley LedgerConfig (ShelleyBlock eraFrom)
ShelleyLedgerConfig eraFrom
cfgFrom LedgerConfig (ShelleyBlock eraTo)
ShelleyLedgerConfig eraTo
cfgTo
translateLedgerStateShelleyToAllegraWrapper ::
RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (AllegraEra c))
translateLedgerStateShelleyToAllegraWrapper :: RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
translateLedgerStateShelleyToAllegraWrapper =
Translate
LedgerState
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
-> RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
forall k (f :: k -> k -> *) (x :: k) (y :: k) (h :: k -> *).
f x y -> RequiringBoth h f x y
ignoringBoth (Translate
LedgerState
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
-> RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c)))
-> Translate
LedgerState
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
-> RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
forall a b. (a -> b) -> a -> b
$
(EpochNo
-> LedgerState (ShelleyBlock (ShelleyEra c))
-> LedgerState (ShelleyBlock (ShelleyEra c)))
-> Translate
LedgerState
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
forall (f :: * -> *) x y.
(EpochNo -> f x -> f y) -> Translate f x y
Translate ((EpochNo
-> LedgerState (ShelleyBlock (ShelleyEra c))
-> LedgerState (ShelleyBlock (ShelleyEra c)))
-> Translate
LedgerState
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c)))
-> (EpochNo
-> LedgerState (ShelleyBlock (ShelleyEra c))
-> LedgerState (ShelleyBlock (ShelleyEra c)))
-> Translate
LedgerState
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (ShelleyEra c))
forall a b. (a -> b) -> a -> b
$ \EpochNo
_epochNo LedgerState (ShelleyBlock (ShelleyEra c))
ledgerShelley -> LedgerState (ShelleyBlock (ShelleyEra c))
ledgerShelley
translateTxShelleyToAllegraWrapper ::
InjectTx
(ShelleyBlock (ShelleyEra c))
(ShelleyBlock (AllegraEra c))
translateTxShelleyToAllegraWrapper :: InjectTx
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
translateTxShelleyToAllegraWrapper = (GenTx (ShelleyBlock (ShelleyEra c))
-> Maybe (GenTx (ShelleyBlock (ShelleyEra c))))
-> InjectTx
(ShelleyBlock (ShelleyEra c)) (ShelleyBlock (ShelleyEra c))
forall blk blk'.
(GenTx blk -> Maybe (GenTx blk')) -> InjectTx blk blk'
InjectTx GenTx (ShelleyBlock (ShelleyEra c))
-> Maybe (GenTx (ShelleyBlock (ShelleyEra c)))
forall a. a -> Maybe a
Just
translateLedgerStateAllegraToMaryWrapper ::
RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (AllegraEra c))
(ShelleyBlock (MaryEra c))
translateLedgerStateAllegraToMaryWrapper :: RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (AllegraEra c))
(ShelleyBlock (AllegraEra c))
translateLedgerStateAllegraToMaryWrapper =
Translate
LedgerState
(ShelleyBlock (AllegraEra c))
(ShelleyBlock (AllegraEra c))
-> RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (AllegraEra c))
(ShelleyBlock (AllegraEra c))
forall k (f :: k -> k -> *) (x :: k) (y :: k) (h :: k -> *).
f x y -> RequiringBoth h f x y
ignoringBoth (Translate
LedgerState
(ShelleyBlock (AllegraEra c))
(ShelleyBlock (AllegraEra c))
-> RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (AllegraEra c))
(ShelleyBlock (AllegraEra c)))
-> Translate
LedgerState
(ShelleyBlock (AllegraEra c))
(ShelleyBlock (AllegraEra c))
-> RequiringBoth
WrapLedgerConfig
(Translate LedgerState)
(ShelleyBlock (AllegraEra c))
(ShelleyBlock (AllegraEra c))
forall a b. (a -> b) -> a -> b
$
(EpochNo
-> LedgerState (ShelleyBlock (AllegraEra c))
-> LedgerState (ShelleyBlock (AllegraEra c)))
-> Translate
LedgerState
(ShelleyBlock (AllegraEra c))
(ShelleyBlock (AllegraEra c))
forall (f :: * -> *) x y.
(EpochNo -> f x -> f y) -> Translate f x y
Translate ((EpochNo
-> LedgerState (ShelleyBlock (AllegraEra c))
-> LedgerState (ShelleyBlock (AllegraEra c)))
-> Translate
LedgerState
(ShelleyBlock (AllegraEra c))
(ShelleyBlock (AllegraEra c)))
-> (EpochNo
-> LedgerState (ShelleyBlock (AllegraEra c))
-> LedgerState (ShelleyBlock (AllegraEra c)))
-> Translate
LedgerState
(ShelleyBlock (AllegraEra c))
(ShelleyBlock (AllegraEra c))
forall a b. (a -> b) -> a -> b
$ \EpochNo
_epochNo LedgerState (ShelleyBlock (AllegraEra c))
ledgerAllegra -> LedgerState (ShelleyBlock (AllegraEra c))
ledgerAllegra
translateTxAllegraToMaryWrapper ::
InjectTx
(ShelleyBlock (AllegraEra c))
(ShelleyBlock (MaryEra c))
translateTxAllegraToMaryWrapper :: InjectTx
(ShelleyBlock (AllegraEra c)) (ShelleyBlock (AllegraEra c))
translateTxAllegraToMaryWrapper = (GenTx (ShelleyBlock (AllegraEra c))
-> Maybe (GenTx (ShelleyBlock (AllegraEra c))))
-> InjectTx
(ShelleyBlock (AllegraEra c)) (ShelleyBlock (AllegraEra c))
forall blk blk'.
(GenTx blk -> Maybe (GenTx blk')) -> InjectTx blk blk'
InjectTx GenTx (ShelleyBlock (AllegraEra c))
-> Maybe (GenTx (ShelleyBlock (AllegraEra c)))
forall a. a -> Maybe a
Just