Fix blob sidecar subnet check (#13102)

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
terencechain 2023-10-23 16:08:25 -07:00 committed by GitHub
parent 00826e8858
commit f55708b995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,8 +61,8 @@ func (s *Service) validateBlob(ctx context.Context, pid peer.ID, msg *pubsub.Mes
}
blob := sBlob.Message
// [REJECT] The sidecar is for the correct topic -- i.e. sidecar.index matches the topic {index}.
want := fmt.Sprintf("blob_sidecar_%d", blob.Index)
// [REJECT] The sidecar is for the correct subnet -- i.e. compute_subnet_for_blob_sidecar(sidecar.index) == subnet_id.
want := fmt.Sprintf("blob_sidecar_%d", computeSubnetForBlobSidecar(blob.Index))
if !strings.Contains(*msg.Topic, want) {
log.WithFields(blobFields(blob)).Debug("Sidecar blob does not match topic")
return pubsub.ValidationReject, fmt.Errorf("wrong topic name: %s", *msg.Topic)
@ -237,3 +237,7 @@ func blobFields(b *eth.BlobSidecar) logrus.Fields {
"index": b.Index,
}
}
func computeSubnetForBlobSidecar(index uint64) uint64 {
return index % params.BeaconConfig().BlobsidecarSubnetCount
}