Skip to content

Commit

Permalink
processBlocks for 4844 blocks. Do not compute aggregate proof for emp…
Browse files Browse the repository at this point in the history
…ty array (it crashes)
  • Loading branch information
dgcoffman committed Nov 8, 2022
1 parent aee7d95 commit 656b7d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
16 changes: 14 additions & 2 deletions packages/beacon-node/src/api/impl/beacon/blocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,25 @@ export function getBeaconBlockApi({
},

async publishBlockWithBlobs(signedBeaconBlockAndBlobsSidecar) {
const {message} = signedBeaconBlockAndBlobsSidecar.beaconBlock;
const {beaconBlock} = signedBeaconBlockAndBlobsSidecar;
const {message} = beaconBlock;

const seenTimestampSec = Date.now() / 1000;
await waitForSlot(message.slot);

metrics?.registerBeaconBlock(OpSource.api, seenTimestampSec, message);

await Promise.all([network.gossip.publishSignedBeaconBlockAndBlobsSidecar(signedBeaconBlockAndBlobsSidecar)]);
await Promise.all([
network.gossip.publishSignedBeaconBlockAndBlobsSidecar(signedBeaconBlockAndBlobsSidecar),
// TODO EIP-4844 processBlock for signedBeaconBlockAndBlobsSidecar
// We need to save the blob?
chain.processBlock(beaconBlock).catch((e) => {
if (e instanceof BlockError && e.type.code === BlockErrorCode.PARENT_UNKNOWN) {
network.events.emit(NetworkEvent.unknownBlockParent, beaconBlock, network.peerId.toString());
}
throw e;
}),
]);
},
};
}
8 changes: 7 additions & 1 deletion packages/validator/src/services/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,13 @@ export class BlockProposingService {
blobsSidecar.beaconBlockRoot = blindedOrFullBlockHashTreeRoot(this.config, block);
blobsSidecar.beaconBlockSlot = block.slot;
blobsSidecar.blobs = blobs;
blobsSidecar.kzgAggregatedProof = computeAggregateKzgProof(blobs);

// c-kzg throws an error:
// free(): invalid next size (fast)
// when computeAggregateKzgProof is called with [] blobs
blobsSidecar.kzgAggregatedProof = blobs.length
? computeAggregateKzgProof(blobs)
: ssz.eip4844.KZGProof.defaultValue();

return blobsSidecar;
}
Expand Down

0 comments on commit 656b7d3

Please sign in to comment.