Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class (HasHeader m, GetHeader m, HasHeader (Header m), LedgerSupportsProtocol m, HasHardForkHistory m, LedgerSupportsMempool m, CommonProtocolParams m, HasTxId (GenTx m), Show (ApplyTxErr m), Typeable a, UpdateLedger a, LedgerSupportsMempool a, Show (ApplyTxErr a), NoThunks (LedgerConfig a), NoThunks (CodecConfig a), NoThunks (StorageConfig a), Show (BridgeLedger m a), Eq (BridgeLedger m a), Serialise (BridgeLedger m a), Serialise (BridgeBlock m a), Serialise (BridgeTx m a), Show (BridgeTx m a)) ⇒ Bridge m a where
- type BridgeLedger m a ∷ Type
- type BridgeBlock m a ∷ Type
- type BridgeTx m a ∷ Type
- updateBridgeWithBlock ∷ DualBlock m a → BridgeLedger m a → BridgeLedger m a
- updateBridgeWithTx ∷ Validated (GenTx (DualBlock m a)) → BridgeLedger m a → BridgeLedger m a
- data DualBlock m a = DualBlock {
- dualBlockMain ∷ m
- dualBlockAux ∷ Maybe a
- dualBlockBridge ∷ BridgeBlock m a
- data DualGenTxErr m a = DualGenTxErr {}
- type DualHeader m a = Header (DualBlock m a)
- data DualLedgerConfig m a = DualLedgerConfig {}
- data DualLedgerError m a = DualLedgerError {}
- ctxtDualMain ∷ NestedCtxt_ (DualBlock m a) f x → NestedCtxt_ m f x
- dualExtValidationErrorMain ∷ ExtValidationError (DualBlock m a) → ExtValidationError m
- dualTopLevelConfigMain ∷ TopLevelConfig (DualBlock m a) → TopLevelConfig m
- data family BlockConfig blk ∷ Type
- data family CodecConfig blk ∷ Type
- data family GenTx blk ∷ Type
- data family Header blk ∷ Type
- data family LedgerState blk ∷ Type
- data family NestedCtxt_ blk ∷ (Type → Type) → Type → Type
- data family StorageConfig blk ∷ Type
- data family Ticked st ∷ Type
- data family TxId tx ∷ Type
- data family Validated x ∷ Type
- decodeDualBlock ∷ (Bridge m a, Serialise a) ⇒ Decoder s (ByteString → m) → Decoder s (ByteString → DualBlock m a)
- decodeDualGenTx ∷ (Bridge m a, Serialise (GenTx a)) ⇒ Decoder s (GenTx m) → Decoder s (GenTx (DualBlock m a))
- decodeDualGenTxErr ∷ Serialise (ApplyTxErr a) ⇒ Decoder s (ApplyTxErr m) → Decoder s (ApplyTxErr (DualBlock m a))
- decodeDualGenTxId ∷ Decoder s (GenTxId m) → Decoder s (GenTxId (DualBlock m a))
- decodeDualHeader ∷ Decoder s (ByteString → Header m) → Decoder s (ByteString → Header (DualBlock m a))
- decodeDualLedgerState ∷ (Bridge m a, Serialise (LedgerState a)) ⇒ Decoder s (LedgerState m) → Decoder s (LedgerState (DualBlock m a))
- encodeDualBlock ∷ (Bridge m a, Serialise a) ⇒ (m → Encoding) → DualBlock m a → Encoding
- encodeDualGenTx ∷ (Bridge m a, Serialise (GenTx a)) ⇒ (GenTx m → Encoding) → GenTx (DualBlock m a) → Encoding
- encodeDualGenTxErr ∷ Serialise (ApplyTxErr a) ⇒ (ApplyTxErr m → Encoding) → ApplyTxErr (DualBlock m a) → Encoding
- encodeDualGenTxId ∷ (GenTxId m → Encoding) → GenTxId (DualBlock m a) → Encoding
- encodeDualHeader ∷ (Header m → Encoding) → Header (DualBlock m a) → Encoding
- encodeDualLedgerState ∷ (Bridge m a, Serialise (LedgerState a)) ⇒ (LedgerState m → Encoding) → LedgerState (DualBlock m a) → Encoding
Documentation
class (HasHeader m, GetHeader m, HasHeader (Header m), LedgerSupportsProtocol m, HasHardForkHistory m, LedgerSupportsMempool m, CommonProtocolParams m, HasTxId (GenTx m), Show (ApplyTxErr m), Typeable a, UpdateLedger a, LedgerSupportsMempool a, Show (ApplyTxErr a), NoThunks (LedgerConfig a), NoThunks (CodecConfig a), NoThunks (StorageConfig a), Show (BridgeLedger m a), Eq (BridgeLedger m a), Serialise (BridgeLedger m a), Serialise (BridgeBlock m a), Serialise (BridgeTx m a), Show (BridgeTx m a)) ⇒ Bridge m a where Source #
Bridge the two ledgers
type BridgeLedger m a ∷ Type Source #
Additional information relating both ledgers
type BridgeBlock m a ∷ Type Source #
Information required to update the bridge when applying a block
type BridgeTx m a ∷ Type Source #
Information required to update the bridge when applying a transaction
updateBridgeWithBlock ∷ DualBlock m a → BridgeLedger m a → BridgeLedger m a Source #
updateBridgeWithTx ∷ Validated (GenTx (DualBlock m a)) → BridgeLedger m a → BridgeLedger m a Source #
Pair types
Dual block
The dual block is used to instantiate the consensus with a dual ledger, consisting of two ledger states associated with two types of blocks. The (consensus) chain state will still be updated based on one block type only, which is therefore designed as the main block, while the other block is designated as the auxiliary block.
The auxiliary block is optional; this can be used if some " main " blocks should have no effect on the auxiliary ledger state at all. The motivating example is EBBs: if the main blocks are real Byron blocks, and the auxiliary blocks are Byron spec blocks, then regular Byron blocks correspond to Byron spec blocks, but EBBs don't correspond to a spec block at all and should leave the Byron spec ledger state unchanged.
NOTE: The dual ledger is used for testing purposes only; we do not do any
meaningful NoThunks
checks here.
DualBlock | |
|
Instances
data DualGenTxErr m a Source #
Instances
(Typeable m, Typeable a) ⇒ ShowProxy (DualGenTxErr m a ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual | |
Bridge m a ⇒ Show (DualGenTxErr m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual showsPrec ∷ Int → DualGenTxErr m a → ShowS # show ∷ DualGenTxErr m a → String # showList ∷ [DualGenTxErr m a] → ShowS # |
type DualHeader m a = Header (DualBlock m a) Source #
data DualLedgerConfig m a Source #
Instances
NoThunks (DualLedgerConfig m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
data DualLedgerError m a Source #
Both ledger rules threw an error
We do not verify that the errors agree, merely that they both report some error.
If only one of the two semantics reports an error, we fail with an error
(see agreeOnError
), rather than a regular chain failure; if this happens,
it indicates a bug, and the node should fail (rather than just, for example,
reject a block).
Instances
(Show (LedgerError m), Show (LedgerError a)) ⇒ Show (DualLedgerError m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual showsPrec ∷ Int → DualLedgerError m a → ShowS # show ∷ DualLedgerError m a → String # showList ∷ [DualLedgerError m a] → ShowS # | |
(Eq (LedgerError m), Eq (LedgerError a)) ⇒ Eq (DualLedgerError m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual (==) ∷ DualLedgerError m a → DualLedgerError m a → Bool # (/=) ∷ DualLedgerError m a → DualLedgerError m a → Bool # | |
NoThunks (DualLedgerError m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
Lifted functions
ctxtDualMain ∷ NestedCtxt_ (DualBlock m a) f x → NestedCtxt_ m f x Source #
dualTopLevelConfigMain ∷ TopLevelConfig (DualBlock m a) → TopLevelConfig m Source #
This is only used for block production
Type class family instances
data family BlockConfig blk ∷ Type Source #
Static configuration required to work with this type of blocks
Instances
data family CodecConfig blk ∷ Type 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
data family GenTx blk ∷ Type 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 Header blk ∷ Type Source #
Instances
data family LedgerState blk ∷ Type 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 NestedCtxt_ blk ∷ (Type → Type) → Type → Type Source #
Context identifying what kind of block we have
In almost all places we will use NestedCtxt
rather than NestedCtxt_
.
Instances
data family StorageConfig blk ∷ Type Source #
Config needed for the
NodeInitStorage
class. Defined here to
avoid circular dependencies.
Instances
data family Ticked st ∷ Type 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 TxId tx ∷ Type Source #
A generalized transaction, GenTx
, identifier.
Instances
data family Validated x ∷ Type 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
Serialisation
decodeDualBlock ∷ (Bridge m a, Serialise a) ⇒ Decoder s (ByteString → m) → Decoder s (ByteString → DualBlock m a) Source #
decodeDualGenTx ∷ (Bridge m a, Serialise (GenTx a)) ⇒ Decoder s (GenTx m) → Decoder s (GenTx (DualBlock m a)) Source #
decodeDualGenTxErr ∷ Serialise (ApplyTxErr a) ⇒ Decoder s (ApplyTxErr m) → Decoder s (ApplyTxErr (DualBlock m a)) Source #
decodeDualHeader ∷ Decoder s (ByteString → Header m) → Decoder s (ByteString → Header (DualBlock m a)) Source #
decodeDualLedgerState ∷ (Bridge m a, Serialise (LedgerState a)) ⇒ Decoder s (LedgerState m) → Decoder s (LedgerState (DualBlock m a)) Source #
encodeDualGenTx ∷ (Bridge m a, Serialise (GenTx a)) ⇒ (GenTx m → Encoding) → GenTx (DualBlock m a) → Encoding Source #
encodeDualGenTxErr ∷ Serialise (ApplyTxErr a) ⇒ (ApplyTxErr m → Encoding) → ApplyTxErr (DualBlock m a) → Encoding Source #
encodeDualLedgerState ∷ (Bridge m a, Serialise (LedgerState a)) ⇒ (LedgerState m → Encoding) → LedgerState (DualBlock m a) → Encoding Source #