Skip to content

Update status if tx reverts onchain #72

Merged
adelowo merged 4 commits intomainfrom
check_for_failures
Jan 13, 2025
Merged

Update status if tx reverts onchain #72
adelowo merged 4 commits intomainfrom
check_for_failures

Conversation

@adelowo
Copy link
Copy Markdown
Contributor

@adelowo adelowo commented Jan 9, 2025

Check the receipt status and if it fails, use a reason that specifically tells you it is onchain but reverted

Needs blndgs/model#61

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced transaction failure handling by providing more precise status information for user operation receipts.
    • Improved error reporting mechanism for transaction processing.
  • Chores

    • Updated various dependencies to their latest versions for improved performance and security.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 9, 2025

Walkthrough

The pull request introduces changes to the receipt/handler.go file, which include a new import statement for the protobuf package and modifications to the processEvent function's signature and logic. The handling of the Reason field in the UserOperationReceipt struct is updated to set a more specific status for transaction receipt failures. Additionally, the go.mod file is updated to reflect changes in several dependencies, including version increments and the addition of a new dependency.

Changes

File Change Summary
receipt/handler.go - Added import for protobuf package pb from github.com/blndgs/model/gen/go/proto/v1
- Modified processEvent function signature to include store parameter
- Updated calls to processEvent in GetUserOperationReceipt to include store
- Introduced variable reason to determine the processing status based on transaction receipt conditions
- Updated UserOperationReceipt instantiation to use reason instead of status.Status.String()
go.mod - Updated github.com/blndgs/model from v0.44.0 to v0.56.0
- Updated github.com/goccy/go-json from v0.10.3 to v0.10.4
- Added golang.org/x/crypto at version v0.32.0
- Updated golang.org/x/sync from v0.7.0 to v0.10.0
- Updated github.com/holiman/uint256 from v1.2.4 to v1.3.2
- Updated google.golang.org/protobuf from v1.34.2 to v1.36.2
- Updated golang.org/x/sys from v0.21.0 to v0.29.0
- Updated golang.org/x/text from v0.16.0 to v0.21.0

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff6feeb and 9db0740.

📒 Files selected for processing (1)
  • receipt/handler.go (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • receipt/handler.go

🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

CodeRabbit Configuration 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.

Copy link
Copy Markdown

@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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b470cc and 5cf81c3.

📒 Files selected for processing (1)
  • receipt/handler.go (3 hunks)
🧰 Additional context used
🪛 GitHub Actions: Deploy to ECS
receipt/handler.go

[error] 134-134: undefined: pb.ProcessingStatus_PROCESSING_STATUS_ON_CHAIN_REVERT

🔇 Additional comments (1)
receipt/handler.go (1)

Line range hint 151-162: LGTM! Clear status handling for reverted transactions

The implementation correctly updates the Reason field in the receipt to provide more specific information about on-chain transaction reverts, which aligns well with the PR objective.

Comment thread receipt/handler.go
Comment thread receipt/handler.go
@adelowo adelowo requested review from blewater and hpsing January 9, 2025 08:38
blewater
blewater previously approved these changes Jan 9, 2025
Copy link
Copy Markdown

@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

♻️ Duplicate comments (1)
receipt/handler.go (1)

131-135: ⚠️ Potential issue

Add nil check for receipt before accessing Status field

The receipt should be checked for nil before accessing its Status field to prevent potential panic.

 reason := status.Status.String()

-if receipt.Status == types.ReceiptStatusFailed {
+if receipt != nil && receipt.Status == types.ReceiptStatusFailed {
     reason = pb.ProcessingStatus_PROCESSING_STATUS_ON_CHAIN_REVERT.String()
 }
🧹 Nitpick comments (1)
receipt/handler.go (1)

131-139: Consider consolidating the revert status conditions

The code sets the same revert status in two separate conditions. Consider consolidating them to make the logic clearer and prevent potential confusion about the final state.

 reason := status.Status.String()

-if receipt.Status == types.ReceiptStatusFailed {
-    reason = pb.ProcessingStatus_PROCESSING_STATUS_ON_CHAIN_REVERT.String()
-}
-
-if !it.Event.Success {
+if (receipt != nil && receipt.Status == types.ReceiptStatusFailed) || !it.Event.Success {
     reason = pb.ProcessingStatus_PROCESSING_STATUS_ON_CHAIN_REVERT.String()
-}
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5cf81c3 and 4158cc0.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • go.mod (4 hunks)
  • receipt/handler.go (3 hunks)
🔇 Additional comments (3)
go.mod (1)

8-8: Verify model dependency version compatibility

The update to github.com/blndgs/model v0.56.0 is significant. Please ensure this version includes the required ProcessingStatus_PROCESSING_STATUS_ON_CHAIN_REVERT enum from PR blndgs/model#61.

✅ Verification successful

✓ Model dependency version compatibility verified

The required ProcessingStatus_PROCESSING_STATUS_ON_CHAIN_REVERT enum is present and actively used in the codebase with model v0.56.0, as evidenced by its usage in receipt/handler.go.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the ProcessingStatus enum is properly defined in the model repository
# Test: Search for the ProcessingStatus enum definition
ast-grep --pattern 'enum ProcessingStatus {
  $$$
  PROCESSING_STATUS_ON_CHAIN_REVERT = $_
  $$$
}'

Length of output: 101


Script:

#!/bin/bash
# Search for ProcessingStatus in .proto files
echo "=== Searching .proto files ==="
fd -e proto -x rg -l "ProcessingStatus"

echo -e "\n=== Searching for ProcessingStatus enum usage ==="
rg "ProcessingStatus_PROCESSING_STATUS_ON_CHAIN_REVERT"

echo -e "\n=== Checking imports of model package ==="
rg "github.com/blndgs/model"

Length of output: 1926

receipt/handler.go (2)

17-18: LGTM!

The protobuf import is correctly added and follows the package path convention.


155-155: LGTM!

The UserOperationReceipt struct correctly uses the newly determined reason value.

Copy link
Copy Markdown
Contributor

@hpsing hpsing left a comment

Choose a reason for hiding this comment

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

we should be using updateStatus from the store so that it can be queried using getReceipt with currect status.

@adelowo adelowo requested a review from hpsing January 10, 2025 14:03
@adelowo adelowo merged commit 6f649c4 into main Jan 13, 2025
@adelowo adelowo deleted the check_for_failures branch January 13, 2025 08:27
adelowo added a commit that referenced this pull request Jan 13, 2025
* fix: userops status fixes

* feat: custom user receipt

* fix: receipt fetch from db

* fix: status return for cases

* fix: suggested changes

* fix: store package for db activities

* fix: hardcoded lines

* Update status if tx reverts onchain  (#72)

* check if tx reverted onchain

* use success too for checks

* move check to a single branch

* store in badger

---------

Co-authored-by: singhhp1069 <singhhp1069@gmail.com>
adelowo added a commit that referenced this pull request Jan 13, 2025
* fix: userops status fixes

* feat: custom user receipt

* fix: receipt fetch from db

* fix: status return for cases

* fix: suggested changes

* fix: store package for db activities

* fix: hardcoded lines

* Update status if tx reverts onchain  (#72)

* check if tx reverted onchain

* use success too for checks

* move check to a single branch

* store in badger

---------

Co-authored-by: singhhp1069 <singhhp1069@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants