{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
module Test.Consensus.Byron.Examples (
cfg
, codecConfig
, leaderCredentials
, ledgerConfig
, secParam
, windowSize
, exampleApplyTxErr
, exampleChainDepState
, exampleExtLedgerState
, exampleGenTx
, exampleGenTxId
, exampleHeaderHash
, exampleHeaderState
, exampleLedgerState
, examples
) where
import qualified Cardano.Chain.Block as CC.Block
import qualified Cardano.Chain.Byron.API as CC
import qualified Cardano.Chain.Common as CC
import qualified Cardano.Chain.Update.Validation.Interface as CC.UPI
import qualified Cardano.Chain.UTxO as CC
import Cardano.Ledger.BaseTypes (knownNonZeroBounded)
import Control.Monad.Except (runExcept)
import qualified Data.Map.Strict as Map
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.Byron.Crypto.DSIGN (SignKeyDSIGN (..))
import Ouroboros.Consensus.Byron.Ledger
import Ouroboros.Consensus.Byron.Node (ByronLeaderCredentials (..))
import Ouroboros.Consensus.Config
import Ouroboros.Consensus.HeaderValidation
import Ouroboros.Consensus.Ledger.Abstract
import Ouroboros.Consensus.Ledger.Extended
import Ouroboros.Consensus.Ledger.Query
import Ouroboros.Consensus.Ledger.Tables.Utils
import Ouroboros.Consensus.NodeId
import Ouroboros.Consensus.Protocol.Abstract
import Ouroboros.Consensus.Protocol.PBFT
import qualified Ouroboros.Consensus.Protocol.PBFT.State as S
import Ouroboros.Consensus.Storage.Serialisation
import Ouroboros.Network.Block (Serialised (..))
import qualified Test.Cardano.Chain.Common.Example as CC
import qualified Test.Cardano.Chain.Genesis.Dummy as CC
import qualified Test.Cardano.Chain.Update.Example as CC
import qualified Test.Cardano.Chain.UTxO.Example as CC
import Test.ThreadNet.Infra.Byron.ProtocolInfo (mkLeaderCredentials)
import qualified Test.Util.Serialisation.Examples as Examples
import Test.Util.Serialisation.Examples (Examples (Examples),
Labelled, labelled, unlabelled)
import Test.Util.Serialisation.SomeResult (SomeResult (..))
secParam :: SecurityParam
secParam :: SecurityParam
secParam = NonZero Word64 -> SecurityParam
SecurityParam (NonZero Word64 -> SecurityParam)
-> NonZero Word64 -> SecurityParam
forall a b. (a -> b) -> a -> b
$ forall (n :: Natural) a.
(KnownNat n, 1 <= n, WithinBounds n a, Num a) =>
NonZero a
knownNonZeroBounded @2
windowSize :: S.WindowSize
windowSize :: WindowSize
windowSize = Word64 -> WindowSize
S.WindowSize Word64
2
cfg :: BlockConfig ByronBlock
cfg :: BlockConfig ByronBlock
cfg = ByronConfig {
byronGenesisConfig :: Config
byronGenesisConfig = Config
CC.dummyConfig
, byronProtocolVersion :: ProtocolVersion
byronProtocolVersion = ProtocolVersion
CC.exampleProtocolVersion
, byronSoftwareVersion :: SoftwareVersion
byronSoftwareVersion = SoftwareVersion
CC.exampleSoftwareVersion
}
codecConfig :: CodecConfig ByronBlock
codecConfig :: CodecConfig ByronBlock
codecConfig = Config -> CodecConfig ByronBlock
mkByronCodecConfig Config
CC.dummyConfig
ledgerConfig :: LedgerConfig ByronBlock
ledgerConfig :: LedgerConfig ByronBlock
ledgerConfig = Config
LedgerConfig ByronBlock
CC.dummyConfig
leaderCredentials :: ByronLeaderCredentials
leaderCredentials :: ByronLeaderCredentials
leaderCredentials =
HasCallStack =>
Config -> GeneratedSecrets -> CoreNodeId -> ByronLeaderCredentials
Config -> GeneratedSecrets -> CoreNodeId -> ByronLeaderCredentials
mkLeaderCredentials
Config
CC.dummyConfig
GeneratedSecrets
CC.dummyGeneratedSecrets
(Word64 -> CoreNodeId
CoreNodeId Word64
0)
examples :: Examples ByronBlock
examples :: Examples ByronBlock
examples = Examples {
exampleBlock :: Labelled ByronBlock
exampleBlock = ByronBlock -> ByronBlock -> Labelled ByronBlock
forall a. a -> a -> Labelled a
regularAndEBB ByronBlock
exampleBlock ByronBlock
exampleEBB
, exampleSerialisedBlock :: Labelled (Serialised ByronBlock)
exampleSerialisedBlock = Serialised ByronBlock
-> Serialised ByronBlock -> Labelled (Serialised ByronBlock)
forall a. a -> a -> Labelled a
regularAndEBB Serialised ByronBlock
exampleSerialisedBlock Serialised ByronBlock
exampleSerialisedEBB
, exampleHeader :: Labelled (Header ByronBlock)
exampleHeader = Header ByronBlock
-> Header ByronBlock -> Labelled (Header ByronBlock)
forall a. a -> a -> Labelled a
regularAndEBB Header ByronBlock
exampleHeader Header ByronBlock
exampleEBBHeader
, exampleSerialisedHeader :: Labelled (SerialisedHeader ByronBlock)
exampleSerialisedHeader = SerialisedHeader ByronBlock
-> SerialisedHeader ByronBlock
-> Labelled (SerialisedHeader ByronBlock)
forall a. a -> a -> Labelled a
regularAndEBB SerialisedHeader ByronBlock
exampleSerialisedHeader SerialisedHeader ByronBlock
exampleSerialisedEBBHeader
, exampleHeaderHash :: Labelled (HeaderHash ByronBlock)
exampleHeaderHash = ByronHash -> Labelled ByronHash
forall a. a -> Labelled a
unlabelled ByronHash
exampleHeaderHash
, exampleGenTx :: Labelled (GenTx ByronBlock)
exampleGenTx = GenTx ByronBlock -> Labelled (GenTx ByronBlock)
forall a. a -> Labelled a
unlabelled GenTx ByronBlock
exampleGenTx
, exampleGenTxId :: Labelled (GenTxId ByronBlock)
exampleGenTxId = GenTxId ByronBlock -> Labelled (GenTxId ByronBlock)
forall a. a -> Labelled a
unlabelled GenTxId ByronBlock
exampleGenTxId
, exampleApplyTxErr :: Labelled (ApplyTxErr ByronBlock)
exampleApplyTxErr = ApplyMempoolPayloadErr -> Labelled ApplyMempoolPayloadErr
forall a. a -> Labelled a
unlabelled ApplyMempoolPayloadErr
exampleApplyTxErr
, exampleQuery :: Labelled (SomeBlockQuery (BlockQuery ByronBlock))
exampleQuery = SomeBlockQuery (BlockQuery ByronBlock)
-> Labelled (SomeBlockQuery (BlockQuery ByronBlock))
forall a. a -> Labelled a
unlabelled SomeBlockQuery (BlockQuery ByronBlock)
exampleQuery
, exampleResult :: Labelled (SomeResult ByronBlock)
exampleResult = SomeResult ByronBlock -> Labelled (SomeResult ByronBlock)
forall a. a -> Labelled a
unlabelled SomeResult ByronBlock
exampleResult
, exampleAnnTip :: Labelled (AnnTip ByronBlock)
exampleAnnTip = AnnTip ByronBlock -> Labelled (AnnTip ByronBlock)
forall a. a -> Labelled a
unlabelled AnnTip ByronBlock
exampleAnnTip
, exampleLedgerConfig :: Labelled (LedgerConfig ByronBlock)
exampleLedgerConfig = Config -> Labelled Config
forall a. a -> Labelled a
unlabelled Config
LedgerConfig ByronBlock
ledgerConfig
, exampleLedgerState :: Labelled (LedgerState ByronBlock EmptyMK)
exampleLedgerState = LedgerState ByronBlock EmptyMK
-> Labelled (LedgerState ByronBlock EmptyMK)
forall a. a -> Labelled a
unlabelled (LedgerState ByronBlock EmptyMK
-> Labelled (LedgerState ByronBlock EmptyMK))
-> LedgerState ByronBlock EmptyMK
-> Labelled (LedgerState ByronBlock EmptyMK)
forall a b. (a -> b) -> a -> b
$ LedgerState ByronBlock ValuesMK -> LedgerState ByronBlock EmptyMK
forall (l :: LedgerStateKind) (mk :: MapKind).
HasLedgerTables l =>
l mk -> l EmptyMK
forgetLedgerTables LedgerState ByronBlock ValuesMK
exampleLedgerState
, exampleChainDepState :: Labelled (ChainDepState (BlockProtocol ByronBlock))
exampleChainDepState = PBftState PBftByronCrypto -> Labelled (PBftState PBftByronCrypto)
forall a. a -> Labelled a
unlabelled ChainDepState (BlockProtocol ByronBlock)
PBftState PBftByronCrypto
exampleChainDepState
, exampleExtLedgerState :: Labelled (ExtLedgerState ByronBlock EmptyMK)
exampleExtLedgerState = ExtLedgerState ByronBlock EmptyMK
-> Labelled (ExtLedgerState ByronBlock EmptyMK)
forall a. a -> Labelled a
unlabelled (ExtLedgerState ByronBlock EmptyMK
-> Labelled (ExtLedgerState ByronBlock EmptyMK))
-> ExtLedgerState ByronBlock EmptyMK
-> Labelled (ExtLedgerState ByronBlock EmptyMK)
forall a b. (a -> b) -> a -> b
$ ExtLedgerState ByronBlock ValuesMK
-> ExtLedgerState ByronBlock EmptyMK
forall (l :: LedgerStateKind) (mk :: MapKind).
HasLedgerTables l =>
l mk -> l EmptyMK
forgetLedgerTables ExtLedgerState ByronBlock ValuesMK
exampleExtLedgerState
, exampleSlotNo :: Labelled SlotNo
exampleSlotNo = SlotNo -> Labelled SlotNo
forall a. a -> Labelled a
unlabelled SlotNo
exampleSlotNo
, exampleLedgerTables :: Labelled (LedgerTables (LedgerState ByronBlock) ValuesMK)
exampleLedgerTables = LedgerTables (LedgerState ByronBlock) ValuesMK
-> Labelled (LedgerTables (LedgerState ByronBlock) ValuesMK)
forall a. a -> Labelled a
unlabelled LedgerTables (LedgerState ByronBlock) ValuesMK
forall (mk :: MapKind) (l :: LedgerStateKind).
(ZeroableMK mk, LedgerTableConstraints l) =>
LedgerTables l mk
emptyLedgerTables
}
where
regularAndEBB :: a -> a -> Labelled a
regularAndEBB :: forall a. a -> a -> Labelled a
regularAndEBB a
regular a
ebb = [(String, a)] -> Labelled a
forall a. [(String, a)] -> Labelled a
labelled [(String
"regular", a
regular), (String
"EBB", a
ebb)]
exampleQuery :: SomeBlockQuery (BlockQuery ByronBlock)
exampleQuery = BlockQuery ByronBlock 'QFNoTables State
-> SomeBlockQuery (BlockQuery ByronBlock)
forall (q :: QueryFootprint -> * -> *)
(footprint :: QueryFootprint) result.
SingI footprint =>
q footprint result -> SomeBlockQuery q
SomeBlockQuery BlockQuery ByronBlock 'QFNoTables State
GetUpdateInterfaceState
exampleResult :: SomeResult ByronBlock
exampleResult = BlockQuery ByronBlock 'QFNoTables State
-> State -> SomeResult ByronBlock
forall result blk (fp :: QueryFootprint).
(Eq result, Show result, Typeable result) =>
BlockQuery blk fp result -> result -> SomeResult blk
SomeResult BlockQuery ByronBlock 'QFNoTables State
GetUpdateInterfaceState State
exampleUPIState
exampleBlock :: ByronBlock
exampleBlock :: ByronBlock
exampleBlock =
BlockConfig ByronBlock
-> BlockNo
-> SlotNo
-> TickedLedgerState ByronBlock DiffMK
-> [Validated (GenTx ByronBlock)]
-> PBftIsLeader PBftByronCrypto
-> ByronBlock
forall (mk :: MapKind).
HasCallStack =>
BlockConfig ByronBlock
-> BlockNo
-> SlotNo
-> TickedLedgerState ByronBlock mk
-> [Validated (GenTx ByronBlock)]
-> PBftIsLeader PBftByronCrypto
-> ByronBlock
forgeRegularBlock
BlockConfig ByronBlock
cfg
(Word64 -> BlockNo
BlockNo Word64
1)
(Word64 -> SlotNo
SlotNo Word64
1)
(ComputeLedgerEvents
-> LedgerConfig ByronBlock
-> SlotNo
-> LedgerState ByronBlock EmptyMK
-> TickedLedgerState ByronBlock DiffMK
forall (l :: LedgerStateKind).
IsLedger l =>
ComputeLedgerEvents
-> LedgerCfg l -> SlotNo -> l EmptyMK -> Ticked l DiffMK
applyChainTick ComputeLedgerEvents
OmitLedgerEvents LedgerConfig ByronBlock
ledgerConfig (Word64 -> SlotNo
SlotNo Word64
1) (LedgerState ByronBlock ValuesMK -> LedgerState ByronBlock EmptyMK
forall (l :: LedgerStateKind) (mk :: MapKind).
HasLedgerTables l =>
l mk -> l EmptyMK
forgetLedgerTables LedgerState ByronBlock ValuesMK
ledgerStateAfterEBB))
[GenTx ByronBlock -> Validated (GenTx ByronBlock)
ValidatedByronTx GenTx ByronBlock
exampleGenTx]
(ByronLeaderCredentials -> PBftIsLeader PBftByronCrypto
fakeMkIsLeader ByronLeaderCredentials
leaderCredentials)
where
fakeMkIsLeader :: ByronLeaderCredentials -> PBftIsLeader PBftByronCrypto
fakeMkIsLeader (ByronLeaderCredentials SigningKey
signKey Certificate
dlgCert CoreNodeId
_ Text
_) = PBftIsLeader {
pbftIsLeaderSignKey :: SignKeyDSIGN (PBftDSIGN PBftByronCrypto)
pbftIsLeaderSignKey = SigningKey -> SignKeyDSIGN ByronDSIGN
SignKeyByronDSIGN SigningKey
signKey
, pbftIsLeaderDlgCert :: PBftDelegationCert PBftByronCrypto
pbftIsLeaderDlgCert = Certificate
PBftDelegationCert PBftByronCrypto
dlgCert
}
exampleEBB :: ByronBlock
exampleEBB :: ByronBlock
exampleEBB = BlockConfig ByronBlock
-> SlotNo -> BlockNo -> ChainHash ByronBlock -> ByronBlock
forgeEBB BlockConfig ByronBlock
cfg (Word64 -> SlotNo
SlotNo Word64
0) (Word64 -> BlockNo
BlockNo Word64
0) ChainHash ByronBlock
forall {k} (b :: k). ChainHash b
GenesisHash
exampleSerialisedBlock :: Serialised ByronBlock
exampleSerialisedBlock :: Serialised ByronBlock
exampleSerialisedBlock = ByteString -> Serialised ByronBlock
forall {k} (a :: k). ByteString -> Serialised a
Serialised ByteString
"<BLOCK>"
exampleSerialisedEBB :: Serialised ByronBlock
exampleSerialisedEBB :: Serialised ByronBlock
exampleSerialisedEBB = ByteString -> Serialised ByronBlock
forall {k} (a :: k). ByteString -> Serialised a
Serialised ByteString
"<EBB>"
exampleHeader :: Header ByronBlock
= ByronBlock -> Header ByronBlock
forall blk. GetHeader blk => blk -> Header blk
getHeader ByronBlock
exampleBlock
exampleEBBHeader :: Header ByronBlock
= ByronBlock -> Header ByronBlock
forall blk. GetHeader blk => blk -> Header blk
getHeader ByronBlock
exampleEBB
exampleSerialisedHeader :: SerialisedHeader ByronBlock
= GenDepPair Serialised (NestedCtxt Header ByronBlock)
-> SerialisedHeader ByronBlock
forall blk.
GenDepPair Serialised (NestedCtxt Header blk)
-> SerialisedHeader blk
SerialisedHeaderFromDepPair (GenDepPair Serialised (NestedCtxt Header ByronBlock)
-> SerialisedHeader ByronBlock)
-> GenDepPair Serialised (NestedCtxt Header ByronBlock)
-> SerialisedHeader ByronBlock
forall a b. (a -> b) -> a -> b
$
NestedCtxt Header ByronBlock (AHeader ByteString)
-> Serialised (AHeader ByteString)
-> GenDepPair Serialised (NestedCtxt Header ByronBlock)
forall {k} (f :: k -> *) (a :: k) (g :: k -> *).
f a -> g a -> GenDepPair g f
GenDepPair (NestedCtxt_ ByronBlock Header (AHeader ByteString)
-> NestedCtxt Header ByronBlock (AHeader ByteString)
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (SizeInBytes -> NestedCtxt_ ByronBlock Header (AHeader ByteString)
CtxtByronRegular SizeInBytes
100)) (ByteString -> Serialised (AHeader ByteString)
forall {k} (a :: k). ByteString -> Serialised a
Serialised ByteString
"<HEADER>")
exampleSerialisedEBBHeader :: SerialisedHeader ByronBlock
= GenDepPair Serialised (NestedCtxt Header ByronBlock)
-> SerialisedHeader ByronBlock
forall blk.
GenDepPair Serialised (NestedCtxt Header blk)
-> SerialisedHeader blk
SerialisedHeaderFromDepPair (GenDepPair Serialised (NestedCtxt Header ByronBlock)
-> SerialisedHeader ByronBlock)
-> GenDepPair Serialised (NestedCtxt Header ByronBlock)
-> SerialisedHeader ByronBlock
forall a b. (a -> b) -> a -> b
$
NestedCtxt Header ByronBlock (SlotNo, RawBoundaryHeader)
-> Serialised (SlotNo, RawBoundaryHeader)
-> GenDepPair Serialised (NestedCtxt Header ByronBlock)
forall {k} (f :: k -> *) (a :: k) (g :: k -> *).
f a -> g a -> GenDepPair g f
GenDepPair (NestedCtxt_ ByronBlock Header (SlotNo, RawBoundaryHeader)
-> NestedCtxt Header ByronBlock (SlotNo, RawBoundaryHeader)
forall (f :: * -> *) blk a.
NestedCtxt_ blk f a -> NestedCtxt f blk a
NestedCtxt (SizeInBytes
-> NestedCtxt_ ByronBlock Header (SlotNo, RawBoundaryHeader)
CtxtByronBoundary SizeInBytes
100)) (ByteString -> Serialised (SlotNo, RawBoundaryHeader)
forall {k} (a :: k). ByteString -> Serialised a
Serialised ByteString
"<EBB_HEADER>")
exampleAnnTip :: AnnTip ByronBlock
exampleAnnTip :: AnnTip ByronBlock
exampleAnnTip = AnnTip {
annTipSlotNo :: SlotNo
annTipSlotNo = Word64 -> SlotNo
SlotNo Word64
37
, annTipBlockNo :: BlockNo
annTipBlockNo = Word64 -> BlockNo
BlockNo Word64
23
, annTipInfo :: TipInfo ByronBlock
annTipInfo = HeaderHash ByronBlock -> IsEBB -> TipInfoIsEBB ByronBlock
forall blk. HeaderHash blk -> IsEBB -> TipInfoIsEBB blk
TipInfoIsEBB HeaderHash ByronBlock
ByronHash
exampleHeaderHash IsEBB
IsNotEBB
}
exampleChainDepState :: ChainDepState (BlockProtocol ByronBlock)
exampleChainDepState :: ChainDepState (BlockProtocol ByronBlock)
exampleChainDepState = [PBftSigner PBftByronCrypto] -> PBftState PBftByronCrypto
forall c. PBftCrypto c => [PBftSigner c] -> PBftState c
S.fromList [PBftSigner PBftByronCrypto]
signers
where
signers :: [PBftSigner PBftByronCrypto]
signers = (SlotNo -> PBftSigner PBftByronCrypto)
-> [SlotNo] -> [PBftSigner PBftByronCrypto]
forall a b. (a -> b) -> [a] -> [b]
map (SlotNo
-> PBftVerKeyHash PBftByronCrypto -> PBftSigner PBftByronCrypto
forall c. SlotNo -> PBftVerKeyHash c -> PBftSigner c
`S.PBftSigner` KeyHash
PBftVerKeyHash PBftByronCrypto
CC.exampleKeyHash) [SlotNo
1..SlotNo
4]
emptyLedgerState :: LedgerState ByronBlock ValuesMK
emptyLedgerState :: LedgerState ByronBlock ValuesMK
emptyLedgerState = ByronLedgerState {
byronLedgerTipBlockNo :: WithOrigin BlockNo
byronLedgerTipBlockNo = WithOrigin BlockNo
forall t. WithOrigin t
Origin
, byronLedgerState :: ChainValidationState
byronLedgerState = ChainValidationState
initState
, byronLedgerTransition :: ByronTransition
byronLedgerTransition = Map ProtocolVersion BlockNo -> ByronTransition
ByronTransitionInfo Map ProtocolVersion BlockNo
forall k a. Map k a
Map.empty
}
where
initState :: CC.Block.ChainValidationState
Right ChainValidationState
initState = Except Error ChainValidationState
-> Either Error ChainValidationState
forall e a. Except e a -> Either e a
runExcept (Except Error ChainValidationState
-> Either Error ChainValidationState)
-> Except Error ChainValidationState
-> Either Error ChainValidationState
forall a b. (a -> b) -> a -> b
$
Config -> Except Error ChainValidationState
forall (m :: * -> *).
MonadError Error m =>
Config -> m ChainValidationState
CC.Block.initialChainValidationState Config
LedgerConfig ByronBlock
ledgerConfig
ledgerStateAfterEBB :: LedgerState ByronBlock ValuesMK
ledgerStateAfterEBB :: LedgerState ByronBlock ValuesMK
ledgerStateAfterEBB =
LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock DiffMK -> LedgerState ByronBlock ValuesMK
forall (l :: LedgerStateKind) (l' :: LedgerStateKind).
(SameUtxoTypes l l', HasLedgerTables l, HasLedgerTables l') =>
l ValuesMK -> l' DiffMK -> l' ValuesMK
applyDiffs LedgerState ByronBlock ValuesMK
emptyLedgerState
(LedgerState ByronBlock DiffMK -> LedgerState ByronBlock ValuesMK)
-> (LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock DiffMK)
-> LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock ValuesMK
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ComputeLedgerEvents
-> LedgerConfig ByronBlock
-> ByronBlock
-> Ticked (LedgerState ByronBlock) ValuesMK
-> LedgerState ByronBlock DiffMK
forall (l :: LedgerStateKind) blk.
(ApplyBlock l blk, HasCallStack) =>
ComputeLedgerEvents
-> LedgerCfg l -> blk -> Ticked l ValuesMK -> l DiffMK
reapplyLedgerBlock ComputeLedgerEvents
OmitLedgerEvents LedgerConfig ByronBlock
ledgerConfig ByronBlock
exampleEBB
(Ticked (LedgerState ByronBlock) ValuesMK
-> LedgerState ByronBlock DiffMK)
-> (LedgerState ByronBlock ValuesMK
-> Ticked (LedgerState ByronBlock) ValuesMK)
-> LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock DiffMK
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LedgerState ByronBlock ValuesMK
-> TickedLedgerState ByronBlock DiffMK
-> Ticked (LedgerState ByronBlock) ValuesMK
forall (l :: LedgerStateKind) (l' :: LedgerStateKind).
(SameUtxoTypes l l', HasLedgerTables l, HasLedgerTables l') =>
l ValuesMK -> l' DiffMK -> l' ValuesMK
applyDiffs LedgerState ByronBlock ValuesMK
emptyLedgerState
(TickedLedgerState ByronBlock DiffMK
-> Ticked (LedgerState ByronBlock) ValuesMK)
-> (LedgerState ByronBlock ValuesMK
-> TickedLedgerState ByronBlock DiffMK)
-> LedgerState ByronBlock ValuesMK
-> Ticked (LedgerState ByronBlock) ValuesMK
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ComputeLedgerEvents
-> LedgerConfig ByronBlock
-> SlotNo
-> LedgerState ByronBlock EmptyMK
-> TickedLedgerState ByronBlock DiffMK
forall (l :: LedgerStateKind).
IsLedger l =>
ComputeLedgerEvents
-> LedgerCfg l -> SlotNo -> l EmptyMK -> Ticked l DiffMK
applyChainTick ComputeLedgerEvents
OmitLedgerEvents LedgerConfig ByronBlock
ledgerConfig (Word64 -> SlotNo
SlotNo Word64
0)
(LedgerState ByronBlock EmptyMK
-> TickedLedgerState ByronBlock DiffMK)
-> (LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock EmptyMK)
-> LedgerState ByronBlock ValuesMK
-> TickedLedgerState ByronBlock DiffMK
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LedgerState ByronBlock ValuesMK -> LedgerState ByronBlock EmptyMK
forall (l :: LedgerStateKind) (mk :: MapKind).
HasLedgerTables l =>
l mk -> l EmptyMK
forgetLedgerTables
(LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock ValuesMK)
-> LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock ValuesMK
forall a b. (a -> b) -> a -> b
$ LedgerState ByronBlock ValuesMK
emptyLedgerState
exampleLedgerState :: LedgerState ByronBlock ValuesMK
exampleLedgerState :: LedgerState ByronBlock ValuesMK
exampleLedgerState =
LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock DiffMK -> LedgerState ByronBlock ValuesMK
forall (l :: LedgerStateKind) (l' :: LedgerStateKind).
(SameUtxoTypes l l', HasLedgerTables l, HasLedgerTables l') =>
l ValuesMK -> l' DiffMK -> l' ValuesMK
applyDiffs LedgerState ByronBlock ValuesMK
emptyLedgerState
(LedgerState ByronBlock DiffMK -> LedgerState ByronBlock ValuesMK)
-> (LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock DiffMK)
-> LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock ValuesMK
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ComputeLedgerEvents
-> LedgerConfig ByronBlock
-> ByronBlock
-> Ticked (LedgerState ByronBlock) ValuesMK
-> LedgerState ByronBlock DiffMK
forall (l :: LedgerStateKind) blk.
(ApplyBlock l blk, HasCallStack) =>
ComputeLedgerEvents
-> LedgerCfg l -> blk -> Ticked l ValuesMK -> l DiffMK
reapplyLedgerBlock ComputeLedgerEvents
OmitLedgerEvents LedgerConfig ByronBlock
ledgerConfig ByronBlock
exampleBlock
(Ticked (LedgerState ByronBlock) ValuesMK
-> LedgerState ByronBlock DiffMK)
-> (LedgerState ByronBlock ValuesMK
-> Ticked (LedgerState ByronBlock) ValuesMK)
-> LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock DiffMK
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LedgerState ByronBlock ValuesMK
-> TickedLedgerState ByronBlock DiffMK
-> Ticked (LedgerState ByronBlock) ValuesMK
forall (l :: LedgerStateKind) (l' :: LedgerStateKind).
(SameUtxoTypes l l', HasLedgerTables l, HasLedgerTables l') =>
l ValuesMK -> l' DiffMK -> l' ValuesMK
applyDiffs LedgerState ByronBlock ValuesMK
ledgerStateAfterEBB
(TickedLedgerState ByronBlock DiffMK
-> Ticked (LedgerState ByronBlock) ValuesMK)
-> (LedgerState ByronBlock ValuesMK
-> TickedLedgerState ByronBlock DiffMK)
-> LedgerState ByronBlock ValuesMK
-> Ticked (LedgerState ByronBlock) ValuesMK
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ComputeLedgerEvents
-> LedgerConfig ByronBlock
-> SlotNo
-> LedgerState ByronBlock EmptyMK
-> TickedLedgerState ByronBlock DiffMK
forall (l :: LedgerStateKind).
IsLedger l =>
ComputeLedgerEvents
-> LedgerCfg l -> SlotNo -> l EmptyMK -> Ticked l DiffMK
applyChainTick ComputeLedgerEvents
OmitLedgerEvents LedgerConfig ByronBlock
ledgerConfig (Word64 -> SlotNo
SlotNo Word64
1)
(LedgerState ByronBlock EmptyMK
-> TickedLedgerState ByronBlock DiffMK)
-> (LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock EmptyMK)
-> LedgerState ByronBlock ValuesMK
-> TickedLedgerState ByronBlock DiffMK
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LedgerState ByronBlock ValuesMK -> LedgerState ByronBlock EmptyMK
forall (l :: LedgerStateKind) (mk :: MapKind).
HasLedgerTables l =>
l mk -> l EmptyMK
forgetLedgerTables
(LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock ValuesMK)
-> LedgerState ByronBlock ValuesMK
-> LedgerState ByronBlock ValuesMK
forall a b. (a -> b) -> a -> b
$ LedgerState ByronBlock ValuesMK
ledgerStateAfterEBB
exampleHeaderState :: HeaderState ByronBlock
= WithOrigin (AnnTip ByronBlock)
-> ChainDepState (BlockProtocol ByronBlock)
-> HeaderState ByronBlock
forall blk.
WithOrigin (AnnTip blk)
-> ChainDepState (BlockProtocol blk) -> HeaderState blk
HeaderState (AnnTip ByronBlock -> WithOrigin (AnnTip ByronBlock)
forall t. t -> WithOrigin t
NotOrigin AnnTip ByronBlock
exampleAnnTip) ChainDepState (BlockProtocol ByronBlock)
exampleChainDepState
exampleExtLedgerState :: ExtLedgerState ByronBlock ValuesMK
exampleExtLedgerState :: ExtLedgerState ByronBlock ValuesMK
exampleExtLedgerState = ExtLedgerState {
ledgerState :: LedgerState ByronBlock ValuesMK
ledgerState = LedgerState ByronBlock ValuesMK
exampleLedgerState
, headerState :: HeaderState ByronBlock
headerState = HeaderState ByronBlock
exampleHeaderState
}
exampleHeaderHash :: ByronHash
= ByronBlock -> HeaderHash ByronBlock
forall b. HasHeader b => b -> HeaderHash b
blockHash ByronBlock
exampleBlock
exampleGenTx :: GenTx ByronBlock
exampleGenTx :: GenTx ByronBlock
exampleGenTx = TxId -> ATxAux ByteString -> GenTx ByronBlock
ByronTx TxId
CC.exampleTxId (TxAux -> ATxAux ByteString
CC.annotateTxAux TxAux
CC.exampleTxAux)
exampleGenTxId :: TxId (GenTx ByronBlock)
exampleGenTxId :: GenTxId ByronBlock
exampleGenTxId = TxId -> GenTxId ByronBlock
ByronTxId TxId
CC.exampleTxId
exampleUPIState :: CC.UPI.State
exampleUPIState :: State
exampleUPIState = Config -> State
CC.UPI.initialState Config
LedgerConfig ByronBlock
ledgerConfig
exampleApplyTxErr :: CC.ApplyMempoolPayloadErr
exampleApplyTxErr :: ApplyMempoolPayloadErr
exampleApplyTxErr =
UTxOValidationError -> ApplyMempoolPayloadErr
CC.MempoolTxErr
(UTxOValidationError -> ApplyMempoolPayloadErr)
-> UTxOValidationError -> ApplyMempoolPayloadErr
forall a b. (a -> b) -> a -> b
$ TxValidationError -> UTxOValidationError
CC.UTxOValidationTxValidationError
(TxValidationError -> UTxOValidationError)
-> TxValidationError -> UTxOValidationError
forall a b. (a -> b) -> a -> b
$ Text -> LovelaceError -> TxValidationError
CC.TxValidationLovelaceError Text
"a"
(LovelaceError -> TxValidationError)
-> LovelaceError -> TxValidationError
forall a b. (a -> b) -> a -> b
$ Word64 -> LovelaceError
CC.LovelaceOverflow Word64
0
exampleSlotNo :: SlotNo
exampleSlotNo :: SlotNo
exampleSlotNo = Word64 -> SlotNo
SlotNo Word64
42