diff --git a/CHANGELOG.md b/CHANGELOG.md index fd789a2602ae..9c9cfd4a4eb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -160,6 +160,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* [#13553](https://github.com/cosmos/cosmos-sdk/pull/13553) Ensure all parameter validation for decimal types handles nil decimal values. * [#13145](https://github.com/cosmos/cosmos-sdk/pull/13145) Fix panic when calling `String()` to a Record struct type. * [#13116](https://github.com/cosmos/cosmos-sdk/pull/13116) Fix a dead-lock in the `Group-TotalWeight` `x/group` invariant. * [#12548](https://github.com/cosmos/cosmos-sdk/pull/12548) Prevent signing from wrong key while using multisig. diff --git a/x/mint/types/params.go b/x/mint/types/params.go index 8fee078192d5..1721767862e7 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -92,6 +92,9 @@ func validateInflationRateChange(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } + if v.IsNil() { + return fmt.Errorf("inflation rate change cannot be nil: %s", v) + } if v.IsNegative() { return fmt.Errorf("inflation rate change cannot be negative: %s", v) } @@ -108,6 +111,9 @@ func validateInflationMax(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } + if v.IsNil() { + return fmt.Errorf("max inflation cannot be nil: %s", v) + } if v.IsNegative() { return fmt.Errorf("max inflation cannot be negative: %s", v) } @@ -124,6 +130,9 @@ func validateInflationMin(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } + if v.IsNil() { + return fmt.Errorf("min inflation cannot be nil: %s", v) + } if v.IsNegative() { return fmt.Errorf("min inflation cannot be negative: %s", v) } @@ -140,6 +149,9 @@ func validateGoalBonded(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } + if v.IsNil() { + return fmt.Errorf("goal bonded cannot be nil: %s", v) + } if v.IsNegative() || v.IsZero() { return fmt.Errorf("goal bonded must be positive: %s", v) } diff --git a/x/slashing/types/params.go b/x/slashing/types/params.go index 3dae680c5598..934489a48681 100644 --- a/x/slashing/types/params.go +++ b/x/slashing/types/params.go @@ -5,6 +5,7 @@ import ( "time" "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -84,6 +85,9 @@ func validateMinSignedPerWindow(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } + if v.IsNil() { + return fmt.Errorf("min signed per window cannot be nil: %s", v) + } if v.IsNegative() { return fmt.Errorf("min signed per window cannot be negative: %s", v) } @@ -113,6 +117,9 @@ func validateSlashFractionDoubleSign(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } + if v.IsNil() { + return fmt.Errorf("double sign slash fraction cannot be nil: %s", v) + } if v.IsNegative() { return fmt.Errorf("double sign slash fraction cannot be negative: %s", v) } @@ -129,6 +136,9 @@ func validateSlashFractionDowntime(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } + if v.IsNil() { + return fmt.Errorf("downtime slash fraction cannot be nil: %s", v) + } if v.IsNegative() { return fmt.Errorf("downtime slash fraction cannot be negative: %s", v) } diff --git a/x/staking/types/params.go b/x/staking/types/params.go index 24c7344599dc..448438e8a9ac 100644 --- a/x/staking/types/params.go +++ b/x/staking/types/params.go @@ -194,6 +194,9 @@ func validateMinCommissionRate(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } + if v.IsNil() { + return fmt.Errorf("minimum commission rate cannot be nil: %s", v) + } if v.IsNegative() { return fmt.Errorf("minimum commission rate cannot be negative: %s", v) }