Skip to content

Commit

Permalink
fix: add retry logic when data delete meet an overtime err
Browse files Browse the repository at this point in the history
  • Loading branch information
krish-nr committed Aug 2, 2024
1 parent b9a212b commit 78d68d6
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions op-node/rollup/derive/engine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const (
)

var errNoFCUNeeded = errors.New("no FCU call was needed")
var maxFCURetryAttempts = 5
var fcuRetryDelay = 5 * time.Second

var _ EngineControl = (*EngineController)(nil)
var _ LocalEngineControl = (*EngineController)(nil)
Expand Down Expand Up @@ -399,14 +401,26 @@ func (e *EngineController) InsertUnsafePayload(ctx context.Context, envelope *et
FinalizedBlockHash: e.finalizedHead.Hash,
}

fcuRes, err := e.engine.ForkchoiceUpdate(ctx, &fcuReq, nil)
if fcuRes.PayloadStatus.Status == eth.ExecutionValid {
log.Info("engine processed data successfully")
e.needFCUCall = false
return nil
} else {
return NewTemporaryError(fmt.Errorf("engine failed to process inconsistent data: %w", err))
for attempts := 0; attempts < maxFCURetryAttempts; attempts++ {
fcuRes, err := e.engine.ForkchoiceUpdate(ctx, &fcuReq, nil)
if err != nil {
if strings.Contains(err.Error(), "context deadline exceeded") {
log.Warn("Failed to share forkchoice-updated signal, attempt %d: %v", attempts+1, err)
time.Sleep(fcuRetryDelay)
continue
}
return NewTemporaryError(fmt.Errorf("engine failed to process due to error: %w", err))
}

if fcuRes.PayloadStatus.Status == eth.ExecutionValid {
log.Info("engine processed data successfully")
e.needFCUCall = false
return nil
} else {
return NewTemporaryError(fmt.Errorf("engine failed to process inconsistent data"))
}
}

}

if !e.checkNewPayloadStatus(status.Status) {
Expand Down

0 comments on commit 78d68d6

Please sign in to comment.