-
-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: pull block from peers after a cutoff if corresponding gossip blobs are seen #6534
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import {fromHexString} from "@chainsafe/ssz"; | ||
import {ChainForkConfig} from "@lodestar/config"; | ||
import {phase0, deneb} from "@lodestar/types"; | ||
import {ForkSeq} from "@lodestar/params"; | ||
import {BlockInput, BlockInputType, BlockSource, getBlockInputBlobs, getBlockInput} from "../../chain/blocks/types.js"; | ||
import { | ||
BlockInput, | ||
BlockInputType, | ||
BlockSource, | ||
getBlockInputBlobs, | ||
getBlockInput, | ||
NullBlockInput, | ||
} from "../../chain/blocks/types.js"; | ||
import {PeerIdStr} from "../../util/peerId.js"; | ||
import {INetwork} from "../interface.js"; | ||
import {BlockInputAvailabilitySource} from "../../chain/seenCache/seenGossipBlockInput.js"; | ||
|
@@ -46,16 +54,26 @@ export async function unavailableBeaconBlobsByRoot( | |
config: ChainForkConfig, | ||
network: INetwork, | ||
peerId: PeerIdStr, | ||
unavailableBlockInput: BlockInput, | ||
unavailableBlockInput: BlockInput | NullBlockInput, | ||
metrics: Metrics | null | ||
): Promise<BlockInput> { | ||
if (unavailableBlockInput.type !== BlockInputType.blobsPromise) { | ||
return unavailableBlockInput; | ||
if (unavailableBlockInput.block !== null && unavailableBlockInput.type !== BlockInputType.blobsPromise) { | ||
return unavailableBlockInput as BlockInput; | ||
} | ||
|
||
const blobIdentifiers: deneb.BlobIdentifier[] = []; | ||
const {block, blobsCache, resolveAvailability, blockBytes} = unavailableBlockInput; | ||
// resolve the block if thats unavailable | ||
let block, blobsCache, blockBytes, resolveAvailability; | ||
if (unavailableBlockInput.block === null) { | ||
const allBlocks = await network.sendBeaconBlocksByRoot(peerId, [fromHexString(unavailableBlockInput.blockRootHex)]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now the block source for block, we want to know if it comes from gossip, or this function, or the above same for blobs, we want to know % of them coming from 3 different places as above if it's too much for this PR please have a follow up PR or track in another issue @g11tech There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes lets do a followup on this |
||
block = allBlocks[0].data; | ||
blockBytes = allBlocks[0].bytes; | ||
({blobsCache, resolveAvailability} = unavailableBlockInput); | ||
} else { | ||
({block, blobsCache, resolveAvailability, blockBytes} = unavailableBlockInput); | ||
} | ||
|
||
// resolve missing blobs | ||
const blobIdentifiers: deneb.BlobIdentifier[] = []; | ||
const slot = block.message.slot; | ||
const blockRoot = config.getForkTypes(slot).BeaconBlock.hashTreeRoot(block.message); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after block comes and there are not enough blobs, we already emit this event in
handleValidBeaconBlock()
, then we also emit it here. Is this a duplicate?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is a duplicate aimed to add this peer to the peers for unknown blobs pull