Skip to content

Commit

Permalink
Merge pull request #40 from xrplevm/fix/cosmos/iavl-store-version
Browse files Browse the repository at this point in the history
feat(app): upgrade v5
  • Loading branch information
AdriaCarrera authored Dec 6, 2024
2 parents 289eafc + 7b63e55 commit 0bb3207
Show file tree
Hide file tree
Showing 37 changed files with 95 additions and 57 deletions.
2 changes: 1 addition & 1 deletion app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/evmos/evmos/v20/app/ante"
ethante "github.com/evmos/evmos/v20/app/ante/evm"
etherminttypes "github.com/evmos/evmos/v20/types"
poaante "github.com/xrplevm/node/v4/x/poa/ante"
poaante "github.com/xrplevm/node/v5/x/poa/ante"
)

type AnteHandlerOptions ante.HandlerOptions
Expand Down
23 changes: 13 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/consensus"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
"github.com/xrplevm/node/v4/x/poa"
"github.com/xrplevm/node/v5/x/poa"

"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
Expand Down Expand Up @@ -120,11 +120,11 @@ import (
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types"

"github.com/xrplevm/node/v4/docs"
poakeeper "github.com/xrplevm/node/v4/x/poa/keeper"
poatypes "github.com/xrplevm/node/v4/x/poa/types"
"github.com/xrplevm/node/v5/docs"
poakeeper "github.com/xrplevm/node/v5/x/poa/keeper"
poatypes "github.com/xrplevm/node/v5/x/poa/types"

// "github.com/xrplevm/node/v4/app/ante"
// "github.com/xrplevm/node/v5/app/ante"
"github.com/evmos/evmos/v20/app/ante"
srvflags "github.com/evmos/evmos/v20/server/flags"

Expand All @@ -137,6 +137,7 @@ import (
"github.com/evmos/evmos/v20/x/feemarket"
feemarketkeeper "github.com/evmos/evmos/v20/x/feemarket/keeper"
feemarkettypes "github.com/evmos/evmos/v20/x/feemarket/types"

// Overriders
"github.com/evmos/evmos/v20/x/ibc/transfer"
ibctransferkeeper "github.com/evmos/evmos/v20/x/ibc/transfer/keeper"
Expand Down Expand Up @@ -225,7 +226,7 @@ type App struct {
AuthzKeeper authzkeeper.Keeper
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper stakingkeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper govkeeper.Keeper
Expand Down Expand Up @@ -449,7 +450,7 @@ func New(
// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
// NOTE: Distr and Slashing must be created before calling the Hooks method to avoid returning a Keeper without its table generated
app.StakingKeeper = *stakingKeeper
app.StakingKeeper = stakingKeeper

// exrp keepers
app.PoaKeeper = *poakeeper.NewKeeper(
Expand Down Expand Up @@ -582,7 +583,7 @@ func New(

app.EvmKeeper.WithStaticPrecompiles(
NewAvailableStaticPrecompiles(
app.StakingKeeper,
*app.StakingKeeper,
app.DistrKeeper,
app.BankKeeper,
app.Erc20Keeper,
Expand Down Expand Up @@ -618,6 +619,7 @@ func New(
var transferStack ibcporttypes.IBCModule

transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = ratelimit.NewIBCMiddleware(app.RateLimitKeeper, transferStack)
transferStack = erc20.NewIBCMiddleware(app.Erc20Keeper, transferStack)

// Create static IBC router, add transfer route, then set and seal it
Expand Down Expand Up @@ -654,7 +656,7 @@ func New(
gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.InterfaceRegistry()),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
staking.NewAppModule(appCodec, &app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.AddressCodec()),
evidence.NewAppModule(app.EvidenceKeeper),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
Expand Down Expand Up @@ -718,6 +720,7 @@ func New(
ibcexported.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
ratelimittypes.ModuleName,
)

app.mm.SetOrderEndBlockers(
Expand Down Expand Up @@ -1036,7 +1039,7 @@ func (app *App) GetStakingKeeper() ibctestingtypes.StakingKeeper {

// GetStakingKeeperSDK implements the TestingApp interface.
func (app *App) GetStakingKeeperSDK() *stakingkeeper.Keeper {
return &app.StakingKeeper
return app.StakingKeeper
}

// GetIBCKeeper implements the TestingApp interface.
Expand Down
2 changes: 1 addition & 1 deletion app/simulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli"
"github.com/evmos/evmos/v20/app/ante"
"github.com/stretchr/testify/require"
"github.com/xrplevm/node/v4/app"
"github.com/xrplevm/node/v5/app"
)

func init() {
Expand Down
15 changes: 12 additions & 3 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
ratelimittypes "github.com/cosmos/ibc-apps/modules/rate-limiting/v8/types"
icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
v4 "github.com/xrplevm/node/v4/app/upgrades/v4"
v4 "github.com/xrplevm/node/v5/app/upgrades/v4"
v5 "github.com/xrplevm/node/v5/app/upgrades/v5"
)

func (app *App) setupUpgradeHandlers() {
Expand All @@ -29,6 +29,13 @@ func (app *App) setupUpgradeHandlers() {
app.GovKeeper,
),
)
app.UpgradeKeeper.SetUpgradeHandler(
v5.UpgradeName,
v5.CreateUpgradeHandler(
app.mm,
app.configurator,
),
)

// When a planned update height is reached, the old binary will panic
// writing on disk the height and name of the update that triggered it
Expand All @@ -44,7 +51,6 @@ func (app *App) setupUpgradeHandlers() {

var storeUpgrades *storetypes.StoreUpgrades

//nolint:gocritic
switch upgradeInfo.Name {
case v4.UpgradeName:
storeUpgrades = &storetypes.StoreUpgrades{
Expand All @@ -54,6 +60,9 @@ func (app *App) setupUpgradeHandlers() {
},
Deleted: []string{},
}
case v5.UpgradeName:
// No store upgrades for v5
storeUpgrades = &storetypes.StoreUpgrades{}
}

if storeUpgrades != nil {
Expand Down
5 changes: 5 additions & 0 deletions app/upgrades/v5/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package v5

const (
UpgradeName = "v5.0.0"
)
21 changes: 21 additions & 0 deletions app/upgrades/v5/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package v5

import (
"context"

upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(c)
logger := ctx.Logger().With("upgrade", UpgradeName)
logger.Info("Running v5 upgrade handler...")
return mm.RunMigrations(ctx, configurator, vm)
}
}
2 changes: 1 addition & 1 deletion cmd/exrpd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import (
ethermintserver "github.com/evmos/evmos/v20/server"
ethermintservercfg "github.com/evmos/evmos/v20/server/config"
ethermintserverflags "github.com/evmos/evmos/v20/server/flags"
"github.com/xrplevm/node/v4/app"
"github.com/xrplevm/node/v5/app"
)

type emptyAppOptions struct{}
Expand Down
4 changes: 2 additions & 2 deletions cmd/exrpd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"

"github.com/xrplevm/node/v4/app"
"github.com/xrplevm/node/v4/cmd/exrpd/cmd"
"github.com/xrplevm/node/v5/app"
"github.com/xrplevm/node/v5/cmd/exrpd/cmd"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/xrplevm/node/v4
module github.com/xrplevm/node/v5

go 1.22.7

Expand Down Expand Up @@ -87,7 +87,7 @@ require (
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.1.2 // indirect
github.com/cosmos/iavl v1.1.4 // indirect
github.com/cosmos/ics23/go v0.11.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/cosmos/rosetta v0.50.9 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ
github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU=
github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fro=
github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0=
github.com/cosmos/iavl v1.1.2 h1:zL9FK7C4L/P4IF1Dm5fIwz0WXCnn7Bp1M2FxH0ayM7Y=
github.com/cosmos/iavl v1.1.2/go.mod h1:jLeUvm6bGT1YutCaL2fIar/8vGUE8cPZvh/gXEWDaDM=
github.com/cosmos/iavl v1.1.4 h1:Z0cVVjeQqOUp78/nWt/uhQy83vYluWlAMGQ4zbH9G34=
github.com/cosmos/iavl v1.1.4/go.mod h1:vCYmRQUJU1wwj0oRD3wMEtOM9sJNDP+GFMaXmIxZ/rU=
github.com/cosmos/ibc-apps/modules/rate-limiting/v8 v8.0.0 h1:AQO9NIAP3RFqvBCj7IqM/V1LCxmuvcvGUdu0RIEz/c0=
github.com/cosmos/ibc-apps/modules/rate-limiting/v8 v8.0.0/go.mod h1:/ZpKJSW/SKPkFS7jTqkPVn7kOHUUfRNzu+8aS7YOL8o=
github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI=
Expand Down
2 changes: 1 addition & 1 deletion proto/packages/blockchain/poa/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package packages.blockchain.poa;
import "gogoproto/gogo.proto";
import "packages/blockchain/poa/params.proto";

option go_package = "github.com/xrplevm/node/v4/x/poa/types";
option go_package = "github.com/xrplevm/node/v5/x/poa/types";

// GenesisState defines the poa module's genesis state.
message GenesisState { Params params = 1 [ (gogoproto.nullable) = false ]; }
2 changes: 1 addition & 1 deletion proto/packages/blockchain/poa/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package packages.blockchain.poa;

import "gogoproto/gogo.proto";

option go_package = "github.com/xrplevm/node/v4/x/poa/types";
option go_package = "github.com/xrplevm/node/v5/x/poa/types";

// Params defines the parameters for the module.
message Params { option (gogoproto.goproto_stringer) = false; }
2 changes: 1 addition & 1 deletion proto/packages/blockchain/poa/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "packages/blockchain/poa/params.proto";

option go_package = "github.com/xrplevm/node/v4/x/poa/types";
option go_package = "github.com/xrplevm/node/v5/x/poa/types";

// Query defines the gRPC querier service.
service Query {
Expand Down
2 changes: 1 addition & 1 deletion proto/packages/blockchain/poa/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "cosmos/staking/v1beta1/staking.proto";
import "google/protobuf/any.proto";
import "amino/amino.proto";

option go_package = "github.com/xrplevm/node/v4/x/poa/types";
option go_package = "github.com/xrplevm/node/v5/x/poa/types";

// Msg defines the Msg service.
service Msg {
Expand Down
4 changes: 2 additions & 2 deletions x/poa/ante/poa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"github.com/xrplevm/node/v4/x/poa/testutil"
"github.com/xrplevm/node/v4/x/poa/types"
"github.com/xrplevm/node/v5/x/poa/testutil"
"github.com/xrplevm/node/v5/x/poa/types"
)

func setupPoaDecorator(t *testing.T) (
Expand Down
2 changes: 1 addition & 1 deletion x/poa/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// "github.com/cosmos/cosmos-sdk/client/flags"
// sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/xrplevm/node/v4/x/poa/types"
"github.com/xrplevm/node/v5/x/poa/types"
)

// GetQueryCmd returns the cli query commands for this module
Expand Down
2 changes: 1 addition & 1 deletion x/poa/client/cli/query_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"
"github.com/xrplevm/node/v4/x/poa/types"
"github.com/xrplevm/node/v5/x/poa/types"
)

func CmdQueryParams() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion x/poa/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
"github.com/xrplevm/node/v4/x/poa/types"
"github.com/xrplevm/node/v5/x/poa/types"

"github.com/spf13/cobra"

Expand Down
4 changes: 2 additions & 2 deletions x/poa/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/golang/mock/gomock"
"github.com/xrplevm/node/v4/x/poa/testutil"
"github.com/xrplevm/node/v4/x/poa/types"
"github.com/xrplevm/node/v5/x/poa/testutil"
"github.com/xrplevm/node/v5/x/poa/types"

stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
Expand Down
2 changes: 1 addition & 1 deletion x/poa/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/xrplevm/node/v4/x/poa/types"
"github.com/xrplevm/node/v5/x/poa/types"
)

// InitGenesis initializes the module's state from a provided genesis state.
Expand Down
2 changes: 1 addition & 1 deletion x/poa/keeper/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
"github.com/xrplevm/node/v4/x/poa/testutil"
"github.com/xrplevm/node/v5/x/poa/testutil"
)

func TestPoA_Hooks(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/poa/keeper/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/xrplevm/node/v4/x/poa/types"
"github.com/xrplevm/node/v5/x/poa/types"
)

// RegisterInvariants registers all module invariants
Expand Down
2 changes: 1 addition & 1 deletion x/poa/keeper/invariants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
"github.com/xrplevm/node/v4/x/poa/testutil"
"github.com/xrplevm/node/v5/x/poa/testutil"
)

func TestStakingPowerInvariant_Valid(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/poa/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/xrplevm/node/v4/x/poa/types"
"github.com/xrplevm/node/v5/x/poa/types"
)

type (
Expand Down
4 changes: 2 additions & 2 deletions x/poa/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"github.com/xrplevm/node/v4/x/poa/testutil"
"github.com/xrplevm/node/v4/x/poa/types"
"github.com/xrplevm/node/v5/x/poa/testutil"
"github.com/xrplevm/node/v5/x/poa/types"
)

func poaKeeperTestSetup(t *testing.T) (*Keeper, sdk.Context) {
Expand Down
2 changes: 1 addition & 1 deletion x/poa/keeper/msg_server.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package keeper

import (
"github.com/xrplevm/node/v4/x/poa/types"
"github.com/xrplevm/node/v5/x/poa/types"
)

type msgServer struct {
Expand Down
2 changes: 1 addition & 1 deletion x/poa/keeper/msg_server_add_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/xrplevm/node/v4/x/poa/types"
"github.com/xrplevm/node/v5/x/poa/types"
)

func (k msgServer) AddValidator(goCtx context.Context, msg *types.MsgAddValidator) (*types.MsgAddValidatorResponse, error) {
Expand Down
Loading

0 comments on commit 0bb3207

Please sign in to comment.