Safe Haskell | None |
---|---|
Language | Haskell2010 |
Definition is
IsLedger
Normally this is imported from Ouroboros.Consensus.Ledger.Abstract . We pull this out to avoid circular module dependencies.
Synopsis
- class GetTip l where
- getTipHash :: GetTip l => l -> ChainHash l
- getTipSlot :: GetTip l => l -> WithOrigin SlotNo
-
data
LedgerResult
l a =
LedgerResult
{
- lrEvents :: [ AuxLedgerEvent l]
- lrResult :: !a
- data VoidLedgerEvent l
- castLedgerResult :: AuxLedgerEvent l ~ AuxLedgerEvent l' => LedgerResult l a -> LedgerResult l' a
- embedLedgerResult :: ( AuxLedgerEvent l -> AuxLedgerEvent l') -> LedgerResult l a -> LedgerResult l' a
- pureLedgerResult :: a -> LedgerResult l a
-
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
- type LedgerErr l :: Type
- type AuxLedgerEvent l :: Type
- applyChainTickLedgerResult :: LedgerCfg l -> SlotNo -> l -> LedgerResult l ( Ticked l)
- type family LedgerCfg l :: Type
- applyChainTick :: IsLedger l => LedgerCfg l -> SlotNo -> l -> Ticked l
- type LedgerConfig blk = LedgerCfg ( LedgerState blk)
- type LedgerError blk = LedgerErr ( LedgerState blk)
- data family LedgerState blk :: Type
- type TickedLedgerState blk = Ticked ( LedgerState blk)
GetTip
getTip :: l -> Point l Source #
Point of the most recently applied block
Should be
genesisPoint
when no blocks have been applied yet
Instances
getTipHash :: GetTip l => l -> ChainHash l Source #
getTipSlot :: GetTip l => l -> WithOrigin SlotNo 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.
LedgerResult | |
|
Instances
data VoidLedgerEvent l Source #
A
Void
isomorph for explicitly declaring that some ledger has
no events
castLedgerResult :: AuxLedgerEvent l ~ AuxLedgerEvent l' => LedgerResult l a -> LedgerResult l' a Source #
embedLedgerResult :: ( AuxLedgerEvent l -> AuxLedgerEvent l') -> LedgerResult l a -> LedgerResult l' a Source #
pureLedgerResult :: a -> LedgerResult l a Source #
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 #
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.
applyChainTickLedgerResult :: LedgerCfg 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
type family LedgerCfg l :: Type Source #
Static environment required for the ledger
Instances
type LedgerCfg ( LedgerState ( DualBlock m a)) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
|
type LedgerCfg ( LedgerState ( HardForkBlock xs)) Source # | |
|
|
type LedgerCfg ( ExtLedgerState blk) Source # | |
Defined in Ouroboros.Consensus.Ledger.Extended |
|
type LedgerCfg ( LedgerDB l) Source # | |
|
Link block to its ledger
type LedgerConfig blk = LedgerCfg ( LedgerState blk) Source #
type LedgerError blk = LedgerErr ( LedgerState blk) Source #
data family LedgerState blk :: Type Source #
Ledger state associated with a block
Instances
type TickedLedgerState blk = Ticked ( LedgerState blk) Source #