@lodestar/beacon-node
Version:
A Typescript implementation of the beacon chain
58 lines • 2.72 kB
TypeScript
import { CheckpointWithHex } from "@lodestar/fork-choice";
import { Epoch, RootHex, Slot } from "@lodestar/types";
import { Logger } from "@lodestar/utils";
import { IBeaconDb } from "../../../db/index.js";
import { Metrics } from "../../../metrics/metrics.js";
import { BufferPool } from "../../../util/bufferPool.js";
import { IStateRegenerator } from "../../regen/interface.js";
import { StateArchiveStrategy, StatesArchiveOpts } from "../interface.js";
/**
* Minimum number of epochs between single temp archived states
* These states will be pruned once a new state is persisted
*/
export declare const PERSIST_TEMP_STATE_EVERY_EPOCHS = 32;
export declare enum FrequencyStateArchiveStep {
LoadLastStoredSlot = "load_last_stored_slot",
GetFinalizedState = "get_finalized_state",
PersistState = "persist_state",
LoadStoredSlotsToDelete = "load_stored_slots_to_delete",
DeleteOldStates = "delete_old_states"
}
/**
* Archives finalized states from active bucket to archive bucket.
*
* Only the new finalized state is stored to disk
*/
export declare class FrequencyStateArchiveStrategy implements StateArchiveStrategy {
private readonly regen;
private readonly db;
private readonly logger;
private readonly opts;
private readonly bufferPool?;
constructor(regen: IStateRegenerator, db: IBeaconDb, logger: Logger, opts: StatesArchiveOpts, bufferPool?: BufferPool | null | undefined);
onFinalizedCheckpoint(_finalized: CheckpointWithHex, _metrics?: Metrics | null): Promise<void>;
onCheckpoint(_stateRoot: RootHex, _metrics?: Metrics | null): Promise<void>;
/**
* Persist states every some epochs to
* - Minimize disk space, storing the least states possible
* - Minimize the sync progress lost on unexpected crash, storing temp state every few epochs
*
* At epoch `e` there will be states peristed at intervals of `PERSIST_STATE_EVERY_EPOCHS` = 32
* and one at `PERSIST_TEMP_STATE_EVERY_EPOCHS` = 1024
* ```
* | | | .
* epoch - 1024*2 epoch - 1024 epoch - 32 epoch
* ```
*/
maybeArchiveState(finalized: CheckpointWithHex, metrics?: Metrics | null): Promise<void>;
/**
* Archives finalized states from active bucket to archive bucket.
* Only the new finalized state is stored to disk
*/
archiveState(finalized: CheckpointWithHex, metrics?: Metrics | null): Promise<void>;
}
/**
* Keeps first epoch per interval of persistEveryEpochs, deletes the rest
*/
export declare function computeStateSlotsToDelete(storedStateSlots: Slot[], persistEveryEpochs: Epoch): Slot[];
//# sourceMappingURL=frequencyStateArchiveStrategy.d.ts.map