From 923a858ebf7394770b6d2818c825309f01cd551d Mon Sep 17 00:00:00 2001 From: jaeseung-bae <119839167+jaeseung-bae@users.noreply.github.com> Date: Thu, 28 Mar 2024 13:35:01 +0900 Subject: [PATCH 1/2] fix: update param validation to fail on nil dec (#1323) * fix: update param validation to fail on nil dec * chore: update changelog (cherry picked from commit 55b6566bf3c0811a7e758dd166c980de343ad1f3) # Conflicts: # CHANGELOG.md --- CHANGELOG.md | 23 +++++++++++++++++++++++ x/mint/types/params.go | 18 +++++++++++++----- x/slashing/types/params.go | 12 +++++++++--- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb197ca3e7..3b5de77a17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,11 +43,34 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements ### Bug Fixes +<<<<<<< HEAD * (x/auth) [#1281](https://github.com/Finschia/finschia-sdk/pull/1281) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking. (backport #1274) * (x/foundation) [\#1283](https://github.com/Finschia/finschia-sdk/pull/1283) add init logic of foundation module accounts to InitGenesis in order to eliminate potential panic (backport #1277) * (x/collection) [\#1282](https://github.com/Finschia/finschia-sdk/pull/1282) eliminates potential risk for Insufficient Sanity Check of tokenID in Genesis (backport #1276) * (x/collection) [\#1290](https://github.com/Finschia/finschia-sdk/pull/1290) export x/collection params into genesis (backport #1268) * (x/foundation) [\#1295](https://github.com/Finschia/finschia-sdk/pull/1295) add missing error handling for migration +======= +* chore(deps) [\#1141](https://github.com/Finschia/finschia-sdk/pull/1141) Bump github.com/cosmos/ledger-cosmos-go from 0.12.2 to 0.13.2 to fix ledger signing issue +* (x/auth, x/slashing) [\#1179](https://github.com/Finschia/finschia-sdk/pull/1179) modify missing changes of converting to tendermint +* (x/auth) [#1274](https://github.com/Finschia/finschia-sdk/pull/1274) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking. +* (x/collection) [\#1276](https://github.com/Finschia/finschia-sdk/pull/1276) eliminates potential risk for Insufficient Sanity Check of tokenID in Genesis +* (x/foundation) [\#1277](https://github.com/Finschia/finschia-sdk/pull/1277) add init logic of foundation module accounts to InitGenesis in order to eliminate potential panic +* (x/collection, x/token) [\#1288](https://github.com/Finschia/finschia-sdk/pull/1288) use accAddress to compare in validatebasic function in collection & token modules +* (x/collection) [\#1268](https://github.com/Finschia/finschia-sdk/pull/1268) export x/collection params into genesis +* (x/collection) [\#1294](https://github.com/Finschia/finschia-sdk/pull/1294) reject NFT coins on FT APIs +* (sec) [\#1302](https://github.com/Finschia/finschia-sdk/pull/1302) remove map iteration non-determinism with keys + sorting +* (client) [\#1303](https://github.com/Finschia/finschia-sdk/pull/1303) fix possible overflow in BuildUnsignedTx +* (types) [\#1299](https://github.com/Finschia/finschia-sdk/pull/1299) add missing nil checks +* (x/staking) [\#1301](https://github.com/Finschia/finschia-sdk/pull/1301) Use bytes instead of string comparison in delete validator queue (backport cosmos/cosmos-sdk#12303) +* (x/gov) [\#1304](https://github.com/Finschia/finschia-sdk/pull/1304) fetch a failed proposal tally from proposal.FinalTallyResult in the gprc query +* (x/staking) [\#1306](https://github.com/Finschia/finschia-sdk/pull/1306) add validation for potential slashing evasion during re-delegation +* (client/keys) [#1312](https://github.com/Finschia/finschia-sdk/pull/1312) ignore error when key not found in `keys delete` +* (store) [\#1310](https://github.com/Finschia/finschia-sdk/pull/1310) fix app-hash mismatch if upgrade migration commit is interrupted(backport cosmos/cosmos-sdk#13530) +* (types) [\#1313](https://github.com/Finschia/finschia-sdk/pull/1313) fix correctly coalesce coins even with repeated denominations(backport cosmos/cosmos-sdk#13265) +* (x/crypto) [\#1316](https://github.com/Finschia/finschia-sdk/pull/1316) error if incorrect ledger public key (backport cosmos/cosmos-sdk#14460, cosmos/cosmos-sdk#19691) +* (x/auth) [#1319](https://github.com/Finschia/finschia-sdk/pull/1319) prevent signing from wrong key in multisig +* (x/mint, x/slashing) [\#1323](https://github.com/Finschia/finschia-sdk/pull/1323) add missing nil check for params validation +>>>>>>> 55b6566bf (fix: update param validation to fail on nil dec (#1323)) ### Removed diff --git a/x/mint/types/params.go b/x/mint/types/params.go index 8a9ce49325..b323abae0d 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - yaml "gopkg.in/yaml.v2" + "gopkg.in/yaml.v2" sdk "github.com/Finschia/finschia-sdk/types" paramtypes "github.com/Finschia/finschia-sdk/x/params/types" @@ -120,7 +120,9 @@ func validateInflationRateChange(i interface{}) error { if !ok { 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) } @@ -136,7 +138,9 @@ func validateInflationMax(i interface{}) error { if !ok { 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) } @@ -152,7 +156,9 @@ func validateInflationMin(i interface{}) error { if !ok { 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) } @@ -168,7 +174,9 @@ func validateGoalBonded(i interface{}) error { if !ok { 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 5d7fd6bcab..6f60e2ca41 100644 --- a/x/slashing/types/params.go +++ b/x/slashing/types/params.go @@ -85,7 +85,9 @@ func validateMinSignedPerWindow(i interface{}) error { if !ok { 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) } @@ -114,7 +116,9 @@ func validateSlashFractionDoubleSign(i interface{}) error { if !ok { 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) } @@ -130,7 +134,9 @@ func validateSlashFractionDowntime(i interface{}) error { if !ok { 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 01990a4f67fcf2c88b24b94542547d57f4eaf29c Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Fri, 29 Mar 2024 02:39:11 +0000 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b5de77a17..9767f423de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,34 +43,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements ### Bug Fixes -<<<<<<< HEAD * (x/auth) [#1281](https://github.com/Finschia/finschia-sdk/pull/1281) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking. (backport #1274) * (x/foundation) [\#1283](https://github.com/Finschia/finschia-sdk/pull/1283) add init logic of foundation module accounts to InitGenesis in order to eliminate potential panic (backport #1277) * (x/collection) [\#1282](https://github.com/Finschia/finschia-sdk/pull/1282) eliminates potential risk for Insufficient Sanity Check of tokenID in Genesis (backport #1276) * (x/collection) [\#1290](https://github.com/Finschia/finschia-sdk/pull/1290) export x/collection params into genesis (backport #1268) * (x/foundation) [\#1295](https://github.com/Finschia/finschia-sdk/pull/1295) add missing error handling for migration -======= -* chore(deps) [\#1141](https://github.com/Finschia/finschia-sdk/pull/1141) Bump github.com/cosmos/ledger-cosmos-go from 0.12.2 to 0.13.2 to fix ledger signing issue -* (x/auth, x/slashing) [\#1179](https://github.com/Finschia/finschia-sdk/pull/1179) modify missing changes of converting to tendermint -* (x/auth) [#1274](https://github.com/Finschia/finschia-sdk/pull/1274) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking. -* (x/collection) [\#1276](https://github.com/Finschia/finschia-sdk/pull/1276) eliminates potential risk for Insufficient Sanity Check of tokenID in Genesis -* (x/foundation) [\#1277](https://github.com/Finschia/finschia-sdk/pull/1277) add init logic of foundation module accounts to InitGenesis in order to eliminate potential panic -* (x/collection, x/token) [\#1288](https://github.com/Finschia/finschia-sdk/pull/1288) use accAddress to compare in validatebasic function in collection & token modules -* (x/collection) [\#1268](https://github.com/Finschia/finschia-sdk/pull/1268) export x/collection params into genesis -* (x/collection) [\#1294](https://github.com/Finschia/finschia-sdk/pull/1294) reject NFT coins on FT APIs -* (sec) [\#1302](https://github.com/Finschia/finschia-sdk/pull/1302) remove map iteration non-determinism with keys + sorting -* (client) [\#1303](https://github.com/Finschia/finschia-sdk/pull/1303) fix possible overflow in BuildUnsignedTx -* (types) [\#1299](https://github.com/Finschia/finschia-sdk/pull/1299) add missing nil checks -* (x/staking) [\#1301](https://github.com/Finschia/finschia-sdk/pull/1301) Use bytes instead of string comparison in delete validator queue (backport cosmos/cosmos-sdk#12303) -* (x/gov) [\#1304](https://github.com/Finschia/finschia-sdk/pull/1304) fetch a failed proposal tally from proposal.FinalTallyResult in the gprc query -* (x/staking) [\#1306](https://github.com/Finschia/finschia-sdk/pull/1306) add validation for potential slashing evasion during re-delegation -* (client/keys) [#1312](https://github.com/Finschia/finschia-sdk/pull/1312) ignore error when key not found in `keys delete` -* (store) [\#1310](https://github.com/Finschia/finschia-sdk/pull/1310) fix app-hash mismatch if upgrade migration commit is interrupted(backport cosmos/cosmos-sdk#13530) -* (types) [\#1313](https://github.com/Finschia/finschia-sdk/pull/1313) fix correctly coalesce coins even with repeated denominations(backport cosmos/cosmos-sdk#13265) -* (x/crypto) [\#1316](https://github.com/Finschia/finschia-sdk/pull/1316) error if incorrect ledger public key (backport cosmos/cosmos-sdk#14460, cosmos/cosmos-sdk#19691) -* (x/auth) [#1319](https://github.com/Finschia/finschia-sdk/pull/1319) prevent signing from wrong key in multisig * (x/mint, x/slashing) [\#1323](https://github.com/Finschia/finschia-sdk/pull/1323) add missing nil check for params validation ->>>>>>> 55b6566bf (fix: update param validation to fail on nil dec (#1323)) ### Removed