-
Notifications
You must be signed in to change notification settings - Fork 30
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
revert(relayer): potential deadlock #3036
Conversation
WalkthroughThe recent changes streamline the balance management and request handling in the relayer service. Key modifications include the removal of mutex locks associated with balance checks, simplifying the logic and improving performance. However, these adjustments raise potential concerns about concurrency issues, indicating a shift in synchronization mechanisms and possibly altering how balance-related functionality is handled overall. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant QuoteRequestHandler
participant Relayer
Client->>QuoteRequestHandler: Submit Quote Request
QuoteRequestHandler->>QuoteRequestHandler: Handle Seen
QuoteRequestHandler->>Relayer: Commit Pending Balance
Relayer->>QuoteRequestHandler: Process Request
QuoteRequestHandler->>Client: Response
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 Configuration 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.
PR Summary
This pull request reverts changes related to balance locking mechanisms in the RFQ relayer service, simplifying the code but potentially impacting concurrency control.
- Removed
commitPendingBalance
function and associated locking inhandleSeen
andhandleNotEnoughInventory
functions - Eliminated
balanceMtx
field fromRelayer
andQuoteRequestHandler
structs - Simplified balance checking process in
handleSeen
, directly usingGetCommittableBalance
- Removed
getBalanceMtxKey
function, indicating a change in balance-related synchronization - These changes may improve performance but could introduce potential thread safety issues
3 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
@@ -167,7 +165,6 @@ func NewRelayer(ctx context.Context, metricHandler metrics.Handler, cfg relconfi | |||
apiClient: apiClient, | |||
semaphore: semaphore.NewWeighted(maxConcurrentRequests), | |||
handlerMtx: mapmutex.NewStringMapMutex(), |
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.
logic: balanceMtx initialization removed. Verify if balance synchronization is still properly handled.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3036 +/- ##
===================================================
- Coverage 23.38100% 23.37680% -0.00421%
===================================================
Files 644 644
Lines 50139 50148 +9
Branches 82 82
===================================================
Hits 11723 11723
- Misses 37255 37264 +9
Partials 1161 1161
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Deploying sanguine-fe with Cloudflare Pages
|
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.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (3)
- services/rfq/relayer/service/handlers.go (3 hunks)
- services/rfq/relayer/service/relayer.go (2 hunks)
- services/rfq/relayer/service/statushandler.go (2 hunks)
Additional comments not posted (8)
services/rfq/relayer/service/statushandler.go (3)
Line range hint
34-34
: Review the removal ofbalanceMtx
.The
balanceMtx
field has been removed from theQuoteRequestHandler
struct. Ensure that balance synchronization is handled appropriately elsewhere to avoid concurrency issues.
Line range hint
61-61
: Verify synchronization sufficiency withhandlerMtx
.The
requestToHandler
function now initializesQuoteRequestHandler
withoutbalanceMtx
, relying onhandlerMtx
. Ensure this is sufficient for all synchronization needs.
Line range hint
88-90
: Ensure adequate locking withhandlerMtx
.The
mutexMiddleware
function useshandlerMtx
for locking. Verify that this provides adequate synchronization for the operations performed.services/rfq/relayer/service/relayer.go (2)
64-64
: Review the removal ofbalanceMtx
.The
balanceMtx
field has been removed from theRelayer
struct. Ensure that balance synchronization is handled appropriately elsewhere to avoid concurrency issues.
Line range hint
119-119
: Verify impact of removingbalanceMtx
initialization.The
NewRelayer
function no longer initializesbalanceMtx
. Ensure that this change does not affect functionality or introduce concurrency issues.Verification successful
Impact of Removing
balanceMtx
Initialization VerifiedThe removal of
balanceMtx
initialization in theNewRelayer
function was part of a commit that reverted a previous feature adding mutex on committable balance consumption. This indicates thatbalanceMtx
was used for synchronizing balance requests but has been intentionally removed, likely due to a design decision or because it was no longer needed.
- The commit history shows that
balanceMtx
and its associated logic were completely removed, suggesting that the codebase has been refactored to function without it.- There are no remaining references to
balanceMtx
in the current codebase, confirming its removal and the absence of dependency issues.Therefore, the removal of
balanceMtx
does not negatively impact the current functionality or introduce concurrency issues. The code has been adjusted accordingly to operate without this mutex.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the impact of removing `balanceMtx` initialization in `NewRelayer`. # Test: Check for any dependencies on `balanceMtx` initialization that might affect functionality. rg --type go 'NewRelayer'Length of output: 3456
Script:
#!/bin/bash # Description: Search for references to `balanceMtx` in the codebase to assess its previous usage. # Find all occurrences of `balanceMtx` to understand its role and impact. rg --type go 'balanceMtx'Length of output: 25
Script:
#!/bin/bash # Description: Check the version control history for any recent changes related to `balanceMtx`. # Search the git log for any commits mentioning `balanceMtx`. git log -p -S 'balanceMtx'Length of output: 53648
services/rfq/relayer/service/handlers.go (3)
490-495
: Verify safety of removing balance locking logic.The
handleNotEnoughInventory
function no longer uses balance locking logic. Ensure that this change does not introduce concurrency issues.
214-221
: Verify safety of removing locking mechanisms.The
commitPendingBalance
function no longer uses locking mechanisms. Ensure that this change does not introduce concurrency issues.
214-221
: Verify safety of removing immediate balance commitment.The
handleSeen
function no longer commits pending balances immediately. Ensure that this change does not introduce race conditions or other issues.Verification successful
Removal of Immediate Balance Commitment is Safe
The
handleSeen
function's removal of immediate balance commitment is managed safely by the checks and processes inhandleCommitPending
. The latter ensures that requests are only processed when conditions are met, reducing the risk of race conditions.
- The
handleCommitPending
function checks block confirmations and bridge status before updating request status and forwarding.- These mechanisms ensure that requests are handled safely and sequentially.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the safety of removing immediate balance commitment in `handleSeen`. # Test: Check for potential race conditions or issues introduced by this change. rg --type go 'handleSeen'Length of output: 565
Script:
#!/bin/bash # Search for the implementation of the `handleSeen` function to understand its logic. ast-grep --lang go --pattern 'func (q *QuoteRequestHandler) handleSeen($_, $_, $_) $_'Length of output: 7031
Script:
#!/bin/bash # Search for the implementation of the `handleCommitPending` function to verify its handling of requests. ast-grep --lang go --pattern 'func (q *QuoteRequestHandler) handleCommitPending($_, $_, $_) $_'Length of output: 4326
Description
A clear and concise description of the features you're adding in this pull request.
Additional context
Add any other context about the problem you're solving.
Metadata
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
QuoteRequestHandler
andRelayer
to eliminate balance-related fields and methods, indicating a shift in balance management strategy.Documentation