From 742c37040dad40ef1a4bee8f7452b79c9fc0d601 Mon Sep 17 00:00:00 2001 From: bwty Date: Thu, 7 Sep 2023 01:10:27 +0800 Subject: [PATCH] fix: ibc connection --- app/app.go | 19 ++++++++++--------- go.work.sum | 4 ++++ x/resource/ibc_module.go | 5 ++--- x/resource/types/expected_keepers.go | 7 +++++++ x/resource/types/keys.go | 2 +- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/app.go b/app/app.go index c729c1336..dd223244c 100644 --- a/app/app.go +++ b/app/app.go @@ -225,7 +225,7 @@ type App struct { ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper ScopedICAHostKeeper capabilitykeeper.ScopedKeeper - ScopedResourceKeeper capabilitykeeper.ScopedKeeper // Todo: needed? + ScopedResourceKeeper capabilitykeeper.ScopedKeeper didKeeper didkeeper.Keeper resourceKeeper resourcekeeper.Keeper @@ -532,12 +532,20 @@ func New( AddRoute(icacontrollertypes.SubModuleName, icaControllerStack). AddRoute(icahosttypes.SubModuleName, icaHostStack) + // x/resource + app.resourceKeeper = *resourcekeeper.NewKeeper( + appCodec, keys[resourcetypes.StoreKey], + app.GetSubspace(resourcetypes.ModuleName), + &app.IBCKeeper.PortKeeper, + scopedResourceKeeper, + ) + // create the resource IBC stack var resourceIbcStack porttypes.IBCModule resourceIbcStack = resource.NewIBCModule(app.resourceKeeper) resourceIbcStack = ibcfee.NewIBCMiddleware(resourceIbcStack, app.IBCFeeKeeper) - // Add transfer stack to IBC Router + // Add resource stack to IBC Router ibcRouter.AddRoute(resourcetypes.ModuleName, resourceIbcStack) // Seal the IBC Router @@ -562,13 +570,6 @@ func New( app.GetSubspace(didtypes.ModuleName), ) - app.resourceKeeper = *resourcekeeper.NewKeeper( - appCodec, keys[resourcetypes.StoreKey], - app.GetSubspace(resourcetypes.ModuleName), - &app.IBCKeeper.PortKeeper, - scopedResourceKeeper, - ) - // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) diff --git a/go.work.sum b/go.work.sum index 567ca2691..f0e6453cf 100644 --- a/go.work.sum +++ b/go.work.sum @@ -805,6 +805,8 @@ github.com/checkpoint-restore/go-criu/v4 v4.1.0/go.mod h1:xUQBLp4RLc5zJtWY++yjOo github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= github.com/cheggaaa/pb v1.0.27 h1:wIkZHkNfC7R6GI5w7l/PdAdzXzlrbcI3p8OAlnkTsnc= +github.com/cheqd/cosmos-sdk v0.46.10-barberry h1:ZTp4EvHZw0CLAhvb8nYXIJAo9/Bcq/2KcMt9aDv2eUY= +github.com/cheqd/cosmos-sdk v0.46.10-barberry/go.mod h1:ZFL/yjcIZq67H8FiWoLCnnaChkXnbRRYEEhGrFq8fzE= github.com/cilium/ebpf v0.0.0-20200110133405-4032b1d8aae3/go.mod h1:MA5e5Lr8slmEg9bt0VpxxWqJlO4iwu3FBdHUzV7wQVg= github.com/cilium/ebpf v0.0.0-20200702112145-1c8d4c9ef775/go.mod h1:7cR51M8ViRLIdUjrmSXlK9pkrsDlLHbO8jiB8X8JnOc= github.com/cilium/ebpf v0.2.0/go.mod h1:To2CFviqOWL/M0gIMsvSMlqe7em/l1ALkX1PyjrX2Qs= @@ -2119,6 +2121,8 @@ github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17 github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/vmware/govmomi v0.20.3/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= +github.com/whalelephant/cosmos-sdk v0.0.0-20230906130404-fde27c0060e4 h1:hi5M/6rvWDm0sL3NtI7gZu+nZIrJHAiyiCD/K2/DwHE= +github.com/whalelephant/cosmos-sdk v0.0.0-20230906130404-fde27c0060e4/go.mod h1:ZFL/yjcIZq67H8FiWoLCnnaChkXnbRRYEEhGrFq8fzE= github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI= github.com/xanzy/go-gitlab v0.31.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug= diff --git a/x/resource/ibc_module.go b/x/resource/ibc_module.go index e13dad4ae..a7c3cdddb 100644 --- a/x/resource/ibc_module.go +++ b/x/resource/ibc_module.go @@ -28,7 +28,6 @@ func NewIBCModule(k resourceKeeper.Keeper) IBCModule { func validateChannelParams( ctx sdk.Context, - keeper resourceKeeper.Keeper, order channeltypes.Order, version string, ) error { @@ -54,7 +53,7 @@ func (im IBCModule) OnChanOpenInit( counterparty channeltypes.Counterparty, counterpartyVersion string, ) (string, error) { - if err := validateChannelParams(ctx, im.keeper, order, counterpartyVersion); err != nil { + if err := validateChannelParams(ctx, order, counterpartyVersion); err != nil { return "", err } @@ -84,7 +83,7 @@ func (im IBCModule) OnChanOpenTry( return "", sdkerrors.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) } - if err := validateChannelParams(ctx, im.keeper, order, counterpartyVersion); err != nil { + if err := validateChannelParams(ctx, order, counterpartyVersion); err != nil { return "", err } diff --git a/x/resource/types/expected_keepers.go b/x/resource/types/expected_keepers.go index e4d9d686c..6700ee8f1 100644 --- a/x/resource/types/expected_keepers.go +++ b/x/resource/types/expected_keepers.go @@ -4,6 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" connectiontypes "github.com/cosmos/ibc-go/v6/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" ) // ParamSubspace defines the expected Subspace interface for parameters (noalias) @@ -21,3 +22,9 @@ type ConnectionKeeper interface { type PortKeeper interface { BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability } + +// ChannelKeeper defines the expected IBC channel keeper +type ChannelKeeper interface { + GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) + GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) +} diff --git a/x/resource/types/keys.go b/x/resource/types/keys.go index 5c4d5b24b..fd2a76625 100644 --- a/x/resource/types/keys.go +++ b/x/resource/types/keys.go @@ -17,7 +17,7 @@ const ( IBCVersion = "cheqd-resource-v3" // Port id that this module binds to - ResourcePortId = "cheqd-resource" + ResourcePortId = "cheqdresource" ) const (