Skip to content

Commit

Permalink
fix: ibc connection
Browse files Browse the repository at this point in the history
  • Loading branch information
whalelephant committed Sep 7, 2023
1 parent f45d2d1 commit 742c370
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
19 changes: 10 additions & 9 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand Down
4 changes: 4 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
5 changes: 2 additions & 3 deletions x/resource/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func NewIBCModule(k resourceKeeper.Keeper) IBCModule {

func validateChannelParams(
ctx sdk.Context,
keeper resourceKeeper.Keeper,
order channeltypes.Order,
version string,
) error {
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
7 changes: 7 additions & 0 deletions x/resource/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
2 changes: 1 addition & 1 deletion x/resource/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
IBCVersion = "cheqd-resource-v3"

// Port id that this module binds to
ResourcePortId = "cheqd-resource"
ResourcePortId = "cheqdresource"
)

const (
Expand Down

0 comments on commit 742c370

Please sign in to comment.