-
Notifications
You must be signed in to change notification settings - Fork 657
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
Timing out packets on ordered channels when in flushing state aborts upgrade and closes channel #4475
Merged
chatton
merged 10 commits into
04-channel-upgrades
from
cian/issue#4454-timing-out-packets-on-ordered-channels-when-in-flushing-state
Aug 30, 2023
Merged
Timing out packets on ordered channels when in flushing state aborts upgrade and closes channel #4475
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b6b6e51
chore: moving flushing check to before the channel is closed
chatton d7a0207
chore: adding test case for closed channel when the upgrade is aborted
chatton 306ed18
Merge branch '04-channel-upgrades' into cian/issue#4454-timing-out-pa…
chatton 99ecbaf
wip
chatton 70c30fb
chore: merge 04-channel-upgrades
chatton 680ce92
refactor: adapting logic for aborting upgrade on timeout of ordered c…
damiannolan c8b993d
chore: pull remote changes
chatton 42e828c
Merge branch '04-channel-upgrades' into cian/issue#4454-timing-out-pa…
chatton a634bed
chore: fix build errors
chatton 7b45aaf
Merge branch '04-channel-upgrades' into cian/issue#4454-timing-out-pa…
chatton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -444,6 +444,51 @@ func (suite *KeeperTestSuite) TestTimeoutExecuted() { | |
suite.Require().False(found, "error receipt should not be written") | ||
}, | ||
}, | ||
{ | ||
"ordered channel is closed and upgrade is aborted when timeout is executed", | ||
func() { | ||
path.SetChannelOrdered() | ||
suite.coordinator.Setup(path) | ||
|
||
timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext()) | ||
timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().UnixNano()) | ||
|
||
sequence, err := path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) | ||
suite.Require().NoError(err) | ||
|
||
packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) | ||
chanCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) | ||
|
||
channel := path.EndpointA.GetChannel() | ||
channel.State = types.FLUSHING | ||
path.EndpointA.SetChannel(channel) | ||
path.EndpointA.SetChannelUpgrade(types.Upgrade{ | ||
Fields: path.EndpointA.GetProposedUpgrade().Fields, | ||
Timeout: types.NewTimeout(clienttypes.ZeroHeight(), 1), | ||
}) | ||
path.EndpointA.SetChannelCounterpartyUpgrade(types.Upgrade{ | ||
Timeout: types.NewTimeout(clienttypes.ZeroHeight(), 1), | ||
}) | ||
}, | ||
func(packetCommitment []byte, err error) { | ||
suite.Require().NoError(err) | ||
|
||
channel := path.EndpointA.GetChannel() | ||
suite.Require().Equal(types.CLOSED, channel.State, "channel state should be CLOSED") | ||
|
||
upgrade, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) | ||
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. possible future refactor: checking post-state for cleared upgrade state is done commonly iirc, could be nice if possible to have a helper for this. |
||
suite.Require().False(found, "upgrade should not be present") | ||
suite.Require().Equal(types.Upgrade{}, upgrade, "upgrade should be zero value") | ||
|
||
upgrade, found = suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetCounterpartyUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) | ||
suite.Require().False(found, "counterparty upgrade should not be present") | ||
suite.Require().Equal(types.Upgrade{}, upgrade, "counterparty upgrade should be zero value") | ||
|
||
errorReceipt, found := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) | ||
suite.Require().True(found, "error receipt should be present") | ||
suite.Require().Equal(channel.UpgradeSequence, errorReceipt.Sequence, "error receipt sequence should be equal to channel upgrade sequence") | ||
}, | ||
}, | ||
} | ||
|
||
for i, tc := range testCases { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
Let's say the timeout on
counterpartyUpgrade
is not set yet (TRY has been called, we are in stateFLUSHING
but counterparty timeout is not yet set), but we are in the process of timing out a packet on an ordered channel.We would end up skipping the code in
timeout.IsValid()
, timing out the packet and closing the channel, but the upgrade state would still remain in store.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.
guess we should be able to conditionally delete in the
if channel.Ordering == types.ORDERED
block yea?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.
really nice catch, I guess then the situation we can be in is that
timeout is invalid, LastSequenceSend is 0, but upgradeFields are set. We could use this as the check for also triggering the abort.