Check return and request lengths for blob sidecar by root (#13106)

This commit is contained in:
terencechain 2023-10-24 08:02:44 -07:00 committed by GitHub
parent 45f68fa8d5
commit a2f60364ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@ package sync
import (
"context"
"fmt"
libp2pcore "github.com/libp2p/go-libp2p/core"
"github.com/libp2p/go-libp2p/core/peer"
@ -159,11 +160,14 @@ func (s *Service) sendAndSaveBlobSidecars(ctx context.Context, request types.Blo
if err != nil {
return err
}
if len(sidecars) != len(request) {
return fmt.Errorf("received %d blob sidecars, expected %d for RPC", len(sidecars), len(request))
}
for _, sidecar := range sidecars {
if err := verify.BlobAlignsWithBlock(sidecar, RoBlock); err != nil {
return err
}
log.WithFields(blobFields(sidecar)).Debug("Received blob sidecar gossip RPC")
log.WithFields(blobFields(sidecar)).Debug("Received blob sidecar RPC")
}
return s.cfg.beaconDB.SaveBlobSidecar(ctx, sidecars)