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

feat(opbot): add tx hash after refund [SLT-460] #3375

Merged
merged 7 commits into from
Nov 20, 2024

Conversation

golangisfun123
Copy link
Collaborator

@golangisfun123 golangisfun123 commented Nov 6, 2024

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

  • Fixes #[Link to Issue]

Summary by CodeRabbit

  • New Features

    • Enhanced error handling and messaging for transaction searches and refund submissions.
    • Updated command descriptions for clarity.
  • Bug Fixes

    • Improved responses for cases when no transactions are found or when refund submissions fail.

@github-actions github-actions bot added go Pull requests that update Go code size/xs labels Nov 6, 2024
Copy link
Contributor

coderabbitai bot commented Nov 6, 2024

Walkthrough

The changes in this pull request focus on enhancing the traceCommand and rfqRefund methods in the botmd package. Modifications include improved error handling, more specific user feedback, and updated method signatures. The traceCommand method now provides clearer messages regarding transaction searches, while the rfqRefund method enhances its error messaging and adjusts retry logic for refund submissions. These updates aim to refine the user experience and control flow during command execution.

Changes

File Path Change Summary
contrib/opbot/botmd/commands.go Updated traceCommand method description and error handling; modified rfqRefund for better error messages and adjusted retry logic. Method signatures for both updated.

Possibly related PRs

Suggested labels

M-deps

Suggested reviewers

  • trajan0x
  • dwasse

Poem

In the code where rabbits play,
Error messages brightened the day.
Refunds now clear, transactions in sight,
With each command, things feel just right!
Hopping through logic, we refine our way,
Celebrating changes, hip-hip-hooray! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 golangci-lint

level=warning msg="[config_reader] The configuration option run.skip-files is deprecated, please use issues.exclude-files."
level=warning msg="[config_reader] The configuration option run.skip-dirs is deprecated, please use issues.exclude-dirs."
level=warning msg="[config_reader] The configuration option run.skip-dirs-use-default is deprecated, please use issues.exclude-dirs-use-default."
level=warning msg="[lintersdb] The linter "maligned" is deprecated (step 2) and deactivated. It should be removed from the list of disabled linters. https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle"
level=warning msg="[lintersdb] The linter "exhaustivestruct" is deprecated (step 2) and deactivated. It should be removed from the list of disabled linters. https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle"
level=warning msg="[lintersdb] The linter "ifshort" is deprecated (step 2) and deactivated. It should be removed from the list of disabled linters. https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle"
level=warning msg="[lintersdb] The linter "interfacer" is deprecated (step 2) and deactivated. It should be removed from the list of disabled linters. https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle"
level=warning msg="[lintersdb] The linter "nosnakecase" is deprecated (step 2) and deactivated. It should be removed from the list of disabled linters. https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle"
level=warning msg="[lintersdb] The name "goerr113" is deprecated. The linter has been renamed to: err113."
level=warning msg="The linter 'execinquery' is deprecated (since v1.58.0) due to: The repository of the linter has been archived by the owner. "
level=warning msg="The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar."


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

Copy link

codecov bot commented Nov 6, 2024

Codecov Report

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

Project coverage is 34.90814%. Comparing base (fd8ad75) to head (37b68be).
Report is 24 commits behind head on master.

Files with missing lines Patch % Lines
contrib/opbot/botmd/commands.go 0.00000% 7 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #3375         +/-   ##
===================================================
+ Coverage   33.16732%   34.90814%   +1.74082%     
===================================================
  Files            544          78        -466     
  Lines          34736        2667      -32069     
  Branches          82          82                 
===================================================
- Hits           11521         931      -10590     
+ Misses         22197        1733      -20464     
+ Partials        1018           3       -1015     
Flag Coverage Δ
cctp-relayer ?
core ?
ethergo ?
git-changes-action ?
omnirpc ?
opbot 0.18282% <0.00000%> (-0.00055%) ⬇️
promexporter ?
rfq ?
screener-api ?
scribe ?
tools ?

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.


🚨 Try these New Features:

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: 1

🧹 Outside diff range and nitpick comments (1)
contrib/opbot/botmd/commands.go (1)

348-351: LGTM, but needs test coverage

The error handling improvements look good, with clear error messages and proper distinction between different error cases. However, these changes are not covered by tests.

Would you like me to help create unit tests for these error handling scenarios?

Also applies to: 356-356, 361-364

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 348-351: contrib/opbot/botmd/commands.go#L348-L351
Added lines #L348 - L351 were not covered by tests

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 038f3a6 and 94f3d11.

📒 Files selected for processing (2)
  • contrib/opbot/botmd/commands.go (2 hunks)
  • contrib/opbot/config/signer.txt (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • contrib/opbot/config/signer.txt
🧰 Additional context used
🪛 GitHub Check: codecov/patch
contrib/opbot/botmd/commands.go

[warning] 56-56: contrib/opbot/botmd/commands.go#L56
Added line #L56 was not covered by tests


[warning] 348-351: contrib/opbot/botmd/commands.go#L348-L351
Added lines #L348 - L351 were not covered by tests


[warning] 356-356: contrib/opbot/botmd/commands.go#L356
Added line #L356 was not covered by tests


[warning] 361-361: contrib/opbot/botmd/commands.go#L361
Added line #L361 was not covered by tests


[warning] 363-364: contrib/opbot/botmd/commands.go#L363-L364
Added lines #L363 - L364 were not covered by tests


[warning] 373-373: contrib/opbot/botmd/commands.go#L373
Added line #L373 was not covered by tests

🪛 GitHub Check: Lint (contrib/opbot)
contrib/opbot/botmd/commands.go

[failure] 56-56:
Duplicate words (testing) found (dupword)

🔇 Additional comments (1)
contrib/opbot/botmd/commands.go (1)

368-368: Verify the increased timeout duration

The timeout increase from 30s to 1m is reasonable for blockchain transactions, but let's verify this doesn't impact other system timeouts or user experience.

Also applies to: 370-370, 373-373

✅ Verification successful

Based on the search results, I can see that the timeout values in the codebase vary based on their specific use cases:

  1. For blockchain transaction-related operations:

    • RFQ service uses 1 minute timeout for transaction-related operations
    • Explorer service uses timeouts ranging from 30s to 1m for transaction fetching
    • CCTP relayer uses 90s timeout for blockchain operations
  2. For retry operations with blockchain:

    • Most services use 30s to 1m timeout for retry operations
    • E2E tests use longer timeouts (5m) for setup operations

The change to increase the timeout from 30s to 1m in contrib/opbot/botmd/commands.go aligns well with the timeout patterns used across the codebase for blockchain transaction operations. This is a reasonable duration that matches other similar blockchain transaction handling timeouts.

Timeout duration of 1 minute is consistent with codebase patterns

The increased timeout from 30s to 1m aligns with similar blockchain transaction handling timeouts across the codebase and is a reasonable duration for waiting for transaction confirmations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any other timeouts in the codebase that might need adjustment
rg -A 2 "WithMaxTotalTime|context.*WithTimeout" --type go

Length of output: 26811

@@ -53,7 +53,7 @@
func (b *Bot) traceCommand() *slacker.CommandDefinition {
return b.requiresSignoz(&slacker.CommandDefinition{
Command: "trace {tags} {order}",
Description: "find a transaction in signoz",
Description: "testing testing",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Revert description to meaningful text

The description "testing testing" appears to be test text that was accidentally left in. This should be reverted to the original description "find a transaction in signoz" to maintain clarity and professionalism.

-		Description: "testing testing",
+		Description: "find a transaction in signoz",
📝 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.

Suggested change
Description: "testing testing",
Description: "find a transaction in signoz",
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 56-56: contrib/opbot/botmd/commands.go#L56
Added line #L56 was not covered by tests

🪛 GitHub Check: Lint (contrib/opbot)

[failure] 56-56:
Duplicate words (testing) found (dupword)

Copy link

cloudflare-workers-and-pages bot commented Nov 12, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: ddbc721
Status: ✅  Deploy successful!
Preview URL: https://9ab46e2e.sanguine-fe.pages.dev
Branch Preview URL: https://fix-opbot-tracing.sanguine-fe.pages.dev

View logs

@golangisfun123 golangisfun123 changed the title add tx hash after refund feat(opbot): add tx hash after refund [SLT-460] Nov 12, 2024
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: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 94f3d11 and 37b68be.

📒 Files selected for processing (1)
  • contrib/opbot/botmd/commands.go (3 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
contrib/opbot/botmd/commands.go

[warning] 323-326: contrib/opbot/botmd/commands.go#L323-L326
Added lines #L323 - L326 were not covered by tests


[warning] 338-339: contrib/opbot/botmd/commands.go#L338-L339
Added lines #L338 - L339 were not covered by tests


[warning] 350-350: contrib/opbot/botmd/commands.go#L350
Added line #L350 was not covered by tests

🔇 Additional comments (2)
contrib/opbot/botmd/commands.go (2)

323-326: Enhance error handling and add test coverage

The error handling could be more informative to help with debugging. Consider including more context in the user-facing message while keeping sensitive details in logs.

-				_, err := ctx.Response().Reply("error submitting refund")
+				_, err := ctx.Response().Reply(fmt.Sprintf("Failed to submit refund. Please try again or contact support. Reference: %d", nonce))

Let's verify the test coverage:

#!/bin/bash
# Check for existing test files covering refund error scenarios
fd -e go -E '*_test.go' . | xargs rg "TestRfqRefund.*Error"
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 323-326: contrib/opbot/botmd/commands.go#L323-L326
Added lines #L323 - L326 were not covered by tests


338-343: Add test coverage for retry scenarios

The retry logic for transaction hash verification has been improved with more specific error handling. However, this critical path lacks test coverage.

Let's check for existing retry tests:

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 338-339: contrib/opbot/botmd/commands.go#L338-L339
Added lines #L338 - L339 were not covered by tests

if err != nil {
b.logger.Errorf(ctx.Context(), "error fetching quote request: %v", err)
_, err := ctx.Response().Reply(fmt.Sprintf("refund submitted with nonce %d", nonce))
if err != nil {
log.Println(err)
b.logger.Errorf(ctx.Context(), "error fetching quote request: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove duplicate error logging

This line creates duplicate error logs for the same error condition that was already logged.

-					b.logger.Errorf(ctx.Context(), "error fetching quote request: %v", err)
📝 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.

Suggested change
b.logger.Errorf(ctx.Context(), "error fetching quote request: %v", err)
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 350-350: contrib/opbot/botmd/commands.go#L350
Added line #L350 was not covered by tests

@golangisfun123 golangisfun123 merged commit ff1e9ea into master Nov 20, 2024
28 of 29 checks passed
@golangisfun123 golangisfun123 deleted the fix-opbot-tracing branch November 20, 2024 19:54
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/xs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants