-
Notifications
You must be signed in to change notification settings - Fork 250
feat: implement batch size validation and automatic splitting for DA #2506
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
|
The latest Buf updates on your PR. Results from workflow CI and Release / buf-check (pull_request).
|
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.
Summary of Changes
Hello @randygrok, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces robust validation and automatic batch splitting for Data Availability (DA) layer submissions. The primary goal is to enhance the reliability and resilience of the DA submission process by validating blob sizes upfront and, if necessary, intelligently splitting large batches into smaller, manageable chunks for retry, preventing submission failures due to oversized batches.
Highlights
- DA Batch Splitting: Implemented automatic splitting of Data Availability (DA) submission batches when a
StatusTooBigerror is encountered. If a batch is too large, it's now split in half and retried, preventing infinite retry loops for oversized submissions. If a single item is too large, it will now apply exponential backoff. - Comprehensive DA Size Validation: The DA client's
SubmitWithOptionsfunction now performs strict validation of blob sizes. It checks if individual blobs or the total batch size exceed theMaxBlobSizelimit before attempting submission, returning an error (da.ErrBlobSizeOverLimit) if limits are breached. This replaces previous behavior that could lead to partial submissions or silent dropping of oversized blobs. - Improved Test Coverage: Added new unit tests to verify the batch splitting logic in
block/submitter.goand the comprehensive size validation inda/jsonrpc/client.go, ensuring the new behaviors are correctly implemented and robust.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request introduces two key features: robust batch size validation at the DA client level and automatic batch splitting in the submitter when a batch is too large. The change in da/jsonrpc/client.go is a great improvement, preventing silent dropping of blobs and ensuring that oversized batches are rejected entirely, which enhances correctness. The new tests in block/submitter_test.go and da/jsonrpc/client_test.go provide good coverage for these new behaviors.
My review includes two main suggestions for improvement:
- Refactoring the batch splitting logic in
block/submitter.goto be more efficient and reduce submission latency. - Improving the testability of the retry logic in
block/submitter.goby making the number of attempts configurable, which would allow a currently skipped test to be enabled.
Overall, this is a solid contribution that improves the robustness of the DA submission process.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2506 +/- ##
==========================================
- Coverage 74.46% 74.45% -0.01%
==========================================
Files 70 70
Lines 6537 6711 +174
==========================================
+ Hits 4868 4997 +129
- Misses 1279 1317 +38
- Partials 390 397 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Claude finished @randygrok's task —— View job Code Review: DA Batch Size Validation and Automatic SplittingTodo List
SummaryThis PR successfully implements robust DA batch size validation and automatic batch splitting. The implementation addresses the core issue where oversized batches would cause infinite retry loops by introducing intelligent batch splitting at the node level and comprehensive validation at the DA client level. Code Quality Analysis✅ Strengths
🔍 Areas for Improvement1. Missing Documentation (Medium Priority)Several new functions lack proper documentation:
2. Configuration Flexibility (Low Priority)The // In config
type DAConfig struct {
MaxSubmitAttempts int `mapstructure:"max_submit_attempts"`
// ...
}3. Edge Case Handling (Medium Priority)Single Item Too Large: When a single item exceeds DA blob size limits (
4. Memory Efficiency (Low Priority)The recursive splitting creates multiple copies of slice data. For very large batches, consider using slice indices instead of creating new slices to reduce memory pressure. Security Considerations✅ Secure Implementation
🔒 Security Best Practices Followed
Performance Analysis✅ Performance Benefits
⚡ Performance Considerations
Test Coverage Assessment✅ Excellent Coverage
📊 Coverage MetricsCurrent patch coverage is 81.84% which is solid. Missing coverage likely relates to error paths and edge cases in the recursive splitting logic. Final RecommendationsMust Address Before Merge
Consider for Follow-up
Changelog EntryAs requested by @tac0turtle, this PR needs a changelog entry documenting the new batch splitting and validation features. ConclusionThis is a high-quality implementation that significantly improves the robustness of DA layer interactions. The recursive batch splitting prevents infinite retry loops while ensuring maximum data availability. The comprehensive validation prevents invalid submissions upfront. The code follows Go best practices and includes excellent test coverage. Recommendation: Approve after addressing documentation and merge conflicts. |
| case coreda.StatusSuccess: | ||
| // Record successful DA submission | ||
| m.recordDAMetrics("submission", DAModeSuccess) | ||
| case coreda.StatusNotIncludedInBlock, coreda.StatusAlreadyInMempool: |
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.
do we retry in this case from a call higher up?
tac0turtle
left a comment
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.
left a few minor comments, overall flow makes sense
|
also we need a changelog here |
Manav-Aggarwal
left a comment
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.
Thanks! Left a bunch of comments, think fixing the e2e test is the main thing here.
| includedCount := 0 | ||
| for _, txHashStr := range pendingTxHashes { | ||
| if evm.CheckTxIncluded(t, common.HexToHash(txHashStr)) { | ||
| includedCount++ | ||
| } |
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 think this has anything to do with DA submission whatsover. We should likely look at the DA inclusion block height instead here. Keep track of the block height before (should be way ahead of the DA included block height) we start up the DA layer again, and then make sure that block height is at least a DA included block height after the DA layer starts up.
alpe
left a comment
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.
Good start!
Some minor comments on logging but as I understand the code, there is risk of data loss in the batchActionSkip scenario. Can you check?
| select { | ||
| case <-ctx.Done(): | ||
| return ctx.Err() | ||
| case <-time.After(backoff): |
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.
nit: timer Go routine leak when ctx.Done() . Just move outside the select:
timer := time.NewTimer(backoff)
defer timer.Stop()
block/submitter.go
Outdated
| batches = append(result.splitBatches, batches...) | ||
| case batchActionSkip: | ||
| // Single item too big - skip it | ||
| continue |
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.
If I understand this correct, the batch item would be ignored. Should we error or panic instead?
tac0turtle
left a comment
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.
utACK, there are a few comments from alex left over but otherwise nice job
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 give an utAck, too. Returning an error makes it easier to read. Thank you for addressing my comment.
Please address the merge conflicts before merging.
Now is responsability of the node to split the batch that is sent to the DA. And the client only validates if the blob is too big (does not tries to split it)
NOTE: There exists a case when the blob of a single block is too big, it wont be split and will fail after 30 attempts.'
Closes: #2498
Overview