-
Notifications
You must be signed in to change notification settings - Fork 131
fix(l2): regenerate head state in node initialization #4968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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_stateduring L2 node initialization (matching existing L1 behavior) - Makes
regenerate_head_statepublic 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.
Lines of code reportTotal lines added: Detailed view |
Co-authored-by: Copilot <[email protected]>
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_stateduring L2 node initialization.