-
Notifications
You must be signed in to change notification settings - Fork 246
refactor(block): centralize timeout in client #2903
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 / buf-check (pull_request).
|
|
Claude finished @julienrbrt's task —— View job Code Review: Centralize Timeout in DA ClientI've completed a comprehensive review of this refactoring PR that centralizes timeout configuration in the DA client. SummaryThis is a well-executed refactoring that improves timeout handling consistency across the DA client. The changes centralize timeout management by:
Overall Assessment: ✅ Approved - This is a clean refactoring with good adherence to Go best practices. I've identified a few minor points for consideration but nothing blocking. Detailed Findings✅ Code Quality & ArchitectureStrengths:
Minor Observation:
✅ Error Handling & ResilienceStrengths:
Enhancement Opportunity:
✅ Configuration & DefaultsStrengths:
Recommendation:
✅ TestingStrengths:
Observation:
✅ DocumentationStrengths:
Clarity Enhancement:
✅ Performance & Resource EfficiencyStrengths:
Consideration:
✅ SecurityNo Issues Found:
Code-Specific Comments
submitCtx, cancel := context.WithTimeout(ctx, c.defaultTimeout)
defer cancel()✅ Good: This ensures Submit operations cannot hang indefinitely. The parent context is still respected (if it's already cancelled/timed out, the child will inherit that).
getIDsCtx, cancel := context.WithTimeout(ctx, c.defaultTimeout)
defer cancel()✅ Good: Consistent with Submit. Note that the subsequent batched Get operations (lines 225-227) also apply per-batch timeouts, which is correct.
-const (
- submissionTimeout = 60 * time.Second
- initialBackoff = 100 * time.Millisecond
-)
+const initialBackoff = 100 * time.Millisecond✅ Good: Removes duplication. The timeout is now managed by the DA client layer.
Summary of RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Final VerdictThis refactoring successfully centralizes timeout configuration, improving code maintainability and consistency. The implementation follows Go best practices with proper context management and resource cleanup. Testing changes are appropriate given the new architecture. Recommendation: Approve and Merge ✅ The code is well-structured, safe, and improves the codebase. The minor suggestions above are enhancements for future consideration, not blockers. |
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 refactors the Data Availability (DA) client's timeout mechanisms to centralize and standardize how timeouts are applied across various operations. By moving timeout control into the DA client itself and increasing the default duration, the change aims to provide more consistent and robust handling of potentially slow DA layer interactions, while also simplifying configuration and removing redundant timeout definitions. Highlights
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 refactors timeout handling by centralizing it in the da.Client. The default timeout is increased to 60 seconds, and this timeout is now applied to Submit operations in addition to Retrieve operations. The changes are consistent across the configuration, client, and tests. My main feedback is regarding the error handling for the newly introduced timeout in the Submit function. A timeout will currently be treated as a generic error, and this should be corrected. Additionally, a unit test to verify the timeout behavior in Submit is missing.
| submitCtx, cancel := context.WithTimeout(ctx, c.defaultTimeout) | ||
| defer cancel() | ||
|
|
||
| ids, err := c.da.SubmitWithOptions(submitCtx, data, gasPrice, namespace, options) |
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.
While adding a timeout here is a great improvement, I've noticed two related points:
-
Error Handling: The error handling for
context.DeadlineExceeded(which will be returned byc.da.SubmitWithOptionson timeout) seems to be missing. The current error handling in this function does not specifically handlecontext.DeadlineExceeded. This will cause a timeout to be treated as a generic error (coreda.StatusError) instead of a more specific timeout status likecoreda.StatusContextDeadline. Please consider updating theswitchstatement that handles errors to include a case forcontext.DeadlineExceeded:case errors.Is(err, context.DeadlineExceeded): status = coreda.StatusContextDeadline
-
Missing Test: The timeout mechanism for
Submitis not tested. WhileTestClient_Submithas a case for"context deadline error", it only checks the mapping of a pre-cannedcoreda.ErrContextDeadlineand doesn't verify that thecontext.WithTimeoutworks as expected. A dedicated test, similar toTestClient_Retrieve_Timeout, should be added toclient_test.goto ensure the timeout inSubmitis effective.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2903 +/- ##
==========================================
- Coverage 64.67% 64.52% -0.16%
==========================================
Files 81 81
Lines 7380 7382 +2
==========================================
- Hits 4773 4763 -10
- Misses 2065 2078 +13
+ Partials 542 541 -1
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:
|
* main: build(deps): Bump mdast-util-to-hast from 13.2.0 to 13.2.1 in /docs in the npm_and_yarn group across 1 directory (#2900) refactor(block): centralize timeout in client (#2903) build(deps): Bump the all-go group across 2 directories with 3 updates (#2898) chore: bump default timeout (#2902) fix: revert default db (#2897) refactor: remove obsolete // +build tag (#2899) fix:da visualiser namespace (#2895) refactor: omit unnecessary reassignment (#2892) build(deps): Bump the all-go group across 5 directories with 6 updates (#2881) chore: fix inconsistent method name in retryWithBackoffOnPayloadStatus comment (#2889) fix: ensure consistent network ID usage in P2P subscriber (#2884) build(deps): Bump golangci/golangci-lint-action from 9.0.0 to 9.1.0 (#2885) build(deps): Bump actions/checkout from 5 to 6 (#2886)
* main: refactor(sequencers): persist prepended batch (#2907) feat(evm): add force inclusion command (#2888) feat: DA client, remove interface part 1: copy subset of types needed for the client using blob rpc. (#2905) feat: forced inclusion (#2797) fix: fix and cleanup metrics (sequencers + block) (#2904) build(deps): Bump mdast-util-to-hast from 13.2.0 to 13.2.1 in /docs in the npm_and_yarn group across 1 directory (#2900) refactor(block): centralize timeout in client (#2903) build(deps): Bump the all-go group across 2 directories with 3 updates (#2898) chore: bump default timeout (#2902) fix: revert default db (#2897) refactor: remove obsolete // +build tag (#2899) fix:da visualiser namespace (#2895)
Overview
Small improvements on timeout in da client and config.
Ref: #2902, #2878