Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move baseapp/AppVersionModifer -> core/app #20361

Merged
merged 8 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The type change for versionModifier to app.VersionModifier in the Keeper struct was noted as correctly updated. However, there is still a reference to the old type xp.AppVersionModifier in the codebase:

  • x/upgrade/keeper/keeper.go: The old type is still referenced.

Please ensure that all references to this type are updated accordingly to maintain consistency and avoid potential runtime errors.

Analysis chain

The type change for versionModifier is correctly updated to app.VersionModifier. Ensure all references to this type across the codebase are updated accordingly.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all references to `AppVersionModifier` have been updated to `app.VersionModifier`.

# Test: Search for the old type usage. Expect: No occurrences of the old type.
rg --type go $'xp.AppVersionModifier'

Length of output: 90

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
Loading