From e922deaa63f05b7b50d77b1ac1c9de2a3f37d6ad Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Fri, 26 Jul 2024 09:20:44 +0200 Subject: [PATCH] feat(da): add metric for consecutive failed da submissions (#986) --- da/avail/avail.go | 4 ++++ da/celestia/celestia.go | 5 +++++ types/metrics.go | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/da/avail/avail.go b/da/avail/avail.go index c582832d2..ea9f9dd78 100644 --- a/da/avail/avail.go +++ b/da/avail/avail.go @@ -136,6 +136,8 @@ func (c *DataAvailabilityLayerClient) Init(config []byte, pubsubServer *pubsub.S } } + types.RollappConsecutiveFailedDASubmission.Set(0) + c.ctx, c.cancel = context.WithCancel(context.Background()) return nil } @@ -265,6 +267,7 @@ func (c *DataAvailabilityLayerClient) submitBatchLoop(dataBlob []byte) da.Result var err error daBlockHeight, err = c.broadcastTx(dataBlob) if err != nil { + types.RollappConsecutiveFailedDASubmission.Inc() c.logger.Error("broadcasting batch", "error", err) if errors.Is(err, da.ErrTxBroadcastConfigError) { err = retry.Unrecoverable(err) @@ -295,6 +298,7 @@ func (c *DataAvailabilityLayerClient) submitBatchLoop(dataBlob []byte) da.Result c.logger.Error(err.Error()) continue } + types.RollappConsecutiveFailedDASubmission.Set(0) c.logger.Debug("Successfully submitted batch.") return da.ResultSubmitBatch{ diff --git a/da/celestia/celestia.go b/da/celestia/celestia.go index 4a4a89967..e72f85e6a 100644 --- a/da/celestia/celestia.go +++ b/da/celestia/celestia.go @@ -91,6 +91,8 @@ func (c *DataAvailabilityLayerClient) Init(config []byte, pubsubServer *pubsub.S apply(c) } + types.RollappConsecutiveFailedDASubmission.Set(0) + return nil } @@ -203,6 +205,7 @@ func (c *DataAvailabilityLayerClient) SubmitBatch(batch *types.Batch) da.ResultS height, commitment, err := c.submit(data) if err != nil { c.logger.Error("Submit blob.", "error", err) + types.RollappConsecutiveFailedDASubmission.Inc() backoff.Sleep() continue } @@ -219,6 +222,7 @@ func (c *DataAvailabilityLayerClient) SubmitBatch(batch *types.Batch) da.ResultS result := c.CheckBatchAvailability(daMetaData) if result.Code != da.StatusSuccess { c.logger.Error("Check batch availability: submitted batch but did not get availability success status.", "error", err) + types.RollappConsecutiveFailedDASubmission.Inc() backoff.Sleep() continue } @@ -228,6 +232,7 @@ func (c *DataAvailabilityLayerClient) SubmitBatch(batch *types.Batch) da.ResultS c.logger.Debug("Blob availability check passed successfully.") + types.RollappConsecutiveFailedDASubmission.Set(0) return da.ResultSubmitBatch{ BaseResult: da.BaseResult{ Code: da.StatusSuccess, diff --git a/types/metrics.go b/types/metrics.go index 67dd729a9..d4232086d 100644 --- a/types/metrics.go +++ b/types/metrics.go @@ -34,3 +34,8 @@ var RollappPendingSubmissionsSkewNumBytes = promauto.NewGauge(prometheus.GaugeOp Name: "rollapp_pending_submissions_skew_num_bytes", Help: "The number of bytes (of blocks and commits) which have been accumulated but not yet submitted.", }) + +var RollappConsecutiveFailedDASubmission = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "rollapp_consecutive_failed_da_submissions", + Help: "The number of consecutive times the da fails to submit.", +})