Skip to content

Commit

Permalink
fix: return validators' delegation amount directly
Browse files Browse the repository at this point in the history
  • Loading branch information
j75689 committed Jan 3, 2024
1 parent 1b21736 commit c27e6b7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
11 changes: 1 addition & 10 deletions x/stake/cross_stake/cross_stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,9 @@ func (app *CrossStakeApp) handleUndelegate(ctx sdk.Context, pack *types.CrossSta
}, errCode, nil
}

validator, found := app.stakeKeeper.GetValidator(ctx, pack.Validator)
if !found {
errCode = CrossStakeErrBadDelegation
return sdk.ExecuteResult{
Err: types.ErrNoValidatorFound(app.stakeKeeper.Codespace()),
}, errCode, nil
}

if sdk.IsUpgrade(sdk.FirstSunsetFork) && !validator.IsSelfDelegator(delAddr) {
if sdk.IsUpgrade(sdk.FirstSunsetFork) {
// unbound the delegation directly, do not wait for the breathe block
// this is to prevent too many user get the coins back in the breathe block
// but self delegation still needs to wait until the unbonding period

_, _, err := app.stakeKeeper.UnboundDelegation(ctx.WithCrossStake(true), delAddr, pack.Validator, shares)
if err != nil {
Expand Down
8 changes: 1 addition & 7 deletions x/stake/handler_sidechain.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,9 @@ func handleMsgSideChainUndelegate(ctx sdk.Context, msg MsgSideChainUndelegate, k
events sdk.Events
)

validator, found := k.GetValidator(ctx, msg.ValidatorAddr)
if !found {
return types.ErrNoValidatorFound(k.Codespace()).Result()
}

if sdk.IsUpgrade(sdk.FirstSunsetFork) && !validator.IsSelfDelegator(msg.DelegatorAddr) {
if sdk.IsUpgrade(sdk.FirstSunsetFork) {
// unbound the delegation directly, do not wait for the breathe block
// this is to prevent too many user get the coins back in the breathe block
// but self delegation still needs to wait until the unbonding period

ubd, events, err = k.UnboundDelegation(ctx, msg.DelegatorAddr, msg.ValidatorAddr, shares)
if err != nil {
Expand Down

0 comments on commit c27e6b7

Please sign in to comment.