Skip to content

Commit

Permalink
call verification of counterparty channel, upgrade in upgradetry. (#4310
Browse files Browse the repository at this point in the history
)
  • Loading branch information
DimitrisJim authored Aug 9, 2023
1 parent 9d9fb4e commit 8fa23dc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
24 changes: 24 additions & 0 deletions modules/core/04-channel/keeper/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,30 @@ func (k Keeper) ChanUpgradeTry(
FlushStatus: types.NOTINFLUSH,
}

// verify the counterparty channel state containing the upgrade sequence
if err := k.connectionKeeper.VerifyChannelState(
ctx,
connection,
proofHeight, proofCounterpartyChannel,
channel.Counterparty.PortId,
channel.Counterparty.ChannelId,
counterpartyChannel,
); err != nil {
return types.Upgrade{}, errorsmod.Wrap(err, "failed to verify counterparty channel state")
}

// verifies the proof that a particular proposed upgrade has been stored in the upgrade path of the counterparty
if err := k.connectionKeeper.VerifyChannelUpgrade(
ctx,
channel.Counterparty.PortId,
channel.Counterparty.ChannelId,
connection,
counterpartyUpgrade,
proofCounterpartyUpgrade, proofHeight,
); err != nil {
return types.Upgrade{}, errorsmod.Wrap(err, "failed to verify counterparty upgrade")
}

if err = k.startFlushUpgradeHandshake(
ctx,
portID, channelID,
Expand Down
11 changes: 10 additions & 1 deletion modules/core/04-channel/keeper/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,16 @@ func (suite *KeeperTestSuite) TestChanUpgradeTry() {
types.ErrInvalidUpgrade,
},
{
"startFlushUpgradeHandshake fails due to proof verification failure, counterparty upgrade connection hops are tampered with",
"fails due to proof verification failure, counterparty channel ordering does not match expected ordering",
func() {
channel := path.EndpointB.GetChannel()
channel.Ordering = types.ORDERED
path.EndpointB.SetChannel(channel)
},
commitmenttypes.ErrInvalidProof,
},
{
"fails due to proof verification failure, counterparty upgrade connection hops are tampered with",
func() {
counterpartyUpgrade.Fields.ConnectionHops = []string{ibctesting.InvalidID}
},
Expand Down

0 comments on commit 8fa23dc

Please sign in to comment.