-
Notifications
You must be signed in to change notification settings - Fork 245
feat(submitting): add posting strategies #2973
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
|
The latest Buf updates on your PR. Results from workflow CI / buf-check (pull_request).
|
|
Claude finished @julienrbrt's task in 2m 16s —— View job Code Review CompleteI've completed a comprehensive code review of PR #2973. Overall, this is a well-designed and thoroughly tested implementation of batching strategies for DA submissions. The code demonstrates strong Go idioms, good test coverage, and thoughtful architecture. Below are my findings organized by focus area. 1. Code Quality & Architecture ⭐Strengths:
Issues: ❌ Critical: Concurrency Safety Issue in
|
Summary of ChangesHello @julienrbrt, 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 significantly upgrades the Data Availability (DA) layer submission process by introducing a robust and configurable batching system. Instead of immediate submission, the system can now intelligently decide when to send data based on various strategies, such as accumulating a certain amount of data, waiting for a specific time interval, or an adaptive combination of both. This enhancement aims to improve the efficiency and cost-effectiveness of data submissions, particularly for DA layers like Celestia, by better utilizing blob capacity and reducing transaction overhead. The maximum blob size has also been updated to reflect current DA layer capabilities. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe 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 by creating a comment using either
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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
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 configurable batching strategies for DA submissions, a valuable feature for optimizing costs and latency. The implementation is well-structured, adding immediate, size, time, and adaptive strategies, along with comprehensive tests. My review focuses on improving the efficiency and robustness of the new logic in the submitter, particularly around size estimation and data fetching.
| // Wait if current utilization is below minimum threshold | ||
| // Use epsilon for floating point comparison | ||
| const epsilon = 0.001 | ||
| currentUtilization := float64(currentSize) / float64(maxBlobSize) |
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.
There's a potential for division by zero if maxBlobSize is 0. In Go, floating-point division by zero results in +Inf or NaN rather than a panic, but this can lead to unexpected behavior in the comparison that follows. It would be safer to add a guard against this, similar to the pattern used in calculateBatchMetrics.
| if s.headerSubmissionMtx.TryLock() { | ||
| s.logger.Debug().Time("t", time.Now()).Uint64("headers", headersNb).Msg("Header submission in progress") | ||
| go func() { |
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 current implementation fetches pending headers from the cache (s.cache.GetPendingHeaders) inside this goroutine to estimate the batch size. Then, if the strategy decides to submit, s.daSubmitter.SubmitHeaders fetches the same headers again. This double-fetching can be inefficient, especially if there are many pending headers.
Consider refactoring daSubmitter.SubmitHeaders to accept the list of headers directly, avoiding the second fetch. This same feedback applies to the data submission logic below.
| data, err := h.MarshalBinary() | ||
| if err == nil { | ||
| totalSize += len(data) | ||
| } |
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.
Errors from h.MarshalBinary() are silently ignored. This could lead to an inaccurate totalSize, causing the batching strategy to make a suboptimal decision (e.g., delaying a submission). It's better to log these errors for visibility.
Additionally, this size estimation logic is duplicated for data submission. Consider extracting it into a shared helper function to improve maintainability.
data, err := h.MarshalBinary()
if err != nil {
s.logger.Warn().Err(err).Msg("failed to marshal header for size estimation")
continue
}
totalSize += len(data)| data, err := d.MarshalBinary() | ||
| if err == nil { | ||
| totalSize += len(data) | ||
| } |
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.
Similar to the header submission logic, errors from d.MarshalBinary() are silently ignored here. This can lead to inaccurate size estimations and suboptimal batching. It's better to log these errors for improved diagnostics and robustness.
data, err := d.MarshalBinary()
if err != nil {
s.logger.Warn().Err(err).Msg("failed to marshal data for size estimation")
continue
}
totalSize += len(data)
Closes: #2890
Add submission strategies.