-
Notifications
You must be signed in to change notification settings - Fork 37
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
fix: prevent nil memory access #130
Conversation
WalkthroughThe changes in this pull request focus on the Changes
Possibly related PRs
🪧 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
jsonrpc/backend/tx.go (1)
187-188
: Consider adding debug logging for better observability.Adding debug logs when a transaction is skipped due to being nil or pending would help with troubleshooting and monitoring.
} else if rpcTx == nil || rpcTx.BlockNumber == nil || rpcTx.BlockNumber.ToInt() == nil { + b.logger.Debug("transaction not ready for receipt", "hash", hash, "status", func() string { + switch { + case rpcTx == nil: + return "not_found" + case rpcTx.BlockNumber == nil: + return "no_block_number" + default: + return "invalid_block_number" + } + }()) return nil, nil // tx is not found or in pending/queued state
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
jsonrpc/backend/tx.go
(1 hunks)
🔇 Additional comments (1)
jsonrpc/backend/tx.go (1)
187-188
: LGTM! Comprehensive nil checks prevent memory access issues.
The additional nil checks properly handle the race condition between getTransaction
and getReceipt
calls, preventing potential crashes in marshalReceipt
when a transaction is in pending/queued state.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #130 +/- ##
=======================================
Coverage 56.93% 56.93%
=======================================
Files 110 110
Lines 10063 10063
=======================================
Hits 5729 5729
Misses 3508 3508
Partials 826 826
|
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.
LGTM
Description
Closes: #XXXX
There may be a timing issue when fetching the receipt, specifically between the getTransaction and getReceipt calls. The getTransaction call can return a transaction in a pending state, while the getReceipt call might complete when the transaction has already transitioned to the committed state.
As a result, when attempting to marshalReceipt with transaction data from the pending state, it can lead to a crash during the query.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
Summary by CodeRabbit
Bug Fixes
Documentation