From a1bfe5d2853238c53c38f337f40bc01b56559085 Mon Sep 17 00:00:00 2001 From: ocnc <97242826+ocnc@users.noreply.github.com> Date: Tue, 19 Mar 2024 14:21:02 -0400 Subject: [PATCH] feat(x/staking): allow zero unbonding time (#19779) --- x/staking/CHANGELOG.md | 2 ++ x/staking/keeper/msg_server_test.go | 2 +- x/staking/types/params.go | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/x/staking/CHANGELOG.md b/x/staking/CHANGELOG.md index a9280795de..f22c5e4fa8 100644 --- a/x/staking/CHANGELOG.md +++ b/x/staking/CHANGELOG.md @@ -31,6 +31,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* [#19779](https://github.com/cosmos/cosmos-sdk/pull/19779) Allows for setting `unbonding_time` to zero. + * [#19277](https://github.com/cosmos/cosmos-sdk/pull/19277) Hooks calls on `SetUnbondingDelegationEntry`, `SetRedelegationEntry`, `Slash` and `RemoveValidator` returns errors instead of logging just like other hooks calls. * [#18636](https://github.com/cosmos/cosmos-sdk/pull/18636) `IterateBondedValidatorsByPower`, `GetDelegatorBonded`, `Delegate`, `Unbond`, `Slash`, `Jail`, `SlashRedelegation`, `ApplyAndReturnValidatorSetUpdates` methods no longer panics on any kind of errors but instead returns appropriate errors. * [#18506](https://github.com/cosmos/cosmos-sdk/pull/18506) Detect the length of the ed25519 pubkey in CreateValidator to prevent panic. diff --git a/x/staking/keeper/msg_server_test.go b/x/staking/keeper/msg_server_test.go index b13bbca6d4..f4719364f6 100644 --- a/x/staking/keeper/msg_server_test.go +++ b/x/staking/keeper/msg_server_test.go @@ -1170,7 +1170,7 @@ func (s *KeeperTestSuite) TestMsgUpdateParams() { BondDenom: "denom", }, }, - expErrMsg: "unbonding time must be positive", + expErrMsg: "unbonding time must not be negative", }, } diff --git a/x/staking/types/params.go b/x/staking/types/params.go index ac8b8a32e1..3db7b75d1c 100644 --- a/x/staking/types/params.go +++ b/x/staking/types/params.go @@ -128,8 +128,8 @@ func validateUnbondingTime(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } - if v <= 0 { - return fmt.Errorf("unbonding time must be positive: %d", v) + if v < 0 { + return fmt.Errorf("unbonding time must not be negative: %d", v) } return nil