Skip to content

Commit

Permalink
Fix logic transition stake
Browse files Browse the repository at this point in the history
  • Loading branch information
trinitys7 committed Sep 5, 2024
1 parent dc39df3 commit 65bb037
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 0 additions & 2 deletions tests/e2e/slashing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,6 @@ func TestSlasingImmediateUnbond(t *testing.T) {
base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf(`{"validator": "%s"}`, myLocalValidatorAddr))))
providerCli.MustExecVault(execLocalStakingMsg)

assert.Equal(t, 100_000_000, providerCli.QueryVaultFreeBalance())

// Check slashable amount
require.Equal(t, 20_000_000, providerCli.QuerySlashableAmount())
// Check free collateral
Expand Down
9 changes: 3 additions & 6 deletions x/meshsecurityprovider/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func (k Keeper) HandleUnstakeMsg(ctx sdk.Context, actor sdk.AccAddress, unstakeM
return nil, nil, sdkerrors.ErrUnauthorized.Wrapf("contract has no permission for mesh security operations")
}

fmt.Println("proxyContract: ", proxyRes.Proxy)
proxyContract, err := sdk.AccAddressFromBech32(proxyRes.Proxy)
if err != nil {
return nil, nil, sdkerrors.ErrInvalidAddress.Wrapf("native staking proxy contract not able to get")
Expand Down Expand Up @@ -295,7 +296,7 @@ func (k Keeper) unstake(ctx sdk.Context, proxyContract sdk.AccAddress, validator
}

func (k Keeper) InstantUndelegate(ctx sdk.Context, delAddr sdk.AccAddress, validator stakingtypes.Validator, sharesAmount sdk.Dec) (sdk.Coin, error) {
returnAmount, err := k.stakingKeeper.Unbond(ctx, delAddr, sdk.ValAddress(validator.OperatorAddress), sharesAmount)
returnAmount, err := k.stakingKeeper.Unbond(ctx, delAddr, validator.GetOperator(), sharesAmount)
if err != nil {
return sdk.Coin{}, err
}
Expand All @@ -305,11 +306,7 @@ func (k Keeper) InstantUndelegate(ctx sdk.Context, delAddr sdk.AccAddress, valid
amt := sdk.NewCoin(bondDenom, returnAmount)
res := sdk.NewCoins(amt)

moduleName := stakingtypes.NotBondedPoolName
if validator.IsBonded() {
moduleName = stakingtypes.BondedPoolName
}
err = k.bankKeeper.UndelegateCoinsFromModuleToAccount(ctx, moduleName, delAddr, res)
err = k.bankKeeper.UndelegateCoinsFromModuleToAccount(ctx, stakingtypes.NotBondedPoolName, delAddr, res)
if err != nil {
return sdk.Coin{}, err
}
Expand Down

0 comments on commit 65bb037

Please sign in to comment.