Skip to content

Commit

Permalink
Added ChannelId to MsgChannelOpenInitResponse (#848) (#856)
Browse files Browse the repository at this point in the history
## Description
added ChannelId to MsgChannelOpenInitResponse
this is needed for distribution within interchain security

Also my go imports didn't like go metrics so I had to add the go-metrics alias

Supersedes: #839

Quote from @AdityaSripal
Context for the other folks reviewing: This is a problem in general not just for CCV. But currently, in CCV we want to initiate a transfer channel and know what the channelID is.

So if we want to do this as part of third-party module logic, it's currently impossible with the codebase. Since, if you try to use channelKeeper directly you will need portCapability; and a third party module will not have transfer's portCapability.

So we have to use the MsgServer, but the response doesn't include the channelID which we need since then we want to send transfer packets over the established channel.

So this is going to be an issue for any third-party module that wants to initialize a channel of a different IBC application and then use that channel to send packets over

---

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

- [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting))
- [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [x] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md).
- [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing)
- [x] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`)
- [x] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).
- [x] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md`
- [x] Re-reviewed `Files changed` in the Github PR explorer
- [ ] Review `Codecov Report` in the comment section below once CI passes

(cherry picked from commit 7b7eb9f)

Co-authored-by: frog power 4000 <[email protected]>
  • Loading branch information
mergify[bot] and rigelrozanski authored Feb 7, 2022
1 parent 402a3bf commit 45a84f2
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 74 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking

* (channel( [\#848](https://github.com/cosmos/ibc-go/pull/848) Added `ChannelId` to MsgChannelOpenInitResponse
* (testing( [\#813](https://github.com/cosmos/ibc-go/pull/813) The `ack` argument to the testing function `RelayPacket` has been removed as it is no longer needed.
* (testing) [\#774](https://github.com/cosmos/ibc-go/pull/774) Added `ChainID` arg to `SetupWithGenesisValSet` on the testing app. `Coordinator` generated ChainIDs now starts at index 1
* (transfer) [\#675](https://github.com/cosmos/ibc-go/pull/675) Transfer `NewKeeper` now takes in an ICS4Wrapper. The ICS4Wrapper may be the IBC Channel Keeper when ICS20 is not used in a middleware stack. The ICS4Wrapper is required for applications wishing to connect middleware to ICS20.
Expand Down
5 changes: 5 additions & 0 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,11 @@ is called by a relayer on Chain A.
MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `channel_id` | [string](#string) | | |





Expand Down
194 changes: 123 additions & 71 deletions modules/core/04-channel/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package keeper
import (
"context"

"github.com/armon/go-metrics"
metrics "github.com/armon/go-metrics"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -191,7 +192,9 @@ func (k Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgChan
// Write channel into state
k.ChannelKeeper.WriteOpenInitChannel(ctx, msg.PortId, channelID, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.Channel.Counterparty, msg.Channel.Version)

return &channeltypes.MsgChannelOpenInitResponse{}, nil
return &channeltypes.MsgChannelOpenInitResponse{
ChannelId: channelID,
}, nil
}

// ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry.
Expand Down
4 changes: 3 additions & 1 deletion proto/ibc/core/channel/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ message MsgChannelOpenInit {
}

// MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type.
message MsgChannelOpenInitResponse {}
message MsgChannelOpenInitResponse {
string channel_id = 1 [(gogoproto.moretags) = "yaml:\"channel_id\""];
}

// MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel
// on Chain B. The version field within the Channel field has been deprecated. Its
Expand Down

0 comments on commit 45a84f2

Please sign in to comment.