ouroboros-consensus-0.1.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Ledger.Basics

Description

Definition is IsLedger

Normally this is imported from Ouroboros.Consensus.Ledger.Abstract. We pull this out to avoid circular module dependencies.

Synopsis

GetTip

class GetTip l where Source #

Methods

getTip ∷ l → Point l Source #

Point of the most recently applied block

Should be genesisPoint when no blocks have been applied yet

Instances

Instances details
Bridge m a ⇒ GetTip (Ticked (LedgerState (DualBlock m a))) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

CanHardFork xs ⇒ GetTip (Ticked (LedgerState (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

IsLedger (LedgerState blk) ⇒ GetTip (Ticked (ExtLedgerState blk)) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Extended

IsLedger l ⇒ GetTip (Ticked (LedgerDB l)) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.InMemory

Methods

getTipTicked (LedgerDB l) → Point (Ticked (LedgerDB l)) Source #

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

Defined in Ouroboros.Consensus.Ledger.Dual

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

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

IsLedger (LedgerState blk) ⇒ GetTip (ExtLedgerState blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Extended

IsLedger l ⇒ GetTip (LedgerDB l) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.InMemory

Methods

getTipLedgerDB l → Point (LedgerDB l) Source #

getTipHashGetTip l ⇒ l → ChainHash l Source #

Ledger Events

data LedgerResult l a Source #

The result of invoke a ledger function that does validation

Note: we do not instantiate Applicative or Monad for this type because those interfaces would typically incur space leaks. We encourage you to process the events each time you invoke a ledger function.

Constructors

LedgerResult 

Fields

Instances

Instances details
Functor (LedgerResult l) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Basics

Methods

fmap ∷ (a → b) → LedgerResult l a → LedgerResult l b Source #

(<$) ∷ a → LedgerResult l b → LedgerResult l a Source #

Foldable (LedgerResult l) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Basics

Methods

foldMonoid m ⇒ LedgerResult l m → m Source #

foldMapMonoid m ⇒ (a → m) → LedgerResult l a → m Source #

foldMap'Monoid m ⇒ (a → m) → LedgerResult l a → m Source #

foldr ∷ (a → b → b) → b → LedgerResult l a → b Source #

foldr' ∷ (a → b → b) → b → LedgerResult l a → b Source #

foldl ∷ (b → a → b) → b → LedgerResult l a → b Source #

foldl' ∷ (b → a → b) → b → LedgerResult l a → b Source #

foldr1 ∷ (a → a → a) → LedgerResult l a → a Source #

foldl1 ∷ (a → a → a) → LedgerResult l a → a Source #

toListLedgerResult l a → [a] Source #

nullLedgerResult l a → Bool Source #

lengthLedgerResult l a → Int Source #

elemEq a ⇒ a → LedgerResult l a → Bool Source #

maximumOrd a ⇒ LedgerResult l a → a Source #

minimumOrd a ⇒ LedgerResult l a → a Source #

sumNum a ⇒ LedgerResult l a → a Source #

productNum a ⇒ LedgerResult l a → a Source #

Traversable (LedgerResult l) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Basics

Methods

traverseApplicative f ⇒ (a → f b) → LedgerResult l a → f (LedgerResult l b) Source #

sequenceAApplicative f ⇒ LedgerResult l (f a) → f (LedgerResult l a) Source #

mapMMonad m ⇒ (a → m b) → LedgerResult l a → m (LedgerResult l b) Source #

sequenceMonad m ⇒ LedgerResult l (m a) → m (LedgerResult l a) Source #

data VoidLedgerEvent l Source #

A Void isomorph for explicitly declaring that some ledger has no events

Definition of a ledger independent of a choice of block

class (Show l, Eq l, NoThunks l, NoThunks (LedgerCfg l), Show (LedgerErr l), Eq (LedgerErr l), NoThunks (LedgerErr l), GetTip l, GetTip (Ticked l)) ⇒ IsLedger l where Source #

Associated Types

type LedgerErr l ∷ Type Source #

Errors that can arise when updating the ledger

This is defined here rather than in ApplyBlock, since the type of these errors does not depend on the type of the block.

type AuxLedgerEvent l ∷ Type Source #

Event emitted by the ledger

TODO we call this AuxLedgerEvent to differentiate from LedgerEvent in InspectLedger. When that module is rewritten to make use of ledger derived events, we may rename this type.

Methods

applyChainTickLedgerResultLedgerCfg l → SlotNo → l → LedgerResult l (Ticked l) Source #

Apply "slot based" state transformations

When a block is applied to the ledger state, a number of things happen purely based on the slot number of that block. For example:

  • In Byron, scheduled updates are applied, and the update system state is updated.
  • In Shelley, delegation state is updated (on epoch boundaries).

The consensus layer must be able to apply such a "chain tick" function, primarily when validating transactions in the mempool (which, conceptually, live in "some block in the future") or when extracting valid transactions from the mempool to insert into a new block to be produced.

This is not allowed to throw any errors. After all, if this could fail, it would mean a previous block set up the ledger state in such a way that as soon as a certain slot was reached, any block would be invalid.

PRECONDITION: The slot number must be strictly greater than the slot at the tip of the ledger (except for EBBs, obviously..).

NOTE: applyChainTickLedgerResult should not change the tip of the underlying ledger state, which should still refer to the most recent applied block. In other words, we should have

   ledgerTipPoint (applyChainTick cfg slot st)
== ledgerTipPoint st

Instances

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

Defined in Ouroboros.Consensus.Ledger.Dual

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

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

(IsLedger (LedgerState blk), LedgerSupportsProtocol blk) ⇒ IsLedger (ExtLedgerState blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Extended

Associated Types

type LedgerErr (ExtLedgerState blk) Source #

type AuxLedgerEvent (ExtLedgerState blk) Source #

IsLedger l ⇒ IsLedger (LedgerDB l) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.InMemory

Associated Types

type LedgerErr (LedgerDB l) Source #

type AuxLedgerEvent (LedgerDB l) Source #

type family LedgerCfg l ∷ Type Source #

Static environment required for the ledger

Link block to its ledger

data family LedgerState blk ∷ Type Source #

Ledger state associated with a block

Instances

Instances details
Isomorphic LedgerState Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Embed.Unary

Inject LedgerState Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Embed.Nary

Methods

inject ∷ ∀ x (xs ∷ [Type]). CanHardFork xs ⇒ Exactly xs BoundIndex xs x → LedgerState x → LedgerState (HardForkBlock xs) Source #

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

Defined in Ouroboros.Consensus.Ledger.Dual

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

Defined in Ouroboros.Consensus.HardFork.Combinator.Basics

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

Defined in Ouroboros.Consensus.Ledger.Dual

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

Defined in Ouroboros.Consensus.HardFork.Combinator.Basics

Generic (Ticked (LedgerState (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

Associated Types

type Rep (Ticked (LedgerState (HardForkBlock xs))) ∷ TypeType Source #

NoThunks (Ticked (LedgerState (DualBlock m a))) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

Methods

noThunks ∷ Context → Ticked (LedgerState (DualBlock m a)) → IO (Maybe ThunkInfo) #

wNoThunks ∷ Context → Ticked (LedgerState (DualBlock m a)) → IO (Maybe ThunkInfo) #

showTypeOfProxy (Ticked (LedgerState (DualBlock m a))) → String #

CanHardFork xs ⇒ NoThunks (Ticked (LedgerState (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

Methods

noThunks ∷ Context → Ticked (LedgerState (HardForkBlock xs)) → IO (Maybe ThunkInfo) #

wNoThunks ∷ Context → Ticked (LedgerState (HardForkBlock xs)) → IO (Maybe ThunkInfo) #

showTypeOfProxy (Ticked (LedgerState (HardForkBlock xs))) → String #

NoThunks (LedgerState (DualBlock m a)) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

Methods

noThunks ∷ Context → LedgerState (DualBlock m a) → IO (Maybe ThunkInfo) #

wNoThunks ∷ Context → LedgerState (DualBlock m a) → IO (Maybe ThunkInfo) #

showTypeOfProxy (LedgerState (DualBlock m a)) → String #

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

Defined in Ouroboros.Consensus.HardFork.Combinator.Basics

Methods

noThunks ∷ Context → LedgerState (HardForkBlock xs) → IO (Maybe ThunkInfo) #

wNoThunks ∷ Context → LedgerState (HardForkBlock xs) → IO (Maybe ThunkInfo) #

showTypeOfProxy (LedgerState (HardForkBlock xs)) → String #

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

Defined in Ouroboros.Consensus.Ledger.Dual

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

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

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

Defined in Ouroboros.Consensus.Ledger.Dual

CanHardFork xs ⇒ GetTip (Ticked (LedgerState (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

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

Defined in Ouroboros.Consensus.Ledger.Dual

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

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

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

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

SerialiseHFC xs ⇒ DecodeDisk (HardForkBlock xs) (LedgerState (HardForkBlock xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.SerialiseDisk

Methods

decodeDiskCodecConfig (HardForkBlock xs) → ∀ s. Decoder s (LedgerState (HardForkBlock xs)) Source #

SerialiseHFC xs ⇒ EncodeDisk (HardForkBlock xs) (LedgerState (HardForkBlock xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.SerialiseDisk

Methods

encodeDiskCodecConfig (HardForkBlock xs) → LedgerState (HardForkBlock xs) → Encoding Source #

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

Defined in Ouroboros.Consensus.Ledger.Dual

Isomorphic (Ticked :.: LedgerState) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Embed.Unary

type Rep (Ticked (LedgerState (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

type Rep (Ticked (LedgerState (HardForkBlock xs))) = D1 ('MetaData "Ticked" "Ouroboros.Consensus.HardFork.Combinator.Ledger" "ouroboros-consensus-0.1.0.0-inplace" 'False) (C1 ('MetaCons "TickedHardForkLedgerState" 'PrefixI 'True) (S1 ('MetaSel ('Just "tickedHardForkLedgerStateTransition") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TransitionInfo) :*: S1 ('MetaSel ('Just "tickedHardForkLedgerStatePerEra") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (HardForkState (Ticked :.: LedgerState) xs))))
type HeaderHash (LedgerState blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Basics

data Ticked (LedgerState (DualBlock m a)) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

data Ticked (LedgerState (HardForkBlock xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

newtype LedgerState (HardForkBlock xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Basics

type LedgerErr (LedgerState (DualBlock m a)) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

type LedgerErr (LedgerState (HardForkBlock xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

type AuxLedgerEvent (LedgerState (DualBlock m a)) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

type AuxLedgerEvent (LedgerState (HardForkBlock xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

type LedgerCfg (LedgerState (DualBlock m a)) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

type LedgerCfg (LedgerState (HardForkBlock xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Basics

data LedgerState (DualBlock m a) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual