Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/04-channel-upgrades' into charly/#…
Browse files Browse the repository at this point in the history
…3648-start-flush-upgrade
  • Loading branch information
colin-axner committed Jun 5, 2023
2 parents 85df989 + 67db04c commit d3029e4
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions testing/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,24 @@ func (endpoint *Endpoint) TimeoutOnClose(packet channeltypes.Packet) error {
return endpoint.Chain.sendMsgs(timeoutOnCloseMsg)
}

// QueryChannelUpgradeProof returns all the proofs necessary to execute UpgradeTry/UpgradeAck/UpgradeOpen.
// It returns the proof for the channel on the counterparty chain, the proof for the upgrade attempt on the
// counterparty chain, and the height at which the proof was queried.
func (endpoint *Endpoint) QueryChannelUpgradeProof() ([]byte, []byte, clienttypes.Height) {
counterpartyChannelID := endpoint.Counterparty.ChannelID
counterpartyPortID := endpoint.Counterparty.ChannelConfig.PortID

// query proof for the channel on the counterparty
channelKey := host.ChannelKey(counterpartyPortID, counterpartyChannelID)
proofChannel, height := endpoint.Counterparty.Chain.QueryProof(channelKey)

// query proof for the upgrade attempt on the counterparty
upgradeKey := host.ChannelUpgradeKey(counterpartyPortID, counterpartyChannelID)
proofUpgrade, _ := endpoint.Counterparty.Chain.QueryProof(upgradeKey)

return proofChannel, proofUpgrade, height
}

// ChanUpgradeInit sends a MsgChannelUpgradeInit on the associated endpoint.
// A default upgrade proposal is used with overrides from the ProposedUpgrade
// in the channel config.
Expand All @@ -586,15 +604,9 @@ func (endpoint *Endpoint) ChanUpgradeTry(timeout channeltypes.Timeout) error {
err := endpoint.UpdateClient()
require.NoError(endpoint.Chain.TB, err)

counterpartyChannelID := endpoint.Counterparty.ChannelID
counterpartyPortID := endpoint.Counterparty.ChannelConfig.PortID

channelKey := host.ChannelKey(counterpartyPortID, counterpartyChannelID)
proofChannel, height := endpoint.Counterparty.Chain.QueryProof(channelKey)
upgradeKey := host.ChannelUpgradeKey(counterpartyPortID, counterpartyChannelID)
proofUpgrade, _ := endpoint.Counterparty.Chain.QueryProof(upgradeKey)
proofChannel, proofUpgrade, height := endpoint.QueryChannelUpgradeProof()

counterpartyUpgrade, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(endpoint.Counterparty.Chain.GetContext(), counterpartyPortID, counterpartyChannelID)
counterpartyUpgrade, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(endpoint.Counterparty.Chain.GetContext(), endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID)
require.True(endpoint.Chain.TB, found)

msg := channeltypes.NewMsgChannelUpgradeTry(
Expand Down

0 comments on commit d3029e4

Please sign in to comment.