Skip to content

Conversation

@ManuelBilbao
Copy link
Contributor

Motivation

We are saving the latest Store as the "current" one. This means the next time a batch is constructed, it might use a latter checkpoint than the needed. This can occur if the batch is sealed with less blocks than the available (e.g., if there's no more available space).

Description

Save a checkpoint from the batch execution instead

@ManuelBilbao ManuelBilbao self-assigned this Nov 1, 2025
Copilot AI review requested due to automatic review settings November 1, 2025 01:22
@ManuelBilbao ManuelBilbao requested a review from a team as a code owner November 1, 2025 01:22
@ManuelBilbao ManuelBilbao added the L2 Rollup client label Nov 1, 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 refactors the batch production logic in the L1 committer by extracting the batch creation code into a separate produce_batch method. The refactoring simplifies the main commit flow and changes how checkpoints are managed during batch production.

Key changes:

  • Extracted batch production logic into a new produce_batch method
  • Changed from temporary checkpoints to permanent checkpoints created during batch production
  • Updated checkpoint management to assign checkpoints directly rather than creating them separately
  • Introduced a batch_checkpoint_name helper function to standardize checkpoint naming

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

async fn produce_batch(&mut self, batch_number: u64) -> Result<Option<Batch>, CommitterError> {
let last_committed_blocks = self
.rollup_store
.get_block_numbers_by_batch(batch_number-1)
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

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

Missing spaces around the subtraction operator. Should be batch_number - 1 for consistency with Rust formatting conventions.

Suggested change
.get_block_numbers_by_batch(batch_number-1)
.get_block_numbers_by_batch(batch_number - 1)

Copilot uses AI. Check for mistakes.
.get_block_numbers_by_batch(batch_number-1)
.await?
.ok_or(
CommitterError::RetrievalError(format!("Failed to get batch with batch number {}. Batch is missing when it should be present. This is a bug", batch_number))
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

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

The error message refers to getting a batch but is actually fetching block numbers by batch. The message should say 'Failed to get blocks for batch number {}' to accurately reflect what failed.

Suggested change
CommitterError::RetrievalError(format!("Failed to get batch with batch number {}. Batch is missing when it should be present. This is a bug", batch_number))
CommitterError::RetrievalError(format!("Failed to get blocks for batch number {}. Block numbers are missing when they should be present. This is a bug", batch_number))

Copilot uses AI. Check for mistakes.
batch.number
));
// We need to create a one-time checkpoint copy because if witness generation fails the checkpoint would be modified
info!(batch = batch.number, "WITNESS OTC");
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

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

Debug log message 'WITNESS OTC' appears to be temporary debugging code that should be removed before merging to production.

Suggested change
info!(batch = batch.number, "WITNESS OTC");

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Nov 1, 2025

Lines of code report

Total lines added: 2
Total lines removed: 0
Total lines changed: 2

Detailed view
+--------------------------------------------+-------+------+
| File                                       | Lines | Diff |
+--------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_committer.rs | 1034  | +2   |
+--------------------------------------------+-------+------+

@ilitteri ilitteri added this pull request to the merge queue Nov 1, 2025
Merged via the queue into main with commit 59d2ccb Nov 1, 2025
38 checks passed
@ilitteri ilitteri deleted the current_checkpoint branch November 1, 2025 02:34
@github-project-automation github-project-automation bot moved this to Done in ethrex_l2 Nov 1, 2025
xqft pushed a commit that referenced this pull request Nov 11, 2025
**Motivation**

<!-- Why does this pull request exist? What are its goals? -->
We are saving the latest `Store` as the "current" one. This means the
next time a batch is constructed, it might use a latter checkpoint than
the needed. This can occur if the batch is sealed with less blocks than
the available (e.g., if there's no more available space).

**Description**

<!-- A clear and concise general description of the changes this PR
introduces -->
Save a checkpoint from the batch execution instead

<!-- Link to issues: Resolves #111, Resolves #222 -->
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.

4 participants