-
Notifications
You must be signed in to change notification settings - Fork 610
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
ICS4: Fix Sequencing logic in UpgradeTry #5419
Conversation
The following test should cover some of the cases mentioned:
And then case 6 by And I added tests for cases 4, 5 7, and 8. |
I get |
The account sequence mismatch error is arising because we only increment the account sequence in the testing pkg if the tx goes through successfully. In the test in which its failing, we call the upgrade cancel handler, and expect an error, but later try to send another msg to the chain with a stale signing sequence. https://github.com/cosmos/ibc-go/blob/main/testing/chain.go#L373-L377 edit: we could probably wrap the above code in a edit2: I modified the testing pkg code to use the |
Thank you for finding the problem, @damiannolan! Would you like to push the fix? |
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, looks good to me, happy to move forward with this! LGTM
I can cherry-pick the commit to main for TestChain.SendMsgs()
if needs be, but I think its probably fine to keep it in the feat branch and just let it get merged through there!
// The ChanUpgradeTry message may arrive first, in this case, **IF** the upgrade fields are mutually compatible; the counterparty will simply | ||
// fast forward their sequence to our own and continue the upgrade. The following ChanUpgradeCancel message will be rejected as it is below the current sequence. | ||
|
||
return channel, upgrade, types.NewUpgradeError(upgradeSequence, errorsmod.Wrapf( |
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.
Its intensional that the channel and upgrade are returned here instead of empty structs, right?
This is the only place where an upgrade error is return from the try handler and it looks like the channel returned is used for emitting error receipt events in this case:
https://github.com/cosmos/ibc-go/blob/04-channel-upgrades/modules/core/keeper/msg_server.go#L818-L820
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, cov is also clean, amazing! 💯
if counterpartyUpgradeSequence < channel.UpgradeSequence { | ||
return channel, upgrade, types.NewUpgradeError(channel.UpgradeSequence-1, errorsmod.Wrapf( | ||
// In this case, the counterparty upgrade is outdated. We want to force the counterparty |
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.
delicious documentation @AdityaSripal, very helpful
@@ -344,6 +344,14 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*abci.ExecTxResult, error) { | |||
// ensure the chain has the latest time | |||
chain.Coordinator.UpdateTimeForChain(chain) | |||
|
|||
// increment acc sequence regardless of success or failure tx execution |
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.
great find @damiannolan 👀
Added more assertions to tests and wrapped steps in |
Description
While writing quint tests against the spec I noticed a few issues surrounding our sequencing logic. This PR fixes them.
Issues:
See the following issues on spec:
cosmos/ibc#1052
cosmos/ibc#1053
cosmos/ibc#1054
This PR on the spec address the issues:
cosmos/ibc#1055
Unit tests to write:
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.