-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling packets recv on unknown channels #292
Comments
Probably it makes sense to move this description of handling packets received on unknown channels to an ADR. @jtremback What do you think? |
So, correct me if I'm wrong: anyone can try to open a CCV channel, and once the first VSC packet is received on the consumer, the channel it came on is marked the "canonical" CCV channel. Any packets coming on other channels are ignored. So when you write "it MUST handle packets received on other channels than the established CCV channel", by "handle" you mean "ignore"? How does this differ from the provider, where "it SHOULD NOT handle packets"? |
Yes. And for cleaning up the state, we should close the other channels so that we don't leave random open channels in the state.
The IBC core module on the provider will not even pass to the |
@jtremback According to the EDIT in the issue description, i.e.,
the consumer will not receive packets that were not sent by the provider (as long as the provider follows the protocol, which we assume it does, i.e., less than 1/3 of the voting power is Byzantine). Since the provider only sends So, this branch
Notice though that on the consumer, multiple channels could be OPEN (i.e., after executing
@AdityaSripal is there a way in IBC to iterate through all the channels built on top of the same connection? |
Re. garbage collection, this issue is related to #293. One of the solutions should be sufficient to deal with closing the redundant channels on both sides. |
I would like it very much if we could delete everything in this code path, since it is impossible to receive CCV packets on the wrong channel.
Such as |
Ref. #274 (comment)
The discussion is about whether the CCV modules (both on provider and consumers) should handle the case of IBC packets received on other channels than the established CCV channel. Note that one of the properties guaranteed by Interchain Security is that the CCV channel is unique.
Sending
MsgRecvPacket
messages to the core IBC core module is permissionless. However, there are several requirements for that packet (contained in the message) to be passed to theOnRecvPacket
handler of an IBC application module. The relevant requirements for this discussions are:portId, channelId
, whereportId = msg.Packet.DestinationPort
andchannelId = msg.Packet.DestinationChannel
, see https://github.com/cosmos/ibc-go/blob/05c4bfbbebb20d1cc078ddf1d29dadc766d9251b/modules/core/keeper/msg_server.go#L380Consumer
Channel capabilities
The consumer CCV module claims a channel's capability in
OnChanOpenInit
, seeinterchain-security/x/ccv/consumer/module.go
Line 281 in f3a9966
Sending
MsgChannelOpenInit
messages to he core IBC core module is permissionless. Moreover, the only requirement (relevant for this discussion) for those messages to be passed to theOnChanOpenInit
handler of an IBC application module is that the module claimed the port capability, see https://github.com/cosmos/ibc-go/blob/05c4bfbbebb20d1cc078ddf1d29dadc766d9251b/modules/core/keeper/msg_server.go#L170.The consumer CCV module claims the port capability at genesis, see
interchain-security/x/ccv/consumer/keeper/genesis.go
Line 30 in f3a9966
ProviderChannel
key is not set yet), seeinterchain-security/x/ccv/consumer/module.go
Line 258 in f3a9966
Open channels
The consumer CCV module channel endpoint moves to
OPEN
inChannelOpenAck
after executing theOnChanOpenAck
handler, see https://github.com/cosmos/ibc-go/blob/05c4bfbbebb20d1cc078ddf1d29dadc766d9251b/modules/core/04-channel/keeper/handshake.go#L279. Thus, as long as the CCV channel is not already established, every channel (with the corresponding params) will move to OPEN.Provider
Channel capabilities
The provider CCV module claims a channel's capability in
OnChanOpenTry
, seeinterchain-security/x/ccv/provider/module.go
Line 270 in f3a9966
Sending
MsgChannelOpenTry
messages to he core IBC core module is permissionless. Moreover, the only requirement (relevant for this discussion) for those messages to be passed to theOnChanOpenTry
handler of an IBC application module is that the module claimed the port capability, see https://github.com/cosmos/ibc-go/blob/05c4bfbbebb20d1cc078ddf1d29dadc766d9251b/modules/core/keeper/msg_server.go#L212The provider CCV module claims the port capability at genesis, see
interchain-security/x/ccv/provider/keeper/genesis.go
Line 19 in f3a9966
interchain-security/x/ccv/provider/module.go
Line 249 in f3a9966
Open channels
The provider CCV module channel endpoint moves to
OPEN
inChannelOpenConfirm
after executing theOnChanOpenConfirm
handler, see https://github.com/cosmos/ibc-go/blob/05c4bfbbebb20d1cc078ddf1d29dadc766d9251b/modules/core/04-channel/keeper/handshake.go#L362.In
OnChanOpenConfirm
, if there already exists an established CCV channel, the channel (for which the handshake is in progress) is closed. Otherwise, the channel is set as the established CCV channel. In other words, only the first channel that gets to this point is marked as the CCV channel and moved toOPEN
. The other channels are closed, seeinterchain-security/x/ccv/provider/keeper/keeper.go
Line 276 in f3a9966
Conclusion
The consumer CCV module could claim the capabilities of multiple channels that could be
OPEN
, which means that it MUST handle packets received on other channels than the established CCV channel.Note: All the channels for which the consumer CCV module claims capabilities must be on the expected client (set during genesis) and connection, see
interchain-security/x/ccv/consumer/module.go
Line 287 in f3a9966
The provider CCV module CANNOT claim the capabilities of multiple channels that could be
OPEN
, which means that it SHOULD NOT handle packets received on other channels than the established CCV channel.The text was updated successfully, but these errors were encountered: