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

Ouroboros.Consensus.Storage.LedgerDB.Init

Description

LedgerDB initialization either from a LedgerState or from a DiskSnapshot

Synopsis

Initialization

data InitLog blk Source #

Initialization log

The initialization log records which snapshots from disk were considered, in which order, and why some snapshots were rejected. It is primarily useful for monitoring purposes.

Constructors

InitFromGenesis

Defaulted to initialization from genesis

NOTE: Unless the blockchain is near genesis, we should see this only if data corrupted occurred.

InitFromSnapshot DiskSnapshot (RealPoint blk)

Used a snapshot corresponding to the specified tip

InitFailure DiskSnapshot (SnapshotFailure blk) (InitLog blk)

Initialization skipped a snapshot

We record the reason why it was skipped.

NOTE: We should only see this if data corrupted occurred.

Instances

Instances details
Generic (InitLog blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Init

Associated Types

type Rep (InitLog blk) ∷ TypeType #

Methods

fromInitLog blk → Rep (InitLog blk) x #

toRep (InitLog blk) x → InitLog blk #

StandardHash blk ⇒ Show (InitLog blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Init

Methods

showsPrecIntInitLog blk → ShowS #

showInitLog blk → String #

showList ∷ [InitLog blk] → ShowS #

StandardHash blk ⇒ Eq (InitLog blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Init

Methods

(==)InitLog blk → InitLog blk → Bool #

(/=)InitLog blk → InitLog blk → Bool #

type Rep (InitLog blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Init

newtype ReplayStart blk Source #

Which point the replay started from

Constructors

ReplayStart (Point blk) 

Instances

Instances details
StandardHash blk ⇒ Show (ReplayStart blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Init

Methods

showsPrecIntReplayStart blk → ShowS #

showReplayStart blk → String #

showList ∷ [ReplayStart blk] → ShowS #

StandardHash blk ⇒ Eq (ReplayStart blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Init

Methods

(==)ReplayStart blk → ReplayStart blk → Bool #

(/=)ReplayStart blk → ReplayStart blk → Bool #

initLedgerDB Source #

Arguments

∷ ∀ m blk. (IOLike m, LedgerSupportsProtocol blk, InspectLedger blk, HasCallStack) 
Tracer m (ReplayGoal blk → TraceReplayEvent blk) 
Tracer m (TraceSnapshotEvent blk) 
SomeHasFS m 
→ (∀ s. Decoder s (ExtLedgerState blk)) 
→ (∀ s. Decoder s (HeaderHash blk)) 
LedgerDbCfg (ExtLedgerState blk) 
→ m (ExtLedgerState blk)

Genesis ledger state

StreamAPI m blk blk 
→ m (InitLog blk, LedgerDB' blk, Word64) 

Initialize the ledger DB from the most recent snapshot on disk

If no such snapshot can be found, use the genesis ledger DB. Returns the initialized DB as well as the block reference corresponding to the snapshot we found on disk (the latter primarily for testing/monitoring purposes).

We do not catch any exceptions thrown during streaming; should any be thrown, it is the responsibility of the ChainDB to catch these and trigger (further) validation. We only discard snapshots if

  • We cannot deserialise them, or
  • they are ahead of the chain

It is possible that the Ledger DB will not be able to roll back k blocks after initialization if the chain has been truncated (data corruption).

We do not attempt to use multiple ledger states from disk to construct the ledger DB. Instead we load only a single ledger state from disk, and compute all subsequent ones. This is important, because the ledger states obtained in this way will (hopefully) share much of their memory footprint with their predecessors.

Trace

newtype ReplayGoal blk Source #

Which point the replay is expected to end at

Constructors

ReplayGoal (Point blk) 

Instances

Instances details
StandardHash blk ⇒ Show (ReplayGoal blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Init

Methods

showsPrecIntReplayGoal blk → ShowS #

showReplayGoal blk → String #

showList ∷ [ReplayGoal blk] → ShowS #

StandardHash blk ⇒ Eq (ReplayGoal blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Init

Methods

(==)ReplayGoal blk → ReplayGoal blk → Bool #

(/=)ReplayGoal blk → ReplayGoal blk → Bool #

data TraceReplayEvent blk Source #

Events traced while replaying blocks against the ledger to bring it up to date w.r.t. the tip of the ImmutableDB during initialisation. As this process takes a while, we trace events to inform higher layers of our progress.

Constructors

ReplayFromGenesis

There were no LedgerDB snapshots on disk, so we're replaying all blocks starting from Genesis against the initial ledger.

Fields

  • (ReplayGoal blk)

    the block at the tip of the ImmutableDB | There was a LedgerDB snapshot on disk corresponding to the given tip. We're replaying more recent blocks against it.

ReplayFromSnapshot 

Fields

  • DiskSnapshot
     
  • (ReplayStart blk)

    the block at which this replay started

  • (ReplayGoal blk)

    the block at the tip of the ImmutableDB | We replayed the given block (reference) on the genesis snapshot during the initialisation of the LedgerDB. Used during ImmutableDB replay.

ReplayedBlock 

Fields

Instances

Instances details
Generic (TraceReplayEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Init

Associated Types

type Rep (TraceReplayEvent blk) ∷ TypeType #

Methods

fromTraceReplayEvent blk → Rep (TraceReplayEvent blk) x #

toRep (TraceReplayEvent blk) x → TraceReplayEvent blk #

(StandardHash blk, InspectLedger blk) ⇒ Show (TraceReplayEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Init

(StandardHash blk, InspectLedger blk) ⇒ Eq (TraceReplayEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Init

Methods

(==)TraceReplayEvent blk → TraceReplayEvent blk → Bool #

(/=)TraceReplayEvent blk → TraceReplayEvent blk → Bool #

type Rep (TraceReplayEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Init

decorateReplayTracerWithGoal Source #

Arguments

Point blk

Tip of the ImmutableDB

Tracer m (TraceReplayEvent blk) 
Tracer m (ReplayGoal blk → TraceReplayEvent blk) 

Add the tip of the Immutable DB to the trace event

Between the tip of the immutable DB and the point of the starting block, the node could (if it so desired) easily compute a "percentage complete".

decorateReplayTracerWithStart Source #

Arguments

Point blk

Starting point of the replay

Tracer m (ReplayGoal blk → TraceReplayEvent blk) 
Tracer m (ReplayStart blk → ReplayGoal blk → TraceReplayEvent blk) 

Add the block at which a replay started.

This allows to compute a "percentage complete" when tracing the events.