Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type Ix = Word
- data Addr
- type TxOut = (Addr, Amount)
- type TxIn = (TxId, Ix)
- data family TxId tx
- data Tx where
- data family Header blk
- data family StorageConfig blk
- data family CodecConfig blk
- data family BlockConfig blk
- data family Ticked st
- data family LedgerState blk
- data family Validated x
- data family GenTx blk
- data family BlockQuery blk ∷ Type → Type
- data MockState blk = MockState {}
- type AddrDist = Map Addr NodeId
- type SimpleBlock c ext = SimpleBlock' c ext ext
- data SimpleBlock' c ext ext' = SimpleBlock {
- simpleHeader ∷ Header (SimpleBlock' c ext ext')
- simpleBody ∷ SimpleBody
- data SimpleBody = SimpleBody {}
- class (HashAlgorithm (SimpleHash c), Typeable c) ⇒ SimpleCrypto c where
- type SimpleHash c ∷ Type
- type SimpleHeader c ext = Header (SimpleBlock c ext)
- data SimpleStdHeader c ext = SimpleStdHeader {}
- data SimpleLedgerConfig c ext = SimpleLedgerConfig {}
- class (SimpleCrypto c, Typeable ext, Show (MockLedgerConfig c ext), NoThunks (MockLedgerConfig c ext)) ⇒ MockProtocolSpecific c ext where
- type MockLedgerConfig c ext ∷ Type
- data SimpleMockCrypto
- data SimpleStandardCrypto
- data SignedSimpleBft c c' = SignedSimpleBft {
- signedSimpleBft ∷ SimpleStdHeader c (SimpleBftExt c c')
- type SimpleBftBlock c c' = SimpleBlock c (SimpleBftExt c c')
- newtype SimpleBftExt c c' = SimpleBftExt {
- simpleBftExt ∷ BftFields c' (SignedSimpleBft c c')
- type SimpleBftHeader c c' = SimpleHeader c (SimpleBftExt c c')
- data SignedSimplePBft c c' = SignedSimplePBft {
- signedSimplePBft ∷ SimpleStdHeader c (SimplePBftExt c c')
- type SimplePBftBlock c c' = SimpleBlock c (SimplePBftExt c c')
- newtype SimplePBftExt c c' = SimplePBftExt {
- simplePBftExt ∷ PBftFields c' (SignedSimplePBft c c')
- type SimplePBftHeader c c' = SimpleHeader c (SimplePBftExt c c')
- data SignedSimplePraos c c' = SignedSimplePraos {}
- type SimplePraosBlock c c' = SimpleBlock c (SimplePraosExt c c')
- newtype SimplePraosExt c c' = SimplePraosExt {
- simplePraosExt ∷ PraosFields c' (SignedSimplePraos c c')
- type SimplePraosHeader c c' = SimpleHeader c (SimplePraosExt c c')
- data PraosCryptoUnused
- type SimplePraosRuleBlock c = SimpleBlock c SimplePraosRuleExt
- newtype SimplePraosRuleExt = SimplePraosRuleExt {}
- type SimplePraosRuleHeader c = SimpleHeader c SimplePraosRuleExt
- newtype ForgeExt c ext = ForgeExt {
- forgeExt ∷ TopLevelConfig (SimpleBlock c ext) → IsLeader (BlockProtocol (SimpleBlock c ext)) → SimpleBlock' c ext () → SimpleBlock c ext
- data StakeHolder
- newtype StakeDist = StakeDist {}
- data MockError blk
- = MockExpired !SlotNo !SlotNo
- | MockUtxoError UtxoError
- | MockInvalidHash (ChainHash blk) (ChainHash blk)
- type Amount = Word
- data Expiry
- type Utxo = Map TxIn TxOut
- class HasMockTxs a where
- getMockTxs ∷ a → [Tx]
- data UtxoError
- genesisUtxo ∷ AddrDist → Utxo
- mkAddrDist ∷ NumCoreNodes → AddrDist
- countSimpleGenTxs ∷ SimpleBlock c ext → Word64
- matchesSimpleHeader ∷ SimpleCrypto c ⇒ Header (SimpleBlock' c ext ext') → SimpleBlock' c ext ext'' → Bool
- mkSimpleHeader ∷ SimpleCrypto c ⇒ (ext' → Encoding) → SimpleStdHeader c ext → ext' → Header (SimpleBlock' c ext ext')
- genesisSimpleLedgerState ∷ AddrDist → LedgerState (SimpleBlock c ext)
- updateSimpleLedgerState ∷ (SimpleCrypto c, Typeable ext) ⇒ SimpleBlock c ext → TickedLedgerState (SimpleBlock c ext) → Except (MockError (SimpleBlock c ext)) (LedgerState (SimpleBlock c ext))
- mkSimpleGenTx ∷ Tx → GenTx (SimpleBlock c ext)
- txSize ∷ GenTx (SimpleBlock c ext) → ByteSize32
- decodeSimpleHeader ∷ SimpleCrypto c ⇒ (ext' → Encoding) → (∀ s. Decoder s ext') → ∀ s. Decoder s (Header (SimpleBlock' c ext ext'))
- encodeSimpleHeader ∷ (ext' → Encoding) → Header (SimpleBlock' c ext ext') → Encoding
- simpleBlockBinaryBlockInfo ∷ (SimpleCrypto c, Serialise ext', Typeable ext, Typeable ext') ⇒ SimpleBlock' c ext ext' → BinaryBlockInfo
- simpleBlockCapacity ∷ ByteSize32
- forgeBftExt ∷ ∀ c c'. (SimpleCrypto c, BftCrypto c', Signable (BftDSIGN c') (SignedSimpleBft c c')) ⇒ ForgeExt c (SimpleBftExt c c')
- forgePBftExt ∷ ∀ c c'. (SimpleCrypto c, PBftCrypto c', Signable (PBftDSIGN c') (SignedSimplePBft c c'), ContextDSIGN (PBftDSIGN c') ~ ()) ⇒ ForgeExt c (SimplePBftExt c c')
- forgePraosExt ∷ ∀ c c'. (SimpleCrypto c, PraosCrypto c', Signable (PraosKES c') (SignedSimplePraos c c')) ⇒ HotKey c' → ForgeExt c (SimplePraosExt c c')
- forgePraosRuleExt ∷ SimpleCrypto c ⇒ ForgeExt c SimplePraosRuleExt
- forgeSimple ∷ ∀ c ext. SimpleCrypto c ⇒ ForgeExt c ext → TopLevelConfig (SimpleBlock c ext) → BlockNo → SlotNo → TickedLedgerState (SimpleBlock c ext) → [GenTx (SimpleBlock c ext)] → IsLeader (BlockProtocol (SimpleBlock c ext)) → SimpleBlock c ext
- equalStakeDist ∷ AddrDist → StakeDist
- genesisStakeDist ∷ AddrDist → StakeDist
- relativeStakes ∷ Map StakeHolder Amount → StakeDist
- stakeWithDefault ∷ Rational → CoreNodeId → StakeDist → Rational
- totalStakes ∷ Map Addr NodeId → Utxo → Map StakeHolder Amount
- updateMockState ∷ (GetPrevHash blk, HasMockTxs blk) ⇒ blk → MockState blk → Except (MockError blk) (MockState blk)
- updateMockTip ∷ GetPrevHash blk ⇒ Header blk → MockState blk → Except (MockError blk) (MockState blk)
- updateMockUTxO ∷ HasMockTxs a ⇒ SlotNo → a → MockState blk → Except (MockError blk) (MockState blk)
- genesisMockState ∷ AddrDist → MockState blk
- confirmed ∷ HasMockTxs a ⇒ a → Set TxId
- txIns ∷ HasMockTxs a ⇒ a → Set TxIn
- txOuts ∷ HasMockTxs a ⇒ a → Utxo
- updateUtxo ∷ HasMockTxs a ⇒ a → Utxo → Except UtxoError Utxo
- genesisTx ∷ AddrDist → Tx
Documentation
Mock address
Instances
IsString Addr Source # | |
Defined in Ouroboros.Consensus.Mock.Ledger.Address fromString ∷ String → Addr # | |
Show Addr Source # | |
FromCBOR Addr Source # | |
ToCBOR Addr Source # | |
NFData Addr Source # | |
Defined in Ouroboros.Consensus.Mock.Ledger.Address | |
Eq Addr Source # | |
Ord Addr Source # | |
NoThunks Addr Source # | |
Condense Addr Source # | |
Serialise Addr Source # | |
A generalized transaction, GenTx
, identifier.
Instances
Instances
Generic Tx Source # | |
Show Tx Source # | |
ToCBOR Tx Source # | |
NFData Tx Source # | |
Defined in Ouroboros.Consensus.Mock.Ledger.UTxO | |
Eq Tx Source # | |
Ord Tx Source # | |
NoThunks Tx Source # | |
Condense Tx Source # | |
HasMockTxs Tx Source # | |
Defined in Ouroboros.Consensus.Mock.Ledger.UTxO getMockTxs ∷ Tx → [Tx] Source # | |
Serialise Tx Source # | |
type Rep Tx Source # | |
Defined in Ouroboros.Consensus.Mock.Ledger.UTxO type Rep Tx = D1 ('MetaData "Tx" "Ouroboros.Consensus.Mock.Ledger.UTxO" "ouroboros-consensus-0.20.1.0-inplace-unstable-mock-block" 'False) (C1 ('MetaCons "UnsafeTx" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Expiry) :*: (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set TxIn)) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TxOut])))) |
data family Header blk Source #
Instances
data family StorageConfig blk Source #
Config needed for the
NodeInitStorage
class. Defined here to
avoid circular dependencies.
Instances
data family CodecConfig blk Source #
Static configuration required for serialisation and deserialisation of types pertaining to this type of block.
Data family instead of type family to get better type inference.
Instances
Generic (CodecConfig (SimpleBlock c ext)) Source # | |
Defined in Ouroboros.Consensus.Mock.Ledger.Block type Rep (CodecConfig (SimpleBlock c ext)) ∷ Type → Type # from ∷ CodecConfig (SimpleBlock c ext) → Rep (CodecConfig (SimpleBlock c ext)) x # to ∷ Rep (CodecConfig (SimpleBlock c ext)) x → CodecConfig (SimpleBlock c ext) # | |
NoThunks (CodecConfig (SimpleBlock c ext)) Source # | |
Defined in Ouroboros.Consensus.Mock.Ledger.Block noThunks ∷ Context → CodecConfig (SimpleBlock c ext) → IO (Maybe ThunkInfo) Source # wNoThunks ∷ Context → CodecConfig (SimpleBlock c ext) → IO (Maybe ThunkInfo) Source # showTypeOf ∷ Proxy (CodecConfig (SimpleBlock c ext)) → String Source # | |
type Rep (CodecConfig (SimpleBlock c ext)) Source # | |
Defined in Ouroboros.Consensus.Mock.Ledger.Block | |
data CodecConfig (SimpleBlock c ext) Source # | |
Defined in Ouroboros.Consensus.Mock.Ledger.Block |
data family BlockConfig blk Source #
Static configuration required to work with this type of blocks
Instances
data family Ticked st Source #
" Ticked " piece of state, either LedgerState
or ChainDepState
Ticking refers to the passage of time (the ticking of the clock). When a
piece of state is marked as ticked, it means that time-related changes have
been applied to the state. There are exactly two methods in the interface
that do that: tickChainDepState
and
applyChainTickLedgerResult
.
Also note that a successful forecast
must equal
forecastFor
(ledgerViewForecastAt
cfg st)
slot
. Thus a
protocolLedgerView
cfg
(applyChainTick
cfg slot st)LedgerView
can only be projected
from a Ticked
state, but cannot itself be ticked.
Some examples of time related changes:
- Scheduled delegations might have been applied in Byron
- New leader schedule computed for Shelley
- Transition from Byron to Shelley activated in the hard fork combinator.
- Nonces switched out at the start of a new epoch.
Instances
data family LedgerState blk Source #
Ledger state associated with a block
This is the Consensus notion of a ledger state. Each block type is
associated with one of the Ledger types for the ledger state. Virtually
every concept in this codebase revolves around this type, or the referenced
blk
. Whenever we use the type variable l
, we intend to denote that the
expected instantiation is either a LedgerState
or some wrapper over it
(like the ExtLedgerState
).
The main operations we can do with a LedgerState
are ticking (defined in
IsLedger
), and applying a block (defined in
ApplyBlock
).
Instances
data family Validated x Source #
" Validated " transaction or block
The ledger defines how to validate transactions and blocks. It's possible the type before and after validation may be distinct (eg Alonzo transactions), which originally motivated this family.
We also gain the related benefit that certain interface functions, such as those that reapply blocks, can have a more precise type now. TODO
Similarly, the Node-to-Client mini protocols can explicitly indicate that the
client trusts the blocks from the local server, by having the server send
Validated
blocks to the client. TODO
Note that validation has different implications for a transaction than for a block. In particular, a validated transaction can be " reapplied " to different ledger states, whereas a validated block must only be " reapplied " to the exact same ledger state (eg as part of rebuilding from an on-disk ledger snapshot).
Since the ledger defines validation, see the ledger details for concrete
examples of what determines the validity (wrt to a LedgerState
) of a
transaction and/or block. Example properties include: a transaction's claimed
inputs exist and are still unspent, a block carries a sufficient
cryptographic signature, etc.
Instances
data family GenTx blk Source #
Generalized transaction
The mempool (and, accordingly, blocks) consist of "generalized transactions"; this could be "proper" transactions (transferring funds) but also other kinds of things such as update proposals, delegations, etc.
Instances
data family BlockQuery blk ∷ Type → Type Source #
Different queries supported by the ledger, indexed by the result type.
Instances
Instances
Generic (MockState blk) Source # | |
StandardHash blk ⇒ Show (MockState blk) Source # | |
StandardHash blk ⇒ Eq (MockState blk) Source # | |
StandardHash blk ⇒ NoThunks (MockState blk) Source # | |
Serialise (HeaderHash blk) ⇒ Serialise (MockState blk) Source # | |
type Rep (MockState blk) Source # | |
Defined in Ouroboros.Consensus.Mock.Ledger.State type Rep (MockState blk) = D1 ('MetaData "MockState" "Ouroboros.Consensus.Mock.Ledger.State" "ouroboros-consensus-0.20.1.0-inplace-unstable-mock-block" 'False) (C1 ('MetaCons "MockState" 'PrefixI 'True) (S1 ('MetaSel ('Just "mockUtxo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Utxo) :*: (S1 ('MetaSel ('Just "mockConfirmed") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set TxId)) :*: S1 ('MetaSel ('Just "mockTip") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Point blk))))) |
type AddrDist = Map Addr NodeId Source #
Mapping from addresses to node IDs
This is needed in order to assign stake to nodes.
type SimpleBlock c ext = SimpleBlock' c ext ext Source #
data SimpleBlock' c ext ext' Source #
SimpleBlock | |
|