-
Notifications
You must be signed in to change notification settings - Fork 142
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
da: add submit, get context timeouts #1507
Conversation
WalkthroughThe recent updates to the Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (1)
- da/da.go (4 hunks)
Additional comments: 3
da/da.go (3)
- 8-8: The import of the
time
package is correctly added to support the new timeout functionality.- 123-125: The introduction of a timeout context in
SubmitBlocks
usingsubmitTimeout
is correctly implemented. However, ensure that the cancellation function,cancel
, is always called, even if theSubmit
method does not return an error, to avoid potential leaks of context resources.- 175-177: Similar to
SubmitBlocks
, theRetrieveBlocks
method correctly applies a timeout context usingretrieveTimeout
. The use ofcancel
after retrieving the blocks ensures that resources are properly released.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1507 +/- ##
==========================================
+ Coverage 50.23% 50.31% +0.08%
==========================================
Files 52 52
Lines 6762 6735 -27
==========================================
- Hits 3397 3389 -8
+ Misses 3024 3004 -20
- Partials 341 342 +1 ☔ View full report in Codecov by Sentry. |
61bb3c0
to
5f1c3ed
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.
5f1c3ed
to
fc38b78
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.
16eee79
to
3603be5
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.
@tuxcanfly is there a way to test this? i don't think it is addressing any problem. |
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- da/da.go (4 hunks)
- da/da_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- da/da.go
Additional comments: 5
da/da_test.go (5)
- 4-4: The addition of the
bytes
package is appropriate given the use ofbytes.Repeat
in the testTestMockDAErrors
under thesubmit_timeout
scenario. This ensures the necessary functionality is available for manipulating byte slices in tests.- 71-76: Modification to the
Submit
method inMockDA
to handle context cancellation is a crucial improvement. It allows the method to respect context timeouts or cancellations, aligning with the PR's objective to introduce context with timeouts for submission operations. This change ensures that the DA client can properly handle scenarios where a submission might take longer than expected, thereby preventing indefinite blocking.- 84-102: The refactoring of the test function
TestMockDAErrors
to include asubmit_timeout
scenario is well-implemented. It effectively tests the new context cancellation handling in theSubmit
method by simulating a timeout. This is achieved by setting up the mock to return after a delay (After(100*time.Millisecond)
) and then callingdoTestSubmitTimeout
with a context that times out sooner (time.Second
). This test ensures that theSubmit
method behaves as expected under timeout conditions, which is critical for the reliability of the DA client.- 104-107: The addition of a
max_blob_size_error
test scenario withinTestMockDAErrors
is a good practice. It tests the DA client's behavior when an error occurs while fetching the maximum blob size, which is a potential failure point. By mocking an error response forMaxBlobSize
and then verifying the error handling indoTestMaxBlockSizeError
, this test ensures that the DA client can gracefully handle errors related to maximum blob size constraints.- 161-169: The implementation of
doTestSubmitTimeout
function correctly tests the timeout behavior introduced in theSubmit
method. By setting a shortersubmitTimeout
than the mock's delay and asserting that the response message contains "context deadline exceeded", this test validates that the DA client correctly handles submission timeouts. This is a critical test for ensuring that the DA client's submission process is robust and can handle network or processing delays gracefully.
@gupadhyaya added test case for context timeout. The submit call relies on a sync endpoint in core and can stall the block submission loop if we don't use a context deadline, see: https://gist.github.com/tuxcanfly/207ab3dc1fac4bb9c38bedad2a053f18 for an example, but there can be other reasons the core endpoint can timeout e.g. during inscriptions flood or improperly configured reverse proxy. There's also a related issue here which is that if a transaction that is already in the mempool, then it should not be retried with backoff immediately, because it will error with |
6ff199c
to
42ffbb5
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- da/da.go (4 hunks)
- da/da_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (2)
- da/da.go
- da/da_test.go
Overview
This PR adds context with sane default timeouts to submit and get blob methods on the DA client. Fixes #1036
Checklist
Summary by CodeRabbit
New Features
Bug Fixes
Tests