Skip to content

Commit

Permalink
fix(baseapp): allow empty consensus params (#18531)
Browse files Browse the repository at this point in the history
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
(cherry picked from commit fa5280f)
  • Loading branch information
facundomedica authored and mergify[bot] committed Nov 28, 2023
1 parent ab80e48 commit 22e187c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes

* (server) [#18537](https://github.com/cosmos/cosmos-sdk/pull/18537) Fix panic when defining minimum gas config as `100stake;100uatom`. Use a `,` delimiter instead of `;`. Fixes the server config getter to use the correct delimiter.
* [#18531](https://github.com/cosmos/cosmos-sdk/pull/18531) Baseapp's `GetConsensusParams` returns an empty struct instead of panicking if no params are found.
* (client/tx) [#18472](https://github.com/cosmos/cosmos-sdk/pull/18472) Utilizes the correct Pubkey when simulating a transaction.
* (baseapp) [#18486](https://github.com/cosmos/cosmos-sdk/pull/18486) Fixed FinalizeBlock calls not being passed to ABCIListeners.

Expand Down
6 changes: 5 additions & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,11 @@ func (app *BaseApp) GetConsensusParams(ctx sdk.Context) cmtproto.ConsensusParams

cp, err := app.paramStore.Get(ctx)
if err != nil {
panic(fmt.Errorf("consensus key is nil: %w", err))
// This could happen while migrating from v0.45/v0.46 to v0.50, we should
// allow it to happen so during preblock the upgrade plan can be executed
// and the consensus params set for the first time in the new format.
app.logger.Error("failed to get consensus params", "err", err)
return cmtproto.ConsensusParams{}
}

return cp
Expand Down
11 changes: 11 additions & 0 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,17 @@ func TestGetMaximumBlockGas(t *testing.T) {
require.Panics(t, func() { suite.baseApp.GetMaximumBlockGas(ctx) })
}

func TestGetEmptyConsensusParams(t *testing.T) {
suite := NewBaseAppSuite(t)
_, err := suite.baseApp.InitChain(&abci.RequestInitChain{})
require.NoError(t, err)
ctx := suite.baseApp.NewContext(true)

cp := suite.baseApp.GetConsensusParams(ctx)
require.Equal(t, cmtproto.ConsensusParams{}, cp)
require.Equal(t, uint64(0), suite.baseApp.GetMaximumBlockGas(ctx))
}

func TestLoadVersionPruning(t *testing.T) {
logger := log.NewNopLogger()
pruningOptions := pruningtypes.NewCustomPruningOptions(10, 15)
Expand Down

0 comments on commit 22e187c

Please sign in to comment.