Safe Haskell | None |
---|---|
Language | Haskell2010 |
Interface to the ledger layer
Synopsis
- data family Validated x :: Type
-
class
(
IsLedger
l,
HeaderHash
l ~
HeaderHash
blk,
HasHeader
blk,
HasHeader
(
Header
blk)) =>
ApplyBlock
l blk
where
- applyBlockLedgerResult :: HasCallStack => LedgerCfg l -> blk -> Ticked l -> Except ( LedgerErr l) ( LedgerResult l l)
- reapplyBlockLedgerResult :: HasCallStack => LedgerCfg l -> blk -> Ticked l -> LedgerResult l l
- class ApplyBlock ( LedgerState blk) blk => UpdateLedger blk
- applyLedgerBlock :: ( ApplyBlock l blk, HasCallStack ) => LedgerCfg l -> blk -> Ticked l -> Except ( LedgerErr l) l
- foldLedger :: ApplyBlock l blk => LedgerCfg l -> [blk] -> l -> Except ( LedgerErr l) l
- reapplyLedgerBlock :: ( ApplyBlock l blk, HasCallStack ) => LedgerCfg l -> blk -> Ticked l -> l
- refoldLedger :: ApplyBlock l blk => LedgerCfg l -> [blk] -> l -> l
- tickThenApply :: ApplyBlock l blk => LedgerCfg l -> blk -> l -> Except ( LedgerErr l) l
- tickThenApplyLedgerResult :: ApplyBlock l blk => LedgerCfg l -> blk -> l -> Except ( LedgerErr l) ( LedgerResult l l)
- tickThenReapply :: ApplyBlock l blk => LedgerCfg l -> blk -> l -> l
- tickThenReapplyLedgerResult :: ApplyBlock l blk => LedgerCfg l -> blk -> l -> LedgerResult l l
- ledgerTipHash :: forall blk. UpdateLedger blk => LedgerState blk -> ChainHash blk
- ledgerTipPoint :: UpdateLedger blk => Proxy blk -> LedgerState blk -> Point blk
- ledgerTipSlot :: forall blk. UpdateLedger blk => LedgerState blk -> WithOrigin SlotNo
- module Ouroboros.Consensus.Ledger.Basics
Type-level validation marker
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
Apply block
class ( IsLedger l, HeaderHash l ~ HeaderHash blk, HasHeader blk, HasHeader ( Header blk)) => ApplyBlock l blk where Source #
applyBlockLedgerResult :: HasCallStack => LedgerCfg l -> blk -> Ticked l -> Except ( LedgerErr l) ( LedgerResult l l) Source #
Apply a block to the ledger state.
This is passed the ledger state ticked with the slot of the given block, so
applyChainTickLedgerResult
has already been called.
reapplyBlockLedgerResult :: HasCallStack => LedgerCfg l -> blk -> Ticked l -> LedgerResult l l Source #
Re-apply a block to the very same ledger state it was applied in before.
Since a block can only be applied to a single, specific, ledger state, if we apply a previously applied block again it will be applied in the very same ledger state, and therefore can't possibly fail.
It is worth noting that since we already know that the block is valid in the provided ledger state, the ledger layer should not perform any validation checks.
Instances
class ApplyBlock ( LedgerState blk) blk => UpdateLedger blk Source #
Interaction with the ledger layer
Instances
CanHardFork xs => UpdateLedger ( HardForkBlock xs) Source # | |
Bridge m a => UpdateLedger ( DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
Derived
applyLedgerBlock :: ( ApplyBlock l blk, HasCallStack ) => LedgerCfg l -> blk -> Ticked l -> Except ( LedgerErr l) l Source #
foldLedger :: ApplyBlock l blk => LedgerCfg l -> [blk] -> l -> Except ( LedgerErr l) l Source #
reapplyLedgerBlock :: ( ApplyBlock l blk, HasCallStack ) => LedgerCfg l -> blk -> Ticked l -> l Source #
refoldLedger :: ApplyBlock l blk => LedgerCfg l -> [blk] -> l -> l Source #
tickThenApply :: ApplyBlock l blk => LedgerCfg l -> blk -> l -> Except ( LedgerErr l) l Source #
tickThenApplyLedgerResult :: ApplyBlock l blk => LedgerCfg l -> blk -> l -> Except ( LedgerErr l) ( LedgerResult l l) Source #
tickThenReapply :: ApplyBlock l blk => LedgerCfg l -> blk -> l -> l Source #
tickThenReapplyLedgerResult :: ApplyBlock l blk => LedgerCfg l -> blk -> l -> LedgerResult l l Source #
Short-hand
ledgerTipHash :: forall blk. UpdateLedger blk => LedgerState blk -> ChainHash blk Source #
ledgerTipPoint :: UpdateLedger blk => Proxy blk -> LedgerState blk -> Point blk Source #
Wrapper around
ledgerTipPoint
that uses a proxy to fix
blk
This is occassionally useful to guide type inference
ledgerTipSlot :: forall blk. UpdateLedger blk => LedgerState blk -> WithOrigin SlotNo Source #