-
Notifications
You must be signed in to change notification settings - Fork 190
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
Prevent panic in TransactionByHash for non-existent transactions #2373
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2373 +/- ##
==========================================
- Coverage 74.70% 74.67% -0.03%
==========================================
Files 110 110
Lines 12021 12024 +3
==========================================
- Hits 8980 8979 -1
Misses 2349 2349
- Partials 692 696 +4 ☔ View full report in Codecov by Sentry. |
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.
Need some tests
5131bee
to
1760dc8
Compare
When searching for a transaction in the pending block, the code would continue to AdaptTransaction even if no matching transaction was found. This could lead to a panic when trying to adapt a nil transaction. Added a nil check and an early break from the loop to ensure we properly handle non-existent transactions with ErrTxnHashNotFound. Changes: - Add break statement to exit loop once matching transaction is found - Add explicit nil check for txn before attempting to adapt it - Return ErrTxnHashNotFound if no matching transaction is found
1760dc8
to
3c1e532
Compare
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
nit: for the commit message I would recommend focusing on "what" and "why" while letting the code say "how". In my opinion, the changes in bullet points are unnecessary. |
Fixes an issue where the code could panic when attempting to adapt a nil transaction in the pending block. This ensures the function gracefully handles non-existent transactions by returning ErrTxnHashNotFound.