ouroboros-consensus
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Description

Snapshots

Snapshotting a ledger state means saving a copy of the state to disk, so that a later start of a cardano-node can use such a snapshot as a starting point instead of having to replay from Genesis.

A snapshot is identified by the slot number of the ledger state it contains and possibly has a suffix in the name. The consensus logic will not delete a snapshot if it has a suffix. This can be used to store important snapshots. The suffix can be manually added to the snapshot by renaming the folder (see the caveats in snapshotManager for the LSM backend). It will also be added automatically by some tools such as db-analyser.

In general snapshots will be stored in the ./ledger directory inside the ChainDB directory, but each LedgerDB backend is free to store it somewhere else. Management of snapshots is done through the SnapshotManager record (see the snapshotManager functions on each backend).

Snapshots cosists of two parts:

  • the ledger state tables: location and format differs among backends,
  • the rest of the ledger state: a CBOR serialization of an ExtLedgerState blk EmptyMK, stored in the ./state file in the snapshot directory.

V2 backends will provide means of loading a snapshot via the method openStateRefFromSnapshot.

Synopsis

Snapshots

data CRCError Source #

Constructors

CRCInvalid 
CRCNoFile 

Instances

Instances details
Eq CRCError Source # 
Instance details

Defined in Ouroboros.Consensus.Util.CRC

Methods

(==)CRCErrorCRCErrorBool #

(/=)CRCErrorCRCErrorBool #

Show CRCError Source # 
Instance details

Defined in Ouroboros.Consensus.Util.CRC

Methods

showsPrecIntCRCErrorShowS #

showCRCErrorString #

showList ∷ [CRCError] → ShowS #

data DiskSnapshot Source #

Name of a disk snapshot.

The snapshot itself might not yet exist on disk.

Constructors

DiskSnapshot 

Fields

  • dsNumberWord64

    Snapshots are numbered. We will try the snapshots with the highest number first.

    When creating a snapshot, we use the slot number of the ledger state it corresponds to as the snapshot number. This gives an indication of how recent the snapshot is.

    Note that the snapshot names are only indicative, we don't rely on the snapshot number matching the slot number of the corresponding ledger state. We only use the snapshots numbers to determine the order in which we try them.

  • dsSuffixMaybe String

    Snapshots can optionally have a suffix, separated by the snapshot number with an underscore, e.g., 4492799_last_Byron. This suffix acts as metadata for the operator of the node. Snapshots with a suffix will not be deleted.

Instances

Instances details
Eq DiskSnapshot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Generic DiskSnapshot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Associated Types

type Rep DiskSnapshot 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep DiskSnapshot = D1 ('MetaData "DiskSnapshot" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "DiskSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "dsNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "dsSuffix") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String))))
Show DiskSnapshot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep DiskSnapshot Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep DiskSnapshot = D1 ('MetaData "DiskSnapshot" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "DiskSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "dsNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64) :*: S1 ('MetaSel ('Just "dsSuffix") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String))))

data MetadataErr Source #

Constructors

MetadataFileDoesNotExist

The metadata file does not exist

MetadataInvalid String

The metadata file is invalid and does not deserialize

MetadataBackendMismatch

The metadata file has the incorrect backend

data ReadSnapshotErr Source #

Constructors

ReadSnapshotFailed ReadIncrementalErr

Error while de-serialising data

ReadSnapshotDataCorruption

Checksum of read snapshot differs from the one tracked by its corresponding metadata file

ReadMetadataError FsPath MetadataErr

An error occurred while reading the snapshot metadata file

ReadSnapshotIsLegacy

We were given a legacy snapshot

data SnapshotFailure blk Source #

Constructors

InitFailureRead ReadSnapshotErr

We failed to deserialise the snapshot

This can happen due to data corruption in the ledger DB or if the codecs changed.

InitFailureTooRecent DiskSnapshot (Point blk)

This snapshot is too recent (ahead of the tip of the immutable chain)

InitFailureGenesis

This snapshot was of the ledger state at genesis, even though we never take snapshots at genesis, so this is unexpected.

Instances

Instances details
StandardHash blk ⇒ Eq (SnapshotFailure blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Methods

(==)SnapshotFailure blk → SnapshotFailure blk → Bool #

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

Generic (SnapshotFailure blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Associated Types

type Rep (SnapshotFailure blk) 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep (SnapshotFailure blk) = D1 ('MetaData "SnapshotFailure" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "InitFailureRead" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ReadSnapshotErr)) :+: (C1 ('MetaCons "InitFailureTooRecent" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Point blk))) :+: C1 ('MetaCons "InitFailureGenesis" 'PrefixI 'False) (U1TypeType)))

Methods

fromSnapshotFailure blk → Rep (SnapshotFailure blk) x #

toRep (SnapshotFailure blk) x → SnapshotFailure blk #

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

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Methods

showsPrecIntSnapshotFailure blk → ShowS #

showSnapshotFailure blk → String #

showList ∷ [SnapshotFailure blk] → ShowS #

type Rep (SnapshotFailure blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep (SnapshotFailure blk) = D1 ('MetaData "SnapshotFailure" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "InitFailureRead" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ReadSnapshotErr)) :+: (C1 ('MetaCons "InitFailureTooRecent" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Point blk))) :+: C1 ('MetaCons "InitFailureGenesis" 'PrefixI 'False) (U1TypeType)))

newtype NumOfDiskSnapshots Source #

Number of snapshots to be stored on disk. See the SnapshotPolicy documentation for more information.

Instances

Instances details
Eq NumOfDiskSnapshots Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Generic NumOfDiskSnapshots Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Associated Types

type Rep NumOfDiskSnapshots 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep NumOfDiskSnapshots = D1 ('MetaData "NumOfDiskSnapshots" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-4.0.0.0-inplace" 'True) (C1 ('MetaCons "NumOfDiskSnapshots" 'PrefixI 'True) (S1 ('MetaSel ('Just "getNumOfDiskSnapshots") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word)))
Show NumOfDiskSnapshots Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep NumOfDiskSnapshots Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep NumOfDiskSnapshots = D1 ('MetaData "NumOfDiskSnapshots" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-4.0.0.0-inplace" 'True) (C1 ('MetaCons "NumOfDiskSnapshots" 'PrefixI 'True) (S1 ('MetaSel ('Just "getNumOfDiskSnapshots") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word)))

defaultSnapshotPolicyArgsSnapshotPolicyArgs Source #

Default snapshot policy args are Mithril snapshot policy args

mithrilSnapshotPolicyArgsSnapshotPolicyArgs Source #

Snapshot Policy arguments to be used by Mithril

The snapshot interval is derived as follows: * The epoch in Shelley is 432,000 (10k/f) slots long, which corresponds to 5 days. * We want to take a snapshot a day, so that is 40*k.

Note that we will take a snapshot at the beginning of each epoch too, but we won't write it immediately, instead we will write it 5 - 10 minutes later, so we don't risk imposing more work on the epoch boundary.

Codec

readExtLedgerState ∷ ∀ (m ∷ TypeType) blk. IOLike m ⇒ SomeHasFS m → (∀ s. Decoder s (ExtLedgerState blk EmptyMK)) → (∀ s. Decoder s (HeaderHash blk)) → FsPathExceptT ReadIncrementalErr m (ExtLedgerState blk EmptyMK, CRC) Source #

Read an extended ledger state from disk

writeExtLedgerStateMonadThrow m ⇒ SomeHasFS m → (ExtLedgerState blk EmptyMKEncoding) → FsPathExtLedgerState blk EmptyMK → m CRC Source #

Write an extended ledger state to disk

Paths

diskSnapshotIsTemporaryDiskSnapshotBool Source #

The snapshots that are periodically created are temporary, they will be deleted when trimming or if they fail to deserialize.

snapshotToStatePathDiskSnapshotFsPath Source #

The path within the LedgerDB's filesystem to the file that contains the snapshot's serialized ledger state

snapshotToDirPathDiskSnapshotFsPath Source #

The path within the LedgerDB's filesystem to the snapshot's directory

Management

data SnapshotManager (m ∷ TypeType) blk st Source #

Management of snapshots for the different LedgerDB backends.

defaultDeleteSnapshotIfTemporary(MonadCatch m, HasCallStack)SomeHasFS m → Tracer m (TraceSnapshotEvent blk) → DiskSnapshot → m () Source #

Delete snapshot from disk

defaultListSnapshotsMonad m ⇒ SomeHasFS m → m [DiskSnapshot] Source #

List on-disk snapshots, highest number first.

trimSnapshotsMonad m ⇒ SnapshotManager m blk st → SnapshotPolicy → m [DiskSnapshot] Source #

Trim the number of on disk snapshots so that at most onDiskNumSnapshots snapshots are stored on disk. The oldest snapshots are deleted.

The deleted snapshots are returned.

loadSnapshotMetadata ∷ ∀ (m ∷ TypeType). IOLike m ⇒ SomeHasFS m → DiskSnapshotExceptT MetadataErr m SnapshotMetadata Source #

Load a snapshot metadata JSON file.

writeSnapshotMetadataMonadThrow m ⇒ SomeHasFS m → DiskSnapshotSnapshotMetadata → m () Source #

Write a snapshot metadata JSON file.

Policy

data SnapshotPolicy Source #

Snapshots policy

We only write ledger states that are older than k blocks to disk (that is, snapshots that are guaranteed valid). The on-disk policy determines how often we write to disk and how many checkpoints we keep.

Constructors

SnapshotPolicy 

Fields

  • onDiskNumSnapshotsNumOfDiskSnapshots

    How many snapshots do we want to keep on disk?

    A higher number of on-disk snapshots is primarily a safe-guard against disk corruption: it trades disk space for reliability.

    Examples:

    • 0: Delete the snapshot immediately after writing. Probably not a useful value :-D
    • 1: Delete the previous snapshot immediately after writing the next Dangerous policy: if for some reason the deletion happens before the new snapshot is written entirely to disk (we don't fsync), we have no choice but to start at the genesis snapshot on the next startup.
    • 2: Always keep 2 snapshots around. This means that when we write the next snapshot, we delete the oldest one, leaving the middle one available in case of truncation of the write. This is probably a sane value in most circumstances.
  • onDiskSnapshotSelectorSnapshotSelectorContext → [SlotNo]

    Select the slots to take a snapshot for, in increasing order. Must be a sublist of sscSnapshotSlots.

    See also defaultSnapshotPolicy

  • onDiskSnapshotDelayRangeSnapshotDelayRange

    Minimum and maximum durations of the random delay between requesting a snapshot and taking that snapshot.

data SnapshotDelayRange Source #

Range from which the randomised snapshot delay will be taken. The randomly chosen duration will be at least minimumDelay and at most maximumDelay.

Constructors

SnapshotDelayRange 

Fields

  • minimumDelay ∷ !DiffTime

    minimum acceptable delay between requesting a snapshot and taking the snapshot

  • maximumDelay ∷ !DiffTime

    maximum acceptable delay between requesting a snapshot and taking the snapshot

Instances

Instances details
Eq SnapshotDelayRange Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Generic SnapshotDelayRange Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Associated Types

type Rep SnapshotDelayRange 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep SnapshotDelayRange = D1 ('MetaData "SnapshotDelayRange" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "SnapshotDelayRange" 'PrefixI 'True) (S1 ('MetaSel ('Just "minimumDelay") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DiffTime) :*: S1 ('MetaSel ('Just "maximumDelay") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DiffTime)))
Show SnapshotDelayRange Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

NoThunks SnapshotDelayRange Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep SnapshotDelayRange Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep SnapshotDelayRange = D1 ('MetaData "SnapshotDelayRange" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "SnapshotDelayRange" 'PrefixI 'True) (S1 ('MetaSel ('Just "minimumDelay") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DiffTime) :*: S1 ('MetaSel ('Just "maximumDelay") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DiffTime)))

data SnapshotSelectorContext Source #

Constructors

SnapshotSelectorContext 

Fields

  • sscTimeSinceLastMaybe DiffTime

    The time since the last snapshot, or Nothing if none was taken yet. Note that Nothing merely means no snapshot had been taking yet since the node was started; it does not necessarily mean that none exist on disk.

  • sscSnapshotSlots ∷ [SlotNo]

    An increasing list of slots for which a snapshot can be taken (as the corresponding ledger state is immutable). The result of onDiskSnapshotSelector must be a subset of this list.

data SnapshotFrequencyArgs Source #

Determines when/how often we take ledger snapshots.

We only write snapshots for ledger states that are immutable. Concretely, for every slot s out of

sfaOffset, sfaOffset + sfaInterval, sfaOffset + 2 * sfaInterval, sfaOffset + 3 * sfaInterval, ...

we write a snapshot for the most recent immutable ledger state before s. This way, nodes with the same sfaInterval/sfaOffset configuration create snapshots for precisely the same slots.

For example, on Cardano mainnet, where k=2160 and f=1/20, setting sfaInterval = 10*k/f = 432000 (one epoch) and sfaOffset = 0 will cause the node to create snapshots for the last block in every Shelley epoch. By setting sfaOffset to eg 5*k/f (half an epoch), snapshots are created just before the midway point in each epoch.

Additionally, there is an (optional, opt-out) rate limit (useful while bulk-syncing). When set to a given duration, we will skip writing a snapshot if less time than the given duration has passed since we finished writing the previous snapshot (if any).

To avoid skipping a snapshot write when caught-up, it is advisable to set sfaRateLimit to something significantly smaller than the wall-clock duration of sfaInterval.

Constructors

SnapshotFrequencyArgs 

Fields

data SnapshotInterval Source #

How many slots to leave between snapshots, see SnapshotFrequencyArgs.

The interval is only resolved into a concrete number of slots once the SecurityParam is known, see resolveSnapshotInterval.

Constructors

DefaultSnapshotInterval

40k slots, see mithrilSnapshotPolicyArgs.

RequestedSnapshotInterval (NonZero Word64)

An explicit number of slots.

resolveSnapshotIntervalSecurityParamSnapshotIntervalNonZero Word64 Source #

Resolve a SnapshotInterval into a concrete number of slots.

defaultSnapshotPolicySecurityParamSnapshotPolicyArgsSnapshotPolicy Source #

Default on-disk policy suitable to use with cardano-node

mithrilEpochSizeWord64 Source #

The Cardano mainnet epoch length in slots, used as the reference for the Mithril snapshot compatibility check in sanityCheckSnapshotPolicyArgs. Mithril requires a ledger snapshot at each epoch boundary; for snapshots to land on every epoch boundary, sfaInterval must divide this value evenly.

sanityCheckSnapshotPolicyArgsSecurityParamSnapshotPolicyArgs → [SanityCheckIssue] Source #

Check a SnapshotPolicyArgs for suspicious configurations and return a (possibly empty) list of SanityCheckIssues describing any problems found.

Only Override values are checked — UseDefault values are known-good and are never flagged. Checks that are specific to SnapshotFrequency are skipped entirely when spaFrequency is DisableSnapshots.

pattern DoDiskSnapshotChecksumFlag "DoDiskSnapshotChecksum" Source #

Type-safe flag to regulate the checksum policy of the ledger state snapshots.

These patterns are exposed to cardano-node and will be passed as part of SnapshotPolicy.

pattern NoDoDiskSnapshotChecksumFlag "DoDiskSnapshotChecksum" Source #

Type-safe flag to regulate the checksum policy of the ledger state snapshots.

These patterns are exposed to cardano-node and will be passed as part of SnapshotPolicy.

Requesting snapshots

data SnapshotRequest (m ∷ TypeType) Source #

A pending request to write ledger snapshots to disk.

The ledger states to snapshot have already been selected and pinned down (the request holds on to duplicated ledger tables handles), but nothing has been written yet. Serving the request via writeSnapshots is what writes the snapshots and releases those handles again.

Constructors

SnapshotRequest 

Fields

  • snapshotRequestedAt ∷ !Time

    The time at which the ledger states to snapshot were selected.

  • snapshotRequestSlots ∷ !(NonEmpty SlotNo)

    The slots of the ledger states that will be snapshotted, for tracing.

  • writeSnapshots ∷ !(m ())

    Write the snapshots and release the ledger tables handles this request holds on to.

    This is a closure rather than data that whoever serves the request could act on, because writing a snapshot needs the ledger tables handles and the backend-specific machinery of the LedgerDB implementation, neither of which is nameable outside of it. All that is left to the server is when to run this.

data SnapshotRequestQueue (m ∷ TypeType) Source #

A queue holding at most one SnapshotRequest.

It is shared between the thread deciding that a snapshot must be taken and the background thread taking it. The former never blocks (tryEnqueueSnapshotRequest drops the request when the queue is occupied), the latter is parked on the queue until there is work to do (withSnapshotRequest).

The queue stays occupied for as long as a request is being served, not merely while it is waiting to be picked up. Hence at most one snapshot request is alive at any point in time.

Bounding it this way is not something the SnapshotPolicy rate limit can do on its own: sscTimeSinceLast is derived from the last completed request, so it stays satisfied for the whole of a request's delay, and it can be disabled altogether (SnapshotRateLimitDisabled). Without this bound, every advance of the immutable tip during one delay would start another request, each pinning a ledger state and each writing a snapshot that trimSnapshots then discards.

snapshotQueueDelayRange ∷ ∀ (m ∷ TypeType). SnapshotRequestQueue m → SnapshotDelayRange Source #

The range to draw the randomised delay before writing the snapshots from, see onDiskSnapshotDelayRange.

It lives on the queue, and not in every SnapshotRequest, because it is a property of the SnapshotPolicy the LedgerDB was opened with, hence the same for every request.

snapshotRequestInFlightMonadMVar m ⇒ SnapshotRequestQueue m → m Bool Source #

Whether a request is currently queued or being served.

Merely a hint: by the time the caller acts on it, the answer might have changed. It is meant to let a would-be producer skip the (not entirely cheap) work of assembling a request that tryEnqueueSnapshotRequest would then drop anyway.

tryEnqueueSnapshotRequestMonadMVar m ⇒ SnapshotRequestQueue m → SnapshotRequest m → m Bool Source #

Enqueue a request, unless one is already queued or being served.

Never blocks. Returns False when the request was dropped, in which case the caller is responsible for releasing the resources it holds on to.

tryWithSnapshotRequest(MonadMVar m, MonadThrow m)SnapshotRequestQueue m → (SnapshotRequest m → m ()) → m () Source #

Like withSnapshotRequest, but do nothing when no request is queued instead of waiting for one.

withSnapshotRequest(MonadMVar m, MonadThrow m)SnapshotRequestQueue m → (SnapshotRequest m → m a) → m a Source #

Block until a request is enqueued, then serve it.

The queue is only freed once the given action has returned or thrown, so that no further request is accepted while this one is being served.

Tracing

data TraceSnapshotEvent blk Source #

Constructors

InvalidSnapshot DiskSnapshot (SnapshotFailure blk)

An on disk snapshot was skipped because it was invalid.

SnapshotRequestDelayed Time DiffTime (NonEmpty SlotNo)

A delayed snapshot requested was issued at a timestamp, with a delay and for ledger states at the specified slot numbers

SnapshotRequestCompleted

A snapshot request was completed

TookSnapshot DiskSnapshot (RealPoint blk) EnclosingTimed

A snapshot was written to disk.

DeletedSnapshot DiskSnapshot

An old or invalid on-disk snapshot was deleted

Instances

Instances details
StandardHash blk ⇒ Eq (TraceSnapshotEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Generic (TraceSnapshotEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

Associated Types

type Rep (TraceSnapshotEvent blk) 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep (TraceSnapshotEvent blk) = D1 ('MetaData "TraceSnapshotEvent" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-4.0.0.0-inplace" 'False) ((C1 ('MetaCons "InvalidSnapshot" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SnapshotFailure blk))) :+: C1 ('MetaCons "SnapshotRequestDelayed" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Time) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiffTime) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmpty SlotNo))))) :+: (C1 ('MetaCons "SnapshotRequestCompleted" 'PrefixI 'False) (U1TypeType) :+: (C1 ('MetaCons "TookSnapshot" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (RealPoint blk)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 EnclosingTimed))) :+: C1 ('MetaCons "DeletedSnapshot" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot)))))
StandardHash blk ⇒ Show (TraceSnapshotEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep (TraceSnapshotEvent blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.LedgerDB.Snapshots

type Rep (TraceSnapshotEvent blk) = D1 ('MetaData "TraceSnapshotEvent" "Ouroboros.Consensus.Storage.LedgerDB.Snapshots" "ouroboros-consensus-4.0.0.0-inplace" 'False) ((C1 ('MetaCons "InvalidSnapshot" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SnapshotFailure blk))) :+: C1 ('MetaCons "SnapshotRequestDelayed" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Time) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiffTime) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmpty SlotNo))))) :+: (C1 ('MetaCons "SnapshotRequestCompleted" 'PrefixI 'False) (U1TypeType) :+: (C1 ('MetaCons "TookSnapshot" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (RealPoint blk)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 EnclosingTimed))) :+: C1 ('MetaCons "DeletedSnapshot" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DiskSnapshot)))))

Re-exports

newtype Flag (name ∷ Symbol) Source #

Type-safe boolean flags with type level tags

It is recommended to create pattern synonyms for the true and false values.

See DiskSnapshotChecksum for an example.

Constructors

Flag 

Fields

Instances

Instances details
Eq (Flag name) Source # 
Instance details

Defined in Ouroboros.Consensus.Util

Methods

(==)Flag name → Flag name → Bool #

(/=)Flag name → Flag name → Bool #

Generic (Flag name) Source # 
Instance details

Defined in Ouroboros.Consensus.Util

Associated Types

type Rep (Flag name) 
Instance details

Defined in Ouroboros.Consensus.Util

type Rep (Flag name) = D1 ('MetaData "Flag" "Ouroboros.Consensus.Util" "ouroboros-consensus-4.0.0.0-inplace" 'True) (C1 ('MetaCons "Flag" 'PrefixI 'True) (S1 ('MetaSel ('Just "getFlag") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

Methods

fromFlag name → Rep (Flag name) x #

toRep (Flag name) x → Flag name #

Show (Flag name) Source # 
Instance details

Defined in Ouroboros.Consensus.Util

Methods

showsPrecIntFlag name → ShowS #

showFlag name → String #

showList ∷ [Flag name] → ShowS #

type Rep (Flag name) Source # 
Instance details

Defined in Ouroboros.Consensus.Util

type Rep (Flag name) = D1 ('MetaData "Flag" "Ouroboros.Consensus.Util" "ouroboros-consensus-4.0.0.0-inplace" 'True) (C1 ('MetaCons "Flag" 'PrefixI 'True) (S1 ('MetaSel ('Just "getFlag") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

Testing

decodeLBackwardsCompatible ∷ ∀ l blk. Proxy blk → (∀ s. Decoder s l) → (∀ s. Decoder s (HeaderHash blk)) → ∀ s. Decoder s l Source #

To remain backwards compatible with existing snapshots stored on disk, we must accept the old format as well as the new format.

The old format:

  • The tip: WithOrigin (RealPoint blk)
  • The chain length: Word64
  • The ledger state: l

The new format is described by snapshotEncodingVersion1.

This decoder will accept and ignore them. The encoder (encodeSnapshot) will no longer encode them.

destroySnapshotsMonad m ⇒ SnapshotManager m blk st → m () Source #

Testing only! Destroy all snapshots in the DB.

encodeL ∷ (l → Encoding) → l → Encoding Source #

Encoder to be used in combination with decodeSnapshotBackwardsCompatible.

snapshotsMapM_Monad m ⇒ SnapshotManager m blk st → (DiskSnapshot → m a) → m () Source #