Skip to content

Commit

Permalink
add height flag for upgrade clients tx (cosmos#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilkumarpilli committed Jan 18, 2021
1 parent 565ce8f commit 93d579f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 8 additions & 3 deletions cmd/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ func upgradeClientsCmd() *cobra.Command {
return err
}

height, err := cmd.Flags().GetInt64(flags.FlagHeight)
if err != nil {
return err
}

// ensure that keys exist
if _, err = c[src].GetAddress(); err != nil {
return err
Expand All @@ -156,13 +161,13 @@ func upgradeClientsCmd() *cobra.Command {
targetChainID := args[1]
// send the upgrade message on the targetChainID
if src == targetChainID {
return c[src].UpgradeClients(c[dst])
return c[src].UpgradeClients(c[dst], height)
}

return c[dst].UpgradeClients(c[src])
return c[dst].UpgradeClients(c[src], height)
},
}
return cmd
return heightFlag(cmd)
}

func createConnectionCmd() *cobra.Command {
Expand Down
7 changes: 5 additions & 2 deletions relayer/client-tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,18 @@ func (c *Chain) UpdateClients(dst *Chain) (err error) {
}

// UpgradesClients upgrades the client on src after dst chain has undergone an upgrade.
func (c *Chain) UpgradeClients(dst *Chain) error {
func (c *Chain) UpgradeClients(dst *Chain, height int64) error {
sh, err := NewSyncHeaders(c, dst)
if err != nil {
return err
}
if err := sh.Updates(c, dst); err != nil {
return err
}
height := int64(sh.GetHeight(dst.ChainID))

if height == 0 {
height = int64(sh.GetHeight(dst.ChainID))
}

// TODO: construct method of only attempting to get dst header
// Note: we explicitly do not check the error since the source
Expand Down

0 comments on commit 93d579f

Please sign in to comment.