Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/blockchain/dev/block_producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use ethrex_rpc::clients::{EngineClient, EngineClientError};
use ethrex_rpc::types::fork_choice::{ForkChoiceState, PayloadAttributesV3};
use sha2::{Digest, Sha256};
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use tokio::time::sleep;

pub async fn start_block_producer(
execution_client_auth_url: String,
Expand Down Expand Up @@ -51,6 +52,7 @@ pub async fn start_block_producer(
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

tries += 1;
continue;
}
Expand All @@ -73,6 +75,7 @@ pub async fn start_block_producer(
tracing::error!(
"Failed to produce block: error sending engine_getPayloadV5: {error}"
);
sleep(Duration::from_millis(300)).await;
tries += 1;
continue;
}
Expand Down Expand Up @@ -106,6 +109,7 @@ pub async fn start_block_producer(
tracing::error!(
"Failed to produce block: error sending engine_newPayloadV4: {error}"
);
sleep(Duration::from_millis(300)).await;
tries += 1;
continue;
}
Expand All @@ -117,6 +121,7 @@ pub async fn start_block_producer(
tracing::error!(
"Failed to produce block: latest_valid_hash is None in PayloadStatus: {payload_status:?}"
);
sleep(Duration::from_millis(300)).await;
tries += 1;
continue;
};
Expand Down
Loading