ouroboros-consensus-0.1.0.1: Consensus layer for the Ouroboros blockchain protocol
Safe Haskell None
Language Haskell2010

Ouroboros.Consensus.Ledger.Abstract

Description

Interface to the ledger layer

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
CanHardFork xs => Eq ( 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

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

Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool

Generic ( 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

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

Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool

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.1.0.1-DT4Cvwf63DZKctsEvaJqCU" ' True ) ( C1 (' MetaCons "HardForkValidatedGenTx" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "getHardForkValidatedGenTx") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 ( OneEraValidatedGenTx xs))))
data Validated ( GenTx ( DualBlock m a)) Source #
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

newtype Validated ( GenTx ( HardForkBlock xs)) Source #
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Mempool

Apply block

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

Methods

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

Instances details
LedgerSupportsProtocol blk => ApplyBlock ( ExtLedgerState blk) blk Source #
Instance details

Defined in Ouroboros.Consensus.Ledger.Extended

ApplyBlock l blk => ApplyBlock ( LedgerDB l) blk Source #
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.InMemory

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

Derived

Short-hand

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

Re-exports