Skip to content

Conversation

@avilagaston9
Copy link
Contributor

Motivation

Our L2 integration tests sometimes fail with the following error:

 2025-11-25T14:51:56.997348Z ERROR Failed to produce block: error sending engine_forkchoiceUpdatedV3 with PayloadAttributes: Invalid forkchoice state: "invalid timestamp"

I have found two issues:

  • tick() only ensures that some interval has passed since the previous tick() call, so the first tick() finish immediately.
  • Given that we use a block_production_interval_ms of 1 sec, it is possible for two consecutive forkchoice messages to have the same timestamp.

Description

  • Replaces tick() with sleep() .

Closes None

@avilagaston9 avilagaston9 marked this pull request as ready for review November 26, 2025 17:47
@avilagaston9 avilagaston9 requested a review from a team as a code owner November 26, 2025 17:47
Copilot AI review requested due to automatic review settings November 26, 2025 17:47
@github-actions github-actions bot added the L2 Rollup client label Nov 26, 2025
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 intermittent L2 integration test failures caused by timestamp collisions in the dev-mode block producer. The fix replaces tokio::time::interval with tokio::time::sleep to ensure consistent timing between block production cycles.

Key Changes:

  • Replaced ticker.tick().await with sleep(Duration::from_millis(block_production_interval_ms)).await to guarantee full intervals between operations
  • Updated comments to reflect the new sleep-based approach
Comments suppressed due to low confidence (1)

crates/blockchain/dev/block_producer.rs:25

  • The tries counter is only incremented on errors (lines 54, 77, 111, 123), but not after successful block production. This means the loop will run indefinitely if blocks are produced successfully, ignoring the max_tries limit. Consider incrementing tries at the end of each successful iteration or restructuring the loop to properly handle both success and failure cases.
    while tries < max_tries {

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

@github-actions
Copy link

Lines of code report

Total lines added: 0
Total lines removed: 1
Total lines changed: 1

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

@ilitteri ilitteri enabled auto-merge November 26, 2025 18:30
@ilitteri ilitteri added this pull request to the merge queue Nov 26, 2025
Merged via the queue into main with commit 0773636 Nov 26, 2025
56 checks passed
@ilitteri ilitteri deleted the fix/l2/sleep_to_avoid_timestamp_collition branch November 26, 2025 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L2 Rollup client

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants