From 458d5093a16e6e31db5969230fe6209ae3400386 Mon Sep 17 00:00:00 2001 From: Omri Date: Sun, 19 Feb 2023 14:42:08 +0100 Subject: [PATCH] refactor: enhanced logging on batch submission retry to base layers (#258) --- block/manager.go | 8 +++++--- block/manager_test.go | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/block/manager.go b/block/manager.go index 0285f4dd0..d4b3f3b9b 100644 --- a/block/manager.go +++ b/block/manager.go @@ -722,7 +722,8 @@ func (m *Manager) submitBatchToSL(batch *types.Batch, resultSubmitToDA *da.Resul err := retry.Do(func() error { resultSubmitToSL = m.settlementClient.SubmitBatch(batch, m.dalc.GetClientType(), resultSubmitToDA) if resultSubmitToSL.Code != settlement.StatusSuccess { - err := fmt.Errorf("failed to submit batch to SL layer: %s", resultSubmitToSL.Message) + m.logger.Error("Failed to submit batch to SL layer", "startHeight", batch.StartHeight, "endHeight", batch.EndHeight, "error", resultSubmitToSL.Message) + err := fmt.Errorf("Failed to submit batch to SL layer: %s", resultSubmitToSL.Message) return err } return nil @@ -730,7 +731,7 @@ func (m *Manager) submitBatchToSL(batch *types.Batch, resultSubmitToDA *da.Resul // Panic if we failed not due to context cancellation m.batchRetryMu.Lock() if err != nil && m.batchRetryCtx.Err() == nil { - m.logger.Error("Failed to submit batch to SL Layer", "startHeight", batch.StartHeight, "EndHeight", batch.EndHeight, "error", err) + m.logger.Error("Failed to submit batch to SL Layer", "startHeight", batch.StartHeight, "endHeight", batch.EndHeight, "error", err) panic(err) } m.batchRetryMu.Unlock() @@ -741,7 +742,8 @@ func (m *Manager) submitBatchToDA(ctx context.Context, batch *types.Batch) (*da. err := retry.Do(func() error { res = m.dalc.SubmitBatch(batch) if res.Code != da.StatusSuccess { - return fmt.Errorf("failed to submit batch to DA layer: %s", res.Message) + m.logger.Error("Failed to submit batch to DA layer", "startHeight", batch.StartHeight, "endHeight", batch.EndHeight, "error", res.Message) + return fmt.Errorf("Failed to submit batch to DA layer: %s", res.Message) } return nil }, retry.Context(ctx), retry.LastErrorOnly(true), retry.Delay(DABatchRetryDelay)) diff --git a/block/manager_test.go b/block/manager_test.go index fbada7d1c..c8ac919c3 100644 --- a/block/manager_test.go +++ b/block/manager_test.go @@ -205,7 +205,7 @@ func TestPublishWhenDALayerDisconnected(t *testing.T) { daResultSubmitBatch := manager.dalc.SubmitBatch(batch) assert.Equal(t, daResultSubmitBatch.Code, da.StatusError) - _, err = manager.submitBatchToDA(context.Background(), nil) + _, err = manager.submitBatchToDA(context.Background(), batch) assert.ErrorContains(t, err, connectionRefusedErrorMessage) }