@lodestar/beacon-node
Version:
A Typescript implementation of the beacon chain
151 lines • 5.48 kB
TypeScript
import { ChainForkConfig } from "@lodestar/config";
import { MaybeValidExecutionStatus } from "@lodestar/fork-choice";
import { ForkPostDeneb } from "@lodestar/params";
import { CachedBeaconStateAllForks, DataAvailabilityStatus } from "@lodestar/state-transition";
import { RootHex, SignedBeaconBlock, Slot, deneb } from "@lodestar/types";
export declare enum BlockInputType {
preData = "preData",
outOfRangeData = "outOfRangeData",
availableData = "availableData",
dataPromise = "dataPromise"
}
/** Enum to represent where blocks come from */
export declare enum BlockSource {
gossip = "gossip",
api = "api",
byRange = "req_resp_by_range",
byRoot = "req_resp_by_root"
}
/** Enum to represent where blobs come from */
export declare enum BlobsSource {
gossip = "gossip",
api = "api",
byRange = "req_resp_by_range",
byRoot = "req_resp_by_root"
}
export declare enum GossipedInputType {
block = "block",
blob = "blob"
}
type BlobsCacheMap = Map<number, deneb.BlobSidecar>;
type ForkBlobsInfo = {
fork: ForkPostDeneb;
};
export type BlockInputBlobs = {
blobs: deneb.BlobSidecar[];
blobsSource: BlobsSource;
};
export type BlockInputDataBlobs = ForkBlobsInfo & BlockInputBlobs;
export type BlockInputData = BlockInputDataBlobs;
type Availability<T> = {
availabilityPromise: Promise<T>;
resolveAvailability: (data: T) => void;
};
type CachedBlobs = {
blobsCache: BlobsCacheMap;
} & Availability<BlockInputDataBlobs>;
export type CachedData = ForkBlobsInfo & CachedBlobs;
export type BlockInput = {
block: SignedBeaconBlock;
source: BlockSource;
} & ({
type: BlockInputType.preData | BlockInputType.outOfRangeData;
} | ({
type: BlockInputType.availableData;
} & {
blockData: BlockInputData;
}) | ({
type: BlockInputType.dataPromise;
} & {
cachedData: CachedData;
}));
export type NullBlockInput = {
block: null;
blockRootHex: RootHex;
blockInputPromise: Promise<BlockInput>;
} & {
cachedData: CachedData;
};
export declare function blockRequiresBlobs(config: ChainForkConfig, blockSlot: Slot, clockSlot: Slot): boolean;
export declare const getBlockInput: {
preData(config: ChainForkConfig, block: SignedBeaconBlock, source: BlockSource): BlockInput;
outOfRangeData(config: ChainForkConfig, block: SignedBeaconBlock, source: BlockSource): BlockInput;
availableData(config: ChainForkConfig, block: SignedBeaconBlock, source: BlockSource, blockData: BlockInputData): BlockInput;
dataPromise(config: ChainForkConfig, block: SignedBeaconBlock, source: BlockSource, cachedData: CachedData): BlockInput;
};
export declare function getBlockInputBlobs(blobsCache: BlobsCacheMap): Omit<BlockInputBlobs, "blobsSource">;
export declare enum AttestationImportOpt {
Skip = 0,
Force = 1
}
export declare enum BlobSidecarValidation {
/** When recieved in gossip the blobs are individually verified before import */
Individual = 0,
/**
* Blobs when recieved in req/resp can be fully verified before import
* but currently used in spec tests where blobs come without proofs and assumed
* to be valid
*/
Full = 1
}
export type ImportBlockOpts = {
/**
* TEMP: Review if this is safe, Lighthouse always imports attestations even in finalized sync.
*/
importAttestations?: AttestationImportOpt;
/**
* If error would trigger BlockErrorCode ALREADY_KNOWN or GENESIS_BLOCK, just ignore the block and don't verify nor
* import the block and return void | Promise<void>.
* Used by range sync and unknown block sync.
*/
ignoreIfKnown?: boolean;
/**
* If error would trigger WOULD_REVERT_FINALIZED_SLOT, it means the block is finalized and we could ignore the block.
* Don't import and return void | Promise<void>
* Used by range sync.
*/
ignoreIfFinalized?: boolean;
/**
* From RangeSync module, we won't attest to this block so it's okay to ignore a SYNCING message from execution layer
*/
fromRangeSync?: boolean;
/**
* Verify signatures on main thread or not.
*/
blsVerifyOnMainThread?: boolean;
/**
* Metadata: `true` if only the block proposer signature has been verified
*/
validProposerSignature?: boolean;
/**
* Metadata: `true` if all the signatures including the proposer signature have been verified
*/
validSignatures?: boolean;
/** Set to true if already run `validateBlobSidecars()` sucessfully on the blobs */
validBlobSidecars?: BlobSidecarValidation;
/** Seen timestamp seconds */
seenTimestampSec?: number;
/** Set to true if persist block right at verification time */
eagerPersistBlock?: boolean;
/** Set to true if the importing block is from gossip */
isGossipBlock?: boolean;
};
/**
* A wrapper around a `SignedBeaconBlock` that indicates that this block is fully verified and ready to import
*/
export type FullyVerifiedBlock = {
blockInput: BlockInput;
postState: CachedBeaconStateAllForks;
parentBlockSlot: Slot;
proposerBalanceDelta: number;
/**
* If the execution payload couldnt be verified because of EL syncing status,
* used in optimistic sync or for merge block
*/
executionStatus: MaybeValidExecutionStatus;
dataAvailabilityStatus: DataAvailabilityStatus;
/** Seen timestamp seconds */
seenTimestampSec: number;
};
export {};
//# sourceMappingURL=types.d.ts.map