From b2f777b4e7b03a5e9900d266661ca657171f266b Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 20 Jun 2023 14:58:03 +0200 Subject: [PATCH 1/2] update upgrade seq comparison --- modules/core/04-channel/keeper/upgrade.go | 2 +- modules/core/04-channel/keeper/upgrade_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/04-channel/keeper/upgrade.go b/modules/core/04-channel/keeper/upgrade.go index b171e16d50b..3a3d2d603ad 100644 --- a/modules/core/04-channel/keeper/upgrade.go +++ b/modules/core/04-channel/keeper/upgrade.go @@ -448,7 +448,7 @@ 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 { + 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) } diff --git a/modules/core/04-channel/keeper/upgrade_test.go b/modules/core/04-channel/keeper/upgrade_test.go index 9677f6d7c6f..412bcb173a3 100644 --- a/modules/core/04-channel/keeper/upgrade_test.go +++ b/modules/core/04-channel/keeper/upgrade_test.go @@ -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(), } From 95577f294c772aed210a13dd979d27bb2c4f69cc Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 20 Jun 2023 16:19:36 +0200 Subject: [PATCH 2/2] pr suggestions --- modules/core/04-channel/keeper/upgrade.go | 2 +- modules/core/04-channel/keeper/upgrade_test.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/core/04-channel/keeper/upgrade.go b/modules/core/04-channel/keeper/upgrade.go index 3a3d2d603ad..2448c483108 100644 --- a/modules/core/04-channel/keeper/upgrade.go +++ b/modules/core/04-channel/keeper/upgrade.go @@ -449,7 +449,7 @@ func (k Keeper) ChanUpgradeTimeout( // 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) + 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( diff --git a/modules/core/04-channel/keeper/upgrade_test.go b/modules/core/04-channel/keeper/upgrade_test.go index 412bcb173a3..bb152f17af3 100644 --- a/modules/core/04-channel/keeper/upgrade_test.go +++ b/modules/core/04-channel/keeper/upgrade_test.go @@ -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 {