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 continues generating quotes if one fails #2264

Merged
merged 2 commits into from
Mar 15, 2024
Merged

Conversation

dwasse
Copy link
Collaborator

@dwasse dwasse commented Mar 13, 2024

Description
Fixes issue where an error generating an individual quote causes all quotes to fail.

Summary by CodeRabbit

  • New Features
    • Enhanced the handling of gas balances for better accuracy in transactions.
    • Improved quote generation for bridgeable tokens, including detailed token info parsing and fee calculations.

Copy link
Contributor

coderabbitai bot commented Mar 13, 2024

Warning

Rate Limit Exceeded

@trajan0x has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 26 minutes and 9 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 6d4d33e and 0dca5ef.

Walkthrough

The recent updates introduce enhanced handling for gas balances in the inventory management system and refine the quote generation process for bridgeable tokens. By ensuring gas balance retrieval and streamlining quote generation with a new dedicated function, these changes aim to improve efficiency and accuracy in operations.

Changes

File Path Change Summary
.../inventory/manager.go Added check for gas token balance retrieval in GetCommittableBalance method.
.../relayer/quoter/quoter.go Updated to include a new generateQuote function for detailed quote generation for bridgeable tokens.

🐇✨
In the code's woven maze, a rabbit hops,
Enhancing balance checks and swap shop props.
With every line, a better path it maps,
For tokens to bridge, no more perhaps.
Here's to the changes, may they make waves,
In the digital realm, where the blockchain paves.
🎉🐰

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-tests 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 tests 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 tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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

codecov bot commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 53.42466% with 34 lines in your changes are missing coverage. Please review.

Project coverage is 47.86207%. Comparing base (e513a28) to head (0dca5ef).
Report is 41 commits behind head on master.

Files Patch % Lines
services/rfq/relayer/quoter/quoter.go 56.52174% 23 Missing and 7 partials ⚠️
services/rfq/relayer/inventory/manager.go 0.00000% 4 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2264         +/-   ##
===================================================
+ Coverage   47.84597%   47.86207%   +0.01610%     
===================================================
  Files            360         360                 
  Lines          26903       26942         +39     
  Branches          83          83                 
===================================================
+ Hits           12872       12895         +23     
- Misses         12691       12708         +17     
+ Partials        1340        1339          -1     
Flag Coverage Δ
rfq 32.48671% <53.42466%> (+0.30864%) ⬆️
stiprelayer 3.33333% <ø> (ø)

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 Mar 13, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0dca5ef
Status: ✅  Deploy successful!
Preview URL: https://cdd32546.sanguine-fe.pages.dev
Branch Preview URL: https://fix-gas-balance.sanguine-fe.pages.dev

View logs

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.

Review Status

Actionable comments generated: 4

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between f6e4834 and 6d4d33e.
Files selected for processing (2)
  • services/rfq/relayer/inventory/manager.go (1 hunks)
  • services/rfq/relayer/quoter/quoter.go (1 hunks)
Check Runs (10)
codecov/patch completed (8)
  • services/rfq/relayer/inventory/manager.go: 87-90: Added lines #L87 - L90 were not covered by tests
  • services/rfq/relayer/quoter/quoter.go: 291-295: Added lines #L291 - L295 were not covered by tests
  • services/rfq/relayer/quoter/quoter.go: 309-310: Added lines #L309 - L310 were not covered by tests
  • services/rfq/relayer/quoter/quoter.go: 319-320: Added lines #L319 - L320 were not covered by tests
  • services/rfq/relayer/quoter/quoter.go: 325-326: Added lines #L325 - L326 were not covered by tests
  • services/rfq/relayer/quoter/quoter.go: 329-330: Added lines #L329 - L330 were not covered by tests
  • services/rfq/relayer/quoter/quoter.go: 333-334: Added lines #L333 - L334 were not covered by tests
  • services/rfq/relayer/quoter/quoter.go: 339-340: Added lines #L339 - L340 were not covered by tests
Go Generate (Module Changes) (services/stiprelayer) completed (6)
Go Coverage (1.21.x, ubuntu-latest, services/stiprelayer) completed (4)
Lint (services/rfq) completed (2)
Get PR Metadata completed (2)
Build (1.21.x, ubuntu-latest) completed (2)
Change Detection completed (13)
general-linters completed (1)
label-statuses completed (3)
pr-labeler completed (2)
Additional comments: 1
services/rfq/relayer/quoter/quoter.go (1)
  • 268-297: The introduction of the generateQuote function within generateQuotes is a significant improvement in handling individual quote generation failures. This change allows the system to continue generating quotes for other tokens even if one fails, which aligns with the PR's objectives. However, it's noted that the error handling within this loop logs the error but does not stop the execution or report it in a way that could be monitored or alerted on. Consider implementing a mechanism to track these failures for operational monitoring and alerting.

Consider enhancing error handling by introducing error tracking or alerting mechanisms to monitor individual quote generation failures. This could involve incrementing a metric counter for failures or logging errors to a centralized system where they can be tracked and alerted on.

Comment on lines +87 to +90
gasBalance, ok := i.gasBalances[chainID]
if !ok || gasBalance == nil {
return nil, fmt.Errorf("could not get gas balance for chain %d", chainID)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The added logic for handling gas balances when the gas token is not found in the inventory tokens map is a good improvement. It ensures that gas balances are properly managed, addressing a potential gap in the system's inventory management capabilities. However, it appears these changes are not covered by tests.

Ensuring test coverage for this new logic is crucial for validating its correctness and reliability. Consider adding unit tests that cover scenarios where the gas token is not found in the inventory tokens map, as well as cases where the gas balance is successfully retrieved or when it fails.

services/rfq/relayer/quoter/quoter.go Outdated Show resolved Hide resolved
Comment on lines +291 to +295
// continue generating quotes even if one fails
span.AddEvent("error generating quote", trace.WithAttributes(
attribute.String("key_token_id", keyTokenID),
))
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

The loop within generateQuotes that continues generating quotes even if one fails is a crucial improvement. However, the added lines were not covered by tests according to the static analysis hints. Ensuring comprehensive test coverage for this new logic is essential for validating its correctness and reliability.

Would you like assistance in writing tests to cover the new logic introduced in the generateQuotes function? This could help ensure the robustness and reliability of the changes.

Comment on lines +309 to +310
return nil, fmt.Errorf("error converting origin chainID: %w", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Several error handling blocks within the generateQuote function are not covered by tests, as indicated by static analysis hints. It's crucial to have tests that cover these scenarios to ensure the function behaves as expected under various error conditions.

I can help create tests that cover the error handling scenarios within the generateQuote function. Ensuring these paths are tested will improve the overall reliability of the quote generation process.

Also applies to: 319-320, 325-326, 329-330, 333-334, 339-340

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@dwasse dwasse merged commit 4032665 into master Mar 15, 2024
46 checks passed
@dwasse dwasse deleted the fix/gas-balance branch March 15, 2024 15:38
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 needs-go-generate-services/rfq size/s
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants