Skip to content

Conversation

@ilitteri
Copy link
Contributor

Motivation

Since the path-based feature was added, the database stores the state 128 blocks behind the head block, while the state of the blocks in between is kept in in-memory-diff-layers.

After the node is shut down, those in-memory layers are lost, and the database won't have the state for those blocks. It will have the blocks, though.

When the node is started again, the state needs to be regenerated by re-applying the blocks from the last known state root up to the head block.

This is already handled in the L1 node, but not in the L2 node.

Description

Calls regenerate_head_state during L2 node initialization.

@ilitteri ilitteri self-assigned this Oct 20, 2025
@ilitteri ilitteri requested a review from a team as a code owner October 20, 2025 20:07
Copilot AI review requested due to automatic review settings October 20, 2025 20:07
@github-actions github-actions bot added the L2 Rollup client label Oct 20, 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 adds state regeneration functionality to L2 node initialization to handle the loss of in-memory diff layers after node restarts. Since the path-based feature stores state 128 blocks behind the head block with intermediate states in memory, these need to be regenerated on startup.

Key Changes:

  • Calls regenerate_head_state during L2 node initialization (matching existing L1 behavior)
  • Makes regenerate_head_state public and adds comprehensive documentation
  • Improves code formatting and comments in the regeneration logic

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/ethrex/l2/initializers.rs Imports and calls regenerate_head_state after blockchain initialization
cmd/ethrex/initializers.rs Makes regenerate_head_state public, adds documentation, and improves code formatting

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions
Copy link

github-actions bot commented Oct 20, 2025

Lines of code report

Total lines added: 9
Total lines removed: 0
Total lines changed: 9

Detailed view
+--------------------------------------+-------+------+
| File                                 | Lines | Diff |
+--------------------------------------+-------+------+
| ethrex/cmd/ethrex/initializers.rs    | 466   | +8   |
+--------------------------------------+-------+------+
| ethrex/cmd/ethrex/l2/initializers.rs | 250   | +1   |
+--------------------------------------+-------+------+

@ilitteri ilitteri enabled auto-merge October 20, 2025 20:18
@ilitteri ilitteri disabled auto-merge October 20, 2025 20:22
@ilitteri ilitteri enabled auto-merge October 20, 2025 20:34
@ilitteri ilitteri added this pull request to the merge queue Oct 20, 2025
Merged via the queue into main with commit ed4f08c Oct 20, 2025
41 checks passed
@ilitteri ilitteri deleted the regenerate_head_state_l2 branch October 20, 2025 21:18
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