-
Notifications
You must be signed in to change notification settings - Fork 11
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: add validator cap and bond checks when creating the delegation strategy #810
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
x/liquidstake/keeper/liquidstake.go
Outdated
|
||
// just delegate if the validator does not exceed any of the validator specific caps | ||
if !k.stakingKeeper.CheckExceedsValidatorBondCap(ctx, validator, outputShares) && | ||
!k.stakingKeeper.CheckExceedsValidatorLiquidStakingCap(ctx, validator, outputShares, false) { |
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.
here if it still has some space, we should try to fill everything up
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 do you mean ?
I've done a rework on the function and modified the LiquidStake one as well. The previous version was wrong. You'll also see I've removed a few test parts that were checking exact delegations since the delegation strategy uses a map and it is not possible to have consistent results when testing. Still, the overall amounts are checked. |
if leftOver.LT(numValidators) { // if the leftover is less than the number of validators to be delegated, just add it to the first one that can receive it | ||
diffPerValidator = leftOver | ||
} | ||
for strAddr := range delegations { |
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.
this is a ticking bomb for non determinism. do not iterate over maps. both here and https://github.com/persistenceOne/pstake-native/pull/810/files#diff-d71073dfa714aa345a7e072ed4d0626328925c093d70acb85254b12df28eb45dR562
No description provided.