-
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
feat: unbonding state transitions #27
Conversation
…ING, later expiry checker will mark unbonded by logic
@gusin13 "marks delegations which are naturally expired as Unbonding -> Withdrawable." this statement seems wrong to me. The BBN will emit I was referring to this comment in the babylon code
If this is correct then my above assumption should hold. But if not, then core team need to fix this comment and explicity point out the |
if err := s.db.UpdateBTCDelegationState( | ||
ctx, unbondedEarlyEvent.StakingTxHash, types.DelegationState(unbondedEarlyEvent.NewState), | ||
ctx, unbondedEarlyEvent.StakingTxHash, types.StateUnbonding, |
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.
could we have a method in the utils to map the BBN state into web state? i.e types.DelegationState(unbondedEarlyEvent.NewState)
seems ok to me, but not sure why it's removed?
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.
the state sent in Babylon event is Unbonded
, types.DelegationState(unbondedEarlyEvent.NewState) would give us Unbonded
but the indexer needs to treat this as Unbonding
internal/services/expiry-checker.go
Outdated
} | ||
|
||
// previous state should be unbonding | ||
if delegation.State != types.StateUnbonding { |
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.
I think this validation is too strong which will leads to issues when we have duplicated entries in db upon re-bootstrap of the service.
We have this set of methods in the phase-1 which i think we can re-use in phase-2 https://github.com/babylonlabs-io/staking-api-service/blob/main/internal/shared/utils/state_transition.go#L34
i.e ignore if the state is already beyond the withdrawable state
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.
i see, sure i have removed the check.
this might required lot of change in code for the outdated/qualified state transitions, would prefer to do in separate pr
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.
Approved with some comments
In Babylon this event is sent at |
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.
Great work! Some nits and questions:
@gusin13 gotcha. In that case, yeah, make sense to have the natural unbonded event to be tracked in the expiry process so we can transition to the |
@jrwbabylonlab i found some comments here which explains this case. Basically after the VP is lost, the delegation is neither active nor withdrawable, there is a middle state which can be referred as unbonding |
let's move this conversation to slack |
This PR
Sets up internal expiry checker service which reads the timelock_queue table and mark the delegations as Withdrawable
Note -
ran into this issue - ref tl;dr - this pr only marks delegations which are naturally expired as Unbonding -> Withdrawable.
for manual unbonding some extra work is needed as logged in above issue
i couldn't properly test the expiry checker as i can't access btc node locally, have pinged devops