-
Notifications
You must be signed in to change notification settings - Fork 683
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
Implement openUpgradeHandshake subprotocol #3759
Implement openUpgradeHandshake subprotocol #3759
Conversation
// WriteUpgradeOpenChannel writes the agreed upon upgrade fields to the channel fields. This can be called in one of two cases: | ||
// - In the UpgradeAck step of the handshake both sides have already flushed any in-flight packets. | ||
// - In the UpgradeOpen step of the handshake. | ||
func (k Keeper) WriteUpgradeOpenChannel(ctx sdk.Context, portID, channelID 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.
Question. It would be nice if we could get information about who called us (Ack
or Open
) since that can be used in the error messages and when incrementing the telemetry counter. Would a bool (or enum :^)) be the preferred approach?
I don't think we can use the previousState here to make assumptions about who called us but I haven't thought too hard about it yet.
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.
why can't we use the previousState
?
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.
If my understanding of the state transitions are correct (ref recent PR https://github.com/cosmos/ibc/pull/978/files). We can end up in the subprotocol from both open and from ack with channel state being ACKUPGRADE
for channel A
.
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.
are you talking about the case where this subprotocol is being called on chain B, where chain A has automatically moved from ACK -> OPEN bc the pending in flight packets check results in an automatic chan OPEN?
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.
if so, i think we could then still use this because the previousState of the chain B channel should be accurate.
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.
wouldn't B
be in TRYUPGRADE
?
To be a bit more verbose about my confusion, during ChanUpgradeAck
and after startFlushUpgradeHandshake
the states of A
and B
will be (ACKUPGRADE, TRYUPGRADE)
(referencing the PR linked in the previous comment). If at this point both A and B have finished flushing, openUpgradeHandShake
will be called with those two states for A and B.
OTOH, if they have not finished flushing, after they do, the relayer will submit the ChanUpgradeClose
messages to both A
and B
and the states, having not changed, will still be (ACKUPGRADE, TRYUPGRADE)
.
I feel I'm missing something here but can't see it yet. Either way, this doesn't affect the core logic, its mostly for the telemetry counter and the err messages.
// WriteUpgradeOpenChannel writes the agreed upon upgrade fields to the channel fields. This can be called in one of two cases: | ||
// - In the UpgradeAck step of the handshake both sides have already flushed any in-flight packets. | ||
// - In the UpgradeOpen step of the handshake. | ||
func (k Keeper) WriteUpgradeOpenChannel(ctx sdk.Context, portID, channelID 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.
why can't we use the previousState
?
a41350e
to
d394e0a
Compare
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.
Nice! LGTM
// WriteUpgradeOpenChannel writes the agreed upon upgrade fields to the channel, sets the channel flush status to `NOTINFLUSH` and sets the channel state back to `OPEN`. This can be called in one of two cases: | ||
// - In the UpgradeAck step of the handshake if both sides have already flushed all in-flight packets. | ||
// - In the UpgradeOpen step of the handshake. | ||
func (k Keeper) writeUpgradeOpenChannel(ctx sdk.Context, portID, channelID 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.
will this method not be called from the core msg server and need to be unexported?
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.
can be updated when its used
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
// WriteUpgradeOpenChannel writes the agreed upon upgrade fields to the channel, sets the channel flush status to `NOTINFLUSH` and sets the channel state back to `OPEN`. This can be called in one of two cases: | ||
// - In the UpgradeAck step of the handshake if both sides have already flushed all in-flight packets. | ||
// - In the UpgradeOpen step of the handshake. | ||
func (k Keeper) writeUpgradeOpenChannel(ctx sdk.Context, portID, channelID 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.
can be updated when its used
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.
One note is that I didn't use checks in spec since they would be duplicated. So in spec it is caller responsibility. Up to implementation team whether it makes sense to have checks in the function or not
0f5c081
to
563548d
Compare
…ehandshake-subprotocol
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.
Nice, @DimitrisJim!
Co-authored-by: Carlos Rodriguez <[email protected]>
…ehandshake-subprotocol
…ehandshake-subprotocol
Description
Add the
openUpgradeHandshake
sub protocol (renamed toWriteUpgradeOpenChannel
as per the comments in the issue.closes: #3644
Commit Message / Changelog Entry
see the guidelines for commit messages. (view raw markdown for examples)
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.Files changed
in the Github PR explorer.Codecov Report
in the comment section below once CI passes.