-
Notifications
You must be signed in to change notification settings - Fork 4
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: handle slashing state #51
Conversation
if dbErr != nil { | ||
return false, types.NewError( | ||
if dbErr := s.db.UpdateDelegationsStateByFinalityProvider( | ||
ctx, fpBTCPKHex, types.StateSlashed, |
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.
what if service restart in the mid of this process? e.g there are 1m delegations under the FP PK. we only processed 10k of those then we deployed the service again
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.
hmm so if this happens then last processed height not updated.
in next restart, it picks up from same height (at which it failed in prev run), finds this slashing event and then tries to make a bulk update again 🤔
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.
ah, but slashing operation is very time consuming. we shall not couple it with the main processing thread.
Given the same example above, say u have 1 million delegations under this FP. our indexer will be blocked on this operation until all delegations are updated.
My proposal is to perform this slashing operation in a different go routine, you can do this by either:
- Emit "slashing msg" into rabbitmq, then process it by indexer itself. only delete the msg once all delegations are processed.
- OR, you create a temporary db collection just for slashing. let's say
slashing_registry
. then a go routing monitoring this collection and remove the entry once no more delegations to process.
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 created a ticket to optimize the slashing process
#57
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 but with a comment in which you can probably handle it in a seperate PR to get the state transition out of the door for now
Intercepts the slashing event from Babylon and then transitions all delegations for the slashed fp to "Slashed" state.
Note -
Currently Babylon doesn't emit slashing tx so indexer cannot identify when the slashing output is spent and the slashing withdrawal has happened or not.
Have added a todo for now regarding this, also created a ticket on babylon
babylonlabs-io/babylon#271