Skip to content

Commit a00d4ea

Browse files
committed
clarify
1 parent 58d7c2b commit a00d4ea

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

execution/evm/execution.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func validatePayloadStatus(status engine.PayloadStatusV1) error {
7474
// - Fails immediately on ErrInvalidPayloadStatus (permanent failures)
7575
// - Respects context cancellation for graceful shutdown
7676
// - Uses exponential backoff that doubles on each attempt
77-
func retryWithBackoff(ctx context.Context, fn func() error, maxRetries int, initialBackoff time.Duration, operation string) error {
77+
func retryWithBackoffOnPayloadStatus(ctx context.Context, fn func() error, maxRetries int, initialBackoff time.Duration, operation string) error {
7878
backoff := initialBackoff
7979

8080
for attempt := 1; attempt <= maxRetries; attempt++ {
@@ -186,7 +186,7 @@ func (c *EngineClient) InitChain(ctx context.Context, genesisTime time.Time, ini
186186
}
187187

188188
// Acknowledge the genesis block with retry logic for SYNCING status
189-
err := retryWithBackoff(ctx, func() error {
189+
err := retryWithBackoffOnPayloadStatus(ctx, func() error {
190190
var forkchoiceResult engine.ForkChoiceResponse
191191
err := c.engineClient.CallContext(ctx, &forkchoiceResult, "engine_forkchoiceUpdatedV3",
192192
engine.ForkchoiceStateV1{
@@ -291,7 +291,7 @@ func (c *EngineClient) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight
291291

292292
// Call forkchoice update with retry logic for SYNCING status
293293
var payloadID *engine.PayloadID
294-
err = retryWithBackoff(ctx, func() error {
294+
err = retryWithBackoffOnPayloadStatus(ctx, func() error {
295295
var forkchoiceResult engine.ForkChoiceResponse
296296
err := c.engineClient.CallContext(ctx, &forkchoiceResult, "engine_forkchoiceUpdatedV3", args, evPayloadAttrs)
297297
if err != nil {
@@ -340,7 +340,7 @@ func (c *EngineClient) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight
340340

341341
// Submit payload with retry logic for SYNCING status
342342
var newPayloadResult engine.PayloadStatusV1
343-
err = retryWithBackoff(ctx, func() error {
343+
err = retryWithBackoffOnPayloadStatus(ctx, func() error {
344344
err := c.engineClient.CallContext(ctx, &newPayloadResult, "engine_newPayloadV4",
345345
payloadResult.ExecutionPayload,
346346
[]string{}, // No blob hashes
@@ -396,7 +396,7 @@ func (c *EngineClient) setFinal(ctx context.Context, blockHash common.Hash, isFi
396396
c.mu.Unlock()
397397

398398
// Call forkchoice update with retry logic for SYNCING status
399-
err := retryWithBackoff(ctx, func() error {
399+
err := retryWithBackoffOnPayloadStatus(ctx, func() error {
400400
var forkchoiceResult engine.ForkChoiceResponse
401401
err := c.engineClient.CallContext(ctx, &forkchoiceResult, "engine_forkchoiceUpdatedV3", args, nil)
402402
if err != nil {

execution/evm/execution_status_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ func TestValidatePayloadStatus(t *testing.T) {
7777
}
7878
}
7979

80-
// TestRetryWithBackoff tests the retry logic with exponential backoff
81-
func TestRetryWithBackoff(t *testing.T) {
80+
// TestRetryWithBackoffOnPayloadStatus tests the retry logic with exponential backoff
81+
func TestRetryWithBackoffOnPayloadStatus(t *testing.T) {
8282
t.Parallel()
8383

8484
tests := []struct {
@@ -157,7 +157,7 @@ func TestRetryWithBackoff(t *testing.T) {
157157
}
158158

159159
ctx := context.Background()
160-
err := retryWithBackoff(ctx, retryFn, tt.maxRetries, 1*time.Millisecond, "test_operation")
160+
err := retryWithBackoffOnPayloadStatus(ctx, retryFn, tt.maxRetries, 1*time.Millisecond, "test_operation")
161161

162162
if tt.shouldSucceed {
163163
require.NoError(t, err, "expected success but got error")
@@ -170,8 +170,8 @@ func TestRetryWithBackoff(t *testing.T) {
170170
}
171171
}
172172

173-
// TestRetryWithBackoff_ContextCancellation tests that retry respects context cancellation
174-
func TestRetryWithBackoff_ContextCancellation(t *testing.T) {
173+
// TestRetryWithBackoffOnPayloadStatus_ContextCancellation tests that retry respects context cancellation
174+
func TestRetryWithBackoffOnPayloadStatus_ContextCancellation(t *testing.T) {
175175
t.Parallel()
176176

177177
attempts := 0
@@ -183,16 +183,16 @@ func TestRetryWithBackoff_ContextCancellation(t *testing.T) {
183183
ctx, cancel := context.WithCancel(context.Background())
184184
cancel() // Cancel immediately
185185

186-
err := retryWithBackoff(ctx, retryFn, 5, 100*time.Millisecond, "test_operation")
186+
err := retryWithBackoffOnPayloadStatus(ctx, retryFn, 5, 100*time.Millisecond, "test_operation")
187187

188188
require.Error(t, err, "expected error due to context cancellation")
189189
assert.ErrorIs(t, err, context.Canceled, "expected context.Canceled error")
190190
// Should fail fast on context cancellation without retries
191191
assert.LessOrEqual(t, attempts, 1, "expected at most 1 attempt, got %d", attempts)
192192
}
193193

194-
// TestRetryWithBackoff_ContextTimeout tests that retry respects context timeout
195-
func TestRetryWithBackoff_ContextTimeout(t *testing.T) {
194+
// TestRetryWithBackoffOnPayloadStatus_ContextTimeout tests that retry respects context timeout
195+
func TestRetryWithBackoffOnPayloadStatus_ContextTimeout(t *testing.T) {
196196
t.Parallel()
197197

198198
attempts := 0
@@ -205,16 +205,16 @@ func TestRetryWithBackoff_ContextTimeout(t *testing.T) {
205205
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
206206
defer cancel()
207207

208-
err := retryWithBackoff(ctx, retryFn, 10, 1*time.Second, "test_operation")
208+
err := retryWithBackoffOnPayloadStatus(ctx, retryFn, 10, 1*time.Second, "test_operation")
209209

210210
require.Error(t, err, "expected error due to context timeout")
211211
assert.ErrorIs(t, err, context.DeadlineExceeded, "expected context.DeadlineExceeded error")
212212
// Should stop on timeout, not exhaust all retries
213213
assert.Less(t, attempts, 10, "expected fewer than 10 attempts due to timeout, got %d", attempts)
214214
}
215215

216-
// TestRetryWithBackoff_RPCErrors tests that RPC errors are not retried
217-
func TestRetryWithBackoff_RPCErrors(t *testing.T) {
216+
// TestRetryWithBackoffOnPayloadStatus_RPCErrors tests that RPC errors are not retried
217+
func TestRetryWithBackoffOnPayloadStatus_RPCErrors(t *testing.T) {
218218
t.Parallel()
219219

220220
rpcError := errors.New("RPC connection failed")
@@ -225,16 +225,16 @@ func TestRetryWithBackoff_RPCErrors(t *testing.T) {
225225
}
226226

227227
ctx := context.Background()
228-
err := retryWithBackoff(ctx, retryFn, 5, 1*time.Millisecond, "test_operation")
228+
err := retryWithBackoffOnPayloadStatus(ctx, retryFn, 5, 1*time.Millisecond, "test_operation")
229229

230230
require.Error(t, err, "expected error from RPC failure")
231231
assert.Equal(t, rpcError, err, "expected original RPC error to be returned")
232232
// Should fail immediately without retries on non-syncing errors
233233
assert.Equal(t, 1, attempts, "expected exactly 1 attempt, got %d", attempts)
234234
}
235235

236-
// TestRetryWithBackoff_WrappedRPCErrors tests that wrapped RPC errors are not retried
237-
func TestRetryWithBackoff_WrappedRPCErrors(t *testing.T) {
236+
// TestRetryWithBackoffOnPayloadStatus_WrappedRPCErrors tests that wrapped RPC errors are not retried
237+
func TestRetryWithBackoffOnPayloadStatus_WrappedRPCErrors(t *testing.T) {
238238
t.Parallel()
239239

240240
rpcError := errors.New("connection refused")
@@ -245,7 +245,7 @@ func TestRetryWithBackoff_WrappedRPCErrors(t *testing.T) {
245245
}
246246

247247
ctx := context.Background()
248-
err := retryWithBackoff(ctx, retryFn, 5, 1*time.Millisecond, "test_operation")
248+
err := retryWithBackoffOnPayloadStatus(ctx, retryFn, 5, 1*time.Millisecond, "test_operation")
249249

250250
require.Error(t, err, "expected error from RPC failure")
251251
// Should fail immediately without retries on non-syncing errors

0 commit comments

Comments
 (0)