-
Notifications
You must be signed in to change notification settings - Fork 2
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 handling of the restart during unbonding #20
Conversation
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.
Nice fix! A refactoring and unit tests can be done in a separate PR
staker/stakerapp.go
Outdated
// delegation was send to Babylon and activated by covenants, check wheter we: | ||
// - did not spent tx beore restart | ||
// - did not sent unbonding tx before restart |
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.
// delegation was send to Babylon and activated by covenants, check wheter we: | |
// - did not spent tx beore restart | |
// - did not sent unbonding tx before restart | |
// delegation was sent to Babylon and activated by covenants, check whether we: | |
// - did not spend tx before restart | |
// - did not send unbonding tx before restart |
} | ||
|
||
if !stakingOutputSpent { | ||
continue |
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.
we can add a comment here explaining we don't need to do anything if the output is not spent
staker/stakerapp.go
Outdated
return err | ||
} | ||
|
||
// unbonding tx is in mempool, wait for confirmation and infrom event |
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.
// unbonding tx is in mempool, wait for confirmation and infrom event | |
// unbonding tx is in mempool, wait for confirmation and inform event |
staker/stakerapp.go
Outdated
if err := app.txTracker.SetTxSpentOnBtc(stakingTxHash); err != nil { | ||
return err | ||
} |
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.
seems we can have app.MustSetTxSpentOnBtc
to avoid embedded if condition and panic upon err
staker/stakerapp.go
Outdated
if err := app.txTracker.SetTxSpentOnBtc(stakingTxHash); err != nil { | ||
return err | ||
} |
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.
same here
* Fix handling of the restart during unbonding
* Fix handling of the restart during unbonding
Fixes: #18
Fixes handling of the case in which program crashes in between sending of unbonding transactions and unbonding transaction confirmation.
Note: this is still not perfect, as it may happen that:
UNBONDING_REQUESTED
but this would be breaking change to existing db that we want to avoid rn.Follow up task: #19