Skip to content

Commit

Permalink
update upgrade seq comparison in ChanUpgradeTimeout (#3905)
Browse files Browse the repository at this point in the history
* update upgrade seq comparison

* pr suggestions
  • Loading branch information
charleenfei authored Jun 20, 2023
1 parent 6453bd4 commit 4f5f627
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions modules/core/04-channel/keeper/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ func (k Keeper) ChanUpgradeTimeout(
// timeout for this sequence can only succeed if the error receipt written into the error path on the counterparty
// was for a previous sequence by the timeout deadline.
upgradeSequence := channel.UpgradeSequence
if upgradeSequence < prevErrorReceipt.Sequence {
return errorsmod.Wrapf(types.ErrInvalidUpgradeSequence, "previous counterparty error receipt sequence is greater than our current upgrade sequence: %d > %d", prevErrorReceipt.Sequence, upgradeSequence)
if upgradeSequence <= prevErrorReceipt.Sequence {
return errorsmod.Wrapf(types.ErrInvalidUpgradeSequence, "previous counterparty error receipt sequence is greater than or equal to our current upgrade sequence: %d > %d", prevErrorReceipt.Sequence, upgradeSequence)
}

if err := k.connectionKeeper.VerifyChannelUpgradeError(
Expand Down
12 changes: 11 additions & 1 deletion modules/core/04-channel/keeper/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeTimeout() {
"success: non-nil error receipt",
func() {
errReceipt = &types.ErrorReceipt{
Sequence: 1,
Sequence: 0,
Message: types.ErrInvalidUpgrade.Error(),
}

Expand Down Expand Up @@ -628,6 +628,16 @@ func (suite *KeeperTestSuite) TestChanUpgradeTimeout() {
},
types.ErrInvalidUpgradeSequence,
},
{
"non-nil error receipt: error receipt seq equal to current upgrade seq",
func() {
errReceipt = &types.ErrorReceipt{
Sequence: 1,
Message: types.ErrInvalidUpgrade.Error(),
}
},
types.ErrInvalidUpgradeSequence,
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 4f5f627

Please sign in to comment.