ouroboros-consensus-0.21.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Consensus.Ledger.Abstract

Description

Interface to the ledger layer

This module defines how to apply blocks to a ledger state, and re-exports (from Ouroboros.Consensus.Ledger.Basics) how to tick ledger states. These are the two main operations we can do with a LedgerState.

Synopsis

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

Instances details
Generic (Validated (GenTx (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool

Associated Types

type Rep (Validated (GenTx (HardForkBlock xs))) ∷ TypeType #

CanHardFork xs ⇒ Show (Validated (GenTx (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool

Bridge m a ⇒ Show (Validated (GenTx (DualBlock m a))) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

Methods

showsPrecIntValidated (GenTx (DualBlock m a)) → ShowS #

showValidated (GenTx (DualBlock m a)) → String #

showList ∷ [Validated (GenTx (DualBlock m a))] → ShowS #

CanHardFork xs ⇒ Eq (Validated (GenTx (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool

CanHardFork xs ⇒ NoThunks (Validated (GenTx (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool

NoThunks (Validated (GenTx (DualBlock m a))) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

type Rep (Validated (GenTx (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool

type Rep (Validated (GenTx (HardForkBlock xs))) = D1 ('MetaData "Validated" "Ouroboros.Consensus.HardFork.Combinator.Mempool" "ouroboros-consensus-0.21.0.0-inplace" 'True) (C1 ('MetaCons "HardForkValidatedGenTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "getHardForkValidatedGenTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (OneEraValidatedGenTx xs))))
newtype Validated (GenTx (HardForkBlock xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool

data Validated (GenTx (DualBlock m a)) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

Apply block

class (IsLedger l, HeaderHash l ~ HeaderHash blk, HasHeader blk, HasHeader (Header blk)) ⇒ ApplyBlock l blk where Source #

Methods

applyBlockLedgerResultHasCallStackLedgerCfg 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 to the slot of the given block, so applyChainTickLedgerResult has already been called.

reapplyBlockLedgerResultHasCallStackLedgerCfg 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

Instances details
LedgerSupportsProtocol blk ⇒ ApplyBlock (ExtLedgerState blk) blk Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Extended

CanHardFork xs ⇒ ApplyBlock (LedgerState (HardForkBlock xs)) (HardForkBlock xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

Bridge m a ⇒ ApplyBlock (LedgerState (DualBlock m a)) (DualBlock m a) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

class ApplyBlock (LedgerState blk) blk ⇒ UpdateLedger blk Source #

Interaction with the ledger layer

Instances

Instances details
CanHardFork xs ⇒ UpdateLedger (HardForkBlock xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

Bridge m a ⇒ UpdateLedger (DualBlock m a) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

Derived

foldLedgerApplyBlock l blk ⇒ LedgerCfg l → [blk] → l → Except (LedgerErr l) l Source #

refoldLedgerApplyBlock l blk ⇒ LedgerCfg l → [blk] → l → l Source #

tickThenApplyApplyBlock l blk ⇒ LedgerCfg l → blk → l → Except (LedgerErr l) l Source #

tickThenReapplyApplyBlock l blk ⇒ LedgerCfg l → blk → l → l Source #

Short-hand

Re-exports