Skip to content

Commit 1aa2af4

Browse files
committed
fix(metrics): proper count of pending blobs metrics
1 parent 455b6c1 commit 1aa2af4

File tree

4 files changed

+4
-59
lines changed

4 files changed

+4
-59
lines changed

block/internal/submitting/da_submitter.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ func (s *DASubmitter) SubmitHeaders(ctx context.Context, headers []*types.Signed
235235
"header",
236236
s.client.GetHeaderNamespace(),
237237
[]byte(s.config.DA.SubmitOptions),
238-
func() uint64 { return cache.NumPendingHeaders() },
239238
)
240239
}
241240

@@ -435,7 +434,6 @@ func (s *DASubmitter) SubmitData(ctx context.Context, unsignedDataList []*types.
435434
"data",
436435
s.client.GetDataNamespace(),
437436
[]byte(s.config.DA.SubmitOptions),
438-
func() uint64 { return cache.NumPendingData() },
439437
)
440438
}
441439

@@ -545,7 +543,6 @@ func submitToDA[T any](
545543
itemType string,
546544
namespace []byte,
547545
options []byte,
548-
getTotalPendingFn func() uint64,
549546
) error {
550547
if len(items) != len(marshaled) {
551548
return fmt.Errorf("items length (%d) does not match marshaled length (%d)", len(items), len(marshaled))
@@ -570,11 +567,6 @@ func submitToDA[T any](
570567
marshaled = batchMarshaled
571568
}
572569

573-
// Update pending blobs metric to track total backlog
574-
if getTotalPendingFn != nil {
575-
s.metrics.DASubmitterPendingBlobs.Set(float64(getTotalPendingFn()))
576-
}
577-
578570
// Start the retry loop
579571
for rs.Attempt < pol.MaxAttempts {
580572
// Record resend metric for retry attempts (not the first attempt)
@@ -615,20 +607,12 @@ func submitToDA[T any](
615607
s.logger.Info().Str("itemType", itemType).Uint64("count", res.SubmittedCount).Msg("successfully submitted items to DA layer")
616608
if int(res.SubmittedCount) == len(items) {
617609
rs.Next(reasonSuccess, pol)
618-
// Update pending blobs metric to reflect total backlog
619-
if getTotalPendingFn != nil {
620-
s.metrics.DASubmitterPendingBlobs.Set(float64(getTotalPendingFn()))
621-
}
622610
return nil
623611
}
624612
// partial success: advance window
625613
items = items[res.SubmittedCount:]
626614
marshaled = marshaled[res.SubmittedCount:]
627615
rs.Next(reasonSuccess, pol)
628-
// Update pending blobs count to reflect total backlog
629-
if getTotalPendingFn != nil {
630-
s.metrics.DASubmitterPendingBlobs.Set(float64(getTotalPendingFn()))
631-
}
632616

633617
case datypes.StatusTooBig:
634618
// Record failure metric
@@ -649,10 +633,6 @@ func submitToDA[T any](
649633
marshaled = marshaled[:half]
650634
s.logger.Debug().Int("newBatchSize", half).Msg("batch too big; halving and retrying")
651635
rs.Next(reasonTooBig, pol)
652-
// Update pending blobs count to reflect total backlog
653-
if getTotalPendingFn != nil {
654-
s.metrics.DASubmitterPendingBlobs.Set(float64(getTotalPendingFn()))
655-
}
656636

657637
case datypes.StatusNotIncludedInBlock:
658638
// Record failure metric

block/internal/submitting/da_submitter_mocks_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ func TestSubmitToDA_MempoolRetry_IncreasesGasAndSucceeds(t *testing.T) {
8080
"item",
8181
nsBz,
8282
opts,
83-
nil,
8483
)
8584
assert.NoError(t, err)
8685

@@ -129,7 +128,6 @@ func TestSubmitToDA_UnknownError_RetriesSameGasThenSucceeds(t *testing.T) {
129128
"item",
130129
nsBz,
131130
opts,
132-
nil,
133131
)
134132
assert.NoError(t, err)
135133
assert.Equal(t, []float64{-1, -1}, usedGas)
@@ -180,7 +178,6 @@ func TestSubmitToDA_TooBig_HalvesBatch(t *testing.T) {
180178
"item",
181179
nsBz,
182180
opts,
183-
nil,
184181
)
185182
assert.NoError(t, err)
186183
assert.Equal(t, []int{4, 2}, batchSizes)
@@ -225,7 +222,6 @@ func TestSubmitToDA_SentinelNoGas_PreservesGasAcrossRetries(t *testing.T) {
225222
"item",
226223
nsBz,
227224
opts,
228-
nil,
229225
)
230226
assert.NoError(t, err)
231227
assert.Equal(t, []float64{-1, -1}, usedGas)
@@ -269,7 +265,6 @@ func TestSubmitToDA_PartialSuccess_AdvancesWindow(t *testing.T) {
269265
"item",
270266
nsBz,
271267
opts,
272-
nil,
273268
)
274269
assert.NoError(t, err)
275270
assert.Equal(t, 3, totalSubmitted)

block/internal/submitting/submitter.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ func (s *Submitter) daSubmissionLoop() {
185185
case <-ticker.C:
186186
// Check if we should submit headers based on batching strategy
187187
headersNb := s.cache.NumPendingHeaders()
188+
188189
if headersNb > 0 {
189190
lastSubmitNanos := s.lastHeaderSubmit.Load()
190191
timeSinceLastSubmit := time.Since(time.Unix(0, lastSubmitNanos))
@@ -305,6 +306,9 @@ func (s *Submitter) daSubmissionLoop() {
305306
}()
306307
}
307308
}
309+
310+
// Update metrics with current pending counts
311+
s.metrics.DASubmitterPendingBlobs.Set(float64(headersNb + dataNb))
308312
}
309313
}
310314
}

test/mocks/store.go

Lines changed: 0 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)