-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Flexible Channel Handshake Selection #7439
Conversation
Add ProvedID to ChanOpenTry which allows for flexible handshake identifier selection. Add CounterpartyChannelID to OpenAck. Update and add to handshake tests. Modify msgs_test. Counterparty ValidateBasic will return nil on an empty channel identifier to allow for flexible handshake identifier selection to succeed.
Codecov Report
@@ Coverage Diff @@
## master #7439 +/- ##
==========================================
+ Coverage 55.09% 55.11% +0.02%
==========================================
Files 588 588
Lines 36782 36800 +18
==========================================
+ Hits 20266 20284 +18
Misses 14415 14415
Partials 2101 2101 |
…osmos/cosmos-sdk into colin/7025-channel-handshake-selection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, minor comment
@@ -147,6 +148,15 @@ func (k Keeper) ChanOpenTry( | |||
) | |||
} | |||
|
|||
// empty-string is a sentinel value for "allow any identifier" to be selected by | |||
// the counterparty channel | |||
if provedChannelID != channelID && provedChannelID != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, I know the result is the same but if we change the order the second clause won't need to be evaluated as the entire condition will return false. Usually, in JS you would use if object && object.field...
to check for undefined
objects.
if provedChannelID != channelID && provedChannelID != "" { | |
if provedChannelID != "" && provedChannelID != channelID { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea I agree which is why I did this in msgs.go
. I left how the spec ordered it in handshake for consistency. This is also how it is in connection handshake so I'd prefer to update this in a separate pr since it isn't api breaking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc/ @cwgoes should we apply this to the spec? I think it reads slightly better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied to the spec in cosmos/ibc@890e3d0
@@ -214,6 +225,15 @@ func (k Keeper) ChanOpenAck( | |||
return sdkerrors.Wrapf(types.ErrChannelCapabilityNotFound, "caller does not own capability for channel, port ID (%s) channel ID (%s)", portID, channelID) | |||
} | |||
|
|||
// empty-string is a sentinel value for "allow any identifier" to be selected by | |||
// the counterparty channel | |||
if counterpartyChannelID != channel.Counterparty.ChannelId && channel.Counterparty.ChannelId != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
if counterpartyChannelID != channel.Counterparty.ChannelId && channel.Counterparty.ChannelId != "" { | |
if channel.Counterparty.ChannelId != "" && counterpartyChannelID != channel.Counterparty.ChannelId { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also applied to the spec in cosmos/ibc@890e3d0
@@ -164,6 +169,9 @@ func (msg MsgChannelOpenAck) ValidateBasic() error { | |||
if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { | |||
return sdkerrors.Wrap(err, "invalid channel ID") | |||
} | |||
if err := host.ChannelIdentifierValidator(msg.CounterpartyChannelId); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be
if msg.CounterpartyChannelId != "" {
if err := host.ChannelIdentifierValidator(msg.CounterpartyChannelId); err != nil {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, CounterpartyChannelId
must be set. The != ""
check in the handshake is against the stored counterparty channel id not the provided one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the time Ack rolls around, a connection ID should have been selected. The ""
stored string in the handshake just indicates that the selection was flexible and the counterparty channel id should be used as the counterparty's channel id
@fedekunze could you run make proto after this merges and before a rc is cut. My proto tools are still broken so there might be some diffs |
Just checked and there wasn't any diff file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but one thing I don't understand is why not just always have flexible ID selection. It would be simpler to always have chains choosing their own identifiers.
Is there ever a reason why they shouldn't? cc: @cwgoes
channelID, | ||
provedChannelID string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally this is very confusing for me to read. It's not immediately clear what these mean without poring through the spec+comments.
I would prefer channelID => desiredChannelID
and provedChannelID => counterpartyChosenChannelID
cc: @cwgoes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree on the confusion. Why not just desiredChannelID
and chosenChannelID
? Using counterparty can be vague to whether the counterparty chose the channel ID for this chain or if the counterparty chose their own.
Then the logic would be
// empty chosen channel id allows the desired channel id to be used for identifier selection
if chosenChannelID != "" && chosenChannelID != desiredChannelID {
return err
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this renaming, I can update the spec as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upon further reflection I think counterpartyChosenChannelID
works fine since in most cases the Counterparty
will be a different field containing the counterparty.ChannelId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK!
rename provedID to counterpartyChosenID for connection and channel. Update if statement in handshake and tests. Ref: #7439 (comment)
* rename provedID rename provedID to counterpartyChosenID for connection and channel. Update if statement in handshake and tests. Ref: #7439 (comment) * update docs Co-authored-by: Christopher Goes <[email protected]>
* rename provedID rename provedID to counterpartyChosenID for connection and channel. Update if statement in handshake and tests. Ref: cosmos/cosmos-sdk#7439 (comment) * update docs Co-authored-by: Christopher Goes <[email protected]>
Description
closes: #7025
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.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes