Repository navigation
fix: process fulu data columns without waiting for block #9166
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
Changes from 1 commit
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 | ||
|---|---|---|---|---|
|
|
@@ -524,6 +524,7 @@ export function getSlotFromBlobSidecarSerialized(data: Uint8Array): Slot | null | |||
| const SLOT_BYTES_POSITION_IN_SIGNED_DATA_COLUMN_SIDECAR_PRE_GLOAS = 20; | ||||
| const SLOT_BYTES_POSITION_IN_SIGNED_DATA_COLUMN_SIDECAR_POST_GLOAS = 16; | ||||
| const BEACON_BLOCK_ROOT_POSITION_IN_GLOAS_DATA_COLUMN_SIDECAR = 24; | ||||
| const BEACON_BLOCK_HEADER_SIZE = SLOT_SIZE + 8 + ROOT_SIZE + ROOT_SIZE + ROOT_SIZE; | ||||
|
|
||||
| export function getSlotFromDataColumnSidecarSerialized(data: Uint8Array, fork: ForkName): Slot | null { | ||||
| const offset = isForkPostGloas(fork) | ||||
|
|
@@ -551,6 +552,22 @@ export function getBeaconBlockRootFromDataColumnSidecarSerialized(data: Uint8Arr | |||
| return "0x" + blockRootBuf.toString("hex"); | ||||
| } | ||||
|
|
||||
| export function getBeaconBlockRootFromFuluDataColumnSidecarSerialized(data: Uint8Array): RootHex | null { | ||||
| if (data.length < SLOT_BYTES_POSITION_IN_SIGNED_DATA_COLUMN_SIDECAR_PRE_GLOAS + BEACON_BLOCK_HEADER_SIZE) { | ||||
| return null; | ||||
| } | ||||
|
|
||||
| const blockHeader = ssz.phase0.BeaconBlockHeader.deserialize( | ||||
| data.subarray( | ||||
| SLOT_BYTES_POSITION_IN_SIGNED_DATA_COLUMN_SIDECAR_PRE_GLOAS, | ||||
| SLOT_BYTES_POSITION_IN_SIGNED_DATA_COLUMN_SIDECAR_PRE_GLOAS + BEACON_BLOCK_HEADER_SIZE | ||||
| ) | ||||
| ); | ||||
| const blockRoot = ssz.phase0.BeaconBlockHeader.hashTreeRoot(blockHeader); | ||||
|
Member
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. so now we have to do a hashTreeRoot() here which is not cheap
Member
Author
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. yep same concern I had here #9166 (comment), I guess this becomes unnecessary if we do not extract the root since it's skipped anyways here
if there is no root extracted |
||||
| blockRootBuf.set(blockRoot); | ||||
| return `0x${blockRootBuf.toString("hex")}`; | ||||
| } | ||||
|
|
||||
| /** | ||||
| * SignedExecutionPayloadEnvelope SSZ Layout: | ||||
| * ├─ 4 bytes: message offset (points to byte 100) | ||||
|
|
||||
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.
getBeaconBlockRootFromFuluDataColumnSidecarSerialized()now callsssz.phase0.BeaconBlockHeader.deserialize(...)directly during the network pre-processing path, but this helper is expected to be non-throwing (all other extractors returnnullfor invalid input). A malformed sidecar with valid length but invalid header encoding can make this deserialize call throw, andonPendingGossipsubMessagedoes not catch extractor errors, so untrusted gossip can abort processing instead of being handled as invalid gossip. Please wrap this deserialize in atry/catchand returnnullon parse failure.Useful? React with 👍 / 👎.
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.
I guess this is valid, also calling
hashTreeRoot()here might be a concern in general since we wanna avoid expensive work