From df44182b5dbfcbb990842f5802a9b4bf3ab48f30 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Fri, 14 Oct 2022 15:59:09 -0400 Subject: [PATCH 1/4] bez: updates --- x/staking/types/params.go | 3 +++ 1 file changed, 3 insertions(+) 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) } From 3381acb74322d89240ed23070303671ab0f76766 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Fri, 14 Oct 2022 16:01:16 -0400 Subject: [PATCH 2/4] bez: updates --- x/slashing/types/params.go | 10 ++++++++++ 1 file changed, 10 insertions(+) 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) } From 904a28e44d28884bed26e4e2c0a8a803757f5528 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Fri, 14 Oct 2022 16:02:32 -0400 Subject: [PATCH 3/4] bez: updates --- x/mint/types/params.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) } From f358d212588d2f91d8969858b2bf64cab71e21c0 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Fri, 14 Oct 2022 16:03:21 -0400 Subject: [PATCH 4/4] bez: updates --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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.