From 9e065676c92f767f84c26e2c4f665b7ada09655b Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Sat, 19 Oct 2024 16:23:39 +0100 Subject: [PATCH] feat: forward blinded block ssz bytes to submitBlindedBlock api --- packages/api/src/builder/routes.ts | 6 +++--- packages/beacon-node/src/api/impl/beacon/blocks/index.ts | 7 ++++--- packages/beacon-node/src/execution/builder/http.ts | 7 +++++-- packages/beacon-node/src/execution/builder/interface.ts | 5 ++++- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/api/src/builder/routes.ts b/packages/api/src/builder/routes.ts index a203a93b8af..097edad652e 100644 --- a/packages/api/src/builder/routes.ts +++ b/packages/api/src/builder/routes.ts @@ -71,7 +71,7 @@ export type Endpoints = { submitBlindedBlock: Endpoint< "POST", - {signedBlindedBlock: SignedBlindedBeaconBlock}, + {signedBlindedBlock: SignedBlindedBeaconBlock; blockBytes?: Uint8Array | null}, {body: unknown; headers: {[MetaHeader.Version]: string}}, ExecutionPayload | ExecutionPayloadAndBlobsBundle, VersionMeta @@ -138,10 +138,10 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions { + writeReqSsz: ({signedBlindedBlock, blockBytes}) => { const fork = config.getForkName(signedBlindedBlock.message.slot); return { - body: getExecutionForkTypes(fork).SignedBlindedBeaconBlock.serialize(signedBlindedBlock), + body: blockBytes ?? getExecutionForkTypes(fork).SignedBlindedBeaconBlock.serialize(signedBlindedBlock), headers: { [MetaHeader.Version]: fork, }, diff --git a/packages/beacon-node/src/api/impl/beacon/blocks/index.ts b/packages/beacon-node/src/api/impl/beacon/blocks/index.ts index b54e8752a43..4171c915875 100644 --- a/packages/beacon-node/src/api/impl/beacon/blocks/index.ts +++ b/packages/beacon-node/src/api/impl/beacon/blocks/index.ts @@ -269,7 +269,7 @@ export function getBeaconBlockApi({ const source = ProducedBlockSource.builder; chain.logger.debug("Reconstructing signedBlockOrContents", {slot, blockRoot, source}); - const signedBlockOrContents = await reconstructBuilderBlockOrContents(chain, signedBlindedBlock); + const signedBlockOrContents = await reconstructBuilderBlockOrContents(chain, signedBlindedBlock, context?.sszBytes); // the full block is published by relay and it's possible that the block is already known to us // by gossip @@ -507,13 +507,14 @@ export function getBeaconBlockApi({ async function reconstructBuilderBlockOrContents( chain: ApiModules["chain"], - signedBlindedBlock: SignedBlindedBeaconBlock + signedBlindedBlock: SignedBlindedBeaconBlock, + blockBytes?: Uint8Array | null ): Promise { const executionBuilder = chain.executionBuilder; if (!executionBuilder) { throw Error("executionBuilder required to publish SignedBlindedBeaconBlock"); } - const signedBlockOrContents = await executionBuilder.submitBlindedBlock(signedBlindedBlock); + const signedBlockOrContents = await executionBuilder.submitBlindedBlock(signedBlindedBlock, blockBytes); return signedBlockOrContents; } diff --git a/packages/beacon-node/src/execution/builder/http.ts b/packages/beacon-node/src/execution/builder/http.ts index 13f797d1c69..623e234ac3f 100644 --- a/packages/beacon-node/src/execution/builder/http.ts +++ b/packages/beacon-node/src/execution/builder/http.ts @@ -149,9 +149,12 @@ export class ExecutionBuilderHttp implements IExecutionBuilder { return {header, executionPayloadValue, blobKzgCommitments, executionRequests}; } - async submitBlindedBlock(signedBlindedBlock: SignedBlindedBeaconBlock): Promise { + async submitBlindedBlock( + signedBlindedBlock: SignedBlindedBeaconBlock, + blockBytes?: Uint8Array | null + ): Promise { const res = await this.api.submitBlindedBlock( - {signedBlindedBlock}, + {signedBlindedBlock, blockBytes}, {retries: 2, requestWireFormat: this.sszSupported ? WireFormat.ssz : WireFormat.json} ); diff --git a/packages/beacon-node/src/execution/builder/interface.ts b/packages/beacon-node/src/execution/builder/interface.ts index 5a6a4eb82f6..d674f2881cf 100644 --- a/packages/beacon-node/src/execution/builder/interface.ts +++ b/packages/beacon-node/src/execution/builder/interface.ts @@ -39,5 +39,8 @@ export interface IExecutionBuilder { blobKzgCommitments?: deneb.BlobKzgCommitments; executionRequests?: electra.ExecutionRequests; }>; - submitBlindedBlock(signedBlock: SignedBlindedBeaconBlock): Promise; + submitBlindedBlock( + signedBlindedBlock: SignedBlindedBeaconBlock, + blockBytes?: Uint8Array | null + ): Promise; }