Skip to content

Conversation

@ManuelBilbao
Copy link
Contributor

Motivation

There was a race condition where dev's block producer starts before the RPC. In this scenario, the block producer tries to make some requests to the Engine API, failing three times in a row and thus ending.

Description

Add a small delay between retries so Engine RPC has time to get up

@ManuelBilbao ManuelBilbao self-assigned this Nov 19, 2025
Copilot AI review requested due to automatic review settings November 19, 2025 17:40
@ManuelBilbao ManuelBilbao requested a review from a team as a code owner November 19, 2025 17:40
@ManuelBilbao ManuelBilbao added the L1 Ethereum client label Nov 19, 2025
@ethrex-project-sync ethrex-project-sync bot moved this to In Review in ethrex_l1 Nov 19, 2025
@github-actions
Copy link

Lines of code report

Total lines added: 5
Total lines removed: 0
Total lines changed: 5

Detailed view
+------------------------------------------------+-------+------+
| File                                           | Lines | Diff |
+------------------------------------------------+-------+------+
| ethrex/crates/blockchain/dev/block_producer.rs | 121   | +5   |
+------------------------------------------------+-------+------+

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a race condition where the dev block producer starts before the Engine RPC server is ready, causing immediate failures when the producer attempts to make RPC calls.

Key Changes:

  • Added a 300ms delay between retry attempts to allow the Engine RPC server time to initialize
  • Sleep delays are consistently applied across all four error paths in the block production loop

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

tracing::error!(
"Failed to produce block: error sending engine_forkchoiceUpdatedV3 with PayloadAttributes: {error}"
);
sleep(Duration::from_millis(300)).await;
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retry delay duration (300ms) is hardcoded as a magic number in multiple places. Consider extracting this to a named constant at the module or function level for better maintainability. For example:

const RETRY_DELAY_MS: u64 = 300;

Then use sleep(Duration::from_millis(RETRY_DELAY_MS)).await; throughout the function. This makes it easier to adjust the delay and ensures consistency across all retry points.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@ilitteri ilitteri added this pull request to the merge queue Nov 20, 2025
Merged via the queue into main with commit f505c00 Nov 20, 2025
45 checks passed
@ilitteri ilitteri deleted the dev_block_producer_wait_before_retry branch November 20, 2025 12:12
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants