Skip to content
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
115 changes: 52 additions & 63 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"

ratelimitv2 "github.com/cosmos/ibc-apps/modules/rate-limiting/v10/v2"

"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
"github.com/cosmos/cosmos-sdk/types/msgservice"
Expand All @@ -25,18 +27,21 @@ import (
evmante "github.com/cosmos/evm/evmd/ante"
etherminttypes "github.com/cosmos/evm/types"
cosmosevmutils "github.com/cosmos/evm/utils"
erc20v2 "github.com/cosmos/evm/x/erc20/v2"
"github.com/cosmos/gogoproto/proto"
ratelimit "github.com/cosmos/ibc-apps/modules/rate-limiting/v8"
ratelimittypes "github.com/cosmos/ibc-apps/modules/rate-limiting/v8/types"
ibctransfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
ratelimit "github.com/cosmos/ibc-apps/modules/rate-limiting/v10"
ratelimittypes "github.com/cosmos/ibc-apps/modules/rate-limiting/v10/types"
ibctransfer "github.com/cosmos/ibc-go/v10/modules/apps/transfer"
ibcclienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types"
ibcconnectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types"
ibctm "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v10/testing"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/spf13/cast"

transferv2 "github.com/cosmos/evm/x/ibc/transfer/v2"
vmmod "github.com/cosmos/evm/x/vm"
ibcapi "github.com/cosmos/ibc-go/v10/modules/core/api"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
Expand Down Expand Up @@ -106,23 +111,20 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
evmostypes "github.com/cosmos/evm/types"
"github.com/cosmos/ibc-go/modules/capability"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"

ratelimitkeeper "github.com/cosmos/ibc-apps/modules/rate-limiting/v8/keeper"
ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts"
icahost "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
ratelimitkeeper "github.com/cosmos/ibc-apps/modules/rate-limiting/v10/keeper"
ica "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts"
icahost "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/types"

ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v8/modules/core"
ibcporttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types"
ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v10/modules/core"
ibcporttypes "github.com/cosmos/ibc-go/v10/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v10/modules/core/keeper"

"github.com/xrplevm/node/v9/docs"
poaante "github.com/xrplevm/node/v9/x/poa/ante"
Expand Down Expand Up @@ -229,7 +231,6 @@ type App struct {
AccountKeeper authkeeper.AccountKeeper
AuthzKeeper authzkeeper.Keeper
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
DistrKeeper distrkeeper.Keeper
Expand All @@ -245,10 +246,6 @@ type App struct {
ConsensusParamsKeeper consensusparamkeeper.Keeper
RateLimitKeeper ratelimitkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper

// Ethermint keepers
EvmKeeper *evmkeeper.Keeper
FeeMarketKeeper feemarketkeeper.Keeper
Expand Down Expand Up @@ -338,18 +335,6 @@ func New(
)
bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore)

// add capability keeper and ScopeToModule for ibc module
app.CapabilityKeeper = capabilitykeeper.NewKeeper(
appCodec,
keys[capabilitytypes.StoreKey],
memKeys[capabilitytypes.MemStoreKey],
)

// grant capabilities for the ibc and ibc-transfer modules
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)

// add keepers
app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec,
Expand Down Expand Up @@ -498,11 +483,9 @@ func New(

// Create IBC Keeper
app.IBCKeeper = ibckeeper.NewKeeper(
appCodec, keys[ibcexported.StoreKey],
appCodec, runtime.NewKVStoreService(keys[ibcexported.StoreKey]),
app.GetSubspace(ibcexported.ModuleName),
app.StakingKeeper,
app.UpgradeKeeper,
scopedIBCKeeper,
authAddress,
)
// Create the rate limit keeper
Expand All @@ -513,36 +496,35 @@ func New(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
app.BankKeeper,
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.ClientKeeper,
app.IBCKeeper.ChannelKeeper, // ICS4Wrapper
)
// Create Transfer Keepers
// TODO: Update when migrating to v10
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
keys[ibctransfertypes.StoreKey],
runtime.NewKVStoreService(keys[ibctransfertypes.StoreKey]),
app.GetSubspace(ibctransfertypes.ModuleName),
app.RateLimitKeeper,
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
app.IBCKeeper.ChannelKeeper,
app.MsgServiceRouter(),
app.AccountKeeper,
app.BankKeeper,
scopedTransferKeeper,
app.Erc20Keeper, // Add ERC20 Keeper for ERC20 transfers
authAddress,
)
transferModule := transfer.NewAppModule(app.TransferKeeper)
// Create the app.ICAHostKeeper
app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec, app.keys[icahosttypes.StoreKey],
appCodec, runtime.NewKVStoreService(keys[icahosttypes.StoreKey]),
app.GetSubspace(icahosttypes.SubModuleName),
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
app.AccountKeeper,
scopedICAHostKeeper,
bApp.MsgServiceRouter(),
app.GRPCQueryRouter(),
authAddress,
)
app.ICAHostKeeper.WithQueryRouter(bApp.GRPCQueryRouter())
// create host IBC module
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)

Expand Down Expand Up @@ -591,7 +573,7 @@ func New(
app.Erc20Keeper,
app.AuthzKeeper,
app.TransferKeeper,
app.IBCKeeper.ChannelKeeper,
*app.IBCKeeper.ChannelKeeper,
app.EvmKeeper,
app.GovKeeper,
app.AppCodec(),
Expand All @@ -601,8 +583,6 @@ func New(
/**** IBC Routing ****/

// Sealing prevents other modules from creating scoped sub-keepers
app.CapabilityKeeper.Seal()

/*
Create Transfer Stack

Expand All @@ -627,13 +607,31 @@ func New(
transferStack = ratelimit.NewIBCMiddleware(app.RateLimitKeeper, transferStack)
transferStack = erc20.NewIBCMiddleware(app.Erc20Keeper, transferStack)

/**** IBC V1 ****/

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
ibcRouter.
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(ibctransfertypes.ModuleName, transferStack)
app.IBCKeeper.SetRouter(ibcRouter)

/**** IBC V2 ****/

var transferStackV2 ibcapi.IBCModule
transferStackV2 = transferv2.NewIBCModule(app.TransferKeeper)
transferStackV2 = ratelimitv2.NewIBCMiddleware(app.RateLimitKeeper, transferStackV2)
transferStackV2 = erc20v2.NewIBCMiddleware(transferStackV2, app.Erc20Keeper)

ibcRouterV2 := ibcapi.NewRouter()
ibcRouterV2.AddRoute(ibctransfertypes.ModuleName, transferStackV2)

clientKeeper := app.IBCKeeper.ClientKeeper
storeProvider := app.IBCKeeper.ClientKeeper.GetStoreProvider()

tmLightClientModule := ibctm.NewLightClientModule(appCodec, storeProvider)
clientKeeper.AddRoute(ibctm.ModuleName, &tmLightClientModule)

/**** Module Hooks ****/

// register hooks after all modules have been initialized
Expand All @@ -655,7 +653,6 @@ func New(
),
auth.NewAppModule(appCodec, app.AccountKeeper, nil, app.GetSubspace(authtypes.ModuleName)),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)),
capability.NewAppModule(appCodec, *app.CapabilityKeeper, false),
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
Expand All @@ -672,7 +669,7 @@ func New(
ibc.NewAppModule(app.IBCKeeper),
ica.NewAppModule(nil, &app.ICAHostKeeper),
transferModule,
ibctm.NewAppModule(),
ibctm.NewAppModule(tmLightClientModule),
ratelimit.NewAppModule(appCodec, app.RateLimitKeeper),

// Ethermint app modules
Expand Down Expand Up @@ -840,9 +837,6 @@ func New(
}
}

app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper

return app
}

Expand Down Expand Up @@ -1065,7 +1059,7 @@ func (app *App) GetBaseApp() *baseapp.BaseApp {
}

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

Expand All @@ -1079,11 +1073,6 @@ func (app *App) GetIBCKeeper() *ibckeeper.Keeper {
return app.IBCKeeper
}

// GetScopedIBCKeeper implements the TestingApp interface.
func (app *App) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper {
return app.ScopedIBCKeeper
}

// GetTxConfig implements the TestingApp interface.
func (app *App) GetTxConfig() client.TxConfig {
return app.txConfig
Expand Down
4 changes: 2 additions & 2 deletions app/precompiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
erc20Keeper "github.com/cosmos/evm/x/erc20/keeper"
transferkeeper "github.com/cosmos/evm/x/ibc/transfer/keeper"
evmkeeper "github.com/cosmos/evm/x/vm/keeper"
channelkeeper "github.com/cosmos/ibc-go/v8/modules/core/04-channel/keeper"
channelkeeper "github.com/cosmos/ibc-go/v10/modules/core/04-channel/keeper"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
"golang.org/x/exp/maps"
Expand Down Expand Up @@ -71,7 +71,7 @@ func NewAvailableStaticPrecompiles(
stakingKeeper,
transferKeeper,
// TODO: Update when migrating to v10
channelKeeper,
&channelKeeper,
evmKeeper,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
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"
icahosttypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host/types"
v4 "github.com/xrplevm/node/v9/app/upgrades/v4"
v5 "github.com/xrplevm/node/v9/app/upgrades/v5"
v6 "github.com/xrplevm/node/v9/app/upgrades/v6"
Expand Down
Loading
Loading