@lodestar/beacon-node
Version:
A Typescript implementation of the beacon chain
29 lines • 2.07 kB
TypeScript
import { ForkPostElectra } from "@lodestar/params";
import { IBeaconStateView } from "@lodestar/state-transition";
import { Attestation, electra, phase0 } from "@lodestar/types";
import type { BeaconChain } from "../chain.js";
import { FullyVerifiedBlock, ImportBlockOpts } from "./types.js";
/**
* Imports a fully verified block into the chain state. Produces multiple permanent side-effects.
*
* ImportBlock order of operations must guarantee that BeaconNode does not end in an unknown state:
*
* 1. Persist block to hot DB (pre-emptively)
* - Done before importing block to fork-choice to guarantee that blocks in the fork-choice *always* are persisted
* in the DB. Otherwise the beacon node may end up in an unrecoverable state. If a block is persisted in the hot
* db but is unknown by the fork-choice, then it will just use some extra disk space. On restart is will be
* pruned regardless.
* - Note that doing a disk write first introduces a small delay before setting the head. An improvement where disk
* write happens latter requires the ability to roll back a fork-choice head change if disk write fails
*
* 2. Import block to fork-choice
* 3. Import attestations to fork-choice
* 4. Import attester slashings to fork-choice
* 5. Compute head. If new head, immediately stateCache.setHeadState()
* 6. Queue notifyForkchoiceUpdate to engine api
* 7. Add post state to stateCache
*/
export declare function importBlock(this: BeaconChain, fullyVerifiedBlock: FullyVerifiedBlock, opts: ImportBlockOpts): Promise<void>;
export declare function addAttestationPreElectra(this: BeaconChain, _: IBeaconStateView, target: phase0.Checkpoint, attDataRoot: string, attestation: Attestation, indexedAttestation: phase0.IndexedAttestation): void;
export declare function addAttestationPostElectra(this: BeaconChain, state: IBeaconStateView, target: phase0.Checkpoint, attDataRoot: string, attestation: Attestation<ForkPostElectra>, indexedAttestation: electra.IndexedAttestation): void;
//# sourceMappingURL=importBlock.d.ts.map