fix(baseapp): allow empty consensus params (#18531)
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
co-authored by
Aleksandr Bezobchuk
parent
7d5e9f1c23
commit
fa5280fb4b
+5
-1
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user