-
Notifications
You must be signed in to change notification settings - Fork 579
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
Move channel to OPEN if all in-flight packets have been flushed in UpgradeAck. #4075
Changes from 2 commits
3b41262
ec0cae8
58dff20
cd36f8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -852,6 +852,22 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh | |
|
||
ctx.Logger().Info("channel upgrade ack succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) | ||
|
||
// Move channel to OPEN state if both chains have finished flushing any in-flight packets. Counterparty flush status | ||
// has been verified in ChanUpgradeAck. | ||
if msg.CounterpartyFlushStatus == channeltypes.FLUSHCOMPLETE { | ||
channel, found := k.ChannelKeeper.GetChannel(ctx, msg.PortId, msg.ChannelId) | ||
if !found { | ||
return nil, errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", msg.PortId, msg.ChannelId) | ||
} | ||
if channel.FlushStatus == channeltypes.FLUSHCOMPLETE { | ||
cbs.OnChanUpgradeOpen(ctx, msg.PortId, msg.ChannelId) | ||
|
||
k.ChannelKeeper.WriteUpgradeOpenChannel(ctx, msg.PortId, msg.ChannelId) | ||
Comment on lines
+863
to
+865
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its unnecessary to call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea, the way I'm reasoning about it is that the proof we'd end up doing would be equivalent to what we did for UPGRADEACK (with the difference being we'd expect counterparty flush status to be in |
||
|
||
ctx.Logger().Info("channel upgrade open succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) | ||
} | ||
} | ||
|
||
return &channeltypes.MsgChannelUpgradeAckResponse{Result: channeltypes.SUCCESS}, 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.
Used this instead of
channel.FlushStatus == FLUSHCOMPLETE && counterpartyChannel.FlushStatus == FLUSHCOMPLETE
so as to not consume gas unnecessarily when getting the channel.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 guess the
msg.CounterpartyFlushStatus
has been proven with theCounterpartyChannelProof
on theChannelUpgradeAck
handler so this seems fine.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.
yeah good point, might be worth adding a comment to explicitly state that this value has already been verified in
k.ChannelKeeper.ChanUpgradeAck
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.
happy to go ahead with this for now, we can revisit it when doing the team walkthrough/audit.
Something about looking up the channels and stuff at the core msg server layer always seems a bit off to me but I know there's so many options here. I guess we could also do something like:
But anyways, we can talk about that later
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 think that should also work just fine no? Super cleaner. Will go with current approach for now but probably open a PR for ^ (need to tweak visibility of
hasInflightPackets
and just verify all tests pass correctly). Dope suggestion.