Skip to content

Commit

Permalink
feat: forward blinded block ssz bytes to submitBlindedBlock api
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Oct 21, 2024
1 parent 0e4ea98 commit 0073c2a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/api/src/builder/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -138,10 +138,10 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
signedBlindedBlock: getExecutionForkTypes(fork).SignedBlindedBeaconBlock.fromJson(body),
};
},
writeReqSsz: ({signedBlindedBlock}) => {
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,
},
Expand Down
7 changes: 4 additions & 3 deletions packages/beacon-node/src/api/impl/beacon/blocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -507,13 +507,14 @@ export function getBeaconBlockApi({

async function reconstructBuilderBlockOrContents(
chain: ApiModules["chain"],
signedBlindedBlock: SignedBlindedBeaconBlock
signedBlindedBlock: SignedBlindedBeaconBlock,
sszBytes?: Uint8Array | null
): Promise<SignedBeaconBlockOrContents> {
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;
}
7 changes: 5 additions & 2 deletions packages/beacon-node/src/execution/builder/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,12 @@ export class ExecutionBuilderHttp implements IExecutionBuilder {
return {header, executionPayloadValue, blobKzgCommitments, executionRequests};
}

async submitBlindedBlock(signedBlindedBlock: SignedBlindedBeaconBlock): Promise<SignedBeaconBlockOrContents> {
async submitBlindedBlock(
signedBlindedBlock: SignedBlindedBeaconBlock,
sszBytes?: Uint8Array | null
): Promise<SignedBeaconBlockOrContents> {
const res = await this.api.submitBlindedBlock(
{signedBlindedBlock},
{signedBlindedBlock, sszBytes},
{retries: 2, requestWireFormat: this.sszSupported ? WireFormat.ssz : WireFormat.json}
);

Expand Down
5 changes: 4 additions & 1 deletion packages/beacon-node/src/execution/builder/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,8 @@ export interface IExecutionBuilder {
blobKzgCommitments?: deneb.BlobKzgCommitments;
executionRequests?: electra.ExecutionRequests;
}>;
submitBlindedBlock(signedBlock: SignedBlindedBeaconBlock): Promise<SignedBeaconBlockOrContents>;
submitBlindedBlock(
signedBlindedBlock: SignedBlindedBeaconBlock,
sszBytes?: Uint8Array | null
): Promise<SignedBeaconBlockOrContents>;
}

0 comments on commit 0073c2a

Please sign in to comment.