Skip to content

Commit

Permalink
fix upgrade issues (cosmos#340)
Browse files Browse the repository at this point in the history
* fix upgrade issues

* bump commit
  • Loading branch information
colin-axner committed Jan 5, 2021
1 parent 17ac8e5 commit 4580600
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/avast/retry-go v2.6.0+incompatible
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/containerd/continuity v0.0.0-20200928162600-f2cc35102c2a // indirect
github.com/cosmos/cosmos-sdk v0.40.0-rc5
github.com/cosmos/cosmos-sdk v0.40.0-rc5.0.20201216094120-1c6881def899
github.com/cosmos/go-bip39 v1.0.0
github.com/gogo/protobuf v1.3.1
github.com/gorilla/mux v1.8.0
Expand Down
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-metrics v0.3.4 h1:Xqf+7f2Vhl9tsqDYmXhnXInUdcrtgpRNpIA15/uldSc=
github.com/armon/go-metrics v0.3.4/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc=
github.com/armon/go-metrics v0.3.5/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
github.com/avast/retry-go v2.6.0+incompatible h1:FelcMrm7Bxacr1/RM8+/eqkDkmVN7tjlsy51dOzB3LI=
Expand Down Expand Up @@ -136,13 +137,16 @@ github.com/cosmos/cosmos-sdk v0.40.0-rc3.0.20201207135138-d4a919b7143d h1:35WG4v
github.com/cosmos/cosmos-sdk v0.40.0-rc3.0.20201207135138-d4a919b7143d/go.mod h1:1NNWkanC/d68dpNYjjJ5Qve4aMEBzVg736cn3oUMPeo=
github.com/cosmos/cosmos-sdk v0.40.0-rc5 h1:oUuo/9MtPcH8t/I+wgtqAV9Ad7DjiLOT7VMF/9zQNQc=
github.com/cosmos/cosmos-sdk v0.40.0-rc5/go.mod h1:+oR3VJg5puOc6IDdw5MIKdhjXW+HgBzd5zTfGMjDmNQ=
github.com/cosmos/cosmos-sdk v0.40.0-rc5.0.20201216094120-1c6881def899 h1:iPaoGFOBlQo1FgxbasKFrDEXIOFO39rfNlOYnXyx5Oo=
github.com/cosmos/cosmos-sdk v0.40.0-rc5.0.20201216094120-1c6881def899/go.mod h1:vCqmOJkxKko/QQXjp0S+K1SHNLlVhHvnxVzeAA91qmQ=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/iavl v0.15.0-rc3.0.20201009144442-230e9bdf52cd/go.mod h1:3xOIaNNX19p0QrX0VqWa6voPRoJRGGYtny+DH8NEPvE=
github.com/cosmos/iavl v0.15.0-rc5 h1:AMKgaAjXwGANWv56NL4q4hV+a0puSkLYD6cCQAv3i44=
github.com/cosmos/iavl v0.15.0-rc5/go.mod h1:WqoPL9yPTQ85QBMT45OOUzPxG/U/JcJoN7uMjgxke/I=
github.com/cosmos/iavl v0.15.2/go.mod h1:OLjQiAQ4fGD2KDZooyJG9yz+p2ao2IAYSbke8mVvSA4=
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=
github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY=
github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI=
Expand Down Expand Up @@ -697,6 +701,7 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E=
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -812,6 +817,7 @@ golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 h1:9UQO31fZ+0aKQOFldThf7BKPM
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1 h1:a/mKvvZr9Jcc8oKfcmgzyp7OwF73JPWsQLvH1z2Kxck=
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
Expand Down Expand Up @@ -886,6 +892,7 @@ google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEY
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20201111145450-ac7456db90a6 h1:iRN4+t0lvZX/l9gH14ARF9i58tsVa5a97k6aH95rC3Y=
google.golang.org/genproto v0.0.0-20201111145450-ac7456db90a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
Expand Down
1 change: 1 addition & 0 deletions relayer/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ func (c *Chain) UpgradeChain(dst *Chain, plan *upgradetypes.Plan, deposit sdk.Co
}

upgradedClientState := clientState.ZeroCustomFields().(*ibctmtypes.ClientState)
upgradedClientState.LatestHeight.RevisionHeight = uint64(plan.Height + 1)
upgradedClientState.UnbondingPeriod = unbondingPeriod
upgradedAny, err := clienttypes.PackClientState(upgradedClientState)
if err != nil {
Expand Down
18 changes: 15 additions & 3 deletions relayer/client-tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,16 @@ func (c *Chain) UpgradeClients(dst *Chain) error {
if err != nil {
return err
}
sh.Updates(c, dst)
if err := sh.Updates(c, dst); err != nil {
return err
}
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
// trusted header will fail
_, dstUpdateHeader, _ := sh.GetTrustedHeaders(c, dst)

// query proofs on counterparty
clientState, proofUpgradeClient, _, err := dst.QueryUpgradedClient(height)
if err != nil {
Expand All @@ -170,12 +177,17 @@ func (c *Chain) UpgradeClients(dst *Chain) error {
return err
}

msg := &clienttypes.MsgUpgradeClient{c.PathEnd.ClientID, clientState, consensusState, proofUpgradeClient, proofUpgradeConsensusState, c.MustGetAddress().String()}
upgradeMsg := &clienttypes.MsgUpgradeClient{c.PathEnd.ClientID, clientState, consensusState, proofUpgradeClient, proofUpgradeConsensusState, c.MustGetAddress().String()}
if err != nil {
return err
}

_, _, err = c.SendMsg(msg)
msgs := []sdk.Msg{
c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()),
upgradeMsg,
}

_, _, err = c.SendMsgs(msgs)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions relayer/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ func (c *Chain) QueryUnbondingPeriod() (time.Duration, error) {
func (c *Chain) QueryUpgradedClient(height int64) (*codectypes.Any, []byte, clienttypes.Height, error) {
req := upgradetypes.QueryCurrentPlanRequest{}

queryClient := upgradetypes.NewQueryClient(c.CLIContext(height))
queryClient := upgradetypes.NewQueryClient(c.CLIContext(0))

res, err := queryClient.CurrentPlan(context.Background(), &req)
if err != nil {
Expand All @@ -434,7 +434,7 @@ func (c *Chain) QueryUpgradedConsState(height int64) (*codectypes.Any, []byte, c
LastHeight: height,
}

queryClient := upgradetypes.NewQueryClient(c.CLIContext(height + 1))
queryClient := upgradetypes.NewQueryClient(c.CLIContext(0))

res, err := queryClient.UpgradedConsensusState(context.Background(), &req)
if err != nil {
Expand Down

0 comments on commit 4580600

Please sign in to comment.