Skip to content

Commit

Permalink
When producing a block to propose, assign blobKzgCommitments from Eng…
Browse files Browse the repository at this point in the history
…ine API getBlobsBundle response
  • Loading branch information
dgcoffman committed Nov 7, 2022
1 parent 6a7630f commit a83df9e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
phase0,
allForks,
altair,
eip4844,
Root,
RootHex,
Slot,
Expand Down Expand Up @@ -185,16 +186,20 @@ export async function produceBlockBody<T extends BlockType>(
// See: https://discord.com/channels/595666850260713488/892088344438255616/1009882079632314469
await sleep(PAYLOAD_GENERATION_TIME_MS);
}
const payload = await this.executionEngine.getPayload(payloadId);

const payload = await this.executionEngine.getPayload(payloadId);
console.log(`getPayload returned for payloadId: ${payloadId}`);
(blockBody as allForks.ExecutionBlockBody).executionPayload = payload;

// TODO EIP-4844 -- only make this call for EIP-4844 (based on state? Or block version?)
const blobsBundle = await this.executionEngine.getBlobsBundle(payloadId);

console.log("Also got blobs bundle!", blobsBundle);
// TODO EIP-4844: Actually all forks after EIP-4844
if (forkName === ForkName.eip4844) {
console.log("Dispatching request to Engine API to get blobs");
const blobsBundle = await this.executionEngine.getBlobsBundle(payloadId);
console.log("Got blobs bundle", blobsBundle);

(blockBody as allForks.ExecutionBlockBody).executionPayload = payload;
// TODO EIP-4844: Optional (do it in a follow-up): sanity-check that the KZG commitments match blob contents as described by the spec
(blockBody as eip4844.BeaconBlockBody).blobKzgCommitments = blobsBundle.kzgs;
}

const fetchedTime = Date.now() / 1000 - computeTimeAtSlot(this.config, blockSlot, this.genesisTime);
this.metrics?.blockPayload.payloadFetchedTime.observe({prepType}, fetchedTime);
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export {ts as phase0} from "./phase0/index.js";
export {ts as altair} from "./altair/index.js";
export {ts as bellatrix} from "./bellatrix/index.js";
export {ts as capella} from "./capella/index.js";
export {ts as eip4844} from "./eip4844/index.js";

export {ts as allForks} from "./allForks/index.js";

Expand Down

0 comments on commit a83df9e

Please sign in to comment.