-
Notifications
You must be signed in to change notification settings - Fork 33
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
RFQ Relayer: check for db status mismatch #2769
Conversation
WalkthroughA new validation step has been introduced in the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Relayer
participant Middleware
participant StatusChecker
Client->>Relayer: Request Quote
Relayer->>Middleware: Call mutexMiddleware
Middleware->>StatusChecker: Check status
Note right of StatusChecker: Validate unchanged status
alt Status unchanged
StatusChecker-->>Middleware: Status unchanged
Middleware->>Relayer: Proceed with Request
Relayer->>Client: Send Quote Response
else Status changed
StatusChecker-->>Middleware: Status changed
Middleware->>Relayer: Abort request
Relayer->>Client: Send Error Response
end
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.
PR Summary
- Introduced status mismatch check for quote requests
- Fetch current status from database and compare with request status
- Prevent handler from processing if status mismatch detected
1 file(s) reviewed, no comment(s)
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.
// make sure the status has not changed since we last saw it | ||
dbReq, err := r.db.GetQuoteRequestByID(ctx, req.TransactionID) | ||
if err != nil { | ||
return fmt.Errorf("could not get request: %w", err) | ||
} | ||
if dbReq.Status != req.Status { | ||
span.SetAttributes( | ||
attribute.Bool("status_changed", true), | ||
attribute.String("db_status", dbReq.Status.String()), | ||
attribute.String("handler_status", req.Status.String()), | ||
) | ||
return nil | ||
} |
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.
Ensure robust error handling and log details for status mismatch.
The addition of a status check in mutexMiddleware
is crucial for consistency in handling quote requests. However, when a status mismatch occurs, the function returns nil
without any specific error or log, which might make debugging difficult when status mismatches occur frequently.
Consider logging this event or handling it more explicitly to aid in troubleshooting and provide better visibility into the system's behavior.
if dbReq.Status != req.Status {
span.SetAttributes(
attribute.Bool("status_changed", true),
attribute.String("db_status", dbReq.Status.String()),
attribute.String("handler_status", req.Status.String()),
)
+ // Log the status mismatch for better traceability
+ log.Warn("Status mismatch detected", "db_status", dbReq.Status, "request_status", req.Status)
- return nil
+ return fmt.Errorf("status mismatch detected between database and handler")
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// make sure the status has not changed since we last saw it | |
dbReq, err := r.db.GetQuoteRequestByID(ctx, req.TransactionID) | |
if err != nil { | |
return fmt.Errorf("could not get request: %w", err) | |
} | |
if dbReq.Status != req.Status { | |
span.SetAttributes( | |
attribute.Bool("status_changed", true), | |
attribute.String("db_status", dbReq.Status.String()), | |
attribute.String("handler_status", req.Status.String()), | |
) | |
return nil | |
} | |
// make sure the status has not changed since we last saw it | |
dbReq, err := r.db.GetQuoteRequestByID(ctx, req.TransactionID) | |
if err != nil { | |
return fmt.Errorf("could not get request: %w", err) | |
} | |
if dbReq.Status != req.Status { | |
span.SetAttributes( | |
attribute.Bool("status_changed", true), | |
attribute.String("db_status", dbReq.Status.String()), | |
attribute.String("handler_status", req.Status.String()), | |
) | |
// Log the status mismatch for better traceability | |
log.Warn("Status mismatch detected", "db_status", dbReq.Status, "request_status", req.Status) | |
return fmt.Errorf("status mismatch detected between database and handler") | |
} |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2769 +/- ##
===================================================
- Coverage 25.69814% 25.69165% -0.00649%
===================================================
Files 699 699
Lines 51494 51507 +13
Branches 80 80
===================================================
Hits 13233 13233
- Misses 36914 36927 +13
Partials 1347 1347
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 (1)
- services/rfq/relayer/service/statushandler.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- services/rfq/relayer/service/statushandler.go
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
(updates since last review)
- Added validation check for request status consistency in RFQ Relayer
- Introduced new Slack bot (opbot) with commands and configurations
- Updated dependencies in multiple
go.mod
files - Enhanced README with new entry for opbot
- Added Dockerfile for opbot service
61 file(s) reviewed, no comment(s)
Summary by CodeRabbit