diff --git a/app/app.go b/app/app.go index 55e72c36..6811a7f2 100644 --- a/app/app.go +++ b/app/app.go @@ -240,6 +240,15 @@ func (app *App) Name() string { // BeginBlocker application updates every begin block func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { + consParams := ctx.ConsensusParams() + if consParams == nil || consParams.Block == nil { + baseAppLegacySS, found := app.ParamsKeeper.GetSubspace(baseapp.Paramspace) + if !found { + panic("consensus params not found") + } + cp := baseapp.GetConsensusParams(ctx, baseAppLegacySS) + ctx = ctx.WithConsensusParams(cp) + } return app.mm.BeginBlock(ctx, req) } diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 2dcf0b9c..7bd4663e 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -620,5 +620,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(v0evmtypes.ParamKeyTable()) // nolint: staticcheck paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable()) + paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) return paramsKeeper } diff --git a/app/upgrade_test.go b/app/upgrade_test.go index 3e36b993..82bdc6ac 100644 --- a/app/upgrade_test.go +++ b/app/upgrade_test.go @@ -4,8 +4,10 @@ import ( "os" "path/filepath" "testing" + "time" dbm "github.com/cometbft/cometbft-db" + abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" @@ -27,7 +29,7 @@ func Test_UpgradeAndMigrate(t *testing.T) { fxtypes.SetConfig(true) home := filepath.Join(os.Getenv("HOME"), "tmp") - chainId := fxtypes.MainnetChainId + chainId := fxtypes.TestnetChainId // The upgrade test is not related to chainId, do not modify it db, err := dbm.NewDB("application", dbm.GoLevelDBBackend, filepath.Join(home, "data")) require.NoError(t, err) @@ -41,9 +43,23 @@ func Test_UpgradeAndMigrate(t *testing.T) { ctx := newContext(t, myApp, chainId) - myApp.UpgradeKeeper.ApplyUpgrade(ctx, upgradetypes.Plan{ + require.NoError(t, myApp.UpgradeKeeper.ScheduleUpgrade(ctx, upgradetypes.Plan{ Name: nextversion.Upgrade.UpgradeName, - Height: ctx.BlockHeight() + 5, + Height: ctx.BlockHeight() + 1, + })) + + header := ctx.BlockHeader() + header.Height = header.Height + 1 + header.Time = time.Now().UTC() + require.NotPanics(t, func() { + myApp.BeginBlock(abci.RequestBeginBlock{ + Header: header, + }) + }) + require.NotPanics(t, func() { + myApp.EndBlock(abci.RequestEndBlock{ + Height: header.Height, + }) }) } diff --git a/app/upgrades/v7/upgrade.go b/app/upgrades/v7/upgrade.go index 4cef1477..a6eda601 100644 --- a/app/upgrades/v7/upgrade.go +++ b/app/upgrades/v7/upgrade.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" autytypes "github.com/cosmos/cosmos-sdk/x/auth/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/functionx/fx-core/v7/app/keepers" @@ -17,7 +16,10 @@ import ( func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator, app *keepers.AppKeepers) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { // Migrate Tendermint consensus parameters from x/params module to a dedicated x/consensus module. - baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) + baseAppLegacySS, found := app.ParamsKeeper.GetSubspace(baseapp.Paramspace) + if !found { + panic("baseapp subspace not found") + } baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper) cacheCtx, commit := ctx.CacheContext() diff --git a/x/gov/keeper/abci.go b/x/gov/keeper/abci.go index 4cd5d26f..1c282bd2 100644 --- a/x/gov/keeper/abci.go +++ b/x/gov/keeper/abci.go @@ -33,7 +33,7 @@ func (keeper Keeper) EndBlocker(ctx sdk.Context) { )) logger.Info( - "proposal did not meet minimum deposit; deleted", + "proposal did not meet the minimum deposit requirement and has been deleted", "proposal", proposal.Id, "min_deposit", sdk.NewCoins(keeper.GetMinDeposit(ctx, fxgovtypes.ExtractMsgTypeURL(proposal.Messages))...).String(), "total_deposit", sdk.NewCoins(proposal.TotalDeposit...).String(),