@@ -43,6 +43,11 @@ import (
4343 "github.com/smartcontractkit/chainlink/v2/core/logger"
4444)
4545
46+ const (
47+ blobBroadcastTimeout = 2 * time .Second
48+ maxConcurrentBlobBroadcasts = 10
49+ )
50+
4651var (
4752 isValidIDComponent = regexp .MustCompile (`^[a-zA-Z0-9_]+$` ).MatchString
4853)
@@ -544,11 +549,12 @@ func (r *ReportingPlugin) Observation(ctx context.Context, seqNr uint64, aq type
544549// broadcastBlobPayloads broadcasts each payload as a blob in parallel to reduce
545550// Observation() latency (shortening this phase helps the OCR round finish within
546551// DeltaProgress). Each call is given a 2-second timeout so that a single slow
547- // broadcast cannot stall the entire batch. Individual broadcast failures are logged
548- // and skipped rather than aborting the entire observation, so that one problematic
549- // payload does not prevent the remaining items from being observed. Context
550- // cancellation/deadline errors on the parent context are propagated immediately so
551- // that expired rounds fail fast.
552+ // broadcast cannot stall the entire batch. No more than 10 broadcasts are allowed
553+ // in flight at a time. Individual broadcast failures are logged and skipped rather
554+ // than aborting the entire observation, so that one problematic payload does not
555+ // prevent the remaining items from being observed. Context cancellation/deadline
556+ // errors on the parent context are propagated immediately so that expired rounds
557+ // fail fast.
552558func (r * ReportingPlugin ) broadcastBlobPayloads (
553559 ctx context.Context ,
554560 fetcher ocr3_1types.BlobBroadcastFetcher ,
@@ -563,11 +569,12 @@ func (r *ReportingPlugin) broadcastBlobPayloads(
563569 r .lggr .Debugw ("observation blob broadcast finished" , "seqNr" , seqNr , "blobCount" , len (payloads ), "elapsed" , time .Since (start ))
564570 }()
565571
566- const perBlobTimeout = 2 * time .Second
567572 var g errgroup.Group
573+ g .SetLimit (maxConcurrentBlobBroadcasts )
568574 for i , payload := range payloads {
575+ requestID := requestIDs [i ]
569576 g .Go (func () error {
570- broadcastCtx , cancel := context .WithTimeout (ctx , perBlobTimeout )
577+ broadcastCtx , cancel := context .WithTimeout (ctx , blobBroadcastTimeout )
571578 defer cancel ()
572579
573580 blobHandle , err := fetcher .BroadcastBlob (broadcastCtx , payload , ocr3_1types.BlobExpirationHintSequenceNumber {SeqNr : seqNr + 2 })
@@ -577,7 +584,7 @@ func (r *ReportingPlugin) broadcastBlobPayloads(
577584 }
578585 r .lggr .Warnw ("failed to broadcast pending queue item as blob, skipping" ,
579586 "seqNr" , seqNr ,
580- "requestID" , requestIDs [ i ] ,
587+ "requestID" , requestID ,
581588 "err" , err )
582589 return nil
583590 }
@@ -586,7 +593,7 @@ func (r *ReportingPlugin) broadcastBlobPayloads(
586593 if err != nil {
587594 r .lggr .Warnw ("failed to marshal blob handle, skipping" ,
588595 "seqNr" , seqNr ,
589- "requestID" , requestIDs [ i ] ,
596+ "requestID" , requestID ,
590597 "err" , err )
591598 return nil
592599 }
0 commit comments