refactor: add ibc-go to app

This commit is contained in:
Sai Kumar 2022-05-18 12:52:25 +05:30
parent 26238a6f2f
commit f9c4f75f76
3 changed files with 64 additions and 57 deletions

View File

@ -94,22 +94,19 @@ import (
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os" tmos "github.com/tendermint/tendermint/libs/os"
// "github.com/cosmos/ibc-go/v3/modules/apps/transfer" "github.com/cosmos/ibc-go/v3/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper"
// "github.com/cosmos/ibc-go/v3/modules/apps/transfer" ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
// ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper" ibc "github.com/cosmos/ibc-go/v3/modules/core"
// ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client"
// ibc "github.com/cosmos/ibc-go/v3/modules/core" ibcclientclient "github.com/cosmos/ibc-go/v3/modules/core/02-client/client"
// ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client" porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types"
// ibcclientclient "github.com/cosmos/ibc-go/v3/modules/core/02-client/client" ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
// porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
// ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
// ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
// unnamed import of statik for swagger UI support // unnamed import of statik for swagger UI support
_ "github.com/tharsis/ethermint/client/docs/statik" _ "github.com/tharsis/ethermint/client/docs/statik"
// "github.com/tharsis/ethermint/app/ante"
srvflags "github.com/tharsis/ethermint/server/flags" srvflags "github.com/tharsis/ethermint/server/flags"
ethermint "github.com/tharsis/ethermint/types" ethermint "github.com/tharsis/ethermint/types"
"github.com/tharsis/ethermint/x/evm" "github.com/tharsis/ethermint/x/evm"
@ -162,13 +159,13 @@ var (
mint.AppModuleBasic{}, mint.AppModuleBasic{},
distr.AppModuleBasic{}, distr.AppModuleBasic{},
gov.NewAppModuleBasic( gov.NewAppModuleBasic(
[]govclient.ProposalHandler{paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.LegacyProposalHandler, upgradeclient.LegacyCancelProposalHandler}, []govclient.ProposalHandler{paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.LegacyProposalHandler, upgradeclient.LegacyCancelProposalHandler,
// ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler, ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler},
), ),
params.AppModuleBasic{}, params.AppModuleBasic{},
crisis.AppModuleBasic{}, crisis.AppModuleBasic{},
slashing.AppModuleBasic{}, slashing.AppModuleBasic{},
// ibc.AppModuleBasic{}, ibc.AppModuleBasic{},
authzmodule.AppModuleBasic{}, authzmodule.AppModuleBasic{},
feegrantmodule.AppModuleBasic{}, feegrantmodule.AppModuleBasic{},
upgrade.AppModuleBasic{}, upgrade.AppModuleBasic{},
@ -186,13 +183,13 @@ var (
// module account permissions // module account permissions
maccPerms = map[string][]string{ maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil, authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil, distrtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter}, minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner}, govtypes.ModuleName: {authtypes.Burner},
// ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account
auctiontypes.ModuleName: nil, auctiontypes.ModuleName: nil,
auctiontypes.AuctionBurnModuleAccountName: nil, auctiontypes.AuctionBurnModuleAccountName: nil,
@ -245,9 +242,9 @@ type EthermintApp struct {
ParamsKeeper paramskeeper.Keeper ParamsKeeper paramskeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper AuthzKeeper authzkeeper.Keeper
// IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
EvidenceKeeper evidencekeeper.Keeper EvidenceKeeper evidencekeeper.Keeper
// TransferKeeper ibctransferkeeper.Keeper TransferKeeper ibctransferkeeper.Keeper
// make scoped keepers public for test purposes // make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper ScopedIBCKeeper capabilitykeeper.ScopedKeeper
@ -299,7 +296,7 @@ func NewEthermintApp(
evidencetypes.StoreKey, capabilitytypes.StoreKey, evidencetypes.StoreKey, capabilitytypes.StoreKey,
authzkeeper.StoreKey, authzkeeper.StoreKey,
// ibc keys // ibc keys
// ibchost.StoreKey, ibctransfertypes.StoreKey, ibchost.StoreKey, ibctransfertypes.StoreKey,
// ethermint keys // ethermint keys
evmtypes.StoreKey, feemarkettypes.StoreKey, evmtypes.StoreKey, feemarkettypes.StoreKey,
// chiba-clonk keys // chiba-clonk keys
@ -386,8 +383,8 @@ func NewEthermintApp(
// add capability keeper and ScopeToModule for ibc module // add capability keeper and ScopeToModule for ibc module
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
// scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
// scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
// Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating // Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating
// their scoped modules in `NewApp` with `ScopeToModule` // their scoped modules in `NewApp` with `ScopeToModule`
@ -462,17 +459,18 @@ func NewEthermintApp(
tracer, tracer,
) )
// // Create IBC Keeper // Create IBC Keeper
// app.IBCKeeper = ibckeeper.NewKeeper( app.IBCKeeper = ibckeeper.NewKeeper(
// appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper,
// ) )
// register the proposal types // register the proposal types
govRouter := govv1beta1.NewRouter() govRouter := govv1beta1.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)) AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))
govConfig := govtypes.DefaultConfig() govConfig := govtypes.DefaultConfig()
/* /*
@ -491,19 +489,19 @@ func NewEthermintApp(
), ),
) )
// // Create Transfer Keepers // Create Transfer Keepers
// app.TransferKeeper = ibctransferkeeper.NewKeeper( app.TransferKeeper = ibctransferkeeper.NewKeeper(
// appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName),
// app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
// app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, app.AccountKeeper, app.BankKeeper, scopedTransferKeeper,
// ) )
// transferModule := transfer.NewAppModule(app.TransferKeeper) transferModule := transfer.NewAppModule(app.TransferKeeper)
// transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)
// Create static IBC router, add transfer route, then set and seal it //Create static IBC router, add transfer route, then set and seal it
// ibcRouter := porttypes.NewRouter() ibcRouter := porttypes.NewRouter()
// ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule) ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
// app.IBCKeeper.SetRouter(ibcRouter) app.IBCKeeper.SetRouter(ibcRouter)
// create evidence keeper with router // create evidence keeper with router
evidenceKeeper := evidencekeeper.NewKeeper( evidenceKeeper := evidencekeeper.NewKeeper(
@ -541,9 +539,9 @@ func NewEthermintApp(
params.NewAppModule(app.ParamsKeeper), params.NewAppModule(app.ParamsKeeper),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
// ibc modules // ibc modules
// ibc.NewAppModule(app.IBCKeeper), ibc.NewAppModule(app.IBCKeeper),
transferModule,
// Ethermint app modules // Ethermint app modules
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper), evm.NewAppModule(app.EvmKeeper, app.AccountKeeper),
feemarket.NewAppModule(app.FeeMarketKeeper), feemarket.NewAppModule(app.FeeMarketKeeper),
@ -569,7 +567,9 @@ func NewEthermintApp(
slashingtypes.ModuleName, slashingtypes.ModuleName,
evidencetypes.ModuleName, evidencetypes.ModuleName,
stakingtypes.ModuleName, stakingtypes.ModuleName,
ibchost.ModuleName,
// no-op modules // no-op modules
ibctransfertypes.ModuleName,
authtypes.ModuleName, authtypes.ModuleName,
banktypes.ModuleName, banktypes.ModuleName,
govtypes.ModuleName, govtypes.ModuleName,
@ -593,6 +593,9 @@ func NewEthermintApp(
evmtypes.ModuleName, evmtypes.ModuleName,
feemarkettypes.ModuleName, feemarkettypes.ModuleName,
// no-op modules // no-op modules
// no-op modules
ibchost.ModuleName,
ibctransfertypes.ModuleName,
capabilitytypes.ModuleName, capabilitytypes.ModuleName,
authtypes.ModuleName, authtypes.ModuleName,
banktypes.ModuleName, banktypes.ModuleName,
@ -627,8 +630,10 @@ func NewEthermintApp(
slashingtypes.ModuleName, slashingtypes.ModuleName,
govtypes.ModuleName, govtypes.ModuleName,
minttypes.ModuleName, minttypes.ModuleName,
ibchost.ModuleName,
genutiltypes.ModuleName, genutiltypes.ModuleName,
evidencetypes.ModuleName, evidencetypes.ModuleName,
ibctransfertypes.ModuleName,
authz.ModuleName, authz.ModuleName,
feegrant.ModuleName, feegrant.ModuleName,
paramstypes.ModuleName, paramstypes.ModuleName,
@ -671,7 +676,8 @@ func NewEthermintApp(
evidence.NewAppModule(app.EvidenceKeeper), evidence.NewAppModule(app.EvidenceKeeper),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
// ibc.NewAppModule(app.IBCKeeper), ibc.NewAppModule(app.IBCKeeper),
transferModule,
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper), evm.NewAppModule(app.EvmKeeper, app.AccountKeeper),
feemarket.NewAppModule(app.FeeMarketKeeper), feemarket.NewAppModule(app.FeeMarketKeeper),
) )
@ -682,8 +688,6 @@ func NewEthermintApp(
app.SetInitChainer(app.InitChainer) app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker) app.SetBeginBlocker(app.BeginBlocker)
// app.ScopedIBCKeeper = scopedIBCKeeper
// app.ScopedTransferKeeper = scopedTransferKeeper
maxGasWanted := cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted)) maxGasWanted := cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted))
options := middleware.HandlerOptions{ options := middleware.HandlerOptions{
Codec: app.appCodec, Codec: app.appCodec,
@ -704,6 +708,9 @@ func NewEthermintApp(
app.setTxHandler(options, encodingConfig.TxConfig, cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))) app.setTxHandler(options, encodingConfig.TxConfig, cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents)))
app.SetEndBlocker(app.EndBlocker) app.SetEndBlocker(app.EndBlocker)
app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
return app return app
} }
@ -828,8 +835,8 @@ func (app *EthermintApp) SimulationManager() *module.SimulationManager {
// API server. // API server.
func (app *EthermintApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { func (app *EthermintApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
clientCtx := apiSvr.ClientCtx clientCtx := apiSvr.ClientCtx
// NOTE: in v0.46 legacy routes are removed
// rpc.RegisterRoutes(clientCtx, apiSvr.Router) // rpc.RegisterRoutes(clientCtx, apiSvr.Router)
// evmrest.RegisterTxRoutes(clientCtx, apiSvr.Router) // evmrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
// Register new tx routes from grpc-gateway. // Register new tx routes from grpc-gateway.
@ -891,8 +898,8 @@ func initParamsKeeper(
paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName) paramsKeeper.Subspace(crisistypes.ModuleName)
// paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName)
// paramsKeeper.Subspace(ibchost.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName)
// ethermint subspaces // ethermint subspaces
paramsKeeper.Subspace(evmtypes.ModuleName) paramsKeeper.Subspace(evmtypes.ModuleName)
paramsKeeper.Subspace(feemarkettypes.ModuleName) paramsKeeper.Subspace(feemarkettypes.ModuleName)

4
go.mod
View File

@ -6,10 +6,10 @@ require (
github.com/99designs/gqlgen v0.17.2 github.com/99designs/gqlgen v0.17.2
github.com/btcsuite/btcd v0.22.0-beta github.com/btcsuite/btcd v0.22.0-beta
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
github.com/cosmos/cosmos-sdk v0.46.0-alpha3.0.20220325134903-a69764f9f01b github.com/cosmos/cosmos-sdk v0.46.0-beta2
github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1 github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1
github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/ibc-go/v3 v3.0.0-alpha1.0.20220331200732-34f03df4aa59 github.com/cosmos/ibc-go/v3 v3.0.0-alpha1.0.20220517190049-c4ce2b908a1e
github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set v1.8.0 github.com/deckarep/golang-set v1.8.0
github.com/ethereum/go-ethereum v1.10.17 github.com/ethereum/go-ethereum v1.10.17

4
go.sum
View File

@ -303,8 +303,8 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4
github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
github.com/cosmos/iavl v0.18.0 h1:02ur4vnalMR2GuWCFNkuseUcl/BCVmg9tOeHOGiZOkE= github.com/cosmos/iavl v0.18.0 h1:02ur4vnalMR2GuWCFNkuseUcl/BCVmg9tOeHOGiZOkE=
github.com/cosmos/iavl v0.18.0/go.mod h1:L0VZHfq0tqMNJvXlslGExaaiZM7eSm+90Vh9QUbp6j4= github.com/cosmos/iavl v0.18.0/go.mod h1:L0VZHfq0tqMNJvXlslGExaaiZM7eSm+90Vh9QUbp6j4=
github.com/cosmos/ibc-go/v3 v3.0.0-alpha1.0.20220331200732-34f03df4aa59 h1:JArEGS53oKuhFXFKbgOxabN2AcK9nHieCMwYSFe5l4o= github.com/cosmos/ibc-go/v3 v3.0.0-alpha1.0.20220517190049-c4ce2b908a1e h1:Ib7epelzyhChHJWym0VFX8rr5HO0iGjV9jpX3UiXw4k=
github.com/cosmos/ibc-go/v3 v3.0.0-alpha1.0.20220331200732-34f03df4aa59/go.mod h1:b/e8JFZRZHf0p5xQkOrBbtEO50nthrEEQXAnOaNoD6Q= github.com/cosmos/ibc-go/v3 v3.0.0-alpha1.0.20220517190049-c4ce2b908a1e/go.mod h1:fZZsQ09aFdP1RxMTTi1s6NNhxT8LbZTALHEPc/Gd0s0=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU= github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8= github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8=
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=