diff --git a/CHANGELOG.md b/CHANGELOG.md index 321e65bcd145..38c8fd49cefa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (client/keys) [#18562](https://github.com/cosmos/cosmos-sdk/pull/18562) `keys delete` won't terminate when a key is not found * (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 * (baseapp) [#18383](https://github.com/cosmos/cosmos-sdk/pull/18383) Fixed a data race inside BaseApp.getContext, found by end-to-end (e2e) tests. diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 5036ae5c20fa..7fea57304593 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -522,7 +522,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 diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 67414a9c12d2..75e6a0d9d973 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -720,6 +720,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)