-
Notifications
You must be signed in to change notification settings - Fork 1
feat: l2 block data model update and reorg handling #95
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
base: main
Are you sure you want to change the base?
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 implements an update to the L2 block data model and introduces reorg handling. Key changes include:
- Replacing the use of BlockInfo with L2BlockInfoWithL1Messages in several engine components.
- Updating migration scripts and database models (including renaming tables and adjusting foreign key actions) to support the new data model.
- Adjusting derivation pipeline and tests to handle the updated message and block representations.
Reviewed Changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
crates/engine/src/future/result.rs | Updates the type for L1 consolidation from BlockInfo to L2BlockInfoWithL1Messages. |
crates/engine/src/future/mod.rs | Adjusts futures to use the new L2 block info type and converts execution payload accordingly. |
crates/engine/src/event.rs | Updates the event type for L1 block consolidation to use L2 block info. |
crates/engine/src/error.rs | Simplifies error conversion using #[from] for PayloadError. |
crates/engine/src/driver.rs | Adds new public methods for setting safe/head block info and adapts existing reorg handling calls. |
crates/derivation-pipeline/src/lib.rs | Renames provider cursor functions to set_queue_index_cursor. |
crates/database/migration/*.rs | Renames migrations and alters foreign key actions (from cascade to set-null) to reflect the new L2 block model. |
crates/database/db/src/models/* | Updates models for blocks and messages to include new fields and renames columns as needed. |
crates/database/db/src/operations.rs and db/src/db.rs | Adjusts data access operations and tests to work with the updated block and message types. |
README.md, Cargo.toml | Minor updates to include new modules and dependency changes. |
Comments suppressed due to low confidence (1)
crates/database/migration/src/m20250411_072004_add_l2_block.rs:25
- The foreign key actions have been changed from Cascade to SetNull. Please confirm that this change aligns with the desired reorg handling behavior and that downstream logic can properly handle null batch information.
.on_delete(ForeignKeyAction::SetNull)
self.fcs.update_safe_block_info(block_info.block_info); | ||
|
||
// If we reorged, update the head block info | ||
if reorg { | ||
tracing::warn!(target: "scroll::engine", ?block_info, "reorging head to l1 derived block"); | ||
self.fcs.update_head_block_info(block_info); | ||
self.fcs.update_head_block_info(block_info.block_info); |
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.
The new methods set_safe_block_info and set_head_block_info still accept a BlockInfo parameter, while later updates access properties from L2BlockInfoWithL1Messages (e.g. block_info.block_info). Consider updating these method signatures to accept L2BlockInfoWithL1Messages for consistency throughout the reorg handling code.
Copilot uses AI. Check for mistakes.
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.
I don't agree with this proposal. L1 msg hashes are irrelevant to fcs.
Overview
The objective of this PR is an initial implementation of reorg handling. Upon reorg, the indexer will emit an event that signals if downstream consumers need to update their internal state. It calculates the event by deleting and processing the data stored in the database.
This PR modifies the data model as such:
Some preliminary tests have been implemented but we should expand coverage and introduce integration tests as well.
closes: #77