-
Notifications
You must be signed in to change notification settings - Fork 628
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
check counterparty nextSequenceSend
in recvPacket
#5469
Conversation
…o charly/set_nextseqrecv
…o charly/set_nextseqrecv
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.
fine with this, do we want to maybe add a comment that it is a defensive check that shouldn't occur in practice?
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( |
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.
document that this is unexpected error and that counterparty has messed up if this error is reached
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.
approval pending team consensus on necessity (but i think this seems to be consensus!) thanks @crodriguezvega!
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()) |
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 block receives after try completes but before ack or confirm completes
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.
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 { |
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.
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
suite.Require().False(found) | ||
|
||
// events := ctx.EventManager().Events().ToABCIEvents() | ||
// expEvents := ibctesting.EventsMap{ |
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.
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.
lol #5469 (comment)
I can fix merge conflicts |
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.
…arlos/check-counterparty-nextsequencesend-recvpacket
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.
diffs look clean now, thanks everyone!
Description
closes: #XXXX
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.