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

Fix Nil pointer error in TXM stuck tx detector #14685

Merged
merged 15 commits into from
Oct 9, 2024

Conversation

huangzhen1997
Copy link
Contributor

@huangzhen1997 huangzhen1997 commented Oct 8, 2024

Description

The stuck transaction detector handler in Zircuit checks for both quarantine transaction using rpc call, and utilize existing detectStuckTransactionsHeuristic for potential overflow. The findBroadcastedAttempts in detectStuckTransactionsHeuristic can returns attempts with nil pointers that potentially cause panic.

Changed the return type of findBroadcastedAttempts to be pointers and added nil pointer check.

Reference:

https://chainlink-core.slack.com/archives/C06P81YRSN8/p1728379773038689

@huangzhen1997 huangzhen1997 marked this pull request as ready for review October 8, 2024 15:10
@huangzhen1997 huangzhen1997 requested review from a team as code owners October 8, 2024 15:10
@huangzhen1997 huangzhen1997 requested a review from ilija42 October 8, 2024 15:10
Copy link
Contributor

github-actions bot commented Oct 8, 2024

WF: CI Core#b43bf21

No errors found in this run. 🎉

amit-momin
amit-momin previously approved these changes Oct 8, 2024
ilija42
ilija42 previously approved these changes Oct 8, 2024
Copy link
Collaborator

@patrick-dowell patrick-dowell left a comment

Choose a reason for hiding this comment

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

Left one comment about something that confused me in the logic. In addition, I was wondering - can we add a test case somewhere that triggers this logic? I think we are adding logic to cover an unusual corner case it'd be good to have a test covering it so someone doesn't accidentally come along and break the desired behavior.

// 3. Check if the transaction has at least MinAttempts amount of broadcasted attempts
if broadcastedAttemptsCount < *d.cfg.MinAttempts() {
continue
}
// 4. Check if the newest broadcasted attempt's gas price is higher than what our gas estimator's GetFee method returns
if compareGasFees(newestBroadcastAttempt.TxFee, marketGasPrice) <= 0 {
if newestBroadcastAttempt != nil && compareGasFees(newestBroadcastAttempt.TxFee, marketGasPrice) <= 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if this is nil, shouldn't we log an error, similar to if oldestBroadcastAttempt is nil?

Would it make sense to move both checks up to line 220 before we do anything else? Although interestingly it looks like if oldest is nil we continue and if newest is nil we will add it to the stuck txns.

@huangzhen1997 huangzhen1997 dismissed stale reviews from ilija42 and amit-momin via ae9344c October 8, 2024 21:16
@patrick-dowell patrick-dowell added this pull request to the merge queue Oct 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 9, 2024
@patrick-dowell patrick-dowell added this pull request to the merge queue Oct 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 9, 2024
@ilija42 ilija42 added this pull request to the merge queue Oct 9, 2024
Merged via the queue into develop with commit c5e9f93 Oct 9, 2024
130 checks passed
@ilija42 ilija42 deleted the fix-txm-stuckTxDetector-heuristic-nil-ptr-error branch October 9, 2024 19:35
friedemannf pushed a commit to smartcontractkit/ccip that referenced this pull request Oct 15, 2024
An NPE bug was identified in the Stuck Tx Detector component. The fix
was addressed in this
smartcontractkit/chainlink#14685 in core but
needs to be applied to CCIP as well. Changes could not be cherry-picked
because of other changes made to the component in between so changes
were back ported manually.
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.

5 participants