UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

118 lines 4.96 kB
import { ChainForkConfig } from "@lodestar/config"; import { IForkChoice, ProtoBlock } from "@lodestar/fork-choice"; import { ForkName, ForkPostBellatrix, ForkPostDeneb, ForkPostFulu, ForkPostGloas } from "@lodestar/params"; import { IBeaconStateView, type IBeaconStateViewBellatrix } from "@lodestar/state-transition"; import { BLSPubkey, BLSSignature, BeaconBlock, BeaconBlockBody, BlindedBeaconBlock, BlindedBeaconBlockBody, BlobsBundle, Bytes32, ExecutionPayload, Root, RootHex, SSEPayloadAttributes, Slot, ValidatorIndex, Wei, electra, fulu } from "@lodestar/types"; import { Logger } from "@lodestar/utils"; import { IExecutionEngine, PayloadId } from "../../execution/index.js"; import type { BeaconChain } from "../chain.js"; import { CommonBlockBody } from "../interface.js"; export declare enum PayloadPreparationType { Fresh = "Fresh", Cached = "Cached", Reorged = "Reorged", Blinded = "Blinded" } /** * Block production steps tracked in metrics */ export declare enum BlockProductionStep { proposerSlashing = "proposerSlashing", attesterSlashings = "attesterSlashings", voluntaryExits = "voluntaryExits", blsToExecutionChanges = "blsToExecutionChanges", attestations = "attestations", syncAggregate = "syncAggregate", executionPayload = "executionPayload" } export type BlockAttributes = { randaoReveal: BLSSignature; graffiti: Bytes32; slot: Slot; parentBlock: ProtoBlock; feeRecipient?: string; }; export declare enum BlockType { Full = "Full", Blinded = "Blinded" } export type AssembledBodyType<T extends BlockType> = T extends BlockType.Full ? BeaconBlockBody : BlindedBeaconBlockBody; export type AssembledBlockType<T extends BlockType> = T extends BlockType.Full ? BeaconBlock : BlindedBeaconBlock; export type ProduceFullGloas = { type: BlockType.Full; fork: ForkPostGloas; executionPayload: ExecutionPayload<ForkPostGloas>; executionRequests: electra.ExecutionRequests; blobsBundle: BlobsBundle<ForkPostGloas>; cells: fulu.Cell[][]; parentBlockRoot: Root; }; export type ProduceFullFulu = { type: BlockType.Full; fork: ForkPostFulu; executionPayload: ExecutionPayload<ForkPostFulu>; blobsBundle: BlobsBundle<ForkPostFulu>; cells: fulu.Cell[][]; }; export type ProduceFullDeneb = { type: BlockType.Full; fork: ForkName.deneb | ForkName.electra; executionPayload: ExecutionPayload<ForkPostDeneb>; blobsBundle: BlobsBundle<ForkPostDeneb>; }; export type ProduceFullBellatrix = { type: BlockType.Full; fork: ForkName.bellatrix | ForkName.capella; executionPayload: ExecutionPayload<ForkPostBellatrix>; }; export type ProduceFullPhase0 = { type: BlockType.Full; fork: ForkName.phase0 | ForkName.altair; }; export type ProduceBlinded = { type: BlockType.Blinded; fork: ForkName; }; /** The result of local block production, everything that's not the block itself */ export type ProduceResult = ProduceFullGloas | ProduceFullFulu | ProduceFullDeneb | ProduceFullBellatrix | ProduceFullPhase0 | ProduceBlinded; export declare function produceBlockBody<T extends BlockType>(this: BeaconChain, blockType: T, currentState: IBeaconStateView, blockAttr: BlockAttributes & { proposerIndex: ValidatorIndex; proposerPubKey: BLSPubkey; commonBlockBodyPromise: Promise<CommonBlockBody>; }): Promise<{ body: AssembledBodyType<T>; produceResult: ProduceResult; executionPayloadValue: Wei; shouldOverrideBuilder?: boolean; }>; /** * Produce ExecutionPayload for post-merge. */ export declare function prepareExecutionPayload(chain: { executionEngine: IExecutionEngine; config: ChainForkConfig; }, logger: Logger, fork: ForkPostBellatrix, parentBlockRoot: Root, parentBlockHash: Bytes32, safeBlockHash: RootHex, finalizedBlockHash: RootHex, /** * Post-gloas, when extending a full parent, callers must apply * parent execution payload first (see `withParentPayloadApplied`). */ state: IBeaconStateViewBellatrix, suggestedFeeRecipient: string): Promise<{ prepType: PayloadPreparationType; payloadId: PayloadId; }>; export declare function getPayloadAttributesForSSE(fork: ForkPostBellatrix, chain: { config: ChainForkConfig; forkChoice: IForkChoice; }, { prepareState, prepareSlot, parentBlockRoot, parentBlockHash, feeRecipient }: { /** * Post-gloas, when extending a full parent, callers must apply * parent execution payload first (see `withParentPayloadApplied`). */ prepareState: IBeaconStateViewBellatrix; prepareSlot: Slot; parentBlockRoot: Root; parentBlockHash: Bytes32; feeRecipient: string; }): SSEPayloadAttributes; export declare function produceCommonBlockBody<T extends BlockType>(this: BeaconChain, blockType: T, currentState: IBeaconStateView, { randaoReveal, graffiti, slot, parentBlock }: BlockAttributes): Promise<CommonBlockBody>; //# sourceMappingURL=produceBlockBody.d.ts.map