-
Notifications
You must be signed in to change notification settings - Fork 588
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
Account for moving channel state to flush complete in timeout processing #4425
Changes from 8 commits
7f21276
599aa9a
9bd3d38
ec86acd
625db69
15fb61b
bae3161
80b7006
32f6a9b
2276881
5ee1271
4929770
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 | ||||
---|---|---|---|---|---|---|
|
@@ -132,6 +132,9 @@ func (k Keeper) TimeoutPacket( | |||||
|
||||||
// TimeoutExecuted deletes the commitment send from this chain after it verifies timeout. | ||||||
// If the timed-out packet came from an ORDERED channel then this channel will be closed. | ||||||
// If the channel is in the FLUISHING state and there is a counterparty upgrade, then the | ||||||
// upgrade will be aborted if the upgrade has timed out. Otherwise, if the channel is in | ||||||
// if there are no more inflight packets, then the channel will be set to the FLUISHCOMPLETE state. | ||||||
// | ||||||
// CONTRACT: this function must be called in the IBC handler | ||||||
func (k Keeper) TimeoutExecuted( | ||||||
|
@@ -154,11 +157,6 @@ func (k Keeper) TimeoutExecuted( | |||||
|
||||||
k.deletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) | ||||||
|
||||||
if channel.FlushStatus == types.FLUSHING && !k.HasInflightPackets(ctx, packet.GetSourcePort(), packet.GetSourceChannel()) { | ||||||
channel.FlushStatus = types.FLUSHCOMPLETE | ||||||
k.SetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), channel) | ||||||
} | ||||||
|
||||||
if channel.Ordering == types.ORDERED { | ||||||
channel.Close() | ||||||
k.SetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), channel) | ||||||
Comment on lines
160
to
162
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. This could be slightly funky. Does Should this check be after the flushing state checks. 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. yeah I think you're right! We cane move this to after the new flushing check, nice catch |
||||||
|
@@ -173,6 +171,31 @@ func (k Keeper) TimeoutExecuted( | |||||
"dst_channel", packet.GetDestChannel(), | ||||||
) | ||||||
|
||||||
// if an upgrade is in progress, handling packet flushing and update channel state appropriately | ||||||
if channel.State == types.STATE_FLUSHING { | ||||||
counterpartyUpgrade, found := k.GetCounterpartyUpgrade(ctx, packet.GetSourcePort(), packet.GetSourceChannel()) | ||||||
if !found { | ||||||
return errorsmod.Wrapf(types.ErrUpgradeNotFound, "counterparty upgrade not found for channel: %s", packet.GetSourceChannel()) | ||||||
} | ||||||
|
||||||
timeout := counterpartyUpgrade.Timeout | ||||||
// if the timeout is valid then use it, otherwise it has not been set in the upgrade handshake yet. | ||||||
if timeout.IsValid() { | ||||||
if hasPassed, err := timeout.HasPassed(ctx); hasPassed { | ||||||
// packet flushing timeout has expired, abort the upgrade and return nil, | ||||||
// committing an error receipt to state, restoring the channel and successfully acknowledging the packet. | ||||||
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.
Suggested change
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. caught in the act of copy-paste ❗ |
||||||
k.MustAbortUpgrade(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), err) | ||||||
return nil | ||||||
} | ||||||
|
||||||
// set the channel state to flush complete if all packets have been acknowledged/flushed. | ||||||
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. acknowledged, timed out probs better to just say flushed for this one
Suggested change
|
||||||
if !k.HasInflightPackets(ctx, packet.GetSourcePort(), packet.GetSourceChannel()) { | ||||||
channel.State = types.STATE_FLUSHCOMPLETE | ||||||
k.SetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), channel) | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
// emit an event marking that we have processed the timeout | ||||||
emitTimeoutPacketEvent(ctx, packet, channel) | ||||||
|
||||||
|
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. Awesome, these tests already are setup with Would also be nice to have a test where the channel remains in |
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.
This godoc is a little funky sounding atm!