Skip to content
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

call verification of counterparty channel, upgrade in upgradetry. #4310

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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