Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds additional metrics to the batch-posting path #2369

Merged
merged 6 commits into from
Jun 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ var (
blobGasLimitGauge = metrics.NewRegisteredGauge("arb/batchposter/blobgas/limit", nil)
suggestedTipCapGauge = metrics.NewRegisteredGauge("arb/batchposter/suggestedtipcap", nil)

batchPosterEstimatedBatchBacklogGauge = metrics.NewRegisteredGauge("arb/batchposter/estimated_batch_backlog", nil)

batchPosterDALastSuccessfulActionGauge = metrics.NewRegisteredGauge("arb/batchPoster/action/da_last_success", nil)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding a last successful batch posting metric would also make sense to complement this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little tricky to add last success, because sending it to the dataposter successfully != the batch posting successfully as its asynchronous.

batchPosterDASuccessCounter = metrics.NewRegisteredCounter("arb/batchPoster/action/da_success", nil)
batchPosterDAFailureCounter = metrics.NewRegisteredCounter("arb/batchPoster/action/da_failure", nil)

batchPosterFailureCounter = metrics.NewRegisteredCounter("arb/batchPoster/action/failure", nil)

usableBytesInBlob = big.NewInt(int64(len(kzg4844.Blob{}) * 31 / 32))
blobTxBlobGasPerBlob = big.NewInt(params.BlobTxBlobGasPerBlob)
)
Expand Down Expand Up @@ -1243,6 +1251,7 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
// don't post anything for now
return false, nil
}

sequencerMsg, err := b.building.segments.CloseAndGetBytes()
if err != nil {
return false, err
Expand All @@ -1260,15 +1269,21 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)

gotNonce, gotMeta, err := b.dataPoster.GetNextNonceAndMeta(ctx)
if err != nil {
batchPosterDAFailureCounter.Inc(1)
return false, err
}
if nonce != gotNonce || !bytes.Equal(batchPositionBytes, gotMeta) {
batchPosterDAFailureCounter.Inc(1)
return false, fmt.Errorf("%w: nonce changed from %d to %d while creating batch", storage.ErrStorageRace, nonce, gotNonce)
}
sequencerMsg, err = b.dapWriter.Store(ctx, sequencerMsg, uint64(time.Now().Add(config.DASRetentionPeriod).Unix()), []byte{}, config.DisableDapFallbackStoreDataOnChain)
if err != nil {
batchPosterDAFailureCounter.Inc(1)
return false, err
}

batchPosterDASuccessCounter.Inc(1)
batchPosterDALastSuccessfulActionGauge.Update(time.Now().Unix())
}

prevMessageCount := batchPosition.MessageCount
Expand Down Expand Up @@ -1384,6 +1399,7 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
messagesPerBatch = 1
}
backlog := uint64(unpostedMessages) / messagesPerBatch
batchPosterEstimatedBatchBacklogGauge.Update(int64(backlog))
if backlog > 10 {
logLevel := log.Warn
if recentlyHitL1Bounds {
Expand Down Expand Up @@ -1496,6 +1512,7 @@ func (b *BatchPoster) Start(ctxIn context.Context) {
logLevel = normalGasEstimationFailedEphemeralErrorHandler.LogLevel(err, logLevel)
logLevel = accumulatorNotFoundEphemeralErrorHandler.LogLevel(err, logLevel)
logLevel("error posting batch", "err", err)
batchPosterFailureCounter.Inc(1)
return b.config().ErrorDelay
} else if posted {
return 0
Expand Down
Loading