UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

160 lines • 7.76 kB
import { ChainForkConfig } from "@lodestar/config"; import { ForkName, ForkPostDeneb, ForkPostFulu } from "@lodestar/params"; import { BeaconBlockBody, ColumnIndex, CustodyIndex, DataColumnSidecar, Root, SignedBeaconBlock, SignedBeaconBlockHeader, Slot, deneb, fulu, gloas } from "@lodestar/types"; import { BlockInputColumns } from "../chain/blocks/blockInput/blockInput.js"; import { PayloadEnvelopeInput } from "../chain/blocks/payloadEnvelopeInput/index.js"; import { ChainEventEmitter } from "../chain/emitter.js"; import { Metrics } from "../metrics/metrics.js"; import { NodeId } from "../network/subnets/index.js"; export declare enum RecoverResult { NotAttemptedLessThanHalf = "not_attempted_less_than_half", NotAttemptedFull = "not_attempted_full", SuccessResolved = "success_resolved", SuccessLate = "success_late", Failed = "failed" } export type CustodyConfigOpts = { nodeId: NodeId; config: ChainForkConfig; initialCustodyGroupCount?: number; }; export declare class CustodyConfig { /** * The number of custody groups the node should subscribe to */ targetCustodyGroupCount: number; /** * The custody columns the node should subscribe to */ custodyColumns: ColumnIndex[]; /** * Custody columns map which column maps to which index in the array of columns custodied * with zero representing it is not custodied */ custodyColumnsIndex: Uint8Array; /** * The number of custody groups the node will sample */ sampledGroupCount: number; /** * Custody groups sampled by the node as part of custody sampling */ sampleGroups: CustodyIndex[]; /** * Data columns sampled by the node as part of custody sampling * https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.4/specs/fulu/das-core.md#custody-sampling * * TODO: Consider race conditions if this updates during sync/backfill */ sampledColumns: ColumnIndex[]; /** * Subnets sampled by the node as part of custody sampling */ sampledSubnets: number[]; private config; private nodeId; constructor(opts: CustodyConfigOpts); updateTargetCustodyGroupCount(targetCustodyGroupCount: number): void; private getCustodyColumnsIndex; } /** * Calculate the number of custody groups the node should subscribe to based on the node's effective balance * * SPEC FUNCTION * https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.3/specs/fulu/validator.md#validator-custody */ export declare function getValidatorsCustodyRequirement(config: ChainForkConfig, effectiveBalances: number[]): number; /** * Converts a custody group to an array of column indices. Should be 1-1 as long there are 128 * columns and 128 custody groups. * * SPEC FUNCTION * https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.4/specs/fulu/das-core.md#compute_columns_for_custody_group */ export declare function computeColumnsForCustodyGroup(config: ChainForkConfig, custodyIndex: CustodyIndex): ColumnIndex[]; /** * Converts nodeId and a the number of custody groups to an array of custody indices. Indexes must be * further converted to column indices * * SPEC FUNCTION * https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.4/specs/fulu/das-core.md#get_custody_groups */ export declare function getCustodyGroups(config: ChainForkConfig, nodeId: NodeId, custodyGroupCount: number): CustodyIndex[]; export declare function computePostFuluKzgCommitmentsInclusionProof(fork: ForkName, body: BeaconBlockBody): fulu.KzgCommitmentsInclusionProof; export declare function getDataColumns(config: ChainForkConfig, nodeId: NodeId, custodyGroupCount: number): ColumnIndex[]; /** * Computes the cells for each blob and combines them with cell proofs. * Similar to the computeMatrix function described below. * * SPEC FUNCTION (note: spec currently computes proofs, but we already have them) * https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.4/specs/fulu/das-core.md#compute_matrix */ export declare function getCellsAndProofs(blobBundles: fulu.BlobAndProofV2[]): Promise<{ cells: Uint8Array[]; proofs: Uint8Array[]; }[]>; /** * Get blob KZG commitments from a signed block, handling the different locations * in pre-Gloas (directly in block body) vs post-Gloas (in execution payload bid). */ export declare function getBlobKzgCommitments(fork: ForkName, signedBlock: SignedBeaconBlock<ForkPostDeneb>): deneb.KZGCommitment[]; /** * Given a signed block header and the commitments, inclusion proof, cells/proofs associated with * each blob in the block, assemble the sidecars which can be distributed to peers. * * SPEC FUNCTION * https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.4/specs/fulu/validator.md#get_data_column_sidecars */ export declare function getFuluDataColumnSidecars(signedBlockHeader: SignedBeaconBlockHeader, kzgCommitments: deneb.KZGCommitment[], kzgCommitmentsInclusionProof: fulu.KzgCommitmentsInclusionProof, cellsAndKzgProofs: { cells: Uint8Array[]; proofs: Uint8Array[]; }[]): fulu.DataColumnSidecar[]; /** * Given a signed block and the cells/proofs associated with each blob in the * block, assemble the sidecars which can be distributed to peers. * * SPEC FUNCTION * fulu: https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.4/specs/fulu/validator.md#get_data_column_sidecars_from_block * gloas: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.3/specs/gloas/builder.md#modified-get_data_column_sidecars_from_block */ export declare function getDataColumnSidecarsFromBlock(config: ChainForkConfig, signedBlock: SignedBeaconBlock<ForkPostFulu>, cellsAndKzgProofs: { cells: Uint8Array[]; proofs: Uint8Array[]; }[]): DataColumnSidecar[]; /** * Given a DataColumnSidecar and the cells/proofs associated with each blob corresponding * to the commitments it contains, assemble all sidecars for distribution to peers. * * SPEC FUNCTION * fulu: https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.4/specs/fulu/validator.md#get_data_column_sidecars_from_column_sidecar * gloas: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.3/specs/gloas/validator.md#modified-get_data_column_sidecars_from_column_sidecar */ export declare function getDataColumnSidecarsFromColumnSidecar(sidecar: DataColumnSidecar, cellsAndKzgProofs: { cells: Uint8Array[]; proofs: Uint8Array[]; }[]): DataColumnSidecar[]; export declare function getDataColumnSidecarSlot(sidecar: DataColumnSidecar): Slot; /** * In Gloas, data column sidecars have a simplified structure with `slot` and `beaconBlockRoot` * instead of `signedBlockHeader`, `kzgCommitments`, and `kzgCommitmentsInclusionProof`. * * SPEC FUNCTION * https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.3/specs/gloas/builder.md#modified-get_data_column_sidecars */ export declare function getGloasDataColumnSidecars(slot: Slot, beaconBlockRoot: Root, cellsAndKzgProofs: { cells: Uint8Array[]; proofs: Uint8Array[]; }[]): gloas.DataColumnSidecar[]; /** * If we receive more than half of NUMBER_OF_COLUMNS (64) we should recover all remaining columns */ export declare function recoverDataColumnSidecars(input: BlockInputColumns | PayloadEnvelopeInput, emitter: ChainEventEmitter, metrics: Metrics | null): Promise<DataColumnReconstructionCode>; export declare enum DataColumnReconstructionCode { NotAttemptedAlreadyFull = "not_attempted_full", NotAttemptedHaveLessThanHalf = "not_attempted_less_than_half", NullReturned = "null_returned", SuccessLate = "success_late", SuccessResolved = "success_resolved", Failed = "failed" } //# sourceMappingURL=dataColumns.d.ts.map