@lodestar/beacon-node
Version:
A Typescript implementation of the beacon chain
115 lines • 5.3 kB
TypeScript
import { ChainForkConfig } from "@lodestar/config";
import { ForkPostDeneb, ForkPostFulu, ForkPreFulu } from "@lodestar/params";
import { BlobIndex, ColumnIndex, SignedBeaconBlock, Slot, deneb, fulu } from "@lodestar/types";
import { LodestarError } from "@lodestar/utils";
import { ChainEventEmitter } from "../../chain/emitter.js";
import { IBeaconChain } from "../../chain/interface.js";
import { INetwork } from "../../network/interface.js";
import { PeerSyncMeta } from "../../network/peers/peersData.js";
import { PeerIdStr } from "../../util/peerId.js";
import { WarnResult } from "../../util/wrapError.js";
import { BlockInputSyncCacheItem, PendingBlockInput } from "../types.js";
export type FetchByRootCoreProps = {
config: ChainForkConfig;
chain: IBeaconChain | null;
network: INetwork;
peerMeta: PeerSyncMeta;
};
export type FetchByRootProps = FetchByRootCoreProps & {
cacheItem: BlockInputSyncCacheItem;
blockRoot: Uint8Array;
};
export type FetchByRootAndValidateBlockProps = Omit<FetchByRootCoreProps, "peerMeta"> & {
peerIdStr: PeerIdStr;
blockRoot: Uint8Array;
};
export type FetchByRootAndValidateBlobsProps = FetchByRootAndValidateBlockProps & {
forkName: ForkPreFulu;
block: SignedBeaconBlock<ForkPostDeneb>;
blockRoot: Uint8Array;
missing: BlobIndex[];
};
export type FetchByRootAndValidateColumnsProps = FetchByRootCoreProps & {
blockRoot: Uint8Array;
forkName: ForkPostFulu;
block: SignedBeaconBlock<ForkPostFulu>;
missing: ColumnIndex[];
};
export type FetchByRootResponses = {
block: SignedBeaconBlock;
blobSidecars?: deneb.BlobSidecars;
columnSidecars?: fulu.DataColumnSidecar[];
};
export type DownloadByRootProps = FetchByRootCoreProps & {
cacheItem: BlockInputSyncCacheItem;
chain: IBeaconChain;
emitter: ChainEventEmitter;
};
export declare function downloadByRoot({ config, chain, network, emitter, peerMeta, cacheItem }: DownloadByRootProps): Promise<WarnResult<PendingBlockInput, DownloadByRootError>>;
export declare function fetchByRoot({ config, chain, network, peerMeta, blockRoot, cacheItem }: FetchByRootProps): Promise<WarnResult<FetchByRootResponses, DownloadByRootError>>;
export declare function fetchAndValidateBlock({ config, network, peerIdStr, blockRoot }: Omit<FetchByRootAndValidateBlockProps, "chain">): Promise<SignedBeaconBlock>;
export declare function fetchAndValidateBlobs({ chain, network, peerIdStr, blockRoot, block, missing }: FetchByRootAndValidateBlobsProps): Promise<deneb.BlobSidecars>;
export declare function fetchBlobsByRoot({ network, peerIdStr, blockRoot, missing, indicesInPossession }: Pick<FetchByRootAndValidateBlobsProps, "network" | "peerIdStr" | "blockRoot" | "missing"> & {
indicesInPossession?: number[];
}): Promise<deneb.BlobSidecars>;
export declare function fetchAndValidateColumns({ chain, network, peerMeta, forkName, block, blockRoot, missing }: FetchByRootAndValidateColumnsProps): Promise<WarnResult<fulu.DataColumnSidecar[], DownloadByRootError>>;
export declare function fetchColumnsByRoot({ network, peerMeta, blockRoot, missing }: Pick<FetchByRootAndValidateColumnsProps, "network" | "peerMeta" | "blockRoot" | "missing">): Promise<fulu.DataColumnSidecar[]>;
export declare enum DownloadByRootErrorCode {
MISMATCH_BLOCK_ROOT = "DOWNLOAD_BY_ROOT_ERROR_MISMATCH_BLOCK_ROOT",
EXTRA_SIDECAR_RECEIVED = "DOWNLOAD_BY_ROOT_ERROR_EXTRA_SIDECAR_RECEIVED",
NO_SIDECAR_RECEIVED = "DOWNLOAD_BY_ROOT_ERROR_NO_SIDECAR_RECEIVED",
NOT_ENOUGH_SIDECARS_RECEIVED = "DOWNLOAD_BY_ROOT_ERROR_NOT_ENOUGH_SIDECARS_RECEIVED",
INVALID_INCLUSION_PROOF = "DOWNLOAD_BY_ROOT_ERROR_INVALID_INCLUSION_PROOF",
INVALID_KZG_PROOF = "DOWNLOAD_BY_ROOT_ERROR_INVALID_KZG_PROOF",
MISSING_BLOCK_RESPONSE = "DOWNLOAD_BY_ROOT_ERROR_MISSING_BLOCK_RESPONSE",
MISSING_BLOB_RESPONSE = "DOWNLOAD_BY_ROOT_ERROR_MISSING_BLOB_RESPONSE",
MISSING_COLUMN_RESPONSE = "DOWNLOAD_BY_ROOT_ERROR_MISSING_COLUMN_RESPONSE",
Z = "DOWNLOAD_BY_ROOT_ERROR_Z"
}
export type DownloadByRootErrorType = {
code: DownloadByRootErrorCode.MISMATCH_BLOCK_ROOT;
peer: string;
requestedBlockRoot: string;
receivedBlockRoot: string;
} | {
code: DownloadByRootErrorCode.EXTRA_SIDECAR_RECEIVED;
peer: string;
slot: Slot;
blockRoot: string;
invalidIndices: string;
} | {
code: DownloadByRootErrorCode.NO_SIDECAR_RECEIVED;
peer: string;
slot: Slot;
blockRoot: string;
} | {
code: DownloadByRootErrorCode.NOT_ENOUGH_SIDECARS_RECEIVED;
peer: string;
slot: Slot;
blockRoot: string;
missingIndices: string;
} | {
code: DownloadByRootErrorCode.INVALID_INCLUSION_PROOF;
peer: string;
blockRoot: string;
sidecarIndex: number;
} | {
code: DownloadByRootErrorCode.INVALID_KZG_PROOF;
peer: string;
blockRoot: string;
} | {
code: DownloadByRootErrorCode.MISSING_BLOCK_RESPONSE;
peer: string;
blockRoot: string;
} | {
code: DownloadByRootErrorCode.MISSING_BLOB_RESPONSE;
peer: string;
blockRoot: string;
} | {
code: DownloadByRootErrorCode.MISSING_COLUMN_RESPONSE;
peer: string;
blockRoot: string;
};
export declare class DownloadByRootError extends LodestarError<DownloadByRootErrorType> {
}
//# sourceMappingURL=downloadByRoot.d.ts.map