UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

77 lines 3.43 kB
import { routes } from "@lodestar/api"; import { ProtoBlock } from "@lodestar/fork-choice"; import { IBeaconStateView } from "@lodestar/state-transition"; import { BeaconBlock, Epoch, RootHex, Slot, phase0 } from "@lodestar/types"; import { JobItemQueue } from "../../util/queue/index.js"; import { CheckpointHex } from "../stateCache/types.js"; import { IStateRegenerator, IStateRegeneratorInternal, RegenCaller, StateRegenerationOpts } from "./interface.js"; import { RegenModules } from "./regen.js"; type QueuedStateRegeneratorModules = RegenModules & { signal: AbortSignal; }; type RegenRequestKey = keyof IStateRegeneratorInternal; type RegenRequestByKey = { [K in RegenRequestKey]: { key: K; args: Parameters<IStateRegeneratorInternal[K]>; }; }; export type RegenRequest = RegenRequestByKey[RegenRequestKey]; /** * Regenerates states that have already been processed by the fork choice * * All requests are queued so that only a single state at a time may be regenerated at a time */ export declare class QueuedStateRegenerator implements IStateRegenerator { readonly jobQueue: JobItemQueue<[RegenRequest], IBeaconStateView>; private readonly regen; private readonly forkChoice; private readonly blockStateCache; private readonly checkpointStateCache; private readonly metrics; private readonly logger; constructor(modules: QueuedStateRegeneratorModules); init(): Promise<void>; canAcceptWork(): boolean; dropCache(): void; dumpCacheSummary(): routes.lodestar.StateCacheItem[]; /** * Get a state from block state cache. */ getStateSync(stateRoot: RootHex): IBeaconStateView | null; /** * Get state for block processing. */ getPreStateSync(block: BeaconBlock): IBeaconStateView | null; getCheckpointStateOrBytes(cp: CheckpointHex): Promise<IBeaconStateView | Uint8Array | null>; /** * Get checkpoint state from cache */ getCheckpointStateSync(cp: CheckpointHex): IBeaconStateView | null; /** * Get state closest to head */ getClosestHeadState(head: ProtoBlock): IBeaconStateView | null; pruneOnCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void; pruneOnFinalized(finalizedEpoch: number): void; processState(blockRootHex: RootHex, postState: IBeaconStateView): void; addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView): void; updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void; updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch): number | null; /** * Get the state to run with `block`. * - State after `block.parentRoot` dialed forward to block.slot */ getPreState(block: BeaconBlock, opts: StateRegenerationOpts, rCaller: RegenCaller): Promise<IBeaconStateView>; /** * Get state of provided `blockRoot` and dial forward to `slot` * Use this api with care because we don't want the queue to be busy * For the context, gossip block validation uses this api so we want it to be as fast as possible * @returns */ getBlockSlotState(block: ProtoBlock, slot: Slot, opts: StateRegenerationOpts, rCaller: RegenCaller): Promise<IBeaconStateView>; getState(stateRoot: RootHex, rCaller: RegenCaller): Promise<IBeaconStateView>; private jobQueueProcessor; } export {}; //# sourceMappingURL=queued.d.ts.map