-
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
Merged
colin-axner
merged 25 commits into
04-channel-upgrades
from
carlos/check-counterparty-nextsequencesend-recvpacket
Dec 20, 2023
Merged
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
b7fbb39
add logic for setting next seq recv, update tests
charleenfei a3a10ab
update next seq recv and ack logic to spec
charleenfei 045fdd2
Merge branch '04-channel-upgrades' into charly/set_nextseqrecv
charleenfei 129cc62
typos
charleenfei c95192b
update test
charleenfei d7379a0
Merge branch 'charly/set_nextseqrecv' of github.com:cosmos/ibc-go int…
charleenfei 972faa6
wip changes for spec
charleenfei 3864e91
wip set counterparty upgrade
charleenfei 122c25b
update naming
charleenfei 81c31ee
update endpoint
charleenfei 0ca4bca
spec changes
charleenfei a7a0834
test that counterparty upgrade has been set
charleenfei adaac86
Merge branch '04-channel-upgrades' into charly/set_nextseqrecv
charleenfei 9a6f4c1
update err message
charleenfei ed80a45
pr review
charleenfei 1dd6dcd
Merge branch 'charly/set_nextseqrecv' of github.com:cosmos/ibc-go int…
charleenfei 7b2b487
naming nit
ac742e5
feat: check counterparty next sequence send in recv packet
61251a7
add comment
c0cd6ea
lint
73b255b
add error doc
charleenfei 63dada9
only do defensive check if counterpartyUpgrade is set
AdityaSripal 9e6f552
remove unnecessary 0 check
AdityaSripal 3637bfe
Merge branch '04-channel-upgrades' of github.com:cosmos/ibc-go into c…
colin-axner 5d66985
merge conflict fix: add back deleted test
colin-axner 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,6 +132,27 @@ func (k Keeper) RecvPacket( | |
return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected channel state to be one of [%s, %s], but got %s", types.OPEN, types.FLUSHING, channel.State) | ||
} | ||
|
||
// In the case of the channel being in FLUSHING we need to ensure that the | ||
// packet sequence is < counterparty next sequence send. This is a defensive | ||
// check and if the counterparty is implemented correctly, this should never abort. | ||
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()) | ||
} | ||
|
||
// only error if the counterparty next sequence send is set (> 0) | ||
// 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 counterpartyNextSequenceSend != 0 && packet.GetSequence() >= counterpartyNextSequenceSend { | ||
return errorsmod.Wrapf( | ||
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. document that this is unexpected error and that counterparty has messed up if this error is reached |
||
types.ErrInvalidPacket, | ||
"failed to receive packet, cannot flush packet at sequence greater than or equal to counterparty next sequence send (%d) ≥ (%d)", packet.GetSequence(), counterpartyNextSequenceSend, | ||
) | ||
} | ||
} | ||
|
||
// Authenticate capability to ensure caller has authority to receive packet on this channel | ||
capName := host.ChannelCapabilityPath(packet.GetDestPort(), packet.GetDestChannel()) | ||
if !k.scopedKeeper.AuthenticateCapability(ctx, chanCap, capName) { | ||
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
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!