-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[bugfix] txnotifier: delete ntfn by confirm height always #4620
[bugfix] txnotifier: delete ntfn by confirm height always #4620
Conversation
When we cancel a confirmation request, we should remove the request from the height map regardless of the current height. Otherwise we end up in the situation when the height is reached, the notification is attempted sent which results in a crash.
This test addition would cause the txnotifier to crash prior to the previous commit.
@@ -763,9 +763,7 @@ func (n *TxNotifier) CancelConf(confRequest ConfRequest, confID uint64) { | |||
if confSet.details != nil { | |||
confHeight := confSet.details.BlockHeight + | |||
ntfn.NumConfirmations - 1 | |||
if confHeight <= n.currentHeight { |
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.
@wpaulino Just to make sure: was this condition here for a good reason?
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.
not 100% sure myself, but i think your change is correct. doesn't make sense to continue tracking a canceled request
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.
It looks like I actually meant to write the opposite condition. If the confirmation height has not been reached, then we should delete it as it hasn't been notified yet to prevent the notification, but if it has, then there's no need to delete it as that's already done once the notification is dispatched. Either way, it should be fine to just always delete now.
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 🦘
@@ -763,9 +763,7 @@ func (n *TxNotifier) CancelConf(confRequest ConfRequest, confID uint64) { | |||
if confSet.details != nil { | |||
confHeight := confSet.details.BlockHeight + | |||
ntfn.NumConfirmations - 1 | |||
if confHeight <= n.currentHeight { |
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.
not 100% sure myself, but i think your change is correct. doesn't make sense to continue tracking a canceled request
@@ -763,9 +763,7 @@ func (n *TxNotifier) CancelConf(confRequest ConfRequest, confID uint64) { | |||
if confSet.details != nil { | |||
confHeight := confSet.details.BlockHeight + | |||
ntfn.NumConfirmations - 1 | |||
if confHeight <= n.currentHeight { |
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.
It looks like I actually meant to write the opposite condition. If the confirmation height has not been reached, then we should delete it as it hasn't been notified yet to prevent the notification, but if it has, then there's no need to delete it as that's already done once the notification is dispatched. Either way, it should be fine to just always delete now.
When we cancel a confirmation request, we should remove the request from
the height map regardless of the current height. Otherwise we end up in
the situation when the height is reached, the notification is attempted
sent which results in a crash.