You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if ctx.ChainID() == ColumbusChainID{// Get the last Total Power of the validator set
lastPower := k.GetLastTotalPower(ctx)// Get the power of the current validator power
validatorLastPower := sdk.TokensToConsensusPower(validator.Tokens, k.PowerReduction(ctx))// Get the new power of the validator if delegated the bond amount
validatorNewPower := validatorLastPower + sdk.TokensToConsensusPower(bondAmt, k.PowerReduction(ctx))// Compute what the Total Consensus Power would be if this Delegation goes through
newTotalPower := lastPower.Int64() + sdk.TokensToConsensusPower(bondAmt, k.PowerReduction(ctx))// Compute what the new Validator voting power would be in relation to the new total power// validatorIncreasedDelegationPercent := float32(validatorNewPower) / float32(newTotalPower)
validatorIncreasedDelegationPercent := sdk.NewDec(validatorNewPower).QuoInt64(newTotalPower)// If Delegations are allowed, and the Delegation would have increased the Validator to over 20% of the staking power, do not allow the Delegation to proceedif validatorIncreasedDelegationPercent.GT(sdk.NewDecWithPrec(20,2)){panic("validator power is over the allowed limit")}}
Solution
We can introduce the AfterDelegationModifed hooks, which check the validator power < 20%
kien6034
changed the title
[staking] move validator power limit logic to terrad
[cosmos-sdk] x/staking/delegation limit voting power logic
Nov 2, 2024
kien6034
changed the title
[cosmos-sdk] x/staking/delegation limit voting power logic
[cosmos-sdk](x/staking/delegation) limit voting power logic
Nov 2, 2024
x/staking/keeper/delegation.go/
Solution
We can introduce the
AfterDelegationModifed
hooks, which check the validator power < 20%https://github.com/classic-terra/cosmos-sdk/blob/v0.47.10-terra.1/x/staking/keeper/delegation.go#L731-L733
Commit: 372f6f8
The text was updated successfully, but these errors were encountered: