Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
LedgerDB initialization either from a LedgerState or from a DiskSnapshot
Synopsis
- data InitLog blk
- = InitFromGenesis
- | InitFromSnapshot DiskSnapshot (RealPoint blk)
- | InitFailure DiskSnapshot (SnapshotFailure blk) (InitLog blk)
- newtype ReplayStart blk = ReplayStart (Point blk)
- initLedgerDB ∷ ∀ 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) → StreamAPI m blk blk → m (InitLog blk, LedgerDB' blk, Word64)
- newtype ReplayGoal blk = ReplayGoal (Point blk)
- data TraceReplayEvent blk
- = ReplayFromGenesis (ReplayGoal blk)
- | ReplayFromSnapshot DiskSnapshot (ReplayStart blk) (ReplayGoal blk)
- | ReplayedBlock (RealPoint blk) [LedgerEvent blk] (ReplayStart blk) (ReplayGoal blk)
- decorateReplayTracerWithGoal ∷ Point blk → Tracer m (TraceReplayEvent blk) → Tracer m (ReplayGoal blk → TraceReplayEvent blk)
- decorateReplayTracerWithStart ∷ Point blk → Tracer m (ReplayGoal blk → TraceReplayEvent blk) → Tracer m (ReplayStart blk → ReplayGoal blk → TraceReplayEvent blk)
Initialization
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.
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
newtype ReplayStart blk Source #
Which point the replay started from
ReplayStart (Point blk) |
Instances
StandardHash blk ⇒ Show (ReplayStart blk) Source # | |
Defined in Ouroboros.Consensus.Storage.LedgerDB.Init showsPrec ∷ Int → ReplayStart blk → ShowS # show ∷ ReplayStart blk → String # showList ∷ [ReplayStart blk] → ShowS # | |
StandardHash blk ⇒ Eq (ReplayStart blk) Source # | |
Defined in Ouroboros.Consensus.Storage.LedgerDB.Init (==) ∷ ReplayStart blk → ReplayStart blk → Bool # (/=) ∷ ReplayStart blk → ReplayStart blk → Bool # |
∷ ∀ 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
ReplayGoal (Point blk) |
Instances
StandardHash blk ⇒ Show (ReplayGoal blk) Source # | |
Defined in Ouroboros.Consensus.Storage.LedgerDB.Init showsPrec ∷ Int → ReplayGoal blk → ShowS # show ∷ ReplayGoal blk → String # showList ∷ [ReplayGoal blk] → ShowS # | |
StandardHash blk ⇒ Eq (ReplayGoal blk) Source # | |
Defined in Ouroboros.Consensus.Storage.LedgerDB.Init (==) ∷ 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.
ReplayFromGenesis | There were no LedgerDB snapshots on disk, so we're replaying all blocks starting from Genesis against the initial ledger. |
| |
ReplayFromSnapshot | |
| |
ReplayedBlock | |
|
Instances
decorateReplayTracerWithGoal Source #
∷ 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 #
∷ 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.