Skip to content
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

check counterparty nextSequenceSend in recvPacket #5469

Conversation

crodriguezvega
Copy link
Contributor

Description

closes: #XXXX

Commit Message / Changelog Entry

type: commit message

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.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

Copy link
Contributor

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine with this, do we want to maybe add a comment that it is a defensive check that shouldn't occur in practice?

Carlos Rodriguez added 2 commits December 19, 2023 20:58
@crodriguezvega crodriguezvega added the channel-upgradability Channel upgradability feature label Dec 20, 2023
@damiannolan
Copy link
Member

I thought I saw this code flagged for removal in another PR yesterday?

@crodriguezvega
Copy link
Contributor Author

I thought I saw this code flagged for removal in another PR yesterday?

Yes, but shouldn't we check this anyway as a defensive check? It is also present in the spec.

// only error if the counterparty next sequence send is set (> 0)
counterpartyNextSequenceSend := counterpartyUpgrade.NextSequenceSend
if counterpartyNextSequenceSend != 0 && packet.GetSequence() >= counterpartyNextSequenceSend {
return errorsmod.Wrapf(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document that this is unexpected error and that counterparty has messed up if this error is reached

Copy link
Contributor

@charleenfei charleenfei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approval pending team consensus on necessity (but i think this seems to be consensus!) thanks @crodriguezvega!

@colin-axner colin-axner added the priority PRs that need prompt reviews label Dec 20, 2023
if channel.State == types.FLUSHING {
counterpartyUpgrade, found := k.GetCounterpartyUpgrade(ctx, packet.GetDestPort(), packet.GetDestChannel())
if !found {
return errorsmod.Wrapf(types.ErrUpgradeNotFound, "counterparty upgrade not found: portID (%s), channelID (%s)", packet.GetDestPort(), packet.GetDestChannel())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this block receives after try completes but before ack or confirm completes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm i would be in favor of just not performing this defensive check and allowing it through until we get the info stored. nice catch!

// this error should never be reached, as under normal circumstances the counterparty
// should not send any packets after the upgrade has been started.
counterpartyNextSequenceSend := counterpartyUpgrade.NextSequenceSend
if packet.GetSequence() >= counterpartyNextSequenceSend {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The zero check in the spec is effectively checking if the counterparty upgrade is not set. Since we do this inside if found clause it is unnecessary here.

If the counterpartyUpgrade is set, the counterpartyNextSequenceSend must be set to a nonzero value

Base automatically changed from charly/set_nextseqrecv to 04-channel-upgrades December 20, 2023 14:17
@charleenfei charleenfei requested a review from chatton as a code owner December 20, 2023 14:17
suite.Require().False(found)

// events := ctx.EventManager().Events().ToABCIEvents()
// expEvents := ibctesting.EventsMap{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colin-axner
Copy link
Contributor

I can fix merge conflicts

@colin-axner colin-axner self-assigned this Dec 20, 2023
Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

Thank you @crodriguezvega @AdityaSripal!

edit: And @colin-axner for fixing conflicts! :D

modules/core/04-channel/keeper/upgrade_test.go Outdated Show resolved Hide resolved
…arlos/check-counterparty-nextsequencesend-recvpacket
Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diffs look clean now, thanks everyone!

@colin-axner colin-axner merged commit bb58693 into 04-channel-upgrades Dec 20, 2023
56 checks passed
@colin-axner colin-axner deleted the carlos/check-counterparty-nextsequencesend-recvpacket branch December 20, 2023 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
channel-upgradability Channel upgradability feature priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants