Skip to content

Commit 9bc6311

Browse files
authored
fix(metrics): proper count of pending blobs metrics (#3038)
* fix(metrics): proper count of pending blobs metrics * cl * remove unused
1 parent 5506eb0 commit 9bc6311

File tree

9 files changed

+7
-89
lines changed

9 files changed

+7
-89
lines changed

.claude/skills/ev-node-explainer/block-architecture.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type Component interface {
5151
```
5252

5353
Startup order:
54+
5455
1. Cache Manager (loads persisted state)
5556
2. Syncer (begins sync workers)
5657
3. Executor (begins production loop) - Aggregator only
@@ -476,10 +477,6 @@ var (
476477
DARetrievalFailures = prometheus.NewCounter(...)
477478
DAInclusionHeight = prometheus.NewGauge(...)
478479

479-
// Cache metrics
480-
PendingHeadersCount = prometheus.NewGauge(...)
481-
PendingDataCount = prometheus.NewGauge(...)
482-
483480
// Forced inclusion
484481
ForcedInclusionTxsInGracePeriod = prometheus.NewGauge(...)
485482
ForcedInclusionTxsMalicious = prometheus.NewCounter(...)

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
- Improve cache handling when there is a significant backlog of pending headers and data. ([#3030](https://github.com/evstack/ev-node/pull/3030))
1515
- Decrease MaxBytesSize to `5MB` to increase compatibility with public nodes. ([#3030](https://github.com/evstack/ev-node/pull/3030))
16+
- Proper counting of `DASubmitterPendingBlobs` metrics. [#3038](https://github.com/evstack/ev-node/pull/3038)
1617

1718
## v1.0.0-rc.1
1819

block/internal/common/metrics.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ type Metrics struct {
6363
DARetrievalSuccesses metrics.Counter
6464
DARetrievalFailures metrics.Counter
6565
DAInclusionHeight metrics.Gauge
66-
PendingHeadersCount metrics.Gauge
67-
PendingDataCount metrics.Gauge
6866

6967
// Forced inclusion metrics
7068
ForcedInclusionTxsInGracePeriod metrics.Gauge // Number of forced inclusion txs currently in grace period
@@ -172,20 +170,6 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
172170
Help: "Height at which all blocks have been included in DA",
173171
}, labels).With(labelsAndValues...)
174172

175-
m.PendingHeadersCount = prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
176-
Namespace: namespace,
177-
Subsystem: MetricsSubsystem,
178-
Name: "pending_headers_count",
179-
Help: "Number of headers pending DA submission",
180-
}, labels).With(labelsAndValues...)
181-
182-
m.PendingDataCount = prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
183-
Namespace: namespace,
184-
Subsystem: MetricsSubsystem,
185-
Name: "pending_data_count",
186-
Help: "Number of data blocks pending DA submission",
187-
}, labels).With(labelsAndValues...)
188-
189173
// Forced inclusion metrics
190174
m.ForcedInclusionTxsInGracePeriod = prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
191175
Namespace: namespace,
@@ -259,8 +243,6 @@ func NopMetrics() *Metrics {
259243
DARetrievalSuccesses: discard.NewCounter(),
260244
DARetrievalFailures: discard.NewCounter(),
261245
DAInclusionHeight: discard.NewGauge(),
262-
PendingHeadersCount: discard.NewGauge(),
263-
PendingDataCount: discard.NewGauge(),
264246
DASubmitterFailures: make(map[DASubmitterFailureReason]metrics.Counter),
265247
DASubmitterLastFailure: make(map[DASubmitterFailureReason]metrics.Gauge),
266248
DASubmitterPendingBlobs: discard.NewGauge(),

block/internal/common/metrics_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ func TestMetrics(t *testing.T) {
3030
assert.NotNil(t, em.DARetrievalSuccesses)
3131
assert.NotNil(t, em.DARetrievalFailures)
3232
assert.NotNil(t, em.DAInclusionHeight)
33-
assert.NotNil(t, em.PendingHeadersCount)
34-
assert.NotNil(t, em.PendingDataCount)
3533
})
3634

3735
t.Run("NopMetrics", func(t *testing.T) {
@@ -56,8 +54,6 @@ func TestMetrics(t *testing.T) {
5654
assert.NotNil(t, em.DARetrievalSuccesses)
5755
assert.NotNil(t, em.DARetrievalFailures)
5856
assert.NotNil(t, em.DAInclusionHeight)
59-
assert.NotNil(t, em.PendingHeadersCount)
60-
assert.NotNil(t, em.PendingDataCount)
6157

6258
// Verify no-op metrics don't panic when used
6359
em.Height.Set(100)
@@ -113,8 +109,6 @@ func TestMetricsIntegration(t *testing.T) {
113109
em.DARetrievalSuccesses.Add(9)
114110
em.DARetrievalFailures.Add(1)
115111
em.DAInclusionHeight.Set(995)
116-
em.PendingHeadersCount.Set(3)
117-
em.PendingDataCount.Set(2)
118112
}
119113

120114
func TestMetricsSubsystem(t *testing.T) {

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
}

docs/learn/specs/block-manager.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,15 +682,14 @@ The block components expose comprehensive metrics for monitoring through the sha
682682

683683
### DA Metrics (Submitter and Syncer Components)
684684

685+
- `da_submitter_pending_blobs`: Total of Header/Data pending blobs
685686
- `da_submission_attempts_total`: Total DA submission attempts
686687
- `da_submission_success_total`: Successful DA submissions
687688
- `da_submission_failure_total`: Failed DA submissions
688689
- `da_retrieval_attempts_total`: Total DA retrieval attempts
689690
- `da_retrieval_success_total`: Successful DA retrievals
690691
- `da_retrieval_failure_total`: Failed DA retrievals
691692
- `da_height`: Current DA retrieval height
692-
- `pending_headers_count`: Number of headers pending DA submission
693-
- `pending_data_count`: Number of data blocks pending DA submission
694693

695694
### Sync Metrics (Syncer Component)
696695

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)