From e0b6e285c375c2823f31c87e5cc69bbd7308ea4c Mon Sep 17 00:00:00 2001 From: g11tech Date: Thu, 15 Feb 2024 18:43:08 +0530 Subject: [PATCH] fix: publish blobs sooner than later (#6431) --- packages/beacon-node/src/api/impl/beacon/blocks/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 6fde04bc737c..d4aa2337fe3f 100644 --- a/packages/beacon-node/src/api/impl/beacon/blocks/index.ts +++ b/packages/beacon-node/src/api/impl/beacon/blocks/index.ts @@ -179,6 +179,13 @@ export function getBeaconBlockApi({ const publishPromises = [ // Send the block, regardless of whether or not it is valid. The API // specification is very clear that this is the desired behaviour. + // + // i) Publish blobs and block before importing so that network can see them asap + // ii) publish blobs first because + // a) by the times nodes see block, they might decide to pull blobs + // b) they might require more hops to reach recipients in peerDAS kind of setup where + // blobs might need to hop between nodes because of partial subnet subscription + ...blobSidecars.map((blobSidecar) => () => network.publishBlobSidecar(blobSidecar)), () => network.publishBeaconBlock(signedBlock) as Promise, () => // there is no rush to persist block since we published it to gossip anyway @@ -191,7 +198,6 @@ export function getBeaconBlockApi({ } throw e; }), - ...blobSidecars.map((blobSidecar) => () => network.publishBlobSidecar(blobSidecar)), ]; await promiseAllMaybeAsync(publishPromises); };