fix validation of blob index against gossip topic (#5569)

In `v1.4.0-alpha.0`, the blob index validation on gossip was changed to
use `compute_subnet_for_blob_sidecar` instead of having a separate topic
for each individual blob. We updated the spec reference in #5363 without
updating the code accordingly. Fixing this now, and also adding the new
`MAX_BLOBS_PER_BLOCK` check from `v1.4.0-beta.3` as it shares the theme.
This commit is contained in:
Etan Kissling 2023-11-05 09:14:47 +01:00 committed by GitHub
parent 28b84ff93b
commit e4dacc30c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 7 deletions

View File

@ -312,15 +312,19 @@ proc validateBlobSidecar*(
# an `EpochRef` and checking signatures. This reordering might lead to # an `EpochRef` and checking signatures. This reordering might lead to
# different IGNORE/REJECT results in turn affecting gossip scores. # different IGNORE/REJECT results in turn affecting gossip scores.
# [REJECT] The sidecar is for the correct topic -- # [REJECT] The sidecar's index is consistent with `MAX_BLOBS_PER_BLOCK`
# i.e. sidecar.index matches the topic {index}. # -- i.e. `blob_sidecar.index < MAX_BLOBS_PER_BLOCK`
if sbs.message.index != subnet_id: if not (sbs.message.index < MAX_BLOBS_PER_BLOCK):
return dag.checkedReject("SignedBlobSidecar: mismatched gossip topic index") return dag.checkedReject("SignedBlobSidecar: index inconsistent")
# [REJECT] The sidecar is for the correct subnet -- i.e.
# `compute_subnet_for_blob_sidecar(blob_sidecar.index) == subnet_id`.
if not (compute_subnet_for_blob_sidecar(sbs.message.index) == subnet_id):
return dag.checkedReject("SignedBlobSidecar: subnet incorrect")
# [IGNORE] The sidecar is not from a future slot (with a # [IGNORE] The sidecar is not from a future slot (with a
# MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance) -- i.e. validate that # `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance) -- i.e. validate that
# sidecar.slot <= current_slot (a client MAY queue future sidecars # `block_header.slot <= current_slot` (a client MAY queue future sidecars
# for processing at the appropriate slot).
if not (sbs.message.slot <= if not (sbs.message.slot <=
(wallTime + MAXIMUM_GOSSIP_CLOCK_DISPARITY).slotOrZero): (wallTime + MAXIMUM_GOSSIP_CLOCK_DISPARITY).slotOrZero):
return errIgnore("SignedBlobSidecar: slot too high") return errIgnore("SignedBlobSidecar: slot too high")