Skip to content

Commit

Permalink
fixup! BlobSidecarsByRoot RPC handler
Browse files Browse the repository at this point in the history
  • Loading branch information
kasey committed Jun 12, 2023
1 parent 424730f commit ef74fbb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions beacon-chain/sync/rpc_blob_sidecars_by_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ func (s *Service) blobSidecarByRootRPCHandler(ctx context.Context, msg interface
}

blobIdents := *ref
if uint64(len(blobIdents)) > params.BeaconNetworkConfig().MaxRequestBlobsSidecars {
if err := validateBlobByRootRequest(blobIdents); err != nil {
s.cfg.p2p.Peers().Scorers().BadResponsesScorer().Increment(stream.Conn().RemotePeer())
s.writeErrorResponseToStream(responseCodeInvalidRequest, types.ErrMaxBlobReqExceeded.Error(), stream)
return types.ErrMaxBlobReqExceeded
s.writeErrorResponseToStream(responseCodeInvalidRequest, err.Error(), stream)
}
// Sort the identifiers so that requests for the same blob root will be adjacent, minimizing db lookups.
sort.Sort(blobIdents)
Expand Down Expand Up @@ -123,3 +122,10 @@ func (s *Service) blobSidecarByRootRPCHandler(ctx context.Context, msg interface
closeStream(stream, log)
return nil
}

func validateBlobByRootRequest(blobIdents types.BlobSidecarsByRootReq) error {
if uint64(len(blobIdents)) > params.BeaconNetworkConfig().MaxRequestBlobsSidecars {
return types.ErrMaxBlobReqExceeded
}
return nil
}

0 comments on commit ef74fbb

Please sign in to comment.