Skip to content
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: more speedups #2757

Closed
wants to merge 66 commits into from
Closed

RFQ Relayer: more speedups #2757

wants to merge 66 commits into from

Conversation

dwasse
Copy link
Collaborator

@dwasse dwasse commented Jun 20, 2024

Addresses #2743

Summary by CodeRabbit

  • Refactor
    • Improved efficiency of the quote request handling by processing ShouldProcess and IsProfitable checks concurrently.
    • Enhanced performance of gas sufficiency checks by running origin and destination chain checks in parallel, potentially reducing latency.

Copy link
Contributor

coderabbitai bot commented Jun 20, 2024

Walkthrough

The recent updates in the RFQ relayer service's handlers.go and statushandler.go focus on optimizing concurrent processing. Specifically, handleSeen in QuoteRequestHandler was refactored to concurrently run ShouldProcess and IsProfitable checks using errgroup, improving efficiency. Similarly, gas sufficiency checks on origin and destination chains have been refactored to run in parallel, reducing latency.

Changes

File Change Summary
handlers.go (.../service) Refactored handleSeen in QuoteRequestHandler to use errgroup for concurrent ShouldProcess and IsProfitable
statushandler.go (.../service) Refactored gas sufficiency checks to be performed concurrently using errgroup.WithContext

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant QuoteRequestHandler
    participant Quoter

    Client ->> QuoteRequestHandler: handleSeen(request)
    QuoteRequestHandler ->> Quoter: ShouldProcess(request) (concurrent)
    QuoteRequestHandler ->> Quoter: IsProfitable(request) (concurrent)
    Quoter -->> QuoteRequestHandler: shouldProcess
    Quoter -->> QuoteRequestHandler: isProfitable
    QuoteRequestHandler -->> Client: Return response
Loading
sequenceDiagram
    participant Client
    participant StatusHandler
    participant OriginChain
    participant DestinationChain

    Client ->> StatusHandler: checkGasSufficiency()
    StatusHandler ->> OriginChain: checkGas() (concurrent)
    StatusHandler ->> DestinationChain: checkGas() (concurrent)
    OriginChain -->> StatusHandler: gasStatus
    DestinationChain -->> StatusHandler: gasStatus
    StatusHandler -->> Client: Return response
Loading

Poem

In a realm of Go's fine dance,
Concurrency took its chance,
Quote checks leap in parallel flight,
Gas sufficiency joins the light.
Swiftly now, our code does prance,
For speed and grace, we'd gladly enhance.


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added go Pull requests that update Go code size/s labels Jun 20, 2024
Copy link

codecov bot commented Jun 20, 2024

Codecov Report

Attention: Patch coverage is 0% with 43 lines in your changes missing coverage. Please review.

Project coverage is 25.42623%. Comparing base (1e61249) to head (1232964).
Report is 59 commits behind head on master.

Files Patch % Lines
services/rfq/relayer/service/statushandler.go 0.00000% 25 Missing ⚠️
services/rfq/relayer/service/handlers.go 0.00000% 18 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2757         +/-   ##
===================================================
+ Coverage   25.36072%   25.42623%   +0.06550%     
===================================================
  Files            783         726         -57     
  Lines          56276       53551       -2725     
  Branches          80          80                 
===================================================
- Hits           14272       13616        -656     
+ Misses         40533       38532       -2001     
+ Partials        1471        1403         -68     
Flag Coverage Δ
cctp-relayer ?
opbot 0.18541% <ø> (ø)
packages 90.47619% <ø> (ø)
promexporter ?
rfq 24.85141% <0.00000%> (-0.09216%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

cloudflare-workers-and-pages bot commented Jun 20, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1232964
Status: ✅  Deploy successful!
Preview URL: https://2c8ac2b3.sanguine-fe.pages.dev
Branch Preview URL: https://feat-rfq-more-speedups.sanguine-fe.pages.dev

View logs

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

  • Parallelized ShouldProcess and IsProfitable checks in handleSeen using errgroup for faster quote request processing (services/rfq/relayer/service/handlers.go)
  • Parallelized gas sufficiency checks for origin and destination chains using errgroup to improve speed (services/rfq/relayer/service/statushandler.go)

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between 9cdc208 and 0f0bb77.

Files selected for processing (2)
  • services/rfq/relayer/service/handlers.go (3 hunks)
  • services/rfq/relayer/service/statushandler.go (2 hunks)
Additional comments not posted (2)
services/rfq/relayer/service/statushandler.go (1)

168-176: LGTM! But verify the function usage in the codebase.

The code changes are approved. Running gas sufficiency checks in parallel improves performance.

However, ensure that all function calls to gasMiddleware are correctly handling the new concurrency logic.

services/rfq/relayer/service/handlers.go (1)

140-160: LGTM! But verify the function usage in the codebase.

The code changes are approved. Running ShouldProcess and IsProfitable checks in parallel improves performance.

However, ensure that all function calls to handleSeen are correctly handling the new concurrency logic.

Copy link

@greptile-apps greptile-apps bot left a 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 rfqRefund command to contrib/opbot/botmd/commands.go for handling refund requests.
  • Introduced UpsertQuotes method in services/rfq/api/db/api_db.go for bulk quote handling.
  • Enhanced services/rfq/relayer/quoter/quoter.go to process ShouldProcess and IsProfitable checks concurrently.
  • Added new configuration options in services/rfq/relayer/relconfig/config.go for enabling API withdrawals and embedded guard.
  • Updated services/rfq/relayer/relapi/server.go to include new routes for withdrawing and getting requests by transaction ID.

116 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Jul 21, 2024
@github-actions github-actions bot closed this Jul 27, 2024
@github-actions github-actions bot deleted the feat/rfq-more-speedups branch October 8, 2024 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code size/s Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants