Skip to content

Commit

Permalink
refactor: enhanced logging on batch submission retry to base layers (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
omritoptix authored Feb 19, 2023
1 parent b3642ce commit 458d509
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,15 +722,16 @@ 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
}, retry.Context(m.batchRetryCtx), retry.LastErrorOnly(true), retry.Delay(SLBatchRetryDelay))
// 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()
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion block/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 458d509

Please sign in to comment.