From 0073c2a3841155025f4387a32775f37272baeb77 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..a044c1418f1 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; sszBytes?: Uint8Array | null}, {body: unknown; headers: {[MetaHeader.Version]: string}}, ExecutionPayload | ExecutionPayloadAndBlobsBundle, VersionMeta @@ -138,10 +138,10 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions { + writeReqSsz: ({signedBlindedBlock, sszBytes}) => { const fork = config.getForkName(signedBlindedBlock.message.slot); return { - body: getExecutionForkTypes(fork).SignedBlindedBeaconBlock.serialize(signedBlindedBlock), + body: sszBytes ?? 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..685d2212dc9 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, + sszBytes?: 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, sszBytes); return signedBlockOrContents; } diff --git a/packages/beacon-node/src/execution/builder/http.ts b/packages/beacon-node/src/execution/builder/http.ts index 13f797d1c69..fc81e4fa365 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, + sszBytes?: Uint8Array | null + ): Promise { const res = await this.api.submitBlindedBlock( - {signedBlindedBlock}, + {signedBlindedBlock, sszBytes}, {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..89394dbcfab 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, + sszBytes?: Uint8Array | null + ): Promise; }