Skip to content

Commit

Permalink
refactor: move baseapp/AppVersionModifer -> core/app (#20361)
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
kocubinski and coderabbitai[bot] committed May 13, 2024
1 parent 3a75071 commit 9f42137
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 26 deletions.
9 changes: 0 additions & 9 deletions baseapp/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,3 @@ type ParamStore interface {
Has(ctx context.Context) (bool, error)
Set(ctx context.Context, cp cmtproto.ConsensusParams) error
}

// AppVersionModifier defines the interface fulfilled by BaseApp
// which allows getting and setting it's appVersion field. This
// in turn updates the consensus params that are sent to the
// consensus engine in EndBlock
type AppVersionModifier interface {
SetAppVersion(context.Context, uint64) error
AppVersion(context.Context) (uint64, error)
}
10 changes: 10 additions & 0 deletions core/app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"context"
"time"

appmodulev2 "cosmossdk.io/core/appmodule/v2"
Expand Down Expand Up @@ -64,3 +65,12 @@ type TxResult struct {
GasUsed uint64
Codespace string
}

// VersionModifier defines the interface fulfilled by BaseApp
// which allows getting and setting it's appVersion field. This
// in turn updates the consensus params that are sent to the
// consensus engine in EndBlock
type VersionModifier interface {
SetAppVersion(context.Context, uint64) error
AppVersion(context.Context) (uint64, error)
}
3 changes: 2 additions & 1 deletion runtime/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1"
"cosmossdk.io/core/address"
"cosmossdk.io/core/app"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/comet"
"cosmossdk.io/core/genesis"
Expand Down Expand Up @@ -281,7 +282,7 @@ func ProvideTransientStoreService(key depinject.ModuleKey, app *AppBuilder) stor
return transientStoreService{key: storeKey}
}

func ProvideAppVersionModifier(app *AppBuilder) baseapp.AppVersionModifier {
func ProvideAppVersionModifier(app *AppBuilder) app.VersionModifier {
return app.app
}

Expand Down
4 changes: 2 additions & 2 deletions x/upgrade/depinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (

modulev1 "cosmossdk.io/api/cosmos/upgrade/module/v1"
"cosmossdk.io/core/address"
"cosmossdk.io/core/app"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/depinject"
"cosmossdk.io/depinject/appconfig"
authtypes "cosmossdk.io/x/auth/types"
"cosmossdk.io/x/upgrade/keeper"
"cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
Expand All @@ -39,7 +39,7 @@ type ModuleInputs struct {
Environment appmodule.Environment
Cdc codec.Codec
AddressCodec address.Codec
AppVersionModifier baseapp.AppVersionModifier
AppVersionModifier app.VersionModifier

AppOpts servertypes.AppOptions `optional:"true"`
}
Expand Down
11 changes: 0 additions & 11 deletions x/upgrade/exported/exported.go

This file was deleted.

13 changes: 10 additions & 3 deletions x/upgrade/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (

"github.com/hashicorp/go-metrics"

"cosmossdk.io/core/app"
"cosmossdk.io/core/appmodule"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/store/prefix"
storetypes "cosmossdk.io/store/types"
xp "cosmossdk.io/x/upgrade/exported"
"cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/codec"
Expand All @@ -36,7 +36,7 @@ type Keeper struct {
skipUpgradeHeights map[int64]bool // map of heights to skip for an upgrade
cdc codec.BinaryCodec // App-wide binary codec
upgradeHandlers map[string]types.UpgradeHandler // map of plan name to upgrade handler
versionModifier xp.AppVersionModifier // implements setting the protocol version field on BaseApp
versionModifier app.VersionModifier // implements setting the protocol version field on BaseApp
downgradeVerified bool // tells if we've already sanity checked that this binary version isn't being used against an old state.
authority string // the address capable of executing and canceling an upgrade. Usually the gov module account
initVersionMap module.VersionMap // the module version map at init genesis
Expand All @@ -48,7 +48,14 @@ type Keeper struct {
// cdc - the app-wide binary codec
// homePath - root directory of the application's config
// vs - the interface implemented by baseapp which allows setting baseapp's protocol version field
func NewKeeper(env appmodule.Environment, skipUpgradeHeights map[int64]bool, cdc codec.BinaryCodec, homePath string, vs xp.AppVersionModifier, authority string) *Keeper {
func NewKeeper(
env appmodule.Environment,
skipUpgradeHeights map[int64]bool,
cdc codec.BinaryCodec,
homePath string,
vs app.VersionModifier,
authority string,
) *Keeper {
k := &Keeper{
Environment: env,
homePath: homePath,
Expand Down

0 comments on commit 9f42137

Please sign in to comment.