-
Notifications
You must be signed in to change notification settings - Fork 146
fix(l2): handle better when producing an empty batch #5293
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
Lines of code reportTotal lines added: Detailed view |
This reverts commit 6420c7b.
6420c7b to
79aec4a
Compare
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 fixes a critical bug where the L2 sequencer would crash when attempting to commit an empty batch. The issue occurred during metrics calculation where an underflow would happen in the batch_size computation when no blocks were added to the batch.
- Changed
prepare_batch_from_blockto returnOption<T>to handle empty batches gracefully - Added early detection of empty batches before metrics calculation
- Updated the caller to properly handle the
Nonecase with pattern matching
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6e0447b to
79aec4a
Compare
Motivation
The L2 was failing when trying to commit the first batch that was empty.
Inside
produce_batch_from_blockwhen doing the metrics we do:This could end up in
u64::maxand failing the conversion because if there are no blocks in the batch we never dolast_added_block_number += 1;inside the loop.Description
produce_batch_from_blockto return anOption<T>