From 7c7b34a23f15c7967dadc122bb76eb21e0ef1b8e Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Wed, 26 Aug 2020 18:06:07 -0700 Subject: [PATCH 01/54] WIP: not compiling, some errors fixed --- cmd/lite.go | 2 +- go.mod | 19 +++--- go.sum | 127 ++++++++++++++++++++++++++++++++++++++++ relayer/chain.go | 46 +++++++++++---- relayer/channel-tx.go | 4 +- relayer/contextual.go | 9 ++- relayer/log-tx.go | 4 +- relayer/packetMsgs.go | 5 +- relayer/pathEnd.go | 22 +++---- relayer/query.go | 50 ++++++++-------- relayer/relayPackets.go | 2 +- relayer/verifier.go | 8 +-- test/test_chains.go | 2 +- 13 files changed, 226 insertions(+), 74 deletions(-) diff --git a/cmd/lite.go b/cmd/lite.go index 0fa8581c7..65d679328 100644 --- a/cmd/lite.go +++ b/cmd/lite.go @@ -28,7 +28,7 @@ import ( "github.com/iqlusioninc/relayer/relayer" "github.com/spf13/cobra" "github.com/spf13/viper" - lite "github.com/tendermint/tendermint/lite2" + lite "github.com/tendermint/tendermint/light" ) // chainCmd represents the keys command diff --git a/go.mod b/go.mod index a493a0b16..783933998 100644 --- a/go.mod +++ b/go.mod @@ -7,18 +7,21 @@ 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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200522204605-4a07d536a7cc + github.com/cosmos/cosmos-sdk v0.34.4-0.20200825201020-d9fd4d2ca9a3 github.com/cosmos/gaia v0.0.1-0.20200522222820-2d61264338e5 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d - github.com/gorilla/mux v1.7.4 + github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 - github.com/sirupsen/logrus v1.5.0 // indirect github.com/spf13/cobra v1.0.0 - github.com/spf13/viper v1.7.0 - github.com/stretchr/testify v1.5.1 - github.com/tendermint/tendermint v0.33.4 - github.com/tendermint/tm-db v0.5.1 - gopkg.in/yaml.v2 v2.2.8 + github.com/spf13/viper v1.7.1 + github.com/stretchr/testify v1.6.1 + github.com/tendermint/tendermint v0.34.0-rc3 + github.com/tendermint/tm-db v0.6.1 + gopkg.in/yaml.v2 v2.3.0 ) replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 +replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 + +replace github.com/cosmos/cosmos-sdk => /Users/johnzampolin/go/src/github.com/cosmos/cosmos-sdk +replace github.com/cosmos/gaia => /Users/johnzampolin/go/src/github.com/cosmos/gaia \ No newline at end of file diff --git a/go.sum b/go.sum index f3a37d019..8c310f39b 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,10 @@ github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f h1:4O1om+U github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v3.7.1+incompatible h1:HmA9qHVrHIAqpSvoCYJ+c6qst0lgqEhNW6/KwfkHbS8= github.com/DataDog/datadog-go v3.7.1+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= @@ -45,11 +47,15 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= 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-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= @@ -57,6 +63,7 @@ github.com/avast/retry-go v2.6.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevB github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d/go.mod h1:icNx/6QdFblhsEjZehARqbNumymUT/ydwlLojFdv7Sk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -93,11 +100,18 @@ github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= +github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= +github.com/confio/ics23-iavl v0.6.0/go.mod h1:mmXAxD1vWoO0VP8YHu6mM1QHGv71NQqa1iSVm4HeKcY= +github.com/confio/ics23/go v0.0.0-20200323120010-7d9a00f0a2fa/go.mod h1:W1I3XC8d9N8OTu/ct5VJ84ylcOunZwMXsWkd27nvVts= +github.com/confio/ics23/go v0.0.0-20200610201322-18c7bd6b2dd3/go.mod h1:W1I3XC8d9N8OTu/ct5VJ84ylcOunZwMXsWkd27nvVts= +github.com/confio/ics23/go v0.0.0-20200804135932-65ad804e8539 h1:4AuX7KNUVdNa/am9yCQRqWMfdDJ86EtFJk/xwf6ntgc= +github.com/confio/ics23/go v0.0.0-20200804135932-65ad804e8539/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.0.0-20200228182428-0f16d7a0959c h1:8ahmSVELW1wghbjerVAyuEYD5+Dio66RYvSS0iGfL1M= @@ -105,6 +119,7 @@ github.com/containerd/continuity v0.0.0-20200228182428-0f16d7a0959c/go.mod h1:Dq github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -115,16 +130,21 @@ github.com/cosmos/cosmos-sdk v0.34.4-0.20200511222341-80be50319ca5 h1:pUNa8VBC8S github.com/cosmos/cosmos-sdk v0.34.4-0.20200511222341-80be50319ca5/go.mod h1:T3u1b0ahtqJpdI2Fk6JcmntR7/YLjMq+J6hZrHPZTzc= github.com/cosmos/cosmos-sdk v0.34.4-0.20200522204605-4a07d536a7cc h1:FokA8APz+KqRsnHoAyjorOSldkM6i1Q3r+eZAxcqd/k= github.com/cosmos/cosmos-sdk v0.34.4-0.20200522204605-4a07d536a7cc/go.mod h1:T3u1b0ahtqJpdI2Fk6JcmntR7/YLjMq+J6hZrHPZTzc= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200825201020-d9fd4d2ca9a3 h1:lrmnZC6EqnTHrXmnv85k6VNrbSafEG+q82S2+rKeGBg= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200825201020-d9fd4d2ca9a3/go.mod h1:HXb9uKlB4sR4BFP32aSboY1Se4QhbFbYcJN6Dexil2U= github.com/cosmos/gaia v0.0.1-0.20200511233019-cbc33219c3d9 h1:/JO2pguVvnhiDzkfAREVOKn2IQHQmzMuNUJoYfp/rds= github.com/cosmos/gaia v0.0.1-0.20200511233019-cbc33219c3d9/go.mod h1:GegY2vcug/cfD1e/zokaZQYAXkp6vBRC9BwOM5Je5sA= github.com/cosmos/gaia v0.0.1-0.20200522222820-2d61264338e5 h1:lU62dQpOUsUdCDBvyEDbJa6AoTKaBAeQv2rNDEj3X4E= github.com/cosmos/gaia v0.0.1-0.20200522222820-2d61264338e5/go.mod h1:t9kAXxZ0N4hj0Pcg6T+Ogw2a6ncz3M+9R+FL24ripSg= 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/iavl v0.15.0-rc2 h1:4HI/LYLjWUnou8dehPD+NqEsDc8uamJOU2yHcqdTKv8= +github.com/cosmos/iavl v0.15.0-rc2/go.mod h1:bXLXbwmww0kYtAYRCYNXR/k44lWaK8rIZJlCmqSK8lQ= 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= github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI= +github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= @@ -134,19 +154,25 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgraph-io/badger/v2 v2.0.3/go.mod h1:3KY8+bsP8wI0OEnQJAKpd4wIJW/Mm32yw2j/9FUVnIM= +github.com/dgraph-io/ristretto v0.0.2-0.20200115201040-8f368f2f2ab3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dvsekhvalnov/jose2go v0.0.0-20180829124132-7f401d37b68a h1:mq+R6XEM6lJX5VlLyZIrUSP8tSuJp82xTK89hvBwJbU= github.com/dvsekhvalnov/jose2go v0.0.0-20180829124132-7f401d37b68a/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25 h1:2vLKys4RBU4pn2T/hjXMbvwTr1Cvy5THHrQkbeY9HRk= +github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25/go.mod h1:hTr8+TLQmkUkgcuh3mcr5fjrT9c64ZzsBCdCEC6UppY= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -160,6 +186,8 @@ github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqL github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 h1:E2s37DuLxFhQDg5gKsWoLBOB0n+ZW8s599zru8FJ2/Y= github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= +github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= @@ -183,6 +211,8 @@ github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= +github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= +github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -198,6 +228,7 @@ github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -213,6 +244,8 @@ github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -224,6 +257,7 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -238,10 +272,14 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGa github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= +github.com/gorilla/handlers v1.5.0 h1:4wjo3sf9azi99c8hTmyaxp9y5S+pFszsy3pP0rAw/lw= +github.com/gorilla/handlers v1.5.0/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -250,8 +288,11 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.14.7 h1:Nk5kuHrnWUTf/0GL1a/vchH/om9Ap2/HnVna+jYZgTY= +github.com/grpc-ecosystem/grpc-gateway v1.14.7/go.mod h1:oYZKL012gGh6LMyg/xA7Q2yq6j8bu0wa+9w14EEthWU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= @@ -264,10 +305,13 @@ github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoP github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= @@ -296,22 +340,27 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= +github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -339,6 +388,7 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= +github.com/minio/highwayhash v1.0.0/go.mod h1:xQboMTeM9nY9v/LlAOxFctujiv5+Aq2hR5dxBpaMbdc= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -356,6 +406,7 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= @@ -363,6 +414,7 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -395,6 +447,7 @@ github.com/ory/dockertest/v3 v3.5.5 h1:bhWoPN3xmEHIdZHflA3vOf7KaHFbCOLoRnkCLhZ3e github.com/ory/dockertest/v3 v3.5.5/go.mod h1:4ZOpj8qBUmh8fcBSVzkH2bws2s91JdGvHUqan4GHEuQ= github.com/otiai10/copy v1.1.1 h1:PH7IFlRQ6Fv9vYmuXbDRLdgTHoP1w483kPNUP2bskpo= github.com/otiai10/copy v1.1.1/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= +github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= @@ -403,11 +456,15 @@ github.com/otiai10/mint v1.3.1 h1:BCmzIS3n71sGfHB5NMNDB3lHYPz8fWSkCAErHed//qc= github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= +github.com/pelletier/go-toml v1.8.0 h1:Keo9qb7iRJs2voHvunFtuuYFsbWeOBh8/P9v/kVMFtw= +github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -424,9 +481,12 @@ github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= +github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.5.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.5.1 h1:bdHYieyGlH+6OLEk2YQha8THib30KP0/yD0YH9m6xcA= github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= +github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -441,26 +501,37 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.13.0 h1:vJlpe9wPgDRM1Z+7Wj3zUUjY1nr6/1jNKyl7llliccg= +github.com/prometheus/common v0.13.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/cosmos-proto v0.3.0 h1:24dVpPrPi0GDoPVLesf2Ug98iK5QgVscPl0ga4Eoub0= github.com/regen-network/cosmos-proto v0.3.0/go.mod h1:zuP2jVPHab6+IIyOx3nXHFN+euFNeS3W8XQkcdd4s7A= +github.com/regen-network/protobuf v1.3.2-alpha.regen.4 h1:c9jEnU+xm6vqyrQe3M94UFWqiXxRIKKnqBOh2EACmBE= +github.com/regen-network/protobuf v1.3.2-alpha.regen.4/go.mod h1:/J8/bR1T/NXyIdQDLUaq15LjNE83nRzkyrLAMcPewig= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= @@ -469,6 +540,7 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.5.0 h1:1N5EYkVAPEywqZRJd7cwnRtCb6xJx7NH3T3WUTF980Q= github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= @@ -477,13 +549,17 @@ github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa/go.mod h1:oJyF+mSPH github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= @@ -495,12 +571,15 @@ github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= github.com/spf13/viper v1.6.3 h1:pDDu1OyEDTKzpJwdq4TiuLyMsUgRa/BT5cn5O62NoHs= github.com/spf13/viper v1.6.3/go.mod h1:jUMtyi0/lB5yZH/FjyGAoH7IMNrIhlBf6pXZmbMDvzw= github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= +github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= +github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= @@ -513,6 +592,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d h1:gZZadD8H+fF+n9CmNhYL1Y0dJB+kLOmKd7FbPJLeGHs= @@ -526,17 +607,26 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso= github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ= github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/iavl v0.13.2/go.mod h1:vE1u0XAGXYjHykd4BLp8p/yivrw2PF1TuoljBcsQoGA= github.com/tendermint/iavl v0.13.3 h1:expgBDY1MX+6/3sqrIxGChbTNf9N9aTJ67SH4bPchCs= github.com/tendermint/iavl v0.13.3/go.mod h1:2lE7GiWdSvc7kvT78ncIKmkOjCnp6JEnSb2O7B9htLw= github.com/tendermint/tendermint v0.33.2/go.mod h1:25DqB7YvV1tN3tHsjWoc2vFtlwICfrub9XO6UBO+4xk= github.com/tendermint/tendermint v0.33.4 h1:NM3G9618yC5PaaxGrcAySc5ylc1PAANeIx42u2Re/jo= github.com/tendermint/tendermint v0.33.4/go.mod h1:6NW9DVkvsvqmCY6wbRsOo66qGDhMXglRL70aXajvBEA= +github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= +github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= +github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= github.com/tendermint/tm-db v0.4.1/go.mod h1:JsJ6qzYkCGiGwm5GHl/H5GLI9XLb6qZX7PRe425dHAY= +github.com/tendermint/tm-db v0.5.0/go.mod h1:lSq7q5WRR/njf1LnhiZ/lIJHk2S8Y1Zyq5oP/3o9C2U= github.com/tendermint/tm-db v0.5.1 h1:H9HDq8UEA7Eeg13kdYckkgwwkQLBnJGgX4PgLJRhieY= github.com/tendermint/tm-db v0.5.1/go.mod h1:g92zWjHpCYlEvQXvy9M168Su8V1IBEeawpXVVBaK4f4= +github.com/tendermint/tm-db v0.6.1 h1:w3X87itMPXopcRPlFiqspEKhw4FXihPk2rnFFkP0zGk= +github.com/tendermint/tm-db v0.6.1/go.mod h1:m3x9kRP4UFd7JODJL0yBAZqE7wTw+S37uAE90cTx7OA= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= @@ -546,6 +636,7 @@ github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWp go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -564,6 +655,7 @@ golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -573,6 +665,9 @@ golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200406173513-056763e48d71 h1:DOmugCavvUtnUD114C1Wh+UgTgQZ4pMLzXxi1pSt+/Y= golang.org/x/crypto v0.0.0-20200406173513-056763e48d71/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 h1:DZhuSZLsGlFL4CmhA8BcRA0mnthyA/nZ00AqCUo7vHg= +golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 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= @@ -612,12 +707,16 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191003171128-d98b1b443823/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -632,6 +731,8 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -640,15 +741,21 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200121082415-34d275377bf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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= @@ -682,6 +789,7 @@ golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200110213125-a7a6caa82ab2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= @@ -710,8 +818,13 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a h1:Ob5/580gVHBJZgXnff1cZDbG+xLtMVE5mDRTe+nIsX4= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200324203455-a04cca1dde73/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= 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= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -721,10 +834,13 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.28.1 h1:C1QC6KzgSiLyBabDi87BbjaGreoRgGUF5nOyvfrAZ1k= google.golang.org/grpc v1.28.1/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.31.0 h1:T7P4R73V3SSDPhH7WW7ATbfViLtmamH0DKrP3f9AuDI= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -733,12 +849,18 @@ google.golang.org/protobuf v1.21.0 h1:qdOKuR/EIArgaWNjetjgTzgVTAZ+S/WXVrq9HW9zim google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.22.0 h1:cJv5/xdbk1NnMPR1VP9+HU6gupuG9MLBoH1r6RHZ2MY= google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= @@ -754,11 +876,16 @@ gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRN gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.0.2 h1:kG1BFyqVHuQoVQiR1bWGnfz/fmHvvuiSPIV7rvl360E= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/relayer/chain.go b/relayer/chain.go index ec9790599..5680f3326 100644 --- a/relayer/chain.go +++ b/relayer/chain.go @@ -11,21 +11,22 @@ import ( "sync" "time" - sdkCtx "github.com/cosmos/cosmos-sdk/client/context" + sdkCtx "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" ckeys "github.com/cosmos/cosmos-sdk/client/keys" - aminocodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/hd" keys "github.com/cosmos/cosmos-sdk/crypto/keyring" - codecstd "github.com/cosmos/cosmos-sdk/std" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" authclient "github.com/cosmos/cosmos-sdk/x/auth/client" + authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/go-bip39" "github.com/tendermint/tendermint/libs/log" rpcclient "github.com/tendermint/tendermint/rpc/client" rpchttp "github.com/tendermint/tendermint/rpc/client/http" ctypes "github.com/tendermint/tendermint/rpc/core/types" - libclient "github.com/tendermint/tendermint/rpc/lib/client" + libclient "github.com/tendermint/tendermint/rpc/jsonrpc/client" ) // Chain represents the necessary data for connecting to and indentifying a chain and its counterparites @@ -126,8 +127,7 @@ func (c *Chain) listenLoop(doneChan chan struct{}, tx, block, data bool) { // Init initializes the pieces of a chain that aren't set when it parses a config // NOTE: All validation of the chain should happen here. -func (c *Chain) Init(homePath string, cdc *codecstd.Codec, amino *aminocodec.Codec, - timeout time.Duration, debug bool) error { +func (c *Chain) Init(homePath string, timeout time.Duration, debug bool) error { keybase, err := keys.New(c.ChainID, "test", keysDir(homePath, c.ChainID), nil) if err != nil { return err @@ -148,11 +148,13 @@ func (c *Chain) Init(homePath string, cdc *codecstd.Codec, amino *aminocodec.Cod return fmt.Errorf("failed to parse trusting period (%s) for chain %s", c.TrustingPeriod, c.ChainID) } + encodingConfig := simapp.MakeEncodingConfig() + c.Keybase = keybase c.Client = client - c.Cdc = newContextualStdCodec(cdc, c.UseSDKContext) - c.Amino = newContextualAminoCodec(amino, c.UseSDKContext) - RegisterCodec(amino) + c.Cdc = newContextualStdCodec(encodingConfig.Marshaler, c.UseSDKContext) + c.Amino = newContextualAminoCodec(encodingConfig.Amino, c.UseSDKContext) + RegisterCodec(encodingConfig.Amino) c.HomePath = homePath c.logger = defaultChainLogger() c.timeout = timeout @@ -222,11 +224,13 @@ func (c *Chain) BuildAndSignTx(msgs []sdk.Msg) ([]byte, error) { defer done() // Fetch account and sequence numbers for the account - acc, err := auth.NewAccountRetriever(c.Cdc, c).GetAccount(c.MustGetAddress()) + ctx := c.CLIContext() + accNum, accSeq, err := ctx.AccountRetriever.GetAccountNumberSequence(c.MustGetAddress()) if err != nil { return nil, err } - ctx := sdkCtx.CLIContext{Client: c.Client} + + // TODO: Migrating transaction path is going to take a bit more looking txBldr := auth.NewTxBuilder( auth.DefaultTxEncoder(c.Amino.Codec), acc.GetAccountNumber(), acc.GetSequence(), c.Gas, c.GasAdjustment, true, c.ChainID, @@ -240,9 +244,27 @@ func (c *Chain) BuildAndSignTx(msgs []sdk.Msg) ([]byte, error) { return txBldr.BuildAndSign(c.Key, ckeys.DefaultKeyPass, msgs) } +// CLIContext returns an instance of client.Context derived from Chain +func (c *Chain) CLIContext() sdkCtx.Context { + encodingConfig := simapp.MakeEncodingConfig() + return sdkCtx.Context{}. + WithJSONMarshaler(encodingConfig.Marshaler). + WithInterfaceRegistry(encodingConfig.InterfaceRegistry). + WithTxConfig(encodingConfig.TxConfig). + WithLegacyAmino(encodingConfig.Amino). + WithInput(os.Stdin). + WithAccountRetriever(authTypes.AccountRetriever{}). + WithBroadcastMode(flags.BroadcastBlock). + WithKeyring(c.Keybase). + WithOutputFormat("json"). + WithFrom(c.Key). + WithSkipConfirmation(true). + WithNodeURI(c.RPCAddr) +} + // BroadcastTxCommit takes the marshaled transaction bytes and broadcasts them func (c *Chain) BroadcastTxCommit(txBytes []byte) (sdk.TxResponse, error) { - return sdkCtx.CLIContext{Client: c.Client}.BroadcastTxCommit(txBytes) + return c.CLIContext().BroadcastTxCommit(txBytes) } // Log takes a string and logs the data diff --git a/relayer/channel-tx.go b/relayer/channel-tx.go index e4f1ac44b..7af2de7e1 100644 --- a/relayer/channel-tx.go +++ b/relayer/channel-tx.go @@ -5,7 +5,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" + chantypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ) // CreateChannel runs the channel creation messages on timeout until they pass @@ -68,7 +68,7 @@ func (c *Chain) CreateChannel(dst *Chain, ordered bool, to time.Duration) error // CreateChannelStep returns the next set of messages for creating a channel with given // identifiers between chains src and dst. If the handshake hasn't started, then CreateChannelStep // will begin the handshake on the src chain -func (c *Chain) CreateChannelStep(dst *Chain, ordering ibctypes.Order) (*RelayMsgs, error) { +func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayMsgs, error) { var ( out = &RelayMsgs{Src: []sdk.Msg{}, Dst: []sdk.Msg{}, last: false} scid, dcid = c.ChainID, dst.ChainID diff --git a/relayer/contextual.go b/relayer/contextual.go index 464360cf4..06f3f6a58 100644 --- a/relayer/contextual.go +++ b/relayer/contextual.go @@ -2,21 +2,20 @@ package relayer import ( "github.com/cosmos/cosmos-sdk/codec" - stdcodec "github.com/cosmos/cosmos-sdk/std" ) type contextualStdCodec struct { - *stdcodec.Codec + codec.JSONMarshaler useContext func() func() } type contextualAminoCodec struct { - *codec.Codec + *codec.LegacyAmino useContext func() func() } // newContextualCodec creates a codec that sets and resets context -func newContextualStdCodec(cdc *stdcodec.Codec, useContext func() func()) *contextualStdCodec { +func newContextualStdCodec(cdc codec.JSONMarshaler, useContext func() func()) *contextualStdCodec { return &contextualStdCodec{ Codec: cdc, useContext: useContext, @@ -54,7 +53,7 @@ func (cdc *contextualStdCodec) UnmarshalBinaryBare(bz []byte, ptr codec.ProtoMar } // newContextualCodec creates a codec that sets and resets context -func newContextualAminoCodec(cdc *codec.Codec, useContext func() func()) *contextualAminoCodec { +func newContextualAminoCodec(cdc *codec.LegacyAmino, useContext func() func()) *contextualAminoCodec { return &contextualAminoCodec{ Codec: cdc, useContext: useContext, diff --git a/relayer/log-tx.go b/relayer/log-tx.go index c499c8ddb..d8f8f04e1 100644 --- a/relayer/log-tx.go +++ b/relayer/log-tx.go @@ -42,7 +42,7 @@ func (c *Chain) logPacketsRelayed(dst *Chain, num int) { num, dst.ChainID, dst.PathEnd.PortID, c.ChainID, c.PathEnd.PortID)) } -func logChannelStates(src, dst *Chain, conn map[string]chanTypes.ChannelResponse) { +func logChannelStates(src, dst *Chain, conn map[string]chanTypes.QueryChannelResponse) { // TODO: replace channelID with portID? src.Log(fmt.Sprintf("- [%s]@{%d}chan(%s)-{%s} : [%s]@{%d}chan(%s)-{%s}", src.ChainID, @@ -56,7 +56,7 @@ func logChannelStates(src, dst *Chain, conn map[string]chanTypes.ChannelResponse )) } -func logConnectionStates(src, dst *Chain, conn map[string]connTypes.ConnectionResponse) { +func logConnectionStates(src, dst *Chain, conn map[string]connTypes.QueryConnectionResponse) { src.Log(fmt.Sprintf("- [%s]@{%d}conn(%s)-{%s} : [%s]@{%d}conn(%s)-{%s}", src.ChainID, conn[src.ChainID].ProofHeight, diff --git a/relayer/packetMsgs.go b/relayer/packetMsgs.go index 3465a3dda..34caa4844 100644 --- a/relayer/packetMsgs.go +++ b/relayer/packetMsgs.go @@ -9,9 +9,9 @@ import ( chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ) -var ModuleCdc *codec.Codec +var ModuleCdc *codec.LegacyAmino -func RegisterCodec(cdc *codec.Codec) { +func RegisterCodec(cdc *codec.LegacyAmino) { if ModuleCdc != nil { return } @@ -25,6 +25,7 @@ type MsgSendPacket struct { Sender sdk.AccAddress `json:"sender" yaml:"sender"` // the sender address } +// TODO: Implement ProtoMessage method var _ sdk.Msg = MsgSendPacket{} // NewMsgSendPacket returns a new send request diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index aee2e68de..be60eedc8 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -5,11 +5,11 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" + xferTypes "github.com/cosmos/cosmos-sdk/x/ibc-transfer/types" clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" connTypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" - xferTypes "github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) @@ -30,7 +30,7 @@ type PathEnd struct { } // OrderFromString parses a string into a channel order byte -func OrderFromString(order string) ibctypes.Order { +func OrderFromString(order string) chanTypes.Order { switch order { case "UNORDERED": return ibctypes.UNORDERED @@ -41,7 +41,7 @@ func OrderFromString(order string) ibctypes.Order { } } -func (pe *PathEnd) getOrder() ibctypes.Order { +func (pe *PathEnd) getOrder() chanTypes.Order { return OrderFromString(strings.ToUpper(pe.Order)) } @@ -85,8 +85,8 @@ func (pe *PathEnd) ConnInit(dst *PathEnd, signer sdk.AccAddress) sdk.Msg { // ConnTry creates a MsgConnectionOpenTry // NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE -func (pe *PathEnd) ConnTry(dst *PathEnd, dstConnState connTypes.ConnectionResponse, - dstConsState clientTypes.ConsensusStateResponse, dstCsHeight int64, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) ConnTry(dst *PathEnd, dstConnState connTypes.QueryConnectionResponse, + dstConsState clientTypes.QueryConsensusStateResponse, dstCsHeight int64, signer sdk.AccAddress) sdk.Msg { return connTypes.NewMsgConnectionOpenTry( pe.ConnectionID, pe.ClientID, @@ -104,7 +104,7 @@ func (pe *PathEnd) ConnTry(dst *PathEnd, dstConnState connTypes.ConnectionRespon // ConnAck creates a MsgConnectionOpenAck // NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE -func (pe *PathEnd) ConnAck(dstConnState connTypes.ConnectionResponse, dstConsState clientTypes.ConsensusStateResponse, +func (pe *PathEnd) ConnAck(dstConnState connTypes.QueryConnectionResponse, dstConsState clientTypes.QueryConsensusStateResponse, dstCsHeight int64, signer sdk.AccAddress) sdk.Msg { return connTypes.NewMsgConnectionOpenAck( pe.ConnectionID, @@ -119,7 +119,7 @@ func (pe *PathEnd) ConnAck(dstConnState connTypes.ConnectionResponse, dstConsSta // ConnConfirm creates a MsgConnectionOpenAck // NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE -func (pe *PathEnd) ConnConfirm(dstConnState connTypes.ConnectionResponse, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) ConnConfirm(dstConnState connTypes.QueryConnectionResponse, signer sdk.AccAddress) sdk.Msg { return connTypes.NewMsgConnectionOpenConfirm( pe.ConnectionID, dstConnState.Proof, @@ -143,7 +143,7 @@ func (pe *PathEnd) ChanInit(dst *PathEnd, signer sdk.AccAddress) sdk.Msg { } // ChanTry creates a MsgChannelOpenTry -func (pe *PathEnd) ChanTry(dst *PathEnd, dstChanState chanTypes.ChannelResponse, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) ChanTry(dst *PathEnd, dstChanState chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg { return chanTypes.NewMsgChannelOpenTry( pe.PortID, pe.ChannelID, @@ -160,7 +160,7 @@ func (pe *PathEnd) ChanTry(dst *PathEnd, dstChanState chanTypes.ChannelResponse, } // ChanAck creates a MsgChannelOpenAck -func (pe *PathEnd) ChanAck(dstChanState chanTypes.ChannelResponse, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) ChanAck(dstChanState chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg { return chanTypes.NewMsgChannelOpenAck( pe.PortID, pe.ChannelID, @@ -172,7 +172,7 @@ func (pe *PathEnd) ChanAck(dstChanState chanTypes.ChannelResponse, signer sdk.Ac } // ChanConfirm creates a MsgChannelOpenConfirm -func (pe *PathEnd) ChanConfirm(dstChanState chanTypes.ChannelResponse, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) ChanConfirm(dstChanState chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg { return chanTypes.NewMsgChannelOpenConfirm( pe.PortID, pe.ChannelID, @@ -192,7 +192,7 @@ func (pe *PathEnd) ChanCloseInit(signer sdk.AccAddress) sdk.Msg { } // ChanCloseConfirm creates a MsgChannelCloseConfirm -func (pe *PathEnd) ChanCloseConfirm(dstChanState chanTypes.ChannelResponse, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) ChanCloseConfirm(dstChanState chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg { return chanTypes.NewMsgChannelCloseConfirm( pe.PortID, pe.ChannelID, diff --git a/relayer/query.go b/relayer/query.go index d4f8b6f99..d923c36cd 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -118,8 +118,8 @@ func qConsStateErr(err error) error { return fmt.Errorf("query cons state failed // QueryClientConsensusState retrevies the latest consensus state for a client in state at a given height // NOTE: dstHeight is the height from dst that is stored on src, it is needed to construct the appropriate store query func (c *Chain) QueryClientConsensusState(srcHeight, - srcClientConsHeight int64) (clientTypes.ConsensusStateResponse, error) { - var conStateRes clientTypes.ConsensusStateResponse + srcClientConsHeight int64) (clientTypes.QueryConsensusStateResponse, error) { + var conStateRes clientTypes.QueryConsensusStateResponse if !c.PathSet() { return conStateRes, c.ErrPathNotSet() } @@ -151,7 +151,7 @@ func (c *Chain) QueryClientConsensusState(srcHeight, type csstates struct { sync.Mutex - Map map[string]clientTypes.ConsensusStateResponse + Map map[string]clientTypes.QueryConsensusStateResponse Errs errs } @@ -163,9 +163,9 @@ type chh struct { // QueryClientConsensusStatePair allows for the querying of multiple client states at the same time func QueryClientConsensusStatePair(src, dst *Chain, - srcH, dstH, srcClientConsH, dstClientConsH int64) (map[string]clientTypes.ConsensusStateResponse, error) { + srcH, dstH, srcClientConsH, dstClientConsH int64) (map[string]clientTypes.QueryConsensusStateResponse, error) { hs := &csstates{ - Map: make(map[string]clientTypes.ConsensusStateResponse), + Map: make(map[string]clientTypes.QueryConsensusStateResponse), Errs: []error{}, } @@ -198,8 +198,8 @@ func QueryClientConsensusStatePair(src, dst *Chain, func qClntConsStateErr(err error) error { return fmt.Errorf("query client cons state failed: %w", err) } // QueryClientState retrevies the latest consensus state for a client in state at a given height -func (c *Chain) QueryClientState() (*clientTypes.StateResponse, error) { - var conStateRes *clientTypes.StateResponse +func (c *Chain) QueryClientState() (*clientTypes.QueryClientStateResponse, error) { + var conStateRes *clientTypes.QueryClientStateResponse if !c.PathSet() { return nil, c.ErrPathNotSet() } @@ -234,14 +234,14 @@ func (c *Chain) QueryClientState() (*clientTypes.StateResponse, error) { type cstates struct { sync.Mutex - Map map[string]*clientTypes.StateResponse + Map map[string]*clientTypes.QueryClientStateResponse Errs errs } // QueryClientStatePair returns a pair of connection responses -func QueryClientStatePair(src, dst *Chain) (map[string]*clientTypes.StateResponse, error) { +func QueryClientStatePair(src, dst *Chain) (map[string]*clientTypes.QueryClientStateResponse, error) { hs := &cstates{ - Map: make(map[string]*clientTypes.StateResponse), + Map: make(map[string]*clientTypes.QueryClientStateResponse), Errs: []error{}, } @@ -322,7 +322,7 @@ func (c *Chain) QueryConnections(page, limit int) (conns []connTypes.ConnectionE func qConnsErr(err error) error { return fmt.Errorf("query connections failed: %w", err) } // QueryConnectionsUsingClient gets any connections that exist between chain and counterparty -func (c *Chain) QueryConnectionsUsingClient(height int64) (clientConns connTypes.ClientConnectionsResponse, err error) { +func (c *Chain) QueryConnectionsUsingClient(height int64) (clientConns connTypes.QueryClientConnectionsResponse, err error) { if !c.PathSet() { return clientConns, c.ErrPathNotSet() } @@ -354,9 +354,9 @@ func qConnsUsingClntsErr(err error) error { } // QueryConnection returns the remote end of a given connection -func (c *Chain) QueryConnection(height int64) (connTypes.ConnectionResponse, error) { +func (c *Chain) QueryConnection(height int64) (connTypes.QueryConnectionResponse, error) { if !c.PathSet() { - return connTypes.ConnectionResponse{}, c.ErrPathNotSet() + return connTypes.QueryConnectionResponse{}, c.ErrPathNotSet() } req := abci.RequestQuery{ @@ -368,7 +368,7 @@ func (c *Chain) QueryConnection(height int64) (connTypes.ConnectionResponse, err res, err := c.QueryABCI(req) if err != nil { - return connTypes.ConnectionResponse{}, qConnErr(err) + return connTypes.QueryConnectionResponse{}, qConnErr(err) } else if res.Value == nil { // NOTE: This is returned so that the switch statement in ConnectionStep works properly return emptyConnRes, nil @@ -376,7 +376,7 @@ func (c *Chain) QueryConnection(height int64) (connTypes.ConnectionResponse, err var connection connTypes.ConnectionEnd if err = c.Cdc.UnmarshalBinaryBare(res.Value, &connection); err != nil { - return connTypes.ConnectionResponse{}, qConnErr(err) + return connTypes.QueryConnectionResponse{}, qConnErr(err) } return connTypes.NewConnectionResponse(c.PathEnd.ConnectionID, connection, res.Proof, res.Height), nil @@ -384,7 +384,7 @@ func (c *Chain) QueryConnection(height int64) (connTypes.ConnectionResponse, err type conns struct { sync.Mutex - Map map[string]connTypes.ConnectionResponse + Map map[string]connTypes.QueryConnectionResponse Errs errs } @@ -394,9 +394,9 @@ type chpair struct { } // QueryConnectionPair returns a pair of connection responses -func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (map[string]connTypes.ConnectionResponse, error) { +func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (map[string]connTypes.QueryConnectionResponse, error) { hs := &conns{ - Map: make(map[string]connTypes.ConnectionResponse), + Map: make(map[string]connTypes.QueryConnectionResponse), Errs: []error{}, } @@ -433,7 +433,7 @@ func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (map[string]connType func qConnErr(err error) error { return fmt.Errorf("query connection failed: %w", err) } -var emptyConnRes = connTypes.ConnectionResponse{Connection: connTypes.ConnectionEnd{ID: ""}} +var emptyConnRes = connTypes.QueryConnectionResponse{Connection: &connTypes.ConnectionEnd{ClientId: ""}} // //////////////////////////// // ICS 04 -> CHANNEL // @@ -464,7 +464,7 @@ func (c *Chain) QueryConnectionChannels(connectionID string, page, limit int) ([ } // QueryChannel returns the channel associated with a channelID -func (c *Chain) QueryChannel(height int64) (chanRes chanTypes.ChannelResponse, err error) { +func (c *Chain) QueryChannel(height int64) (chanRes chanTypes.QueryChannelResponse, err error) { if !c.PathSet() { return chanRes, c.ErrPathNotSet() } @@ -500,14 +500,14 @@ func (c *Chain) QueryChannel(height int64) (chanRes chanTypes.ChannelResponse, e type chans struct { sync.Mutex - Map map[string]chanTypes.ChannelResponse + Map map[string]chanTypes.QueryChannelResponse Errs errs } // QueryChannelPair returns a pair of channel responses -func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (map[string]chanTypes.ChannelResponse, error) { +func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (map[string]chanTypes.QueryChannelResponse, error) { hs := &chans{ - Map: make(map[string]chanTypes.ChannelResponse), + Map: make(map[string]chanTypes.QueryChannelResponse), Errs: []error{}, } @@ -588,7 +588,7 @@ func (c *Chain) WaitForNBlocks(n int64) error { } // QueryNextSeqRecv returns the next seqRecv for a configured channel -func (c *Chain) QueryNextSeqRecv(height int64) (recvRes chanTypes.RecvResponse, err error) { +func (c *Chain) QueryNextSeqRecv(height int64) (recvRes chanTypes.QueryNextSequenceReceiveResponse, err error) { if !c.PathSet() { return recvRes, c.ErrPathNotSet() } @@ -1212,7 +1212,7 @@ func (c *Chain) formatTxResult(resTx *ctypes.ResultTx, resBlock *ctypes.ResultBl } // Takes some bytes and a codec and returns an sdk.Tx -func parseTx(cdc *codec.Codec, txBytes []byte) (sdk.Tx, error) { +func parseTx(cdc *codec.JSONMarshaler, txBytes []byte) (sdk.Tx, error) { var tx authTypes.StdTx err := cdc.UnmarshalBinaryBare(txBytes, &tx) if err != nil { diff --git a/relayer/relayPackets.go b/relayer/relayPackets.go index a35541a66..2741c4ada 100644 --- a/relayer/relayPackets.go +++ b/relayer/relayPackets.go @@ -21,7 +21,7 @@ type relayMsgTimeout struct { seq uint64 timeout uint64 timeoutStamp uint64 - dstRecvRes *chanTypes.RecvResponse + dstRecvRes *chanTypes.QueryNextSequenceReceiveResponse pass bool } diff --git a/relayer/verifier.go b/relayer/verifier.go index 94b4cff71..16183e092 100644 --- a/relayer/verifier.go +++ b/relayer/verifier.go @@ -15,10 +15,10 @@ import ( retry "github.com/avast/retry-go" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" - lite "github.com/tendermint/tendermint/lite2" - litep "github.com/tendermint/tendermint/lite2/provider" - litehttp "github.com/tendermint/tendermint/lite2/provider/http" - dbs "github.com/tendermint/tendermint/lite2/store/db" + lite "github.com/tendermint/tendermint/light" + litep "github.com/tendermint/tendermint/light/provider" + litehttp "github.com/tendermint/tendermint/light/provider/http" + dbs "github.com/tendermint/tendermint/light/store/db" ctypes "github.com/tendermint/tendermint/rpc/core/types" ) diff --git a/test/test_chains.go b/test/test_chains.go index e2a7521ac..74cea133a 100644 --- a/test/test_chains.go +++ b/test/test_chains.go @@ -24,7 +24,7 @@ var ( cdc: cdc, amino: amino, dockerImage: "jackzampolin/gaiatest", - dockerTag: "2d61264", + dockerTag: "gaiav3.0", timeout: 3 * time.Second, rpcPort: "26657", accountPrefix: "cosmos", From 90ebd2348ad409622b8bcaaa9b878f5fe34a7d42 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Thu, 27 Aug 2020 12:07:17 -0700 Subject: [PATCH 02/54] s/iqlusioninc/ovrclk/g --- AUTHORS.md | 2 +- Makefile | 8 ++++---- README.md | 8 ++++---- cmd/chains.go | 2 +- cmd/config.go | 2 +- cmd/lite.go | 2 +- cmd/paths.go | 2 +- cmd/query.go | 2 +- cmd/raw.go | 2 +- cmd/start.go | 2 +- cmd/strategy.go | 2 +- cmd/testnets.go | 2 +- cmd/tx.go | 2 +- cmd/xfer.go | 2 +- dev-env | 2 +- go.mod | 2 +- go.sum | 2 ++ main.go | 2 +- scripts/config-relayer | 2 +- scripts/config-three | 2 +- scripts/four-chainz | 2 +- test/relayer_agoric_test.go | 2 +- test/relayer_coco_test.go | 2 +- test/relayer_gaia_test.go | 2 +- test/relayer_mtd_test.go | 2 +- test/relayer_rocketzone_test.go | 2 +- test/test_chains.go | 2 +- test/test_queries.go | 2 +- test/test_setup.go | 2 +- testnets/README.md | 8 ++++---- 30 files changed, 40 insertions(+), 38 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 47675be38..5784ad41f 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -8,4 +8,4 @@ contributions under the terms of the [Apache License, Version 2.0] * Jack Zampolin (@jackzampolin) [Apache License, Version 2.0]: https://www.apache.org/licenses/LICENSE-2.0 -[LICENSE]: https://github.com/iqlusioninc/relayer/blob/master/LICENSE \ No newline at end of file +[LICENSE]: https://github.com/ovrclk/relayer/blob/master/LICENSE \ No newline at end of file diff --git a/Makefile b/Makefile index 5a8119ff9..fdf2647e0 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,10 @@ all: ci-lint install # Build / Install ############################################################################### -LD_FLAGS = -X github.com/iqlusioninc/relayer/cmd.Version=$(VERSION) \ - -X github.com/iqlusioninc/relayer/cmd.Commit=$(COMMIT) \ - -X github.com/iqlusioninc/relayer/cmd.SDKCommit=$(SDKCOMMIT) \ - -X github.com/iqlusioninc/relayer/cmd.GaiaCommit=$(GAIACOMMIT) +LD_FLAGS = -X github.com/ovrclk/relayer/cmd.Version=$(VERSION) \ + -X github.com/ovrclk/relayer/cmd.Commit=$(COMMIT) \ + -X github.com/ovrclk/relayer/cmd.SDKCommit=$(SDKCOMMIT) \ + -X github.com/ovrclk/relayer/cmd.GaiaCommit=$(GAIACOMMIT) BUILD_FLAGS := -ldflags '$(LD_FLAGS)' diff --git a/README.md b/README.md index 10dcf42a6..27cb5816b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![GOZ](./docs/images/github-repo-banner.png) -![Relayer Build](https://github.com/iqlusioninc/relayer/workflows/Build%20then%20run%20CI%20Chains/badge.svg) +![Relayer Build](https://github.com/ovrclk/relayer/workflows/Build%20then%20run%20CI%20Chains/badge.svg) The Cosmos IBC `relayer` package contains a basic relayer implementation that is meant for users wishing to relay packets/data between sets of IBC enabled chains. @@ -29,9 +29,9 @@ If you would like to join the relayer testnet, please [check out the instruction | chain | tests | supported ports | |-------|--------|----------------| -| [`gaia`](https://github.com/cosmos/gaia) | ![gaia](https://github.com/iqlusioninc/relayer/workflows/TESTING%20-%20gaia%20to%20gaia%20integration/badge.svg) | `transfer` | -| `microtick` | ![microtick](https://github.com/iqlusioninc/relayer/workflows/TESTING%20-%20mtd%20to%20ibc%20integration/badge.svg) | `transfer` | -| [`rocketzone`](https://github.com/rocket-protocol/rocketzone) | ![rocketzone](https://github.com/iqlusioninc/relayer/workflows/TESTING%20-%20rocketzone%20to%20ibc%20integration/badge.svg) | `transfer` | +| [`gaia`](https://github.com/cosmos/gaia) | ![gaia](https://github.com/ovrclk/relayer/workflows/TESTING%20-%20gaia%20to%20gaia%20integration/badge.svg) | `transfer` | +| `microtick` | ![microtick](https://github.com/ovrclk/relayer/workflows/TESTING%20-%20mtd%20to%20ibc%20integration/badge.svg) | `transfer` | +| [`rocketzone`](https://github.com/rocket-protocol/rocketzone) | ![rocketzone](https://github.com/ovrclk/relayer/workflows/TESTING%20-%20rocketzone%20to%20ibc%20integration/badge.svg) | `transfer` | | [`coco`](https://github.com/CosmicCompass/post-chain) | ![coco](https://github.com/CosmicCompass/relayer/workflows/TESTING%20-%20coco%20to%20ibc%20integration/badge.svg) | `transfer` | ## Demoing the Relayer diff --git a/cmd/chains.go b/cmd/chains.go index 28512cefc..f1c91db2e 100644 --- a/cmd/chains.go +++ b/cmd/chains.go @@ -12,7 +12,7 @@ import ( "github.com/spf13/cobra" "gopkg.in/yaml.v2" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" ) const ( diff --git a/cmd/config.go b/cmd/config.go index 93ad2a3dc..5da14ae3d 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -25,7 +25,7 @@ import ( "time" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" "github.com/spf13/viper" "gopkg.in/yaml.v2" diff --git a/cmd/lite.go b/cmd/lite.go index 65d679328..fba9c89c7 100644 --- a/cmd/lite.go +++ b/cmd/lite.go @@ -25,7 +25,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" "github.com/spf13/viper" lite "github.com/tendermint/tendermint/light" diff --git a/cmd/paths.go b/cmd/paths.go index fc6ff24f6..75a0bb36c 100644 --- a/cmd/paths.go +++ b/cmd/paths.go @@ -12,7 +12,7 @@ import ( chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" ibcTypes "github.com/cosmos/cosmos-sdk/x/ibc/types" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" "gopkg.in/yaml.v2" ) diff --git a/cmd/query.go b/cmd/query.go index 46e19ce71..0c748ce1d 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/x/auth" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" "github.com/spf13/viper" ) diff --git a/cmd/raw.go b/cmd/raw.go index a9bc5b730..c73242639 100644 --- a/cmd/raw.go +++ b/cmd/raw.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" ) diff --git a/cmd/start.go b/cmd/start.go index 19f33e747..478789660 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -21,7 +21,7 @@ import ( "os/signal" "syscall" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" ) diff --git a/cmd/strategy.go b/cmd/strategy.go index c0d92b1ab..7f1f8c742 100644 --- a/cmd/strategy.go +++ b/cmd/strategy.go @@ -4,7 +4,7 @@ import ( "fmt" "strconv" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" ) diff --git a/cmd/testnets.go b/cmd/testnets.go index a34c91798..3bc8cd4d1 100644 --- a/cmd/testnets.go +++ b/cmd/testnets.go @@ -12,7 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/gorilla/mux" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" ) diff --git a/cmd/tx.go b/cmd/tx.go index c1266fccb..db8a2df4f 100644 --- a/cmd/tx.go +++ b/cmd/tx.go @@ -20,7 +20,7 @@ import ( "strings" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" ) diff --git a/cmd/xfer.go b/cmd/xfer.go index 9d7ec37de..ecb034d88 100644 --- a/cmd/xfer.go +++ b/cmd/xfer.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" ) // NOTE: These commands are registered over in cmd/raw.go diff --git a/dev-env b/dev-env index 54d053864..0aab77735 100755 --- a/dev-env +++ b/dev-env @@ -1,6 +1,6 @@ #/bin/bash -e -RELAYER_DIR="$GOPATH/src/github.com/iqlusioninc/relayer" +RELAYER_DIR="$GOPATH/src/github.com/ovrclk/relayer" RELAYER_CONF="$HOME/.relayer" GAIA_CONF="$(pwd)/data" diff --git a/go.mod b/go.mod index 783933998..bd06c5db6 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/iqlusioninc/relayer +module github.com/ovrclk/relayer go 1.14 diff --git a/go.sum b/go.sum index 8c310f39b..4f78fd8bb 100644 --- a/go.sum +++ b/go.sum @@ -388,6 +388,7 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= +github.com/minio/highwayhash v1.0.0 h1:iMSDhgUILCr0TNm8LWlSjF8N0ZIj2qbO8WHp6Q/J2BA= github.com/minio/highwayhash v1.0.0/go.mod h1:xQboMTeM9nY9v/LlAOxFctujiv5+Aq2hR5dxBpaMbdc= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -540,6 +541,7 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.5.0 h1:1N5EYkVAPEywqZRJd7cwnRtCb6xJx7NH3T3WUTF980Q= github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo= +github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= diff --git a/main.go b/main.go index df561598b..906fdc248 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,7 @@ limitations under the License. */ package main -import "github.com/iqlusioninc/relayer/cmd" +import "github.com/ovrclk/relayer/cmd" func main() { cmd.Execute() diff --git a/scripts/config-relayer b/scripts/config-relayer index 68da43d6c..d3e62c801 100755 --- a/scripts/config-relayer +++ b/scripts/config-relayer @@ -7,7 +7,7 @@ if [[ ! -x "$(which jq)" ]]; then exit 1 fi -RELAYER_DIR="$GOPATH/src/github.com/iqlusioninc/relayer" +RELAYER_DIR="$GOPATH/src/github.com/ovrclk/relayer" RELAYER_CONF="$HOME/.relayer" GAIA_CONF="$RELAYER_DIR/data" diff --git a/scripts/config-three b/scripts/config-three index 9616c2c13..31a0087f7 100755 --- a/scripts/config-three +++ b/scripts/config-three @@ -7,7 +7,7 @@ if [[ ! -x "$(which jq)" ]]; then exit 1 fi -RELAYER_DIR="$GOPATH/src/github.com/iqlusioninc/relayer" +RELAYER_DIR="$GOPATH/src/github.com/ovrclk/relayer" RELAYER_CONF="$HOME/.relayer" GAIA_CONF="$RELAYER_DIR/data" diff --git a/scripts/four-chainz b/scripts/four-chainz index 203e228a1..aa7687bda 100755 --- a/scripts/four-chainz +++ b/scripts/four-chainz @@ -14,7 +14,7 @@ if [[ ! -x "$(which docker-compose)" ]]; then exit 1 fi -RELAYER_DIR="$GOPATH/src/github.com/iqlusioninc/relayer" +RELAYER_DIR="$GOPATH/src/github.com/ovrclk/relayer" RELAYER_CONF="$HOME/.relayer" ENV_FILE="$RELAYER_DIR/.env" diff --git a/test/relayer_agoric_test.go b/test/relayer_agoric_test.go index f8202fd6b..3034a09ff 100644 --- a/test/relayer_agoric_test.go +++ b/test/relayer_agoric_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/stretchr/testify/require" ) diff --git a/test/relayer_coco_test.go b/test/relayer_coco_test.go index 71d764d29..5dea67cb4 100644 --- a/test/relayer_coco_test.go +++ b/test/relayer_coco_test.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/stretchr/testify/require" ) diff --git a/test/relayer_gaia_test.go b/test/relayer_gaia_test.go index 8906976b5..cbb7dc101 100644 --- a/test/relayer_gaia_test.go +++ b/test/relayer_gaia_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/stretchr/testify/require" ) diff --git a/test/relayer_mtd_test.go b/test/relayer_mtd_test.go index 0eac379ff..e71066763 100644 --- a/test/relayer_mtd_test.go +++ b/test/relayer_mtd_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/stretchr/testify/require" ) diff --git a/test/relayer_rocketzone_test.go b/test/relayer_rocketzone_test.go index fa5c72e86..b7e84a1e9 100644 --- a/test/relayer_rocketzone_test.go +++ b/test/relayer_rocketzone_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/stretchr/testify/require" ) diff --git a/test/test_chains.go b/test/test_chains.go index 74cea133a..cbe17bf7c 100644 --- a/test/test_chains.go +++ b/test/test_chains.go @@ -11,7 +11,7 @@ import ( gaia "github.com/cosmos/gaia/app" "github.com/stretchr/testify/require" - ry "github.com/iqlusioninc/relayer/relayer" + ry "github.com/ovrclk/relayer/relayer" ) var ( diff --git a/test/test_queries.go b/test/test_queries.go index 61c42e724..e2c7700f6 100644 --- a/test/test_queries.go +++ b/test/test_queries.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - ry "github.com/iqlusioninc/relayer/relayer" + ry "github.com/ovrclk/relayer/relayer" ) // testClientPair tests that the client for src on dst and dst on src are the only clients on those chains diff --git a/test/test_setup.go b/test/test_setup.go index 6048dfbfb..143db8cca 100644 --- a/test/test_setup.go +++ b/test/test_setup.go @@ -13,7 +13,7 @@ import ( dc "github.com/ory/dockertest/v3/docker" "github.com/stretchr/testify/require" - ry "github.com/iqlusioninc/relayer/relayer" + ry "github.com/ovrclk/relayer/relayer" ) // spinUpTestChains is to be passed any number of test chains with given configuration options diff --git a/testnets/README.md b/testnets/README.md index f06793e3f..192ad5bff 100644 --- a/testnets/README.md +++ b/testnets/README.md @@ -61,7 +61,7 @@ echo 'export GOPATH=$HOME/go' >> ~/.profile echo 'export GOBIN=$GOPATH/bin' >> ~/.profile echo 'export PATH=$PATH:/usr/local/go/bin:$GOBIN' >> ~/.profile echo "export GAIA=\$GOPATH/src/github.com/cosmos/gaia" >> ~/.profile -echo "export RELAYER=\$GOPATH/src/github.com/iqlusioninc/relayer" >> ~/.profile +echo "export RELAYER=\$GOPATH/src/github.com/ovrclk/relayer" >> ~/.profile source ~/.profile # Set these variables to different values that are specific to your chain @@ -75,7 +75,7 @@ export ACCOUNT_PREFIX=cosmos # Start by downloading and installing both gaia and the relayer mkdir -p $(dirname $GAIA) && git clone https://github.com/cosmos/gaia $GAIA && cd $GAIA && git checkout $GAIASHA && make install -mkdir -p $(dirname $RELAYER) && git clone https://github.com/iqlusioninc/relayer $RELAYER && cd $RELAYER && make install +mkdir -p $(dirname $RELAYER) && git clone https://github.com/ovrclk/relayer $RELAYER && cd $RELAYER && make install # Now its time to configure both the relayer and gaia, start with the relayer cd @@ -118,8 +118,8 @@ Once you have your server (you could deploy the relayer on a different machine a ```bash # install the relayer -export RELAYER=$GOPATH/src/github.com/iqlusioninc/relayer -mkdir -p $(dirname $RELAYER) && git clone git@github.com:iqlusioninc/relayer $RELAYER && cd $RELAYER +export RELAYER=$GOPATH/src/github.com/ovrclk/relayer +mkdir -p $(dirname $RELAYER) && git clone git@github.com:ovrclk/relayer $RELAYER && cd $RELAYER make install # then to configure your local relayer to talk to your remote chain From 51526bcdd23783cacf12da5b90e28cab4533fa58 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Thu, 27 Aug 2020 12:08:06 -0700 Subject: [PATCH 03/54] s/iqlusioninc/ovrclk/g --- cmd/keys.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/keys.go b/cmd/keys.go index 4d89a1437..95360cbe3 100644 --- a/cmd/keys.go +++ b/cmd/keys.go @@ -22,7 +22,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/spf13/cobra" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" ) // keysCmd represents the keys command From f5262019ec52959bb1ec856f2dacb56a8e75d0ae Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Thu, 27 Aug 2020 15:25:46 -0700 Subject: [PATCH 04/54] WIP: continued debugging, not close to compiling --- cmd/root.go | 2 - go.mod | 3 +- go.sum | 89 +++++++------------------------- relayer/chain.go | 81 ++++++++++++++++++----------- relayer/channel-tx.go | 38 +++++++------- relayer/client-tx.go | 2 +- relayer/connection-tx.go | 8 +-- relayer/contextual.go | 24 ++++----- relayer/faucet.go | 37 ++----------- relayer/naive-strategy.go | 2 +- relayer/packet-tx.go | 10 ++-- relayer/packetMsgs.go | 106 +++++++++++++++++++------------------- relayer/path.go | 82 +---------------------------- relayer/pathEnd.go | 17 +++--- relayer/query.go | 51 +++++++++--------- test/test_chains.go | 4 -- 16 files changed, 207 insertions(+), 349 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 1764b2b88..f0b3d63e2 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -23,7 +23,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" codecstd "github.com/cosmos/cosmos-sdk/std" - gaia "github.com/cosmos/gaia/app" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -88,7 +87,6 @@ func init() { ) // This is a bit of a cheat :shushing_face: - appCodec, cdc = gaia.MakeCodecs() // cdc = codecstd.MakeCodec(simapp.ModuleBasics) // appCodec = codecstd.NewAppCodec(cdc) } diff --git a/go.mod b/go.mod index bd06c5db6..0ba806391 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/cenkalti/backoff/v3 v3.2.2 // indirect github.com/containerd/continuity v0.0.0-20200228182428-0f16d7a0959c // indirect github.com/cosmos/cosmos-sdk v0.34.4-0.20200825201020-d9fd4d2ca9a3 - github.com/cosmos/gaia v0.0.1-0.20200522222820-2d61264338e5 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 @@ -21,7 +20,7 @@ require ( ) replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 + replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 replace github.com/cosmos/cosmos-sdk => /Users/johnzampolin/go/src/github.com/cosmos/cosmos-sdk -replace github.com/cosmos/gaia => /Users/johnzampolin/go/src/github.com/cosmos/gaia \ No newline at end of file diff --git a/go.sum b/go.sum index 4f78fd8bb..a409a7aca 100644 --- a/go.sum +++ b/go.sum @@ -21,19 +21,19 @@ github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f h1:4O1om+UVU+Hfcihr1timk8YNXHxzZWgCo7ofnrZRApw= -github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v3.7.1+incompatible h1:HmA9qHVrHIAqpSvoCYJ+c6qst0lgqEhNW6/KwfkHbS8= github.com/DataDog/datadog-go v3.7.1+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.4.1 h1:3oxKN3wbHibqx897utPC2LTQU4J+IHWWJO+glkAkpFM= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= +github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= @@ -63,7 +63,6 @@ github.com/avast/retry-go v2.6.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevB github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d/go.mod h1:icNx/6QdFblhsEjZehARqbNumymUT/ydwlLojFdv7Sk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -107,8 +106,6 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/confio/ics23-iavl v0.6.0/go.mod h1:mmXAxD1vWoO0VP8YHu6mM1QHGv71NQqa1iSVm4HeKcY= -github.com/confio/ics23/go v0.0.0-20200323120010-7d9a00f0a2fa/go.mod h1:W1I3XC8d9N8OTu/ct5VJ84ylcOunZwMXsWkd27nvVts= github.com/confio/ics23/go v0.0.0-20200610201322-18c7bd6b2dd3/go.mod h1:W1I3XC8d9N8OTu/ct5VJ84ylcOunZwMXsWkd27nvVts= github.com/confio/ics23/go v0.0.0-20200804135932-65ad804e8539 h1:4AuX7KNUVdNa/am9yCQRqWMfdDJ86EtFJk/xwf6ntgc= github.com/confio/ics23/go v0.0.0-20200804135932-65ad804e8539/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= @@ -126,16 +123,6 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200511222341-80be50319ca5 h1:pUNa8VBC8SBptZTiGSFlZx89JynTZ4+yfUCR6VGMMkw= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200511222341-80be50319ca5/go.mod h1:T3u1b0ahtqJpdI2Fk6JcmntR7/YLjMq+J6hZrHPZTzc= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200522204605-4a07d536a7cc h1:FokA8APz+KqRsnHoAyjorOSldkM6i1Q3r+eZAxcqd/k= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200522204605-4a07d536a7cc/go.mod h1:T3u1b0ahtqJpdI2Fk6JcmntR7/YLjMq+J6hZrHPZTzc= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200825201020-d9fd4d2ca9a3 h1:lrmnZC6EqnTHrXmnv85k6VNrbSafEG+q82S2+rKeGBg= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200825201020-d9fd4d2ca9a3/go.mod h1:HXb9uKlB4sR4BFP32aSboY1Se4QhbFbYcJN6Dexil2U= -github.com/cosmos/gaia v0.0.1-0.20200511233019-cbc33219c3d9 h1:/JO2pguVvnhiDzkfAREVOKn2IQHQmzMuNUJoYfp/rds= -github.com/cosmos/gaia v0.0.1-0.20200511233019-cbc33219c3d9/go.mod h1:GegY2vcug/cfD1e/zokaZQYAXkp6vBRC9BwOM5Je5sA= -github.com/cosmos/gaia v0.0.1-0.20200522222820-2d61264338e5 h1:lU62dQpOUsUdCDBvyEDbJa6AoTKaBAeQv2rNDEj3X4E= -github.com/cosmos/gaia v0.0.1-0.20200522222820-2d61264338e5/go.mod h1:t9kAXxZ0N4hj0Pcg6T+Ogw2a6ncz3M+9R+FL24ripSg= 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/iavl v0.15.0-rc2 h1:4HI/LYLjWUnou8dehPD+NqEsDc8uamJOU2yHcqdTKv8= @@ -154,9 +141,12 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgraph-io/badger/v2 v2.0.3 h1:inzdf6VF/NZ+tJ8RwwYMjJMvsOALTHYdozn0qSl6XJI= github.com/dgraph-io/badger/v2 v2.0.3/go.mod h1:3KY8+bsP8wI0OEnQJAKpd4wIJW/Mm32yw2j/9FUVnIM= +github.com/dgraph-io/ristretto v0.0.2-0.20200115201040-8f368f2f2ab3 h1:MQLRM35Pp0yAyBYksjbj1nZI/w6eyRY/mWoM1sFf4kU= github.com/dgraph-io/ristretto v0.0.2-0.20200115201040-8f368f2f2ab3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= @@ -164,6 +154,7 @@ github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5Xh github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dvsekhvalnov/jose2go v0.0.0-20180829124132-7f401d37b68a h1:mq+R6XEM6lJX5VlLyZIrUSP8tSuJp82xTK89hvBwJbU= github.com/dvsekhvalnov/jose2go v0.0.0-20180829124132-7f401d37b68a/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= @@ -178,7 +169,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= @@ -195,8 +185,6 @@ github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2 github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gibson042/canonicaljson-go v1.0.3 h1:EAyF8L74AWabkyUmrvEFHEt/AGFQeD6RfwbAuf0j1bI= -github.com/gibson042/canonicaljson-go v1.0.3/go.mod h1:DsLpJTThXyGNO+KZlI85C1/KDcImpP67k/RKVjcaEqo= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -214,11 +202,6 @@ github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6 github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -226,15 +209,13 @@ github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4er github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= @@ -257,6 +238,7 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= @@ -271,18 +253,14 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/handlers v1.5.0 h1:4wjo3sf9azi99c8hTmyaxp9y5S+pFszsy3pP0rAw/lw= github.com/gorilla/handlers v1.5.0/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= -github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= @@ -316,6 +294,7 @@ github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= @@ -352,7 +331,6 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= @@ -360,6 +338,7 @@ github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -415,6 +394,7 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= @@ -422,11 +402,9 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo= github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= @@ -446,8 +424,7 @@ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest/v3 v3.5.5 h1:bhWoPN3xmEHIdZHflA3vOf7KaHFbCOLoRnkCLhZ3eQs= github.com/ory/dockertest/v3 v3.5.5/go.mod h1:4ZOpj8qBUmh8fcBSVzkH2bws2s91JdGvHUqan4GHEuQ= -github.com/otiai10/copy v1.1.1 h1:PH7IFlRQ6Fv9vYmuXbDRLdgTHoP1w483kPNUP2bskpo= -github.com/otiai10/copy v1.1.1/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= +github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI= @@ -457,14 +434,14 @@ github.com/otiai10/mint v1.3.1 h1:BCmzIS3n71sGfHB5NMNDB3lHYPz8fWSkCAErHed//qc= github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI= -github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pelletier/go-toml v1.8.0 h1:Keo9qb7iRJs2voHvunFtuuYFsbWeOBh8/P9v/kVMFtw= github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= @@ -483,9 +460,6 @@ github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDf github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -github.com/prometheus/client_golang v1.5.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -github.com/prometheus/client_golang v1.5.1 h1:bdHYieyGlH+6OLEk2YQha8THib30KP0/yD0YH9m6xcA= -github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -532,6 +506,7 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y= github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -539,8 +514,6 @@ github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvH github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.5.0 h1:1N5EYkVAPEywqZRJd7cwnRtCb6xJx7NH3T3WUTF980Q= -github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo= github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= @@ -551,6 +524,7 @@ github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa/go.mod h1:oJyF+mSPH github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= @@ -562,7 +536,6 @@ github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= @@ -575,11 +548,6 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= -github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= -github.com/spf13/viper v1.6.3 h1:pDDu1OyEDTKzpJwdq4TiuLyMsUgRa/BT5cn5O62NoHs= -github.com/spf13/viper v1.6.3/go.mod h1:jUMtyi0/lB5yZH/FjyGAoH7IMNrIhlBf6pXZmbMDvzw= -github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM= -github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -592,8 +560,6 @@ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= @@ -606,22 +572,11 @@ github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= -github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso= github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ= github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/iavl v0.13.2/go.mod h1:vE1u0XAGXYjHykd4BLp8p/yivrw2PF1TuoljBcsQoGA= -github.com/tendermint/iavl v0.13.3 h1:expgBDY1MX+6/3sqrIxGChbTNf9N9aTJ67SH4bPchCs= -github.com/tendermint/iavl v0.13.3/go.mod h1:2lE7GiWdSvc7kvT78ncIKmkOjCnp6JEnSb2O7B9htLw= -github.com/tendermint/tendermint v0.33.2/go.mod h1:25DqB7YvV1tN3tHsjWoc2vFtlwICfrub9XO6UBO+4xk= -github.com/tendermint/tendermint v0.33.4 h1:NM3G9618yC5PaaxGrcAySc5ylc1PAANeIx42u2Re/jo= -github.com/tendermint/tendermint v0.33.4/go.mod h1:6NW9DVkvsvqmCY6wbRsOo66qGDhMXglRL70aXajvBEA= github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= -github.com/tendermint/tm-db v0.4.1/go.mod h1:JsJ6qzYkCGiGwm5GHl/H5GLI9XLb6qZX7PRe425dHAY= -github.com/tendermint/tm-db v0.5.0/go.mod h1:lSq7q5WRR/njf1LnhiZ/lIJHk2S8Y1Zyq5oP/3o9C2U= -github.com/tendermint/tm-db v0.5.1 h1:H9HDq8UEA7Eeg13kdYckkgwwkQLBnJGgX4PgLJRhieY= -github.com/tendermint/tm-db v0.5.1/go.mod h1:g92zWjHpCYlEvQXvy9M168Su8V1IBEeawpXVVBaK4f4= github.com/tendermint/tm-db v0.6.1 h1:w3X87itMPXopcRPlFiqspEKhw4FXihPk2rnFFkP0zGk= github.com/tendermint/tm-db v0.6.1/go.mod h1:m3x9kRP4UFd7JODJL0yBAZqE7wTw+S37uAE90cTx7OA= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -638,6 +593,7 @@ github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWp go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -707,7 +663,6 @@ golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191003171128-d98b1b443823/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -758,7 +713,6 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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= @@ -767,7 +721,6 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -837,10 +790,7 @@ google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.28.1 h1:C1QC6KzgSiLyBabDi87BbjaGreoRgGUF5nOyvfrAZ1k= -google.golang.org/grpc v1.28.1/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.31.0 h1:T7P4R73V3SSDPhH7WW7ATbfViLtmamH0DKrP3f9AuDI= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -862,6 +812,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= @@ -882,8 +833,6 @@ gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= @@ -897,7 +846,5 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/relayer/chain.go b/relayer/chain.go index 5680f3326..6d873f139 100644 --- a/relayer/chain.go +++ b/relayer/chain.go @@ -13,13 +13,12 @@ import ( sdkCtx "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - ckeys "github.com/cosmos/cosmos-sdk/client/keys" + tx "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/crypto/hd" keys "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" - authclient "github.com/cosmos/cosmos-sdk/x/auth/client" + "github.com/cosmos/cosmos-sdk/types/tx/signing" authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/go-bip39" "github.com/tendermint/tendermint/libs/log" @@ -154,7 +153,6 @@ func (c *Chain) Init(homePath string, timeout time.Duration, debug bool) error { c.Client = client c.Cdc = newContextualStdCodec(encodingConfig.Marshaler, c.UseSDKContext) c.Amino = newContextualAminoCodec(encodingConfig.Amino, c.UseSDKContext) - RegisterCodec(encodingConfig.Amino) c.HomePath = homePath c.logger = defaultChainLogger() c.timeout = timeout @@ -205,43 +203,54 @@ func newRPCClient(addr string, timeout time.Duration) (*rpchttp.HTTP, error) { } // SendMsg wraps the msg in a stdtx, signs and sends it -func (c *Chain) SendMsg(datagram sdk.Msg) (sdk.TxResponse, error) { +func (c *Chain) SendMsg(datagram sdk.Msg) (*sdk.TxResponse, error) { return c.SendMsgs([]sdk.Msg{datagram}) } // SendMsgs wraps the msgs in a stdtx, signs and sends it -func (c *Chain) SendMsgs(datagrams []sdk.Msg) (res sdk.TxResponse, err error) { - var out []byte - if out, err = c.BuildAndSignTx(datagrams); err != nil { - return res, err - } - return c.BroadcastTxCommit(out) -} - -// BuildAndSignTx takes messages and builds, signs and marshals a sdk.Tx to prepare it for broadcast -func (c *Chain) BuildAndSignTx(msgs []sdk.Msg) ([]byte, error) { +func (c *Chain) SendMsgs(msgs []sdk.Msg) (res *sdk.TxResponse, err error) { done := c.UseSDKContext() defer done() - // Fetch account and sequence numbers for the account + // Instantiate the client context ctx := c.CLIContext() - accNum, accSeq, err := ctx.AccountRetriever.GetAccountNumberSequence(c.MustGetAddress()) + + // Query account details + txf, err := tx.PrepareFactory(ctx, c.TxFactory()) if err != nil { return nil, err } - // TODO: Migrating transaction path is going to take a bit more looking - txBldr := auth.NewTxBuilder( - auth.DefaultTxEncoder(c.Amino.Codec), acc.GetAccountNumber(), - acc.GetSequence(), c.Gas, c.GasAdjustment, true, c.ChainID, - c.Memo, sdk.NewCoins(), c.getGasPrices()).WithKeybase(c.Keybase) - if c.GasAdjustment > 0 { - txBldr, err = authclient.EnrichWithGas(txBldr, ctx, msgs) - if err != nil { - return nil, err - } + // If users pass gas adjustment, then caclulate gas + // TODO: make all txs estimate/ + _, adjusted, err := tx.CalculateGas(ctx.QueryWithData, txf, msgs...) + if err != nil { + return nil, err } - return txBldr.BuildAndSign(c.Key, ckeys.DefaultKeyPass, msgs) + + // Set the gas amount on the transaction factory + txf = txf.WithGas(adjusted) + + // Build the transaction builder + txb, err := tx.BuildUnsignedTx(txf, msgs...) + if err != nil { + return nil, err + } + + // Attach the signature to the transaction + err = tx.Sign(txf, c.Key, txb) + if err != nil { + return nil, err + } + + // Generate the transaction bytes + txBytes, err := ctx.TxConfig.TxEncoder()(txb.GetTx()) + if err != nil { + return nil, err + } + + // Broadcast those bytes + return ctx.BroadcastTx(txBytes) } // CLIContext returns an instance of client.Context derived from Chain @@ -262,9 +271,19 @@ func (c *Chain) CLIContext() sdkCtx.Context { WithNodeURI(c.RPCAddr) } -// BroadcastTxCommit takes the marshaled transaction bytes and broadcasts them -func (c *Chain) BroadcastTxCommit(txBytes []byte) (sdk.TxResponse, error) { - return c.CLIContext().BroadcastTxCommit(txBytes) +// TxFactory returns an instance of tx.Factory derived from +func (c *Chain) TxFactory() tx.Factory { + ctx := c.CLIContext() + return tx.Factory{}. + WithAccountRetriever(ctx.AccountRetriever). + WithChainID(c.ChainID). + WithTxConfig(ctx.TxConfig). + WithGasAdjustment(c.GasAdjustment). + WithGasPrices(c.GasPrices). + WithGas(c.Gas). + WithMemo(c.Memo). + WithKeybase(c.Keybase). + WithSignMode(signing.SignMode_SIGN_MODE_DIRECT) } // Log takes a string and logs the data diff --git a/relayer/channel-tx.go b/relayer/channel-tx.go index 7af2de7e1..2608f46d9 100644 --- a/relayer/channel-tx.go +++ b/relayer/channel-tx.go @@ -11,11 +11,11 @@ import ( // CreateChannel runs the channel creation messages on timeout until they pass // TODO: add max retries or something to this function func (c *Chain) CreateChannel(dst *Chain, ordered bool, to time.Duration) error { - var order ibctypes.Order + var order chantypes.Order if ordered { - order = ibctypes.ORDERED + order = chantypes.ORDERED } else { - order = ibctypes.UNORDERED + order = chantypes.UNORDERED } ticker := time.NewTicker(to) @@ -87,14 +87,14 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM return nil, err } - chans, err := QueryChannelPair(c, dst, hs[scid].Height-1, hs[dcid].Height-1) + chans, err := QueryChannelPair(c, dst, hs[scid].Header.Height-1, hs[dcid].Header.Height-1) if err != nil { return nil, err } switch { // Handshake hasn't been started on src or dst, relay `chanOpenInit` to src - case chans[scid].Channel.State == ibctypes.UNINITIALIZED && chans[dcid].Channel.State == ibctypes.UNINITIALIZED: + case chans[scid].Channel.State == chantypes.UNINITIALIZED && chans[dcid].Channel.State == chantypes.UNINITIALIZED: if c.debug { logChannelStates(c, dst, chans) } @@ -103,7 +103,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM ) // Handshake has started on dst (1 step done), relay `chanOpenTry` and `updateClient` to src - case chans[scid].Channel.State == ibctypes.UNINITIALIZED && chans[dcid].Channel.State == ibctypes.INIT: + case chans[scid].Channel.State == chantypes.UNINITIALIZED && chans[dcid].Channel.State == chantypes.INIT: if c.debug { logChannelStates(c, dst, chans) } @@ -113,7 +113,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM ) // Handshake has started on src (1 step done), relay `chanOpenTry` and `updateClient` to dst - case chans[scid].Channel.State == ibctypes.INIT && chans[dcid].Channel.State == ibctypes.UNINITIALIZED: + case chans[scid].Channel.State == chantypes.INIT && chans[dcid].Channel.State == chantypes.UNINITIALIZED: if dst.debug { logChannelStates(dst, c, chans) } @@ -123,7 +123,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM ) // Handshake has started on src (2 steps done), relay `chanOpenAck` and `updateClient` to dst - case chans[scid].Channel.State == ibctypes.TRYOPEN && chans[dcid].Channel.State == ibctypes.INIT: + case chans[scid].Channel.State == chantypes.TRYOPEN && chans[dcid].Channel.State == chantypes.INIT: if dst.debug { logChannelStates(dst, c, chans) } @@ -133,7 +133,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM ) // Handshake has started on dst (2 steps done), relay `chanOpenAck` and `updateClient` to src - case chans[scid].Channel.State == ibctypes.INIT && chans[dcid].Channel.State == ibctypes.TRYOPEN: + case chans[scid].Channel.State == chantypes.INIT && chans[dcid].Channel.State == chantypes.TRYOPEN: if c.debug { logChannelStates(c, dst, chans) } @@ -143,7 +143,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM ) // Handshake has confirmed on dst (3 steps done), relay `chanOpenConfirm` and `updateClient` to src - case chans[scid].Channel.State == ibctypes.TRYOPEN && chans[dcid].Channel.State == ibctypes.OPEN: + case chans[scid].Channel.State == chantypes.TRYOPEN && chans[dcid].Channel.State == chantypes.OPEN: if c.debug { logChannelStates(c, dst, chans) } @@ -154,7 +154,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM out.last = true // Handshake has confirmed on src (3 steps done), relay `chanOpenConfirm` and `updateClient` to dst - case chans[scid].Channel.State == ibctypes.OPEN && chans[dcid].Channel.State == ibctypes.TRYOPEN: + case chans[scid].Channel.State == chantypes.OPEN && chans[dcid].Channel.State == chantypes.TRYOPEN: if dst.debug { logChannelStates(dst, c, chans) } @@ -222,7 +222,7 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { return nil, err } - chans, err := QueryChannelPair(c, dst, hs[scid].Height-1, hs[dcid].Height-1) + chans, err := QueryChannelPair(c, dst, hs[scid].Header.Height-1, hs[dcid].Header.Height-1) if err != nil { return nil, err } @@ -231,8 +231,8 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { switch { // Closing handshake has not started, relay `updateClient` and `chanCloseInit` to src or dst according // to the channel state - case chans[scid].Channel.State != ibctypes.CLOSED && chans[dcid].Channel.State != ibctypes.CLOSED: - if chans[scid].Channel.State != ibctypes.UNINITIALIZED { + case chans[scid].Channel.State != chantypes.CLOSED && chans[dcid].Channel.State != chantypes.CLOSED: + if chans[scid].Channel.State != chantypes.UNINITIALIZED { if c.debug { logChannelStates(c, dst, chans) } @@ -240,7 +240,7 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { c.PathEnd.UpdateClient(hs[dcid], c.MustGetAddress()), c.PathEnd.ChanCloseInit(c.MustGetAddress()), ) - } else if chans[dcid].Channel.State != ibctypes.UNINITIALIZED { + } else if chans[dcid].Channel.State != chantypes.UNINITIALIZED { if dst.debug { logChannelStates(dst, c, chans) } @@ -251,8 +251,8 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { } // Closing handshake has started on src, relay `updateClient` and `chanCloseConfirm` to dst - case chans[scid].Channel.State == ibctypes.CLOSED && chans[dcid].Channel.State != ibctypes.CLOSED: - if chans[dcid].Channel.State != ibctypes.UNINITIALIZED { + case chans[scid].Channel.State == chantypes.CLOSED && chans[dcid].Channel.State != chantypes.CLOSED: + if chans[dcid].Channel.State != chantypes.UNINITIALIZED { if dst.debug { logChannelStates(dst, c, chans) } @@ -264,8 +264,8 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { } // Closing handshake has started on dst, relay `updateClient` and `chanCloseConfirm` to src - case chans[dcid].Channel.State == ibctypes.CLOSED && chans[scid].Channel.State != ibctypes.CLOSED: - if chans[scid].Channel.State != ibctypes.UNINITIALIZED { + case chans[dcid].Channel.State == chantypes.CLOSED && chans[scid].Channel.State != chantypes.CLOSED: + if chans[scid].Channel.State != chantypes.UNINITIALIZED { if c.debug { logChannelStates(c, dst, chans) } diff --git a/relayer/client-tx.go b/relayer/client-tx.go index 70da5e3dd..13d86843a 100644 --- a/relayer/client-tx.go +++ b/relayer/client-tx.go @@ -12,7 +12,7 @@ func (c *Chain) CreateClients(dst *Chain) (err error) { clients := &RelayMsgs{Src: []sdk.Msg{}, Dst: []sdk.Msg{}} // Create client for the destination chain on the source chain if it doesn't exist - var srcCs, dstCs *clientTypes.StateResponse + var srcCs, dstCs *clientTypes.QueryClientStateResponse if srcCs, err = c.QueryClientState(); err != nil { return err } else if srcCs == nil { diff --git a/relayer/connection-tx.go b/relayer/connection-tx.go index 2945f1cfd..ae81e0afe 100644 --- a/relayer/connection-tx.go +++ b/relayer/connection-tx.go @@ -5,7 +5,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" + ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" ) // CreateConnection runs the connection creation messages on timeout until they pass @@ -83,7 +83,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { // Query Connection data from src and dst // NOTE: We query connection at height - 1 because of the way tendermint returns // proofs the commit for height n is contained in the header of height n + 1 - conn, err := QueryConnectionPair(c, dst, hs[scid].Height-1, hs[dcid].Height-1) + conn, err := QueryConnectionPair(c, dst, hs[scid].Header.Height-1, hs[dcid].Header.Height-1) if err != nil { return nil, err } @@ -101,11 +101,11 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { } // Store the heights - srcConsH, dstConsH := int64(cs[scid].ClientState.GetLatestHeight()), int64(cs[dcid].ClientState.GetLatestHeight()) + srcConsH, dstConsH := int64(cs[scid].GetLatestHeight()), int64(cs[dcid].GetLatestHeight()) // NOTE: We query connection at height - 1 because of the way tendermint returns // proofs the commit for height n is contained in the header of height n + 1 - cons, err := QueryClientConsensusStatePair(c, dst, hs[scid].Height-1, hs[dcid].Height-1, srcConsH, dstConsH) + cons, err := QueryClientConsensusStatePair(c, dst, hs[scid].Header.Height-1, hs[dcid].Header.Height-1, srcConsH, dstConsH) if err != nil { return nil, err } diff --git a/relayer/contextual.go b/relayer/contextual.go index 06f3f6a58..e32f38baa 100644 --- a/relayer/contextual.go +++ b/relayer/contextual.go @@ -17,8 +17,8 @@ type contextualAminoCodec struct { // newContextualCodec creates a codec that sets and resets context func newContextualStdCodec(cdc codec.JSONMarshaler, useContext func() func()) *contextualStdCodec { return &contextualStdCodec{ - Codec: cdc, - useContext: useContext, + JSONMarshaler: cdc, + useContext: useContext, } } @@ -27,7 +27,7 @@ func (cdc *contextualStdCodec) MarshalJSON(ptr interface{}) ([]byte, error) { done := cdc.useContext() defer done() - return cdc.Codec.MarshalJSON(ptr) + return cdc.MarshalJSON(ptr) } // UnmarshalJSON unmarshals with the original codec and new context @@ -35,28 +35,28 @@ func (cdc *contextualStdCodec) UnmarshalJSON(bz []byte, ptr interface{}) error { done := cdc.useContext() defer done() - return cdc.Codec.UnmarshalJSON(bz, ptr) + return cdc.UnmarshalJSON(bz, ptr) } func (cdc *contextualStdCodec) MarshalBinaryBare(ptr codec.ProtoMarshaler) ([]byte, error) { done := cdc.useContext() defer done() - return cdc.Codec.MarshalBinaryBare(ptr) + return cdc.MarshalBinaryBare(ptr) } func (cdc *contextualStdCodec) UnmarshalBinaryBare(bz []byte, ptr codec.ProtoMarshaler) error { done := cdc.useContext() defer done() - return cdc.Codec.UnmarshalBinaryBare(bz, ptr) + return cdc.UnmarshalBinaryBare(bz, ptr) } // newContextualCodec creates a codec that sets and resets context func newContextualAminoCodec(cdc *codec.LegacyAmino, useContext func() func()) *contextualAminoCodec { return &contextualAminoCodec{ - Codec: cdc, - useContext: useContext, + LegacyAmino: cdc, + useContext: useContext, } } @@ -65,7 +65,7 @@ func (cdc *contextualAminoCodec) MarshalJSON(ptr interface{}) ([]byte, error) { done := cdc.useContext() defer done() - return cdc.Codec.MarshalJSON(ptr) + return cdc.MarshalJSON(ptr) } // UnmarshalJSON unmarshals with the original codec and new context @@ -73,19 +73,19 @@ func (cdc *contextualAminoCodec) UnmarshalJSON(bz []byte, ptr interface{}) error done := cdc.useContext() defer done() - return cdc.Codec.UnmarshalJSON(bz, ptr) + return cdc.UnmarshalJSON(bz, ptr) } func (cdc *contextualAminoCodec) MarshalBinaryBare(ptr interface{}) ([]byte, error) { done := cdc.useContext() defer done() - return cdc.Codec.MarshalBinaryBare(ptr) + return cdc.MarshalBinaryBare(ptr) } func (cdc *contextualAminoCodec) UnmarshalBinaryBare(bz []byte, ptr interface{}) error { done := cdc.useContext() defer done() - return cdc.Codec.UnmarshalBinaryBare(bz, ptr) + return cdc.UnmarshalBinaryBare(bz, ptr) } diff --git a/relayer/faucet.go b/relayer/faucet.go index f0aa2cd35..a7122b3ee 100644 --- a/relayer/faucet.go +++ b/relayer/faucet.go @@ -7,44 +7,15 @@ import ( "net/http" "time" - ckeys "github.com/cosmos/cosmos-sdk/client/keys" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" - "github.com/cosmos/cosmos-sdk/x/bank" + bank "github.com/cosmos/cosmos-sdk/x/bank/types" ) // SendMsgWithKey allows the user to specify which relayer key will sign the message -func (c *Chain) SendMsgWithKey(datagram sdk.Msg, keyName string) (res sdk.TxResponse, err error) { - var out []byte - if out, err = c.BuildAndSignTxWithKey([]sdk.Msg{datagram}, keyName); err != nil { - return res, err - } - return c.BroadcastTxCommit(out) - -} - -// BuildAndSignTxWithKey allows the user to specify which relayer key will sign the message -func (c *Chain) BuildAndSignTxWithKey(datagram []sdk.Msg, keyName string) ([]byte, error) { - - // Fetch account and sequence numbers for the account - info, err := c.Keybase.Key(keyName) - if err != nil { - return nil, err - } - - done := c.UseSDKContext() - defer done() - - acc, err := auth.NewAccountRetriever(c.Cdc, c).GetAccount(info.GetAddress()) - if err != nil { - return nil, err - } +func (c *Chain) SendMsgWithKey(msg sdk.Msg, keyName string) (res *sdk.TxResponse, err error) { + c.Key = keyName + return c.SendMsg(msg) - return auth.NewTxBuilder( - auth.DefaultTxEncoder(c.Amino.Codec), acc.GetAccountNumber(), - acc.GetSequence(), c.Gas, c.GasAdjustment, false, c.ChainID, - c.Memo, sdk.NewCoins(), c.getGasPrices()).WithKeybase(c.Keybase). - BuildAndSign(info.GetName(), ckeys.DefaultKeyPass, datagram) } // FaucetHandler listens for addresses diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index c933e4d84..64cb427b6 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -322,7 +322,7 @@ func packetMsgFromTxQuery(src, dst *Chain, sh *SyncHeaders, seq uint64) (*Chain, // relayPacketFromQueryResponse looks through the events in a sdk.Response // and returns relayPackets with the appropriate data -func relayPacketFromQueryResponse(src, dst *PathEnd, res sdk.TxResponse, +func relayPacketFromQueryResponse(src, dst *PathEnd, res *sdk.TxResponse, sh *SyncHeaders) (rcvPackets []relayPacket, timeoutPackets []relayPacket, err error) { for _, l := range res.Logs { for _, e := range l.Events { diff --git a/relayer/packet-tx.go b/relayer/packet-tx.go index 0bd43fd8c..9fad24495 100644 --- a/relayer/packet-tx.go +++ b/relayer/packet-tx.go @@ -64,7 +64,7 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, var ( hs map[string]*tmclient.Header - seqRecv chanTypes.RecvResponse + seqRecv chanTypes.QueryNextSequenceReceiveResponse seqSend uint64 srcCommitRes CommitmentResponse ) @@ -75,17 +75,17 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, return err } - seqRecv, err = dst.QueryNextSeqRecv(hs[dst.ChainID].Height) + seqRecv, err = dst.QueryNextSeqRecv(hs[dst.ChainID].Header.Height) if err != nil { return err } - seqSend, err = c.QueryNextSeqSend(hs[c.ChainID].Height) + seqSend, err = c.QueryNextSeqSend(hs[c.ChainID].Header.Height) if err != nil { return err } - srcCommitRes, err = c.QueryPacketCommitment(hs[c.ChainID].Height-1, int64(seqSend-1)) + srcCommitRes, err = c.QueryPacketCommitment(hs[c.ChainID].Header.Height-1, int64(seqSend-1)) if err != nil { return err } @@ -123,7 +123,7 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, dst.PathEnd.UpdateClient(hs[c.ChainID], dst.MustGetAddress()), dst.PathEnd.MsgRecvPacket( c.PathEnd, - seqRecv.NextSequenceRecv, + seqRecv.NextSequenceReceive, timeoutHeight, defaultPacketTimeoutStamp(), xferPacket, diff --git a/relayer/packetMsgs.go b/relayer/packetMsgs.go index 34caa4844..84b68cb75 100644 --- a/relayer/packetMsgs.go +++ b/relayer/packetMsgs.go @@ -1,68 +1,68 @@ package relayer -import ( - "github.com/cosmos/cosmos-sdk/codec" +// import ( +// "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +// sdk "github.com/cosmos/cosmos-sdk/types" +// sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" -) +// chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" +// ) -var ModuleCdc *codec.LegacyAmino +// var ModuleCdc *codec.LegacyAmino -func RegisterCodec(cdc *codec.LegacyAmino) { - if ModuleCdc != nil { - return - } - cdc.RegisterConcrete(MsgSendPacket{}, "swingset/SendPacket", nil) - ModuleCdc = cdc -} +// func RegisterCodec(cdc *codec.LegacyAmino) { +// if ModuleCdc != nil { +// return +// } +// cdc.RegisterConcrete(MsgSendPacket{}, "swingset/SendPacket", nil) +// ModuleCdc = cdc +// } -// MsgSendPacket sends an outgoing IBC packet -type MsgSendPacket struct { - Packet chanTypes.Packet `json:"packet" yaml:"packet"` - Sender sdk.AccAddress `json:"sender" yaml:"sender"` // the sender address -} +// // MsgSendPacket sends an outgoing IBC packet +// type MsgSendPacket struct { +// Packet chanTypes.Packet `json:"packet" yaml:"packet"` +// Sender sdk.AccAddress `json:"sender" yaml:"sender"` // the sender address +// } -// TODO: Implement ProtoMessage method -var _ sdk.Msg = MsgSendPacket{} +// // TODO: Implement ProtoMessage method +// var _ sdk.Msg = MsgSendPacket{} -// NewMsgSendPacket returns a new send request -func NewMsgSendPacket(packet chanTypes.Packet, sender sdk.AccAddress) MsgSendPacket { - return MsgSendPacket{ - Packet: packet, - Sender: sender, - } -} +// // NewMsgSendPacket returns a new send request +// func NewMsgSendPacket(packet chanTypes.Packet, sender sdk.AccAddress) MsgSendPacket { +// return MsgSendPacket{ +// Packet: packet, +// Sender: sender, +// } +// } -// Route implements sdk.Msg -func (msg MsgSendPacket) Route() string { - // FIXME: Do we need this if we are only sending? - return "swingset" -} +// // Route implements sdk.Msg +// func (msg MsgSendPacket) Route() string { +// // FIXME: Do we need this if we are only sending? +// return "swingset" +// } -// ValidateBasic implements sdk.Msg -func (msg MsgSendPacket) ValidateBasic() error { - if msg.Sender.Empty() { - return sdkerrors.ErrInvalidAddress - } +// // ValidateBasic implements sdk.Msg +// func (msg MsgSendPacket) ValidateBasic() error { +// if msg.Sender.Empty() { +// return sdkerrors.ErrInvalidAddress +// } - return msg.Packet.ValidateBasic() -} +// return msg.Packet.ValidateBasic() +// } -// GetSignBytes implements sdk.Msg -func (msg MsgSendPacket) GetSignBytes() []byte { - // FIXME: What do we need here? - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) -} +// // GetSignBytes implements sdk.Msg +// func (msg MsgSendPacket) GetSignBytes() []byte { +// // FIXME: What do we need here? +// return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) +// } -// GetSigners implements sdk.Msg -func (msg MsgSendPacket) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{msg.Sender} -} +// // GetSigners implements sdk.Msg +// func (msg MsgSendPacket) GetSigners() []sdk.AccAddress { +// return []sdk.AccAddress{msg.Sender} +// } -// Type implements sdk.Msg -func (msg MsgSendPacket) Type() string { - return "sendpacket" -} +// // Type implements sdk.Msg +// func (msg MsgSendPacket) Type() string { +// return "sendpacket" +// } diff --git a/relayer/path.go b/relayer/path.go index 4a16f13bc..600b01582 100644 --- a/relayer/path.go +++ b/relayer/path.go @@ -5,8 +5,7 @@ import ( "gopkg.in/yaml.v2" - tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" - ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" + chantypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ) var ( // Default identifiers for dummy usage @@ -103,7 +102,7 @@ type Path struct { // Ordered returns true if the path is ordered and false if otherwise func (p *Path) Ordered() bool { - return p.Src.getOrder() == ibctypes.ORDERED + return p.Src.getOrder() == chantypes.ORDERED } // Validate checks that a path is valid @@ -169,80 +168,3 @@ func GenPath(srcChainID, dstChainID, srcPortID, dstPortID, order string, version }, } } - -// FindPaths returns all the open paths that exist between chains -func FindPaths(chains Chains) (*Paths, error) { - var out = &Paths{} - hs, err := QueryLatestHeights(chains...) - if err != nil { - return nil, err - } - for _, src := range chains { - clients, err := src.QueryClients(1, 1000) - if err != nil { - return nil, err - } - for _, client := range clients { - clnt, ok := client.(tmclient.ClientState) - if !ok || clnt.LastHeader.Commit == nil || clnt.LastHeader.Header == nil { - continue - } - dst, err := chains.Get(client.GetChainID()) - if err != nil { - continue - } - - if err = src.AddPath(client.GetID(), dcon, dcha, dpor, "ORDERED"); err != nil { - return nil, err - } - - conns, err := src.QueryConnectionsUsingClient(hs[src.ChainID]) - if err != nil { - return nil, err - } - - for _, connid := range conns.ConnectionPaths { - if err = src.AddPath(client.GetID(), connid, dcha, dpor, "ORDERED"); err != nil { - return nil, err - } - conn, err := src.QueryConnection(hs[src.ChainID]) - if err != nil { - return nil, err - } - if conn.Connection.GetState().String() == "OPEN" { - chans, err := src.QueryConnectionChannels(connid, 1, 1000) - if err != nil { - return nil, err - } - for _, chn := range chans { - if chn.State.String() == "OPEN" { - p := &Path{ - Src: &PathEnd{ - ChainID: src.ChainID, - ClientID: client.GetID(), - ConnectionID: conn.Connection.ID, - ChannelID: chn.ID, - PortID: chn.PortID, - }, - Dst: &PathEnd{ - ChainID: dst.ChainID, - ClientID: conn.Connection.Counterparty.GetClientID(), - ConnectionID: conn.Connection.Counterparty.GetConnectionID(), - ChannelID: chn.Counterparty.GetChannelID(), - PortID: chn.Counterparty.GetPortID(), - }, - Strategy: &StrategyCfg{ - Type: "naive", - }, - } - if err = out.Add(fmt.Sprintf("%s-%s", src.ChainID, dst.ChainID), p); err != nil { - return nil, err - } - } - } - } - } - } - } - return out, nil -} diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index be60eedc8..43b0dc668 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -11,7 +11,6 @@ import ( chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" - ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) // TODO: add Order chanTypes.Order as a property and wire it up in validation @@ -33,11 +32,11 @@ type PathEnd struct { func OrderFromString(order string) chanTypes.Order { switch order { case "UNORDERED": - return ibctypes.UNORDERED + return chanTypes.UNORDERED case "ORDERED": - return ibctypes.ORDERED + return chanTypes.ORDERED default: - return ibctypes.NONE + return chanTypes.NONE } } @@ -49,7 +48,7 @@ func (pe *PathEnd) getOrder() chanTypes.Order { func (pe *PathEnd) UpdateClient(dstHeader *tmclient.Header, signer sdk.AccAddress) sdk.Msg { return tmclient.NewMsgUpdateClient( pe.ClientID, - *dstHeader, + dstHeader, signer, ) } @@ -57,16 +56,18 @@ func (pe *PathEnd) UpdateClient(dstHeader *tmclient.Header, signer sdk.AccAddres // CreateClient creates an sdk.Msg to update the client on src with consensus state from dst func (pe *PathEnd) CreateClient(dstHeader *tmclient.Header, trustingPeriod time.Duration, signer sdk.AccAddress) sdk.Msg { - if err := dstHeader.ValidateBasic(dstHeader.ChainID); err != nil { + if err := dstHeader.ValidateBasic(dstHeader.Header.ChainID); err != nil { panic(err) } // TODO: figure out how to dynmaically set unbonding time return tmclient.NewMsgCreateClient( pe.ClientID, - *dstHeader, + dstHeader, + tmclient.DefaultTrustLevel, trustingPeriod, defaultUnbondingTime, defaultMaxClockDrift, + commitmenttypes.GetSDKSpecs(), signer, ) } @@ -85,6 +86,7 @@ func (pe *PathEnd) ConnInit(dst *PathEnd, signer sdk.AccAddress) sdk.Msg { // ConnTry creates a MsgConnectionOpenTry // NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE +// TODO: Need to do some more looking here func (pe *PathEnd) ConnTry(dst *PathEnd, dstConnState connTypes.QueryConnectionResponse, dstConsState clientTypes.QueryConsensusStateResponse, dstCsHeight int64, signer sdk.AccAddress) sdk.Msg { return connTypes.NewMsgConnectionOpenTry( @@ -203,6 +205,7 @@ func (pe *PathEnd) ChanCloseConfirm(dstChanState chanTypes.QueryChannelResponse, } // MsgRecvPacket creates a MsgPacket +// TODO: need to do some more looking here func (pe *PathEnd) MsgRecvPacket(dst *PathEnd, sequence, timeoutHeight, timeoutStamp uint64, packetData []byte, proof commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress) sdk.Msg { return chanTypes.NewMsgPacket( diff --git a/relayer/query.go b/relayer/query.go index d923c36cd..25100abf5 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -1,6 +1,7 @@ package relayer import ( + "context" "encoding/binary" "encoding/hex" "errors" @@ -12,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/rootmulti" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" @@ -54,19 +56,21 @@ func (c *Chain) QueryBalance(keyName string) (sdk.Coins, error) { addr = info.GetAddress() } - if bz, err = c.Cdc.MarshalJSON(bankTypes.NewQueryAllBalancesParams(addr)); err != nil { - return nil, qBalErr(addr, err) - } + params := bankTypes.NewQueryAllBalancesRequest(addr, &query.PageRequest{ + Key: []byte(""), + Offset: 0, + Limit: 1000, + CountTotal: false, + }) - if bz, _, err = c.QueryWithData(route, bz); err != nil { - return nil, qBalErr(addr, err) - } + queryClient := bankTypes.NewQueryClient(c.CLIContext()) - if err = c.Cdc.UnmarshalJSON(bz, &coins); err != nil { - return nil, qBalErr(addr, err) + res, err := queryClient.AllBalances(context.Background(), params) + if err != nil { + return nil, err } - return coins, nil + return res.Balances, nil } func qBalErr(acc sdk.AccAddress, err error) error { @@ -84,30 +88,29 @@ func (c *Chain) QueryConsensusState(height int64) (*tmclient.ConsensusState, err commit *ctypes.ResultCommit validators *ctypes.ResultValidators err error + page = 1 + perPage = 10000 ) if height == 0 { commit, err = c.Client.Commit(nil) - if err != nil { - return nil, qConsStateErr(err) - } - validators, err = c.Client.Validators(nil, 1, 10000) } else { commit, err = c.Client.Commit(&height) - if err != nil { - return nil, qConsStateErr(err) - } - validators, err = c.Client.Validators(nil, 1, 10000) } if err != nil { return nil, qConsStateErr(err) } + validators, err = c.Client.Validators(nil, &page, &perPage) + if err != nil { + return nil, qConsStateErr(err) + } + state := &tmclient.ConsensusState{ - Timestamp: commit.Time, - Root: commitmenttypes.NewMerkleRoot(commit.AppHash), - ValidatorSet: tmtypes.NewValidatorSet(validators.Validators), + Timestamp: commit.Time, + Root: commitmenttypes.NewMerkleRoot(commit.AppHash), + NextValidatorsHash: tmtypes.NewValidatorSet(validators.Validators).Hash(), } return state, nil @@ -239,9 +242,9 @@ type cstates struct { } // QueryClientStatePair returns a pair of connection responses -func QueryClientStatePair(src, dst *Chain) (map[string]*clientTypes.QueryClientStateResponse, error) { +func QueryClientStatePair(src, dst *Chain) (map[string]clientexported.ClientState, error) { hs := &cstates{ - Map: make(map[string]*clientTypes.QueryClientStateResponse), + Map: make(map[string]clientexported.ClientState), Errs: []error{}, } @@ -259,7 +262,7 @@ func QueryClientStatePair(src, dst *Chain) (map[string]*clientTypes.QueryClientS hs.Unlock() } hs.Lock() - hs.Map[c.ChainID] = conn + hs.Map[c.ChainID] = clientexported.ClientState(conn.ClientState) hs.Unlock() wg.Done() }(hs, &wg, chain) @@ -278,7 +281,7 @@ func (c *Chain) QueryClients(page, limit int) ([]clientexported.ClientState, err clients []clientexported.ClientState ) - if bz, err = c.Cdc.MarshalJSON(clientTypes.NewQueryAllClientsParams(page, limit)); err != nil { + if bz, err = c.Cdc.MarshalJSON(sdk.NewPaginationParams(page, limit)); err != nil { return nil, qClntsErr(err) } diff --git a/test/test_chains.go b/test/test_chains.go index cbe17bf7c..258f847c0 100644 --- a/test/test_chains.go +++ b/test/test_chains.go @@ -8,21 +8,17 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/std" - gaia "github.com/cosmos/gaia/app" "github.com/stretchr/testify/require" ry "github.com/ovrclk/relayer/relayer" ) var ( - cdc, amino = gaia.MakeCodecs() // GAIA BLOCK TIMEOUTS on jackzampolin/gaiatest:master // timeout_commit = "1000ms" // timeout_propose = "1000ms" // 3 second relayer timeout works well with these block times gaiaTestConfig = testChainConfig{ - cdc: cdc, - amino: amino, dockerImage: "jackzampolin/gaiatest", dockerTag: "gaiav3.0", timeout: 3 * time.Second, From 4205283ae65e8d6e668817df535b20074c0ffaef Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Thu, 27 Aug 2020 18:35:28 -0700 Subject: [PATCH 05/54] WIP query migration to new cliContext --- relayer/log-tx.go | 2 +- relayer/pathEnd.go | 8 +- relayer/query.go | 242 ++++++++------------------------------------- 3 files changed, 47 insertions(+), 205 deletions(-) diff --git a/relayer/log-tx.go b/relayer/log-tx.go index d8f8f04e1..3726fc1e1 100644 --- a/relayer/log-tx.go +++ b/relayer/log-tx.go @@ -56,7 +56,7 @@ func logChannelStates(src, dst *Chain, conn map[string]chanTypes.QueryChannelRes )) } -func logConnectionStates(src, dst *Chain, conn map[string]connTypes.QueryConnectionResponse) { +func logConnectionStates(src, dst *Chain, conn map[string]*connTypes.QueryConnectionResponse) { src.Log(fmt.Sprintf("- [%s]@{%d}conn(%s)-{%s} : [%s]@{%d}conn(%s)-{%s}", src.ChainID, conn[src.ChainID].ProofHeight, diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index 43b0dc668..23aa15b21 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -87,8 +87,8 @@ func (pe *PathEnd) ConnInit(dst *PathEnd, signer sdk.AccAddress) sdk.Msg { // ConnTry creates a MsgConnectionOpenTry // NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE // TODO: Need to do some more looking here -func (pe *PathEnd) ConnTry(dst *PathEnd, dstConnState connTypes.QueryConnectionResponse, - dstConsState clientTypes.QueryConsensusStateResponse, dstCsHeight int64, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) ConnTry(dst *PathEnd, dstConnState *connTypes.QueryConnectionResponse, + dstConsState *clientTypes.QueryConsensusStateResponse, dstCsHeight int64, signer sdk.AccAddress) sdk.Msg { return connTypes.NewMsgConnectionOpenTry( pe.ConnectionID, pe.ClientID, @@ -106,7 +106,7 @@ func (pe *PathEnd) ConnTry(dst *PathEnd, dstConnState connTypes.QueryConnectionR // ConnAck creates a MsgConnectionOpenAck // NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE -func (pe *PathEnd) ConnAck(dstConnState connTypes.QueryConnectionResponse, dstConsState clientTypes.QueryConsensusStateResponse, +func (pe *PathEnd) ConnAck(dstConnState *connTypes.QueryConnectionResponse, dstConsState *clientTypes.QueryConsensusStateResponse, dstCsHeight int64, signer sdk.AccAddress) sdk.Msg { return connTypes.NewMsgConnectionOpenAck( pe.ConnectionID, @@ -121,7 +121,7 @@ func (pe *PathEnd) ConnAck(dstConnState connTypes.QueryConnectionResponse, dstCo // ConnConfirm creates a MsgConnectionOpenAck // NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE -func (pe *PathEnd) ConnConfirm(dstConnState connTypes.QueryConnectionResponse, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) ConnConfirm(dstConnState *connTypes.QueryConnectionResponse, signer sdk.AccAddress) sdk.Msg { return connTypes.NewMsgConnectionOpenConfirm( pe.ConnectionID, dstConnState.Proof, diff --git a/relayer/query.go b/relayer/query.go index 25100abf5..47d817190 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -16,8 +16,10 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" + clientUtils "github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/utils" clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" + connUtils "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils" connTypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" @@ -83,78 +85,18 @@ func qBalErr(acc sdk.AccAddress, err error) error { // QueryConsensusState returns a consensus state for a given chain to be used as a // client in another chain, fetches latest height when passed 0 as arg -func (c *Chain) QueryConsensusState(height int64) (*tmclient.ConsensusState, error) { - var ( - commit *ctypes.ResultCommit - validators *ctypes.ResultValidators - err error - page = 1 - perPage = 10000 - ) - - if height == 0 { - commit, err = c.Client.Commit(nil) - } else { - commit, err = c.Client.Commit(&height) - } - - if err != nil { - return nil, qConsStateErr(err) - } - - validators, err = c.Client.Validators(nil, &page, &perPage) - if err != nil { - return nil, qConsStateErr(err) - } - - state := &tmclient.ConsensusState{ - Timestamp: commit.Time, - Root: commitmenttypes.NewMerkleRoot(commit.AppHash), - NextValidatorsHash: tmtypes.NewValidatorSet(validators.Validators).Hash(), - } - - return state, nil +func (c *Chain) QueryConsensusState(height int64) (*tmclient.ConsensusState, int64, error) { + return clientUtils.QueryNodeConsensusState(c.CLIContext()) } -func qConsStateErr(err error) error { return fmt.Errorf("query cons state failed: %w", err) } - // QueryClientConsensusState retrevies the latest consensus state for a client in state at a given height -// NOTE: dstHeight is the height from dst that is stored on src, it is needed to construct the appropriate store query -func (c *Chain) QueryClientConsensusState(srcHeight, - srcClientConsHeight int64) (clientTypes.QueryConsensusStateResponse, error) { - var conStateRes clientTypes.QueryConsensusStateResponse - if !c.PathSet() { - return conStateRes, c.ErrPathNotSet() - } - - req := abci.RequestQuery{ - Path: "store/ibc/key", - Height: srcHeight, - Data: prefixClientKey(c.PathEnd.ClientID, ibctypes.KeyConsensusState(uint64(srcClientConsHeight))), - Prove: true, - } - - res, err := c.QueryABCI(req) - if err != nil { - return conStateRes, qClntConsStateErr(err) - } else if res.Value == nil { - // TODO: Better way to handle this? - return clientTypes.NewConsensusStateResponse("notfound", nil, nil, 0), nil - } - - var cs clientexported.ConsensusState - if err = c.Amino.UnmarshalBinaryLengthPrefixed(res.Value, &cs); err != nil { - if err = c.Amino.UnmarshalBinaryBare(res.Value, &cs); err != nil { - return conStateRes, qClntConsStateErr(err) - } - } - - return clientTypes.NewConsensusStateResponse(c.PathEnd.ClientID, cs, res.Proof, res.Height), nil +func (c *Chain) QueryClientConsensusState(clientConsHeight uint64) (*clientTypes.QueryConsensusStateResponse, error) { + return clientUtils.QueryConsensusStateABCI(c.CLIContext(), c.PathEnd.ClientID, clientConsHeight) } type csstates struct { sync.Mutex - Map map[string]clientTypes.QueryConsensusStateResponse + Map map[string]*clientTypes.QueryConsensusStateResponse Errs errs } @@ -166,9 +108,9 @@ type chh struct { // QueryClientConsensusStatePair allows for the querying of multiple client states at the same time func QueryClientConsensusStatePair(src, dst *Chain, - srcH, dstH, srcClientConsH, dstClientConsH int64) (map[string]clientTypes.QueryConsensusStateResponse, error) { + srcH, dstH, srcClientConsH, dstClientConsH int64) (map[string]*clientTypes.QueryConsensusStateResponse, error) { hs := &csstates{ - Map: make(map[string]clientTypes.QueryConsensusStateResponse), + Map: make(map[string]*clientTypes.QueryConsensusStateResponse), Errs: []error{}, } @@ -182,7 +124,7 @@ func QueryClientConsensusStatePair(src, dst *Chain, for _, chain := range chps { wg.Add(1) go func(hs *csstates, wg *sync.WaitGroup, chp chh) { - conn, err := chp.c.QueryClientConsensusState(chp.h, chp.csh) + conn, err := chp.c.QueryClientConsensusState(uint64(chp.csh)) if err != nil { hs.Lock() hs.Errs = append(hs.Errs, err) @@ -198,51 +140,20 @@ func QueryClientConsensusStatePair(src, dst *Chain, return hs.Map, hs.Errs.err() } -func qClntConsStateErr(err error) error { return fmt.Errorf("query client cons state failed: %w", err) } - // QueryClientState retrevies the latest consensus state for a client in state at a given height func (c *Chain) QueryClientState() (*clientTypes.QueryClientStateResponse, error) { - var conStateRes *clientTypes.QueryClientStateResponse - if !c.PathSet() { - return nil, c.ErrPathNotSet() - } - - req := abci.RequestQuery{ - Path: "store/ibc/key", - Data: prefixClientKey(c.PathEnd.ClientID, ibctypes.KeyClientState()), - Prove: true, - } - - res, err := c.QueryABCI(req) - if err != nil { - return conStateRes, qClntStateErr(err) - } else if res.Value == nil { - // client does not exist - return nil, nil - } - - var cs clientexported.ClientState - - // If this decoding fails, try with UnmarshalBinaryLengthPrefixed this changed - // reciently and will help support older versions. - if err := c.Amino.UnmarshalBinaryBare(res.Value, &cs); err != nil { - if err := c.Amino.UnmarshalBinaryLengthPrefixed(res.Value, &cs); err != nil { - return nil, qClntStateErr(err) - } - } - - csr := clientTypes.NewClientStateResponse(c.PathEnd.ClientID, cs, res.Proof, res.Height) - return &csr, nil + return clientUtils.QueryClientStateABCI(c.CLIContext(), c.PathEnd.ClientID) } type cstates struct { sync.Mutex - Map map[string]*clientTypes.QueryClientStateResponse + Map map[string]clientexported.ClientState Errs errs } // QueryClientStatePair returns a pair of connection responses func QueryClientStatePair(src, dst *Chain) (map[string]clientexported.ClientState, error) { + ctx := src.CLIContext() hs := &cstates{ Map: make(map[string]clientexported.ClientState), Errs: []error{}, @@ -261,8 +172,9 @@ func QueryClientStatePair(src, dst *Chain) (map[string]clientexported.ClientStat hs.Errs = append(hs.Errs, err) hs.Unlock() } + cs, _ := clientTypes.UnpackClientState(conn.ClientState) hs.Lock() - hs.Map[c.ChainID] = clientexported.ClientState(conn.ClientState) + hs.Map[c.ChainID] = cs hs.Unlock() wg.Done() }(hs, &wg, chain) @@ -274,120 +186,50 @@ func QueryClientStatePair(src, dst *Chain) (map[string]clientexported.ClientStat func qClntStateErr(err error) error { return fmt.Errorf("query client state failed: %w", err) } // QueryClients queries all the clients! -func (c *Chain) QueryClients(page, limit int) ([]clientexported.ClientState, error) { - var ( - bz []byte - err error - clients []clientexported.ClientState - ) - - if bz, err = c.Cdc.MarshalJSON(sdk.NewPaginationParams(page, limit)); err != nil { - return nil, qClntsErr(err) - } - - if bz, _, err = c.QueryWithData( - ibcQuerierRoute(clientTypes.QuerierRoute, clientTypes.QueryAllClients), bz); err != nil { - return nil, qClntsErr(err) - } - - if err = c.Cdc.UnmarshalJSON(bz, &clients); err != nil { - return nil, qClntsErr(err) - } - - return clients, nil +func (c *Chain) QueryClients(offset, limit uint64) ([]*clientTypes.IdentifiedClientState, error) { + res, err := clientTypes.NewQueryClient(c.CLIContext()).ClientStates(context.Background(), &clientTypes.QueryClientStatesRequest{ + Pagination: &query.PageRequest{ + Key: []byte(""), + Offset: offset, + Limit: limit, + CountTotal: false, + }, + }) + return res.ClientStates, err } -func qClntsErr(err error) error { return fmt.Errorf("query clients failed: %w", err) } - // //////////////////////////// // ICS 03 -> CONNECTIONS // // //////////////////////////// // QueryConnections gets any connections on a chain -func (c *Chain) QueryConnections(page, limit int) (conns []connTypes.ConnectionEnd, err error) { - var bz []byte - if bz, err = c.Cdc.MarshalJSON(connTypes.NewQueryAllConnectionsParams(page, limit)); err != nil { - return nil, qConnsErr(err) - } - - if bz, _, err = c.QueryWithData( - ibcQuerierRoute(connTypes.QuerierRoute, connTypes.QueryAllConnections), bz); err != nil { - return nil, qConnsErr(err) - } - - if err = c.Cdc.UnmarshalJSON(bz, &conns); err != nil { - return nil, qConnsErr(err) - } - - return conns, nil +func (c *Chain) QueryConnections(page, limit int) (conns []*connTypes.IdentifiedConnection, err error) { + res, err := connTypes.NewQueryClient(c.CLIContext()).Connections(context.Background(), &connTypes.QueryConnectionsRequest{ + Pagination: &query.PageRequest{ + Key: []byte(""), + Offset: 0, + Limit: 1000, + CountTotal: false, + }, + }) + return res.Connections, err } func qConnsErr(err error) error { return fmt.Errorf("query connections failed: %w", err) } // QueryConnectionsUsingClient gets any connections that exist between chain and counterparty -func (c *Chain) QueryConnectionsUsingClient(height int64) (clientConns connTypes.QueryClientConnectionsResponse, err error) { - if !c.PathSet() { - return clientConns, c.ErrPathNotSet() - } - - req := abci.RequestQuery{ - Path: "store/ibc/key", - Height: height, - Data: ibctypes.KeyClientConnections(c.PathEnd.ClientID), - Prove: true, - } - - res, err := c.QueryABCI(req) - if err != nil { - return clientConns, qConnsUsingClntsErr(err) - } - - var paths []string - if err = c.Amino.UnmarshalBinaryLengthPrefixed(res.Value, &paths); err != nil { - if err = c.Amino.UnmarshalBinaryBare(res.Value, &paths); err != nil { - return clientConns, qConnsUsingClntsErr(err) - } - } - - return connTypes.NewClientConnectionsResponse(c.PathEnd.ClientID, paths, res.Proof, res.Height), nil -} - -func qConnsUsingClntsErr(err error) error { - return fmt.Errorf("query connections using clients failed: %w", err) +func (c *Chain) QueryConnectionsUsingClient(height int64) (clientConns *connTypes.QueryClientConnectionsResponse, err error) { + return connUtils.QueryClientConnections(c.CLIContext(), c.PathEnd.ClientID, true) } // QueryConnection returns the remote end of a given connection -func (c *Chain) QueryConnection(height int64) (connTypes.QueryConnectionResponse, error) { - if !c.PathSet() { - return connTypes.QueryConnectionResponse{}, c.ErrPathNotSet() - } - - req := abci.RequestQuery{ - Path: "store/ibc/key", - Data: ibctypes.KeyConnection(c.PathEnd.ConnectionID), - Height: height, - Prove: true, - } - - res, err := c.QueryABCI(req) - if err != nil { - return connTypes.QueryConnectionResponse{}, qConnErr(err) - } else if res.Value == nil { - // NOTE: This is returned so that the switch statement in ConnectionStep works properly - return emptyConnRes, nil - } - - var connection connTypes.ConnectionEnd - if err = c.Cdc.UnmarshalBinaryBare(res.Value, &connection); err != nil { - return connTypes.QueryConnectionResponse{}, qConnErr(err) - } - - return connTypes.NewConnectionResponse(c.PathEnd.ConnectionID, connection, res.Proof, res.Height), nil +func (c *Chain) QueryConnection(height int64) (*connTypes.QueryConnectionResponse, error) { + return connUtils.QueryConnection(c.CLIContext(), c.PathEnd.ConnectionID, true) } type conns struct { sync.Mutex - Map map[string]connTypes.QueryConnectionResponse + Map map[string]*connTypes.QueryConnectionResponse Errs errs } @@ -397,9 +239,9 @@ type chpair struct { } // QueryConnectionPair returns a pair of connection responses -func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (map[string]connTypes.QueryConnectionResponse, error) { +func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (map[string]*connTypes.QueryConnectionResponse, error) { hs := &conns{ - Map: make(map[string]connTypes.QueryConnectionResponse), + Map: make(map[string]*connTypes.QueryConnectionResponse), Errs: []error{}, } From ab62a71337dd9f3fb5ddb03674db7411f37cbaa1 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Sat, 29 Aug 2020 09:16:30 -0700 Subject: [PATCH 06/54] Compiler errors in /relayer --- relayer/log-tx.go | 6 +- relayer/naive-strategy.go | 12 +- relayer/packet-tx.go | 72 +++-- relayer/pathEnd.go | 175 ++++++------ relayer/query.go | 555 +++++--------------------------------- relayer/relayPackets.go | 32 +-- relayer/verifier.go | 24 +- 7 files changed, 250 insertions(+), 626 deletions(-) diff --git a/relayer/log-tx.go b/relayer/log-tx.go index 3726fc1e1..e9936d6df 100644 --- a/relayer/log-tx.go +++ b/relayer/log-tx.go @@ -11,7 +11,7 @@ import ( ) // LogFailedTx takes the transaction and the messages to create it and logs the appropriate data -func (c *Chain) LogFailedTx(res sdk.TxResponse, err error, msgs []sdk.Msg) { +func (c *Chain) LogFailedTx(res *sdk.TxResponse, err error, msgs []sdk.Msg) { if c.debug { c.Log(fmt.Sprintf("- [%s] -> sending transaction:", c.ChainID)) c.Print(msgs, false, false) @@ -33,7 +33,7 @@ func (c *Chain) LogFailedTx(res sdk.TxResponse, err error, msgs []sdk.Msg) { } // LogSuccessTx take the transaction and the messages to create it and logs the appropriate data -func (c *Chain) LogSuccessTx(res sdk.TxResponse, msgs []sdk.Msg) { +func (c *Chain) LogSuccessTx(res *sdk.TxResponse, msgs []sdk.Msg) { c.logger.Info(fmt.Sprintf("✔ [%s]@{%d} - msg(%s) hash(%s)", c.ChainID, res.Height, getMsgAction(msgs), res.TxHash)) } @@ -42,7 +42,7 @@ func (c *Chain) logPacketsRelayed(dst *Chain, num int) { num, dst.ChainID, dst.PathEnd.PortID, c.ChainID, c.PathEnd.PortID)) } -func logChannelStates(src, dst *Chain, conn map[string]chanTypes.QueryChannelResponse) { +func logChannelStates(src, dst *Chain, conn map[string]*chanTypes.QueryChannelResponse) { // TODO: replace channelID with portID? src.Log(fmt.Sprintf("- [%s]@{%d}chan(%s)-{%s} : [%s]@{%d}chan(%s)-{%s}", src.ChainID, diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index 64cb427b6..83c0fe301 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -32,12 +32,14 @@ func (nrs *NaiveStrategy) GetType() string { // UnrelayedSequencesOrdered returns the unrelayed sequence numbers between two chains func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHeaders) (*RelaySequences, error) { - return UnrelayedSequences(src, dst, sh) + // TODO: Implement + return &RelaySequences{}, nil } // UnrelayedSequencesUnordered returns the unrelayed sequence numbers between two chains func (nrs *NaiveStrategy) UnrelayedSequencesUnordered(src, dst *Chain, sh *SyncHeaders) (*RelaySequences, error) { - return UnrelayedSequences(src, dst, sh) + // TODO: Implement + return &RelaySequences{}, nil } // HandleEvents defines how the relayer will handle block and transaction events as they are emitted @@ -185,6 +187,12 @@ func (nrs *NaiveStrategy) sendTxFromEventPackets(src, dst *Chain, rlyPackets []r } } +// RelaySequences represents unrelayed packets on src and dst +type RelaySequences struct { + Src []uint64 + Dst []uint64 +} + // RelayPacketsUnorderedChan creates transactions to relay un-relayed messages func (nrs *NaiveStrategy) RelayPacketsUnorderedChan(src, dst *Chain, sp *RelaySequences, sh *SyncHeaders) error { // TODO: Implement unordered channels diff --git a/relayer/packet-tx.go b/relayer/packet-tx.go index 9fad24495..4845787ef 100644 --- a/relayer/packet-tx.go +++ b/relayer/packet-tx.go @@ -48,9 +48,10 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, done() // MsgTransfer will call SendPacket on src chain + // TODO: FIX txs := RelayMsgs{ Src: []sdk.Msg{c.PathEnd.MsgTransfer( - dst.PathEnd, dstHeader.GetHeight(), sdk.NewCoins(amount), dstAddrString, c.MustGetAddress(), + dst.PathEnd, amount, dstAddrString, c.MustGetAddress(), 1, 1, )}, Dst: []sdk.Msg{}, } @@ -64,9 +65,9 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, var ( hs map[string]*tmclient.Header - seqRecv chanTypes.QueryNextSequenceReceiveResponse + seqRecv *chanTypes.QueryNextSequenceReceiveResponse seqSend uint64 - srcCommitRes CommitmentResponse + srcCommitRes *chanTypes.QueryPacketCommitmentResponse ) if err = retry.Do(func() error { @@ -80,17 +81,12 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, return err } - seqSend, err = c.QueryNextSeqSend(hs[c.ChainID].Header.Height) + srcCommitRes, err = c.QueryPacketCommitment(seqSend - 1) if err != nil { return err } - srcCommitRes, err = c.QueryPacketCommitment(hs[c.ChainID].Header.Height-1, int64(seqSend-1)) - if err != nil { - return err - } - - if srcCommitRes.Proof.Proof == nil { + if srcCommitRes.Proof == nil { return fmt.Errorf("proof nil, retrying") } @@ -110,7 +106,7 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, // reconstructing packet data here instead of retrieving from an indexed node xferPacket := c.PathEnd.XferPacket( - sdk.NewCoins(amount), + amount, srcAddrString, dstAddrString, ) @@ -147,7 +143,7 @@ func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringe amount.Denom = fmt.Sprintf("%s/%s/%s", c.PathEnd.PortID, c.PathEnd.ChannelID, amount.Denom) } - dstHeader, err := dst.UpdateLiteWithHeader() + _, err := dst.UpdateLiteWithHeader() if err != nil { return err } @@ -158,9 +154,10 @@ func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringe done() // MsgTransfer will call SendPacket on src chain + // TODO: FIX txs := RelayMsgs{ Src: []sdk.Msg{c.PathEnd.MsgTransfer( - dst.PathEnd, dstHeader.GetHeight(), sdk.NewCoins(amount), dstAddrString, c.MustGetAddress(), + dst.PathEnd, amount, dstAddrString, c.MustGetAddress(), 1, 1, )}, Dst: []sdk.Msg{}, } @@ -171,27 +168,28 @@ func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringe return nil } -// SendPacket sends arbitrary bytes from src to dst -func (c *Chain) SendPacket(dst *Chain, packetData []byte) error { - dstHeader, err := dst.UpdateLiteWithHeader() - if err != nil { - return err - } - - // MsgSendPacket will call SendPacket on src chain - txs := RelayMsgs{ - Src: []sdk.Msg{c.PathEnd.MsgSendPacket( - dst.PathEnd, - packetData, - dstHeader.GetHeight()+uint64(defaultPacketTimeout), - defaultPacketTimeoutStamp(), - c.MustGetAddress(), - )}, - Dst: []sdk.Msg{}, - } - - if txs.Send(c, dst); !txs.success { - return fmt.Errorf("failed to send packet") - } - return nil -} +// TODO: reimplement +// // SendPacket sends arbitrary bytes from src to dst +// func (c *Chain) SendPacket(dst *Chain, packetData []byte) error { +// dstHeader, err := dst.UpdateLiteWithHeader() +// if err != nil { +// return err +// } + +// // MsgSendPacket will call SendPacket on src chain +// txs := RelayMsgs{ +// Src: []sdk.Msg{c.PathEnd.MsgSendPacket( +// dst.PathEnd, +// packetData, +// dstHeader.GetHeight()+uint64(defaultPacketTimeout), +// defaultPacketTimeoutStamp(), +// c.MustGetAddress(), +// )}, +// Dst: []sdk.Msg{}, +// } + +// if txs.Send(c, dst); !txs.success { +// return fmt.Errorf("failed to send packet") +// } +// return nil +// } diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index 23aa15b21..1dfb6e446 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -89,34 +89,38 @@ func (pe *PathEnd) ConnInit(dst *PathEnd, signer sdk.AccAddress) sdk.Msg { // TODO: Need to do some more looking here func (pe *PathEnd) ConnTry(dst *PathEnd, dstConnState *connTypes.QueryConnectionResponse, dstConsState *clientTypes.QueryConsensusStateResponse, dstCsHeight int64, signer sdk.AccAddress) sdk.Msg { - return connTypes.NewMsgConnectionOpenTry( - pe.ConnectionID, - pe.ClientID, - dst.ConnectionID, - dst.ClientID, - defaultChainPrefix, - defaultIBCVersions, - dstConnState.Proof, - dstConsState.Proof, - dstConnState.ProofHeight+1, - uint64(dstCsHeight), - signer, - ) + return &connTypes.MsgConnectionOpenTry{} + // TODO: reimplement + // return connTypes.NewMsgConnectionOpenTry( + // pe.ConnectionID, + // pe.ClientID, + // dst.ConnectionID, + // dst.ClientID, + // defaultChainPrefix, + // defaultIBCVersions, + // dstConnState.Proof, + // dstConsState.Proof, + // dstConnState.ProofHeight+1, + // uint64(dstCsHeight), + // signer, + // ) } // ConnAck creates a MsgConnectionOpenAck // NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE func (pe *PathEnd) ConnAck(dstConnState *connTypes.QueryConnectionResponse, dstConsState *clientTypes.QueryConsensusStateResponse, dstCsHeight int64, signer sdk.AccAddress) sdk.Msg { - return connTypes.NewMsgConnectionOpenAck( - pe.ConnectionID, - dstConnState.Proof, - dstConsState.Proof, - dstConnState.ProofHeight+1, - uint64(dstCsHeight), - defaultIBCVersion, - signer, - ) + return &connTypes.MsgConnectionOpenAck{} + // TODO: reimplement + // return connTypes.NewMsgConnectionOpenAck( + // pe.ConnectionID, + // dstConnState.Proof, + // dstConsState.Proof, + // dstConnState.ProofHeight+1, + // uint64(dstCsHeight), + // defaultIBCVersion, + // signer, + // ) } // ConnConfirm creates a MsgConnectionOpenAck @@ -145,7 +149,7 @@ func (pe *PathEnd) ChanInit(dst *PathEnd, signer sdk.AccAddress) sdk.Msg { } // ChanTry creates a MsgChannelOpenTry -func (pe *PathEnd) ChanTry(dst *PathEnd, dstChanState chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) ChanTry(dst *PathEnd, dstChanState *chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg { return chanTypes.NewMsgChannelOpenTry( pe.PortID, pe.ChannelID, @@ -162,7 +166,7 @@ func (pe *PathEnd) ChanTry(dst *PathEnd, dstChanState chanTypes.QueryChannelResp } // ChanAck creates a MsgChannelOpenAck -func (pe *PathEnd) ChanAck(dstChanState chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) ChanAck(dstChanState *chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg { return chanTypes.NewMsgChannelOpenAck( pe.PortID, pe.ChannelID, @@ -174,7 +178,7 @@ func (pe *PathEnd) ChanAck(dstChanState chanTypes.QueryChannelResponse, signer s } // ChanConfirm creates a MsgChannelOpenConfirm -func (pe *PathEnd) ChanConfirm(dstChanState chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) ChanConfirm(dstChanState *chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg { return chanTypes.NewMsgChannelOpenConfirm( pe.PortID, pe.ChannelID, @@ -194,7 +198,7 @@ func (pe *PathEnd) ChanCloseInit(signer sdk.AccAddress) sdk.Msg { } // ChanCloseConfirm creates a MsgChannelCloseConfirm -func (pe *PathEnd) ChanCloseConfirm(dstChanState chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) ChanCloseConfirm(dstChanState *chanTypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg { return chanTypes.NewMsgChannelCloseConfirm( pe.PortID, pe.ChannelID, @@ -207,79 +211,87 @@ func (pe *PathEnd) ChanCloseConfirm(dstChanState chanTypes.QueryChannelResponse, // MsgRecvPacket creates a MsgPacket // TODO: need to do some more looking here func (pe *PathEnd) MsgRecvPacket(dst *PathEnd, sequence, timeoutHeight, timeoutStamp uint64, - packetData []byte, proof commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress) sdk.Msg { - return chanTypes.NewMsgPacket( - dst.NewPacket( - pe, - sequence, - packetData, - timeoutHeight, - timeoutStamp, - ), - proof, - proofHeight+1, - signer, - ) + packetData []byte, proof []byte, proofHeight uint64, signer sdk.AccAddress) sdk.Msg { + return &connTypes.MsgConnectionOpenAck{} + // TODO: reimplement + // return chanTypes.NewMsgPacket( + // dst.NewPacket( + // pe, + // sequence, + // packetData, + // timeoutHeight, + // timeoutStamp, + // ), + // proof, + // proofHeight+1, + // signer, + // ) } // MsgTimeout creates MsgTimeout func (pe *PathEnd) MsgTimeout(dst *PathEnd, packetData []byte, seq, timeout, timeoutStamp uint64, - proof commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress) sdk.Msg { - return chanTypes.NewMsgTimeout( - pe.NewPacket( - dst, - seq, - packetData, - timeout, - timeoutStamp, - ), - seq, - proof, - proofHeight+1, - signer, - ) + proof []byte, proofHeight uint64, signer sdk.AccAddress) sdk.Msg { + return &connTypes.MsgConnectionOpenAck{} + // TODO: reimplement + // return chanTypes.NewMsgTimeout( + // pe.NewPacket( + // dst, + // seq, + // packetData, + // timeout, + // timeoutStamp, + // ), + // seq, + // proof, + // proofHeight+1, + // signer, + // ) } // MsgAck creates MsgAck func (pe *PathEnd) MsgAck(dst *PathEnd, sequence, timeoutHeight, timeoutStamp uint64, ack, packetData []byte, - proof commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress) sdk.Msg { - return chanTypes.NewMsgAcknowledgement( - pe.NewPacket( - dst, - sequence, - packetData, - timeoutHeight, - timeoutStamp, - ), - ack, - proof, - proofHeight+1, - signer, - ) + proof []byte, proofHeight uint64, signer sdk.AccAddress) sdk.Msg { + return &connTypes.MsgConnectionOpenAck{} + // TODO: reimplement + // return chanTypes.NewMsgAcknowledgement( + // pe.NewPacket( + // dst, + // sequence, + // packetData, + // timeoutHeight, + // timeoutStamp, + // ), + // ack, + // proof, + // proofHeight+1, + // signer, + // ) } // MsgTransfer creates a new transfer message -func (pe *PathEnd) MsgTransfer(dst *PathEnd, dstHeight uint64, amount sdk.Coins, dstAddr string, - signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) MsgTransfer(dst *PathEnd, amount sdk.Coin, dstAddr string, + signer sdk.AccAddress, timeoutHeight, timeoutTimestamp uint64) sdk.Msg { return xferTypes.NewMsgTransfer( pe.PortID, pe.ChannelID, - dstHeight, amount, signer, dstAddr, + timeoutHeight, + timeoutTimestamp, ) } +// TODO: potentially reimplement // MsgSendPacket creates a new arbitrary packet message -func (pe *PathEnd) MsgSendPacket(dst *PathEnd, packetData []byte, relativeTimeout, timeoutStamp uint64, - signer sdk.AccAddress) sdk.Msg { - // NOTE: Use this just to pass the packet integrity checks. - fakeSequence := uint64(1) - packet := chanTypes.NewPacket(packetData, fakeSequence, pe.PortID, pe.ChannelID, dst.PortID, - dst.ChannelID, relativeTimeout, timeoutStamp) - return NewMsgSendPacket(packet, signer) -} +// func (pe *PathEnd) MsgSendPacket(dst *PathEnd, packetData []byte, relativeTimeout, timeoutStamp uint64, +// signer sdk.AccAddress) sdk.Msg { +// // NOTE: Use this just to pass the packet integrity checks. +// fakeSequence := uint64(1) +// packet := chanTypes.NewPacket(packetData, fakeSequence, pe.PortID, pe.ChannelID, dst.PortID, +// dst.ChannelID, relativeTimeout, timeoutStamp) +// return NewMsgSendPacket(packet, signer) +// } // NewPacket returns a new packet from src to dist w func (pe *PathEnd) NewPacket(dst *PathEnd, sequence uint64, packetData []byte, @@ -297,9 +309,10 @@ func (pe *PathEnd) NewPacket(dst *PathEnd, sequence uint64, packetData []byte, } // XferPacket creates a new transfer packet -func (pe *PathEnd) XferPacket(amount sdk.Coins, sender, receiver string) []byte { +func (pe *PathEnd) XferPacket(amount sdk.Coin, sender, receiver string) []byte { return xferTypes.NewFungibleTokenPacketData( - amount, + amount.Denom, + amount.Amount.Uint64(), sender, receiver, ).GetBytes() @@ -307,7 +320,7 @@ func (pe *PathEnd) XferPacket(amount sdk.Coins, sender, receiver string) []byte // PacketMsg returns a new MsgPacket for forwarding packets from one chain to another func (c *Chain) PacketMsg(dst *Chain, xferPacket []byte, timeout, timeoutStamp uint64, - seq int64, dstCommitRes CommitmentResponse) sdk.Msg { + seq int64, dstCommitRes *chanTypes.QueryPacketCommitmentResponse) sdk.Msg { return c.PathEnd.MsgRecvPacket( dst.PathEnd, uint64(seq), diff --git a/relayer/query.go b/relayer/query.go index 47d817190..8d32c5e85 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -2,7 +2,6 @@ package relayer import ( "context" - "encoding/binary" "encoding/hex" "errors" "fmt" @@ -21,10 +20,10 @@ import ( clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" connUtils "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils" connTypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" + chanUtils "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/client/utils" + "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" - commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" - ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" abci "github.com/tendermint/tendermint/abci/types" rpcclient "github.com/tendermint/tendermint/rpc/client" ctypes "github.com/tendermint/tendermint/rpc/core/types" @@ -42,11 +41,8 @@ var eventFormat = "{eventType}.{eventAttribute}={value}" // QueryBalance returns the amount of coins in the relayer account func (c *Chain) QueryBalance(keyName string) (sdk.Coins, error) { var ( - bz []byte - err error - coins sdk.Coins - addr sdk.AccAddress - route = fmt.Sprintf("custom/%s/%s", bankTypes.QuerierRoute, bankTypes.QueryAllBalances) + err error + addr sdk.AccAddress ) if keyName == "" { addr = c.MustGetAddress() @@ -75,10 +71,6 @@ func (c *Chain) QueryBalance(keyName string) (sdk.Coins, error) { return res.Balances, nil } -func qBalErr(acc sdk.AccAddress, err error) error { - return fmt.Errorf("query balance for acct %s failed: %w", acc.String(), err) -} - // //////////////////////////// // ICS 02 -> CLIENTS // // //////////////////////////// @@ -153,7 +145,6 @@ type cstates struct { // QueryClientStatePair returns a pair of connection responses func QueryClientStatePair(src, dst *Chain) (map[string]clientexported.ClientState, error) { - ctx := src.CLIContext() hs := &cstates{ Map: make(map[string]clientexported.ClientState), Errs: []error{}, @@ -183,8 +174,6 @@ func QueryClientStatePair(src, dst *Chain) (map[string]clientexported.ClientStat return hs.Map, hs.Errs.err() } -func qClntStateErr(err error) error { return fmt.Errorf("query client state failed: %w", err) } - // QueryClients queries all the clients! func (c *Chain) QueryClients(offset, limit uint64) ([]*clientTypes.IdentifiedClientState, error) { res, err := clientTypes.NewQueryClient(c.CLIContext()).ClientStates(context.Background(), &clientTypes.QueryClientStatesRequest{ @@ -203,20 +192,18 @@ func (c *Chain) QueryClients(offset, limit uint64) ([]*clientTypes.IdentifiedCli // //////////////////////////// // QueryConnections gets any connections on a chain -func (c *Chain) QueryConnections(page, limit int) (conns []*connTypes.IdentifiedConnection, err error) { +func (c *Chain) QueryConnections(offset, limit uint64) (conns []*connTypes.IdentifiedConnection, err error) { res, err := connTypes.NewQueryClient(c.CLIContext()).Connections(context.Background(), &connTypes.QueryConnectionsRequest{ Pagination: &query.PageRequest{ Key: []byte(""), - Offset: 0, - Limit: 1000, + Offset: offset, + Limit: limit, CountTotal: false, }, }) return res.Connections, err } -func qConnsErr(err error) error { return fmt.Errorf("query connections failed: %w", err) } - // QueryConnectionsUsingClient gets any connections that exist between chain and counterparty func (c *Chain) QueryConnectionsUsingClient(height int64) (clientConns *connTypes.QueryClientConnectionsResponse, err error) { return connUtils.QueryClientConnections(c.CLIContext(), c.PathEnd.ClientID, true) @@ -271,88 +258,38 @@ func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (map[string]*connTyp return hs.Map, hs.Errs.err() } -// // QueryLatestHeights returns the heights of multiple chains at once -// func QueryLatestHeights(chains ...*Chain) (map[string]int64, error) { - -// } - -func qConnErr(err error) error { return fmt.Errorf("query connection failed: %w", err) } - -var emptyConnRes = connTypes.QueryConnectionResponse{Connection: &connTypes.ConnectionEnd{ClientId: ""}} - // //////////////////////////// // ICS 04 -> CHANNEL // // //////////////////////////// // QueryConnectionChannels queries the channels associated with a connection -func (c *Chain) QueryConnectionChannels(connectionID string, page, limit int) ([]chanTypes.IdentifiedChannel, error) { - var ( - bz []byte - err error - channels []chanTypes.IdentifiedChannel - ) - - if bz, err = c.Cdc.MarshalJSON(chanTypes.NewQueryConnectionChannelsParams(connectionID, page, limit)); err != nil { - return nil, qChansErr(err) - } - - if bz, _, err = c.QueryWithData( - ibcQuerierRoute(chanTypes.QuerierRoute, chanTypes.QueryConnectionChannels), bz); err != nil { - return nil, qChansErr(err) - } - - if err = c.Cdc.UnmarshalJSON(bz, &channels); err != nil { - return nil, qChansErr(err) - } - - return channels, nil +func (c *Chain) QueryConnectionChannels(connectionID string, offset, limit uint64) ([]*chanTypes.IdentifiedChannel, error) { + res, err := chanTypes.NewQueryClient(c.CLIContext()).ConnectionChannels(context.Background(), &chanTypes.QueryConnectionChannelsRequest{ + Pagination: &query.PageRequest{ + Key: []byte(""), + Offset: offset, + Limit: limit, + CountTotal: false, + }, + }) + return res.Channels, err } // QueryChannel returns the channel associated with a channelID -func (c *Chain) QueryChannel(height int64) (chanRes chanTypes.QueryChannelResponse, err error) { - if !c.PathSet() { - return chanRes, c.ErrPathNotSet() - } - - req := abci.RequestQuery{ - Path: "store/ibc/key", - Data: ibctypes.KeyChannel(c.PathEnd.PortID, c.PathEnd.ChannelID), - Height: height, - Prove: true, - } - - res, err := c.QueryABCI(req) - if err != nil { - return chanRes, qChanErr(err) - } else if res.Value == nil { - // NOTE: This is returned so that the switch statement in ChannelStep works properly - return chanTypes.NewChannelResponse(c.PathEnd.PortID, c.PathEnd.ChannelID, - chanTypes.Channel{State: ibctypes.UNINITIALIZED}, nil, 0), nil - } - - var channel chanTypes.Channel - if err = c.Cdc.UnmarshalBinaryBare(res.Value, &channel); err != nil { - return chanRes, qChanErr(err) - } - // if err = c.Amino.UnmarshalBinaryLengthPrefixed(res.Value, &channel); err != nil { - // if err = c.Amino.UnmarshalBinaryBare(res.Value, &channel); err != nil { - // return chanRes, qChanErr(err) - // } - // } - - return chanTypes.NewChannelResponse(c.PathEnd.PortID, c.PathEnd.ChannelID, channel, res.Proof, res.Height), nil +func (c *Chain) QueryChannel(height int64) (chanRes *chanTypes.QueryChannelResponse, err error) { + return chanUtils.QueryChannel(c.CLIContext(), c.PathEnd.PortID, c.PathEnd.ChannelID, true) } type chans struct { sync.Mutex - Map map[string]chanTypes.QueryChannelResponse + Map map[string]*chanTypes.QueryChannelResponse Errs errs } // QueryChannelPair returns a pair of channel responses -func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (map[string]chanTypes.QueryChannelResponse, error) { +func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (map[string]*chanTypes.QueryChannelResponse, error) { hs := &chans{ - Map: make(map[string]chanTypes.QueryChannelResponse), + Map: make(map[string]*chanTypes.QueryChannelResponse), Errs: []error{}, } @@ -382,33 +319,19 @@ func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (map[string]chanTypes.Q return hs.Map, hs.Errs.err() } -func qChanErr(err error) error { return fmt.Errorf("query channel failed: %w", err) } - // QueryChannels returns all the channels that are registered on a chain -func (c *Chain) QueryChannels(page, limit int) ([]chanTypes.IdentifiedChannel, error) { - var ( - bz []byte - err error - channels []chanTypes.IdentifiedChannel - ) - - if bz, err = c.Cdc.MarshalJSON(chanTypes.NewQueryAllChannelsParams(page, limit)); err != nil { - return nil, qChansErr(err) - } - - if bz, _, err = c.QueryWithData(ibcQuerierRoute(chanTypes.QuerierRoute, chanTypes.QueryAllChannels), bz); err != nil { - return nil, qChansErr(err) - } - - if err = c.Cdc.UnmarshalJSON(bz, &channels); err != nil { - return nil, qChansErr(err) - } - - return channels, nil +func (c *Chain) QueryChannels(offset, limit uint64) ([]*chanTypes.IdentifiedChannel, error) { + res, err := types.NewQueryClient(c.CLIContext()).Channels(context.Background(), &types.QueryChannelsRequest{ + Pagination: &query.PageRequest{ + Key: []byte(""), + Offset: offset, + Limit: limit, + CountTotal: false, + }, + }) + return res.Channels, err } -func qChansErr(err error) error { return fmt.Errorf("query channels failed: %w", err) } - // WaitForNBlocks blocks until the next block on a given chain func (c *Chain) WaitForNBlocks(n int64) error { var initial int64 @@ -433,386 +356,47 @@ func (c *Chain) WaitForNBlocks(n int64) error { } // QueryNextSeqRecv returns the next seqRecv for a configured channel -func (c *Chain) QueryNextSeqRecv(height int64) (recvRes chanTypes.QueryNextSequenceReceiveResponse, err error) { - if !c.PathSet() { - return recvRes, c.ErrPathNotSet() - } - - req := abci.RequestQuery{ - Path: "store/ibc/key", - Data: ibctypes.KeyNextSequenceRecv(c.PathEnd.PortID, c.PathEnd.ChannelID), - Height: height, - Prove: true, - } - - res, err := c.QueryABCI(req) - if err != nil { - return recvRes, err - } else if res.Value == nil { - // TODO: figure out how to return not found error - return recvRes, nil - } - - return chanTypes.NewRecvResponse( - c.PathEnd.PortID, - c.PathEnd.ChannelID, - binary.BigEndian.Uint64(res.Value), - res.Proof, - res.Height, - ), nil -} - -// SeqPairs represents the next recv and send seqs from both sides of a given channel -type SeqPairs struct { - sync.Mutex `json:"-" yaml:"-"` - Src *SeqPair `json:"src" yaml:"src"` - Dst *SeqPair `json:"dst" yaml:"dst"` - errs errs -} - -// SeqPair represents the next recv and send seq from a given channel -type SeqPair struct { - sync.Mutex `json:"-" yaml:"-"` - Recv uint64 `json:"recv" yaml:"recv"` - Send uint64 `json:"send" yaml:"send"` -} - -// RelaySequences represents the unrelayed sequence numbers on src and dst -type RelaySequences struct { - Src []uint64 `json:"src,omitempty" yaml:"src,omitempty"` - Dst []uint64 `json:"dst,omitempty" yaml:"dst,omitempty"` -} - -// ToRelay represents an array of sequence numbers on each chain that need to be relayed -func (sp *SeqPairs) ToRelay() *RelaySequences { - return &RelaySequences{ - Src: newRlySeq(sp.Dst.Recv, sp.Src.Send), - Dst: newRlySeq(sp.Src.Recv, sp.Dst.Send), - } -} - -func newRlySeq(start, end uint64) []uint64 { - if end < start { - return []uint64{} - } - s := make([]uint64, 0, 1+(end-start)) - for start < end { - s = append(s, start) - start++ - } - return s -} - -// UnrelayedSequences returns the unrelayed sequence numbers between two chains -func UnrelayedSequences(src, dst *Chain, sh *SyncHeaders) (*RelaySequences, error) { - seqP, err := QueryNextSeqPairs(src, dst, sh) - if err != nil { - return nil, err - } - return seqP.ToRelay(), err -} - -// QueryNextSeqPairs returns a pair of chain's next sequences for the configured channel -func QueryNextSeqPairs(src, dst *Chain, sh *SyncHeaders) (*SeqPairs, error) { - sps := &SeqPairs{Src: &SeqPair{}, Dst: &SeqPair{}, errs: errs{}} - var wg sync.WaitGroup - wg.Add(4) - go src.queryNextSendWG(sps, int64(sh.GetHeight(src.ChainID)), &wg, true) - go src.queryNextRecvWG(sps, int64(sh.GetHeight(src.ChainID)), &wg, true) - go dst.queryNextSendWG(sps, int64(sh.GetHeight(dst.ChainID)), &wg, false) - go dst.queryNextRecvWG(sps, int64(sh.GetHeight(dst.ChainID)), &wg, false) - wg.Wait() - return sps, sps.errs.err() -} - -func (c *Chain) queryNextSendWG(sps *SeqPairs, h int64, wg *sync.WaitGroup, src bool) { - defer wg.Done() - seqSend, err := c.QueryNextSeqSend(h) - sps.Lock() - defer sps.Unlock() - if err != nil { - sps.errs = append(sps.errs, err) - } - if src { - sps.Src.Send = seqSend - } else { - sps.Dst.Send = seqSend - } -} - -func (c *Chain) queryNextRecvWG(sps *SeqPairs, h int64, wg *sync.WaitGroup, src bool) { - defer wg.Done() - seqRecv, err := c.QueryNextSeqRecv(h) - sps.Lock() - defer sps.Unlock() - if err != nil { - sps.errs = append(sps.errs, err) - } - if src { - sps.Src.Recv = seqRecv.NextSequenceRecv - } else { - sps.Dst.Recv = seqRecv.NextSequenceRecv - } -} - -// QueryNextSeqSend returns the next seqSend for a configured channel -func (c *Chain) QueryNextSeqSend(height int64) (uint64, error) { - if !c.PathSet() { - return 0, c.ErrPathNotSet() - } - - req := abci.RequestQuery{ - Path: "store/ibc/key", - Data: ibctypes.KeyNextSequenceSend(c.PathEnd.PortID, c.PathEnd.ChannelID), - Height: height, - Prove: true, - } - - res, err := c.QueryABCI(req) - if err != nil { - return 0, err - } else if res.Value == nil { - // NOTE: figure out how to return not found error - return 0, nil - } - - return binary.BigEndian.Uint64(res.Value), nil +func (c *Chain) QueryNextSeqRecv(height int64) (recvRes *chanTypes.QueryNextSequenceReceiveResponse, err error) { + return chanUtils.QueryNextSequenceReceive(c.CLIContext(), c.PathEnd.PortID, c.PathEnd.ChannelID, true) } // QueryPacketCommitment returns the packet commitment proof at a given height -func (c *Chain) QueryPacketCommitment(height, seq int64) (comRes CommitmentResponse, err error) { - if !c.PathSet() { - return comRes, c.ErrPathNotSet() - } - - req := abci.RequestQuery{ - Path: "store/ibc/key", - Data: ibctypes.KeyPacketCommitment(c.PathEnd.PortID, c.PathEnd.ChannelID, uint64(seq)), - Height: height, - Prove: true, - } - - res, err := c.QueryABCI(req) - if err != nil { - return comRes, qPacketCommitmentErr(err) - } else if res.Value == nil { - // TODO: Is this the not found error we want to return here? - return comRes, nil - } - - return CommitmentResponse{ - Data: res.Value, - Proof: commitmenttypes.MerkleProof{Proof: res.Proof}, - ProofPath: commitmenttypes.NewMerklePath( - strings.Split( - string(ibctypes.KeyPacketCommitment(c.PathEnd.PortID, c.PathEnd.ChannelID, uint64(seq))), - "/", - ), - ), - ProofHeight: uint64(res.Height), - }, nil -} - -func qPacketCommitmentErr(err error) error { - return fmt.Errorf("query packet commitment failed: %w", err) +func (c *Chain) QueryPacketCommitment(seq uint64) (comRes *chanTypes.QueryPacketCommitmentResponse, err error) { + return chanUtils.QueryPacketCommitment(c.CLIContext(), c.PathEnd.PortID, c.PathEnd.ChannelID, seq, true) } -// CommitmentResponse returns the commiment hash along with the proof data -// NOTE: CommitmentResponse is used to wrap query response from querying PacketCommitment AND PacketAcknowledgement -type CommitmentResponse struct { - Data []byte `json:"data" yaml:"data"` - Proof commitmenttypes.MerkleProof `json:"proof,omitempty" yaml:"proof,omitempty"` - ProofPath commitmenttypes.MerklePath `json:"proof_path,omitempty" yaml:"proof_path,omitempty"` - ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"` -} - -// QueryPacketAck returns the packet commitment proof at a given height -func (c *Chain) QueryPacketAck(height, seq int64) (comRes CommitmentResponse, err error) { - if !c.PathSet() { - return comRes, c.ErrPathNotSet() - } - - req := abci.RequestQuery{ - Path: "store/ibc/key", - Data: ibctypes.KeyPacketAcknowledgement(c.PathEnd.PortID, c.PathEnd.ChannelID, uint64(seq)), - Height: height, - Prove: true, - } - - res, err := c.QueryABCI(req) - if err != nil { - return comRes, qPacketAckErr(err) - } else if res.Value == nil { - return comRes, nil - } - - return CommitmentResponse{ - Data: res.Value, - Proof: commitmenttypes.MerkleProof{Proof: res.Proof}, - ProofPath: commitmenttypes.NewMerklePath( - strings.Split( - string(ibctypes.KeyPacketAcknowledgement(c.PathEnd.PortID, c.PathEnd.ChannelID, uint64(seq))), - "/", - ), - ), - ProofHeight: uint64(res.Height), - }, nil -} - -func qPacketAckErr(err error) error { - return fmt.Errorf("query packet acknowledgement failed: %w", err) -} - -// PathStatus returns the status of a given path -type PathStatus struct { - Chains map[string]*ChainStatus `json:"chains" yaml:"chains"` - UnrelayedSeq *RelaySequences `json:"unrelayed-seq" yaml:"unrelayed-seq"` - src string - dst string -} - -// ChainStatus is for printing a chain's link status -type ChainStatus struct { - Reachable bool `json:"reachable" yaml:"reachable"` - Height int64 `json:"height" yaml:"height"` - Client *ClientStatus `json:"client" yaml:"client"` - Connection *ConnectionStatus `json:"connection" yaml:"connection"` - Channel *ChannelStatus `json:"channel" yaml:"channel"` -} - -// ClientStatus is for printing client status -type ClientStatus struct { - ID string `json:"id,omitempty" yaml:"id,omitempty"` - Height uint64 `json:"height,omitempty" yaml:"height,omitempty"` -} - -// ConnectionStatus is for printing connection status -type ConnectionStatus struct { - ID string `json:"id,omitempty" yaml:"id,omitempty"` - State string `json:"state,omitempty" yaml:"state,omitempty"` -} - -// ChannelStatus is for printing channel status -type ChannelStatus struct { - ID string `json:"id,omitempty" yaml:"id,omitempty"` - Port string `json:"port,omitempty" yaml:"port,omitempty"` - State string `json:"state,omitempty" yaml:"state,omitempty"` - Order string `json:"order,omitempty" yaml:"order,omitempty"` -} - -// QueryPathStatus takes both ends of a path and queries all the data about the link -func QueryPathStatus(src, dst *Chain, path *Path) (stat *PathStatus, err error) { - stat = &PathStatus{ - Chains: map[string]*ChainStatus{ - src.ChainID: { - Reachable: false, - Height: -1, - Client: &ClientStatus{}, - Connection: &ConnectionStatus{}, - Channel: &ChannelStatus{}, - }, - dst.ChainID: { - Reachable: false, - Height: -1, - Client: &ClientStatus{}, - Connection: &ConnectionStatus{}, - Channel: &ChannelStatus{}, - }, +// QueryPacketCommitments returns an array of packet commitment proofs +func (c *Chain) QueryPacketCommitments(limit, offset uint64) (comRes []*chanTypes.PacketAckCommitment, err error) { + res, err := chanTypes.NewQueryClient(c.CLIContext()).PacketCommitments(context.Background(), &types.QueryPacketCommitmentsRequest{ + PortId: c.PathEnd.PortID, + ChannelId: c.PathEnd.ChannelID, + Pagination: &query.PageRequest{ + Key: []byte(""), + Offset: offset, + Limit: limit, + CountTotal: false, }, - UnrelayedSeq: &RelaySequences{}, - src: src.ChainID, - dst: dst.ChainID, - } - - if err = src.SetPath(path.Src); err != nil { - return - } - if err = dst.SetPath(path.Dst); err != nil { - return - } - - sh, err := NewSyncHeaders(src, dst) - if err != nil { - return - } - - stat.Chains[src.ChainID].Height = int64(sh.GetHeight(src.ChainID)) - stat.Chains[src.ChainID].Reachable = true - - stat.Chains[dst.ChainID].Height = int64(sh.GetHeight(dst.ChainID)) - stat.Chains[dst.ChainID].Reachable = true - - srcCs, err := src.QueryClientState() - if err != nil { - return - } - stat.Chains[src.ChainID].Client.ID = srcCs.ClientState.GetID() - stat.Chains[src.ChainID].Client.Height = srcCs.ClientState.GetLatestHeight() - - dstCs, err := dst.QueryClientState() - if err != nil { - return - } - stat.Chains[dst.ChainID].Client.ID = dstCs.ClientState.GetID() - stat.Chains[dst.ChainID].Client.Height = dstCs.ClientState.GetLatestHeight() - - srcConn, err := src.QueryConnection(int64(sh.GetHeight(src.ChainID))) - if err != nil { - return - } - stat.Chains[src.ChainID].Connection.ID = srcConn.Connection.ID - stat.Chains[src.ChainID].Connection.State = srcConn.Connection.State.String() - - dstConn, err := dst.QueryConnection(int64(sh.GetHeight(dst.ChainID))) - if err != nil { - return - } - stat.Chains[dst.ChainID].Connection.ID = dstConn.Connection.ID - stat.Chains[dst.ChainID].Connection.State = dstConn.Connection.State.String() - - srcChan, err := src.QueryChannel(int64(sh.GetHeight(src.ChainID))) - if err != nil { - return - } - stat.Chains[src.ChainID].Channel.ID = srcChan.Channel.ID - stat.Chains[src.ChainID].Channel.Port = srcChan.Channel.PortID - stat.Chains[src.ChainID].Channel.State = srcChan.Channel.State.String() - stat.Chains[src.ChainID].Channel.Order = srcChan.Channel.Ordering.String() - - dstChan, err := dst.QueryChannel(int64(sh.GetHeight(dst.ChainID))) - if err != nil { - return - } - stat.Chains[dst.ChainID].Channel.ID = dstChan.Channel.ID - stat.Chains[dst.ChainID].Channel.Port = dstChan.Channel.PortID - stat.Chains[dst.ChainID].Channel.State = dstChan.Channel.State.String() - stat.Chains[dst.ChainID].Channel.Order = dstChan.Channel.Ordering.String() - - unrelayed, err := UnrelayedSequences(src, dst, sh) - if err != nil { - return - } - stat.UnrelayedSeq = unrelayed - return stat, err + }) + return res.Commitments, err } // QueryTx takes a transaction hash and returns the transaction -func (c *Chain) QueryTx(hashHex string) (sdk.TxResponse, error) { +func (c *Chain) QueryTx(hashHex string) (*sdk.TxResponse, error) { hash, err := hex.DecodeString(hashHex) if err != nil { - return sdk.TxResponse{}, err + return &sdk.TxResponse{}, err } resTx, err := c.Client.Tx(hash, true) if err != nil { - return sdk.TxResponse{}, err + return &sdk.TxResponse{}, err } // TODO: validate data coming back with local lite client resBlocks, err := c.queryBlocksForTxResults([]*ctypes.ResultTx{resTx}) if err != nil { - return sdk.TxResponse{}, err + return &sdk.TxResponse{}, err } out, err := c.formatTxResult(resTx, resBlocks[resTx.Height]) @@ -837,7 +421,7 @@ func (c *Chain) QueryTxs(height uint64, page, limit int, events []string) (*sdk. return nil, errors.New("limit must greater than 0") } - resTxs, err := c.Client.TxSearch(strings.Join(events, " AND "), true, page, limit, "") + resTxs, err := c.Client.TxSearch(strings.Join(events, " AND "), true, &page, &limit, "") if err != nil { return nil, err } @@ -975,6 +559,10 @@ func (c *Chain) QueryLatestHeader() (out *tmclient.Header, err error) { // QueryHeaderAtHeight returns the header at a given height func (c *Chain) QueryHeaderAtHeight(height int64) (*tmclient.Header, error) { + var ( + page int = 0 + perPage int = 100000 + ) if height <= 0 { return nil, fmt.Errorf("must pass in valid height, %d not valid", height) } @@ -984,7 +572,12 @@ func (c *Chain) QueryHeaderAtHeight(height int64) (*tmclient.Header, error) { return nil, err } - val, err := c.Client.Validators(&height, 0, 10000) + val, err := c.Client.Validators(&height, &page, &perPage) + if err != nil { + return nil, err + } + + protoVal, err := tmtypes.NewValidatorSet(val.Validators).ToProto() if err != nil { return nil, err } @@ -992,8 +585,8 @@ func (c *Chain) QueryHeaderAtHeight(height int64) (*tmclient.Header, error) { return &tmclient.Header{ // NOTE: This is not a SignedHeader // We are missing a lite.Commit type here - SignedHeader: res.SignedHeader, - ValidatorSet: tmtypes.NewValidatorSet(val.Validators), + SignedHeader: res.SignedHeader.ToProto(), + ValidatorSet: protoVal, }, nil } @@ -1034,9 +627,9 @@ func (c *Chain) queryBlocksForTxResults(resTxs []*ctypes.ResultTx) (map[int64]*c // formatTxResults parses the indexed txs into a slice of TxResponse objects. func (c *Chain) formatTxResults(resTxs []*ctypes.ResultTx, - resBlocks map[int64]*ctypes.ResultBlock) ([]sdk.TxResponse, error) { + resBlocks map[int64]*ctypes.ResultBlock) ([]*sdk.TxResponse, error) { var err error - out := make([]sdk.TxResponse, len(resTxs)) + out := make([]*sdk.TxResponse, len(resTxs)) for i := range resTxs { out[i], err = c.formatTxResult(resTxs[i], resBlocks[resTxs[i].Height]) if err != nil { @@ -1047,19 +640,19 @@ func (c *Chain) formatTxResults(resTxs []*ctypes.ResultTx, } // formatTxResult parses a tx into a TxResponse object -func (c *Chain) formatTxResult(resTx *ctypes.ResultTx, resBlock *ctypes.ResultBlock) (sdk.TxResponse, error) { - tx, err := parseTx(c.Amino.Codec, resTx.Tx) +func (c *Chain) formatTxResult(resTx *ctypes.ResultTx, resBlock *ctypes.ResultBlock) (*sdk.TxResponse, error) { + tx, err := parseTx(c.Cdc.JSONMarshaler, resTx.Tx) if err != nil { - return sdk.TxResponse{}, err + return &sdk.TxResponse{}, err } return sdk.NewResponseResultTx(resTx, tx, resBlock.Block.Time.Format(time.RFC3339)), nil } // Takes some bytes and a codec and returns an sdk.Tx -func parseTx(cdc *codec.JSONMarshaler, txBytes []byte) (sdk.Tx, error) { +func parseTx(cdc codec.JSONMarshaler, txBytes []byte) (sdk.Tx, error) { var tx authTypes.StdTx - err := cdc.UnmarshalBinaryBare(txBytes, &tx) + err := cdc.UnmarshalJSON(txBytes, &tx) if err != nil { return nil, err } @@ -1067,10 +660,6 @@ func parseTx(cdc *codec.JSONMarshaler, txBytes []byte) (sdk.Tx, error) { return tx, nil } -func ibcQuerierRoute(module, path string) string { - return fmt.Sprintf("custom/%s/%s/%s", ibctypes.QuerierRoute, module, path) -} - // ParseEvents takes events in the query format and reutrns func ParseEvents(e string) ([]string, error) { eventsStr := strings.Trim(e, "'") diff --git a/relayer/relayPackets.go b/relayer/relayPackets.go index 2741c4ada..f4c119583 100644 --- a/relayer/relayPackets.go +++ b/relayer/relayPackets.go @@ -21,7 +21,7 @@ type relayMsgTimeout struct { seq uint64 timeout uint64 timeoutStamp uint64 - dstRecvRes *chanTypes.QueryNextSequenceReceiveResponse + dstRecvRes *chanTypes.QueryPacketCommitmentResponse pass bool } @@ -39,15 +39,15 @@ func (rp *relayMsgTimeout) Timeout() uint64 { } func (rp *relayMsgTimeout) FetchCommitResponse(src, dst *Chain, sh *SyncHeaders) (err error) { - var dstRecvRes chanTypes.RecvResponse + var dstRecvRes *chanTypes.QueryPacketCommitmentResponse // retry getting commit response until it succeeds if err = retry.Do(func() error { // NOTE: Timeouts currently only work with ORDERED channels for nwo - dstRecvRes, err = dst.QueryNextSeqRecv(int64(sh.GetHeight(dst.ChainID) - 1)) + dstRecvRes, err = dst.QueryPacketCommitment(rp.seq) if err != nil { return err - } else if dstRecvRes.Proof.Proof == nil { + } else if dstRecvRes.Proof == nil { return fmt.Errorf("- [%s]@{%d} - Packet Commitment Proof is nil seq(%d)", dst.ChainID, int64(sh.GetHeight(dst.ChainID)-1), rp.seq) } @@ -57,7 +57,7 @@ func (rp *relayMsgTimeout) FetchCommitResponse(src, dst *Chain, sh *SyncHeaders) return } - rp.dstRecvRes = &dstRecvRes + rp.dstRecvRes = dstRecvRes return } @@ -82,7 +82,7 @@ type relayMsgRecvPacket struct { seq uint64 timeout uint64 timeoutStamp uint64 - dstComRes *CommitmentResponse + dstComRes *chanTypes.QueryPacketCommitmentResponse pass bool } @@ -111,14 +111,14 @@ func (rp *relayMsgRecvPacket) Timeout() uint64 { } func (rp *relayMsgRecvPacket) FetchCommitResponse(src, dst *Chain, sh *SyncHeaders) (err error) { - var dstCommitRes CommitmentResponse + var dstCommitRes *chanTypes.QueryPacketCommitmentResponse // retry getting commit response until it succeeds if err = retry.Do(func() error { - dstCommitRes, err = dst.QueryPacketCommitment(int64(sh.GetHeight(dst.ChainID)-1), int64(rp.seq)) + dstCommitRes, err = dst.QueryPacketCommitment(rp.seq) if err != nil { return err - } else if dstCommitRes.Proof.Proof == nil { + } else if dstCommitRes.Proof == nil { return fmt.Errorf("- [%s]@{%d} - Packet Commitment Proof is nil seq(%d)", dst.ChainID, int64(sh.GetHeight(dst.ChainID)-1), rp.seq) } @@ -128,7 +128,7 @@ func (rp *relayMsgRecvPacket) FetchCommitResponse(src, dst *Chain, sh *SyncHeade return } - rp.dstComRes = &dstCommitRes + rp.dstComRes = dstCommitRes return } @@ -137,7 +137,7 @@ func (rp *relayMsgRecvPacket) Msg(src, dst *Chain) sdk.Msg { return nil } return src.PacketMsg( - dst, rp.packetData, rp.timeout, rp.timeoutStamp, int64(rp.seq), *rp.dstComRes, + dst, rp.packetData, rp.timeout, rp.timeoutStamp, int64(rp.seq), rp.dstComRes, ) } @@ -147,7 +147,7 @@ type relayMsgPacketAck struct { seq uint64 timeout uint64 timeoutStamp uint64 - dstComRes *CommitmentResponse + dstComRes *chanTypes.QueryPacketCommitmentResponse } func (rp *relayMsgPacketAck) Data() []byte { @@ -175,12 +175,12 @@ func (rp *relayMsgPacketAck) Msg(src, dst *Chain) sdk.Msg { } func (rp *relayMsgPacketAck) FetchCommitResponse(src, dst *Chain, sh *SyncHeaders) (err error) { - var dstCommitRes CommitmentResponse + var dstCommitRes *chanTypes.QueryPacketCommitmentResponse if err = retry.Do(func() error { - dstCommitRes, err = dst.QueryPacketAck(int64(sh.GetHeight(dst.ChainID)-1), int64(rp.seq)) + dstCommitRes, err = dst.QueryPacketCommitment(rp.seq) if err != nil { return err - } else if dstCommitRes.Proof.Proof == nil { + } else if dstCommitRes.Proof == nil { return fmt.Errorf("- [%s]@{%d} - Packet Ack Proof is nil seq(%d)", dst.ChainID, int64(sh.GetHeight(dst.ChainID)-1), rp.seq) } @@ -189,6 +189,6 @@ func (rp *relayMsgPacketAck) FetchCommitResponse(src, dst *Chain, sh *SyncHeader dst.Error(err) return } - rp.dstComRes = &dstCommitRes + rp.dstComRes = dstCommitRes return nil } diff --git a/relayer/verifier.go b/relayer/verifier.go index 16183e092..f3a5db5eb 100644 --- a/relayer/verifier.go +++ b/relayer/verifier.go @@ -20,6 +20,7 @@ import ( litehttp "github.com/tendermint/tendermint/light/provider/http" dbs "github.com/tendermint/tendermint/light/store/db" ctypes "github.com/tendermint/tendermint/rpc/core/types" + tmtypes "github.com/tendermint/tendermint/types" ) type header struct { @@ -90,7 +91,12 @@ func (c *Chain) UpdateLiteWithHeader() (*tmclient.Header, error) { return nil, liteError(err) } - return &tmclient.Header{SignedHeader: *sh, ValidatorSet: vs}, nil + protoVal, err := tmtypes.NewValidatorSet(vs.Validators).ToProto() + if err != nil { + return nil, err + } + + return &tmclient.Header{SignedHeader: sh.ToProto(), ValidatorSet: protoVal}, nil } func (c *Chain) UpdateLiteWithHeaderHeight(height int64) (*tmclient.Header, error) { @@ -116,7 +122,12 @@ func (c *Chain) UpdateLiteWithHeaderHeight(height int64) (*tmclient.Header, erro return nil, err } - return &tmclient.Header{SignedHeader: *sh, ValidatorSet: vs}, nil + protoVal, err := tmtypes.NewValidatorSet(vs.Validators).ToProto() + if err != nil { + return nil, err + } + + return &tmclient.Header{SignedHeader: sh.ToProto(), ValidatorSet: protoVal}, nil } // LiteClientWithoutTrust reads the trusted period off of the chain. @@ -194,7 +205,7 @@ func (c *Chain) TrustNodeInitClient(db dbm.DB) (*lite.Client, error) { return nil, err } - lc, err := c.LiteClient(db, c.TrustOptions(height, header.Hash().Bytes())) + lc, err := c.LiteClient(db, c.TrustOptions(height, header.Header.AppHash)) if err != nil { return nil, err } @@ -307,7 +318,12 @@ func (c *Chain) GetLiteSignedHeaderAtHeight(height int64) (*tmclient.Header, err return nil, err } - return &tmclient.Header{SignedHeader: *sh, ValidatorSet: vs}, nil + protoVal, err := tmtypes.NewValidatorSet(vs.Validators).ToProto() + if err != nil { + return nil, err + } + + return &tmclient.Header{SignedHeader: sh.ToProto(), ValidatorSet: protoVal}, nil } // ErrLiteNotInitialized returns the canonical error for a an uninitialized lite client From dd19d03c1bcea0234f867354acc9add39812c48d Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Sun, 30 Aug 2020 10:01:20 -0700 Subject: [PATCH 07/54] COMPILING --- Makefile | 2 +- cmd/config.go | 2 +- cmd/dev.go | 218 +---------------------------------------------- cmd/flags.go | 6 +- cmd/paths.go | 80 ++++++----------- cmd/query.go | 143 +++++++++---------------------- cmd/raw.go | 32 ++++--- cmd/root.go | 5 +- cmd/tx.go | 86 +++++++++---------- relayer/query.go | 2 +- 10 files changed, 136 insertions(+), 440 deletions(-) diff --git a/Makefile b/Makefile index fdf2647e0..9431ba1ec 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//') COMMIT := $(shell git log -1 --format='%H') SDKCOMMIT := $(shell go list -m -u -f '{{.Version}}' github.com/cosmos/cosmos-sdk) -GAIACOMMIT := $(shell go list -m -u -f '{{.Version}}' github.com/cosmos/gaia) +# GAIACOMMIT := $(shell go list -m -u -f '{{.Version}}' github.com/cosmos/gaia) all: ci-lint install ############################################################################### diff --git a/cmd/config.go b/cmd/config.go index 5da14ae3d..e7c7f5552 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -325,7 +325,7 @@ func validateConfig(c *Config) error { } for _, i := range c.Chains { - if err := i.Init(homePath, appCodec, cdc, to, debug); err != nil { + if err := i.Init(homePath, to, debug); err != nil { return fmt.Errorf("did you remember to run 'rly config init' error:%w", err) } } diff --git a/cmd/dev.go b/cmd/dev.go index b961f4ab3..cf03d567d 100644 --- a/cmd/dev.go +++ b/cmd/dev.go @@ -1,14 +1,10 @@ package cmd import ( - "encoding/csv" - "encoding/json" "fmt" "os" - "time" - "github.com/DataDog/datadog-go/statsd" - tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" + // tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" @@ -26,99 +22,10 @@ func devCommand() *cobra.Command { rlyService(), listenCmd(), genesisCmd(), - gozDataCmd(), - gozCSVCmd(), - gozStatsDCmd(), ) return cmd } -func gozCSVCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "goz-csv [chain-id] [file]", - Aliases: []string{"csv"}, - Short: "read in source of truth csv, and enrich on chain w/ team data", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - to, err := readGoZCsv(args[1]) - if err != nil { - return err - } - - cd, err := fetchClientData(args[0]) - if err != nil { - return err - } - w := csv.NewWriter(os.Stdout) - - for _, c := range cd { - info := to[c.ChainID] - if info != nil { - c.TeamInfo = info - if err := w.Write([]string{c.TeamInfo.Name, c.TeamInfo.Address, c.TeamInfo.RPCAddr, c.ClientID}); err != nil { - return err - } - } - } - w.Flush() - - return nil - }, - } - return cmd -} - -func gozStatsDCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "goz-statsd [chain-id] [file] [statsd-host] [statd-port]", - Aliases: []string{"statsd"}, - Short: "read in source of truth csv", - Args: cobra.ExactArgs(4), - RunE: func(cmd *cobra.Command, args []string) error { - - to, err := readGoZCsv(args[1]) - if err != nil { - return err - } - client, err := statsd.New(args[2]) - if err != nil { - return err - } - - cd, err := fetchClientData(args[0]) - if err != nil { - return err - } - for _, c := range cd { - info := to[c.ChainID] - c.TeamInfo = info - c.StatsD(client, args[3]) - } - return nil - }, - } - return cmd -} - -func gozDataCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "goz-dump [chain-id]", - Aliases: []string{"dump", "goz"}, - Short: "fetch the list of chains connected as a CSV dump", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - cd, err := fetchClientData(args[0]) - if err != nil { - return err - } - out, _ := json.Marshal(cd) - fmt.Println(string(out)) - return nil - }, - } - return cmd -} - func genesisCmd() *cobra.Command { cmd := &cobra.Command{ Use: "genesis [chain-id]", @@ -328,126 +235,3 @@ WantedBy=multi-user.target } return cmd } - -func readGoZCsv(path string) (map[string]*teamInfo, error) { - // open the CSV file - f, err := os.Open(path) - if err != nil { - return nil, err - } - defer f.Close() - - // create the csv reader - cs := csv.NewReader(f) - - // ignore the header line - if _, err := cs.Read(); err != nil { - return nil, err - } - - // read all the records into memory - records, err := cs.ReadAll() - if err != nil { - return nil, err - } - - // format the map[chain-id]Info - var out = map[string]*teamInfo{} - for _, r := range records { - out[r[2]] = &teamInfo{r[0], r[1], r[3]} - } - - return out, nil -} - -type teamInfo struct { - Name string `json:"name"` - Address string `json:"address"` - RPCAddr string `json:"rpc-addr"` -} - -func fetchClientData(chainID string) ([]*clientData, error) { - c, err := config.Chains.Get(chainID) - if err != nil { - return nil, err - } - - clients, err := c.QueryClients(1, 1000) - if err != nil { - return nil, err - } - - header, err := c.UpdateLiteWithHeader() - if err != nil { - return nil, err - } - - chans, err := c.QueryChannels(1, 10000) - if err != nil { - return nil, err - } - - var clientDatas = []*clientData{} - for _, cl := range clients { - tmdata, ok := cl.(tmclient.ClientState) - if !ok { - continue - } - cd := &clientData{ - ClientID: cl.GetID(), - ChainID: cl.GetChainID(), - TimeOfLastUpdate: tmdata.LastHeader.Time, - ChannelIDs: []string{}, - } - - if err := c.AddPath(cd.ClientID, dcon, dcha, dpor, dord); err != nil { - return nil, err - } - - conns, err := c.QueryConnectionsUsingClient(header.Height) - if err != nil { - return nil, err - } - - cd.ConnectionIDs = conns.ConnectionPaths - for _, conn := range cd.ConnectionIDs { - for _, ch := range chans { - for _, co := range ch.ConnectionHops { - if co == conn { - cd.ChannelIDs = append(cd.ChannelIDs, ch.ID) - } - } - } - } - - // todo deal with channels - clientDatas = append(clientDatas, cd) - - } - return clientDatas, nil -} - -type clientData struct { - ClientID string `json:"client-id"` - ConnectionIDs []string `json:"connection-ids"` - ChannelIDs []string `json:"channel-ids"` - ChainID string `json:"chain-id"` - TimeOfLastUpdate time.Time `json:"time-last-update"` - TeamInfo *teamInfo `json:"team-info"` -} - -func (cd *clientData) StatsD(cl *statsd.Client, prefix string) { - switch { - case len(cd.ConnectionIDs) != 1: - byt, _ := json.Marshal(cd) - fmt.Fprintf(os.Stderr, "%s", string(byt)) - case len(cd.ChannelIDs) != 1: - byt, _ := json.Marshal(cd) - fmt.Fprintf(os.Stderr, "%s", string(byt)) - // TODO: add more cases here - } - cl.TimeInMilliseconds(fmt.Sprintf("relayer.%s.client", prefix), //nolint:errcheck // ignore error - float64(time.Since(cd.TimeOfLastUpdate).Milliseconds()), - []string{"teamname", cd.TeamInfo.Name, "chain-id", cd.ChainID, - "client-id", cd.ClientID, "connection-id", cd.ConnectionIDs[0], "channelid", cd.ChannelIDs[0]}, 1) -} diff --git a/cmd/flags.go b/cmd/flags.go index 82b7f22f0..2bc122683 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -53,9 +53,9 @@ func heightFlag(cmd *cobra.Command) *cobra.Command { } func paginationFlags(cmd *cobra.Command) *cobra.Command { - cmd.Flags().IntP(flags.FlagPage, "p", 1, "pagination page of light clients to to query for") - cmd.Flags().IntP(flags.FlagLimit, "l", 100, "pagination limit of light clients to query for") - if err := viper.BindPFlag(flags.FlagPage, cmd.Flags().Lookup(flags.FlagPage)); err != nil { + cmd.Flags().Uint64P(flags.FlagOffset, "o", 0, "pagination offset for query") + cmd.Flags().Uint64P(flags.FlagLimit, "l", 100, "pagination limit for query") + if err := viper.BindPFlag(flags.FlagOffset, cmd.Flags().Lookup(flags.FlagOffset)); err != nil { panic(err) } if err := viper.BindPFlag(flags.FlagLimit, cmd.Flags().Lookup(flags.FlagLimit)); err != nil { diff --git a/cmd/paths.go b/cmd/paths.go index 75a0bb36c..0ffe81e9a 100644 --- a/cmd/paths.go +++ b/cmd/paths.go @@ -6,12 +6,9 @@ import ( "io/ioutil" "os" - "github.com/tendermint/tendermint/types/time" - + clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" connTypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" - tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" - ibcTypes "github.com/cosmos/cosmos-sdk/x/ibc/types" "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" "gopkg.in/yaml.v2" @@ -35,28 +32,11 @@ connection, and channel ids from both the source and destination chains as well pathsAddCmd(), pathsGenCmd(), pathsDeleteCmd(), - pathsFindCmd(), ) return cmd } -func pathsFindCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "find", - Short: "WIP: finds any existing paths between any configured chains and outputs them to stdout", - Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { - paths, err := relayer.FindPaths(config.Chains) - if err != nil { - return err - } - return config.Chains[0].Print(paths, false, false) - }, - } - return cmd -} - func pathsGenCmd() *cobra.Command { cmd := &cobra.Command{ Use: "generate [src-chain-id] [src-port] [dst-chain-id] [dst-port] [name]", @@ -121,12 +101,9 @@ func pathsGenCmd() *cobra.Command { for _, c := range srcClients { // TODO: support other client types through a switch here as they become available - clnt, ok := c.(tmclient.ClientState) - if ok && clnt.LastHeader.Commit != nil && clnt.LastHeader.Header != nil { - if clnt.GetChainID() == dst && !clnt.IsFrozen() && - time.Now().Sub(clnt.GetLatestTimestamp()) < clnt.TrustingPeriod { - path.Src.ClientID = clnt.GetID() - } + clnt, _ := clientTypes.UnpackClientState(c.ClientState) + if clnt.GetLatestHeight() != 0 && !clnt.IsFrozen() && clnt.GetChainID() == dst { + path.Src.ClientID = c.ClientId } } @@ -137,12 +114,9 @@ func pathsGenCmd() *cobra.Command { for _, c := range dstClients { // TODO: support other client types through a switch here as they become available - clnt, ok := c.(tmclient.ClientState) - if ok && clnt.LastHeader.Commit != nil && clnt.LastHeader.Header != nil { - if clnt.GetChainID() == src && !clnt.IsFrozen() && - time.Now().Sub(clnt.GetLatestTimestamp()) < clnt.TrustingPeriod { - path.Dst.ClientID = clnt.GetID() - } + clnt, _ := clientTypes.UnpackClientState(c.ClientState) + if clnt.GetLatestHeight() != 0 && !clnt.IsFrozen() && clnt.GetChainID() == src { + path.Dst.ClientID = c.ClientId } } @@ -185,11 +159,11 @@ func pathsGenCmd() *cobra.Command { return err } - var srcCon connTypes.ConnectionEnd + var srcCon *connTypes.IdentifiedConnection for _, c := range srcConns { - if c.ClientID == path.Src.ClientID { + if c.ClientId == path.Src.ClientID { srcCon = c - path.Src.ConnectionID = c.ID + path.Src.ConnectionID = c.Id } } @@ -198,11 +172,11 @@ func pathsGenCmd() *cobra.Command { return err } - var dstCon connTypes.ConnectionEnd + var dstCon *connTypes.IdentifiedConnection for _, c := range dstConns { - if c.ClientID == path.Dst.ClientID { + if c.ClientId == path.Dst.ClientID { dstCon = c - path.Dst.ConnectionID = c.ID + path.Dst.ConnectionID = c.Id } } @@ -211,8 +185,8 @@ func pathsGenCmd() *cobra.Command { // If we have identified a connection, make sure that each end is the // other's counterparty and that the connection is open. In the failure case // we should generate a new connection identifier - dstCpForSrc := srcCon.Counterparty.ConnectionID == dstCon.ID - srcCpForDst := dstCon.Counterparty.ConnectionID == srcCon.ID + dstCpForSrc := srcCon.Counterparty.ConnectionId == dstCon.Id + srcCpForDst := dstCon.Counterparty.ConnectionId == srcCon.Id srcOpen := srcCon.State.String() == OPEN dstOpen := dstCon.State.String() == OPEN if !(dstCpForSrc && srcCpForDst && srcOpen && dstOpen) { @@ -241,11 +215,11 @@ func pathsGenCmd() *cobra.Command { return err } - var srcChan chanTypes.IdentifiedChannel + var srcChan *chanTypes.IdentifiedChannel for _, c := range srcChans { if c.ConnectionHops[0] == path.Src.ConnectionID { srcChan = c - path.Src.ChannelID = c.ID + path.Src.ChannelID = c.ChannelId } } @@ -254,22 +228,22 @@ func pathsGenCmd() *cobra.Command { return err } - var dstChan chanTypes.IdentifiedChannel + var dstChan *chanTypes.IdentifiedChannel for _, c := range dstChans { if c.ConnectionHops[0] == path.Dst.ConnectionID { dstChan = c - path.Dst.ChannelID = c.ID + path.Dst.ChannelID = c.ChannelId } } switch { case path.Src.ChannelID != "" && path.Dst.ChannelID != "": - dstCpForSrc := srcChan.Counterparty.ChannelID == dstChan.ID - srcCpForDst := dstChan.Counterparty.ChannelID == srcChan.ID + dstCpForSrc := srcChan.Counterparty.ChannelId == dstChan.ChannelId + srcCpForDst := dstChan.Counterparty.ChannelId == srcChan.ChannelId srcOpen := srcChan.State.String() == OPEN dstOpen := dstChan.State.String() == OPEN - srcPort := srcChan.PortID == path.Src.PortID - dstPort := dstChan.PortID == path.Dst.PortID + srcPort := srcChan.PortId == path.Src.PortID + dstPort := dstChan.PortId == path.Dst.PortID srcOrder := srcChan.Ordering.String() == path.Src.Order dstOrder := dstChan.Ordering.String() == path.Dst.Order if !(dstCpForSrc && srcCpForDst && srcOpen && dstOpen && srcPort && dstPort && srcOrder && dstOrder) { @@ -394,7 +368,7 @@ func pathsListCmd() *cobra.Command { srcConn, err := ch[src].QueryConnection(srch) dstConn, _ := ch[dst].QueryConnection(dsth) - if err == nil && srcConn.Connection.State == ibcTypes.OPEN && dstConn.Connection.State == ibcTypes.OPEN { + if err == nil && srcConn.Connection.State == connTypes.OPEN && dstConn.Connection.State == connTypes.OPEN { connection = check } else { printPath(i, k, pth, chains, clients, connection, channel) @@ -404,7 +378,7 @@ func pathsListCmd() *cobra.Command { srcChan, err := ch[src].QueryChannel(srch) dstChan, _ := ch[dst].QueryChannel(dsth) - if err == nil && srcChan.Channel.State == ibcTypes.OPEN && dstChan.Channel.State == ibcTypes.OPEN { + if err == nil && srcChan.Channel.State == chanTypes.OPEN && dstChan.Channel.State == chanTypes.OPEN { channel = check } else { printPath(i, k, pth, chains, clients, connection, channel) @@ -497,13 +471,13 @@ func pathsShowCmd() *cobra.Command { srcConn, err := ch[src].QueryConnection(srch) dstConn, _ := ch[dst].QueryConnection(dsth) - if err == nil && srcConn.Connection.State == ibcTypes.OPEN && dstConn.Connection.State == ibcTypes.OPEN { + if err == nil && srcConn.Connection.State == connTypes.OPEN && dstConn.Connection.State == connTypes.OPEN { connection = true } srcChan, err := ch[src].QueryChannel(srch) dstChan, _ := ch[dst].QueryChannel(dsth) - if err == nil && srcChan.Channel.State == ibcTypes.OPEN && dstChan.Channel.State == ibcTypes.OPEN { + if err == nil && srcChan.Channel.State == chanTypes.OPEN && dstChan.Channel.State == chanTypes.OPEN { channel = true } diff --git a/cmd/query.go b/cmd/query.go index 0c748ce1d..d2eccfc87 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -1,17 +1,16 @@ package cmd import ( - "encoding/json" - "fmt" + "context" "strconv" "strings" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/x/auth" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" - "github.com/spf13/viper" ) // queryCmd represents the chain command @@ -24,7 +23,7 @@ func queryCmd() *cobra.Command { } cmd.AddCommand( - queryFullPathCmd(), + // queryFullPathCmd(), queryUnrelayed(), flags.LineBreak, queryAccountCmd(), @@ -136,12 +135,16 @@ func queryAccountCmd() *cobra.Command { return err } - acc, err := auth.NewAccountRetriever(chain.Cdc, chain).GetAccount(addr) + res, err := types.NewQueryClient(chain.CLIContext()).Account( + context.Background(), + &types.QueryAccountRequest{ + Address: addr, + }) if err != nil { return err } - return chain.Print(acc, false, false) + return chain.Print(res, false, false) }, } return cmd @@ -159,37 +162,20 @@ func queryBalanceCmd() *cobra.Command { return err } - jsn, err := cmd.Flags().GetBool(flagJSON) - if err != nil { - return err - } - - var keyName string + var coins sdk.Coins if len(args) == 2 { - keyName = args[1] + coins, err = chain.QueryBalance(args[1]) + } else { + coins, err = chain.QueryBalance(chain.Key) } - - coins, err := chain.QueryBalance(keyName) if err != nil { return err } - var out string - if jsn { - byt, err := json.Marshal(coins) - if err != nil { - return err - } - out = string(byt) - } else { - out = coins.String() - } - - fmt.Println(out) - return nil + return chain.Print(coins, false, false) }, } - return jsonFlag(cmd) + return cmd } func queryHeaderCmd() *cobra.Command { @@ -237,47 +223,27 @@ func queryHeaderCmd() *cobra.Command { } - if viper.GetBool(flagFlags) { - fmt.Printf("-x %x --height %d", header.SignedHeader.Hash(), header.Header.Height) - return nil - } - return chain.Print(header, false, false) }, } - return flagsFlag(cmd) + return cmd } // GetCmdQueryConsensusState defines the command to query the consensus state of // the chain as defined in https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics#query func queryNodeStateCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "node-state [chain-id] [height]", - Short: "Query the consensus state of a client at a given height", - Args: cobra.RangeArgs(1, 2), + Use: "node-state [chain-id]", + Short: "Query the consensus state of a node", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { chain, err := config.Chains.Get(args[0]) if err != nil { return err } - var height int64 - switch len(args) { - case 1: - height, err = chain.QueryLatestHeight() - if err != nil { - return err - } - case 2: - height, err = strconv.ParseInt(args[1], 10, 64) - if err != nil { - fmt.Println("invalid height, defaulting to latest:", args[1]) - height = 0 - } - } - - csRes, err := chain.QueryConsensusState(height) + csRes, _, err := chain.QueryConsensusState() if err != nil { return err } @@ -329,12 +295,12 @@ func queryClientsCmd() *cobra.Command { return err } - page, err := cmd.Flags().GetInt(flags.FlagPage) + page, err := cmd.Flags().GetUint64(flags.FlagOffset) if err != nil { return err } - limit, err := cmd.Flags().GetInt(flags.FlagLimit) + limit, err := cmd.Flags().GetUint64(flags.FlagLimit) if err != nil { return err } @@ -363,12 +329,12 @@ func queryConnections() *cobra.Command { return err } - page, err := cmd.Flags().GetInt(flags.FlagPage) + page, err := cmd.Flags().GetUint64(flags.FlagOffset) if err != nil { return err } - limit, err := cmd.Flags().GetInt(flags.FlagLimit) + limit, err := cmd.Flags().GetUint64(flags.FlagLimit) if err != nil { return err } @@ -466,12 +432,12 @@ func queryConnectionChannels() *cobra.Command { return err } - page, err := cmd.Flags().GetInt(flags.FlagPage) + page, err := cmd.Flags().GetUint64(flags.FlagOffset) if err != nil { return err } - limit, err := cmd.Flags().GetInt(flags.FlagLimit) + limit, err := cmd.Flags().GetUint64(flags.FlagLimit) if err != nil { return err } @@ -532,12 +498,12 @@ func queryChannels() *cobra.Command { return err } - page, err := cmd.Flags().GetInt(flags.FlagPage) + page, err := cmd.Flags().GetUint64(flags.FlagOffset) if err != nil { return err } - limit, err := cmd.Flags().GetInt(flags.FlagLimit) + limit, err := cmd.Flags().GetUint64(flags.FlagLimit) if err != nil { return err } @@ -601,17 +567,12 @@ func queryPacketCommitment() *cobra.Command { return err } - height, err := chain.QueryLatestHeight() + seq, err := strconv.ParseUint(args[3], 10, 64) if err != nil { return err } - seq, err := strconv.ParseInt(args[3], 10, 64) - if err != nil { - return err - } - - res, err := chain.QueryPacketCommitment(height, seq) + res, err := chain.QueryPacketCommitment(seq) if err != nil { return err } @@ -638,17 +599,12 @@ func queryPacketAck() *cobra.Command { return err } - height, err := chain.QueryLatestHeight() + seq, err := strconv.ParseUint(args[3], 10, 64) if err != nil { return err } - seq, err := strconv.ParseInt(args[3], 10, 64) - if err != nil { - return err - } - - res, err := chain.QueryPacketAck(height, seq) + res, err := chain.QueryPacketCommitment(seq) if err != nil { return err } @@ -690,44 +646,21 @@ func queryUnrelayed() *cobra.Command { return err } - sp, err := relayer.UnrelayedSequences(c[src], c[dst], sh) - if err != nil { - return err - } - - return c[src].Print(sp, false, false) - }, - } - - return cmd -} - -func queryFullPathCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "full-path [path-name]", - Aliases: []string{"link", "connect", "path", "pth"}, - Short: "Query for the status of clients, connections, channels and packets on a path", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - path, err := config.Paths.Get(args[0]) - if err != nil { - return err - } - - src, dst := path.Src.ChainID, path.Dst.ChainID - c, err := config.Chains.Gets(src, dst) + strat, err := path.GetStrategy() if err != nil { return err } - stat, err := relayer.QueryPathStatus(c[src], c[dst], path) + sp, err := strat.UnrelayedSequencesOrdered(c[src], c[dst], sh) if err != nil { return err } - return c[src].Print(stat, false, false) + return c[src].Print(sp, false, false) }, } return cmd } + +// TODO: Reimplement query path status diff --git a/cmd/raw.go b/cmd/raw.go index c73242639..b95b6c8c4 100644 --- a/cmd/raw.go +++ b/cmd/raw.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" + clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" @@ -169,20 +170,24 @@ func connTry() *cobra.Command { // NOTE: We query connection at height - 1 because of the way tendermint returns // proofs the commit for height n is contained in the header of height n + 1 - dstConnState, err := chains[dst].QueryConnection(hs[dst].Height - 1) + dstConnState, err := chains[dst].QueryConnection(hs[dst].Header.Height - 1) if err != nil { return err } // We are querying the state of the client for src on dst and finding the height - dstClientState, err := chains[dst].QueryClientState() + dstClientStateRes, err := chains[dst].QueryClientState() if err != nil { return err } - dstCsHeight := int64(dstClientState.ClientState.GetLatestHeight()) + dstClientState, err := clientTypes.UnpackClientState(dstClientStateRes.ClientState) + if err != nil { + return err + } + dstCsHeight := int64(dstClientState.GetLatestHeight()) // Then we need to query the consensus state for src at that height on dst - dstConsState, err := chains[dst].QueryClientConsensusState(hs[dst].Height-1, dstCsHeight) + dstConsState, err := chains[dst].QueryClientConsensusState(uint64(dstCsHeight)) if err != nil { return err } @@ -226,20 +231,21 @@ func connAck() *cobra.Command { // NOTE: We query connection at height - 1 because of the way tendermint returns // proofs the commit for height n is contained in the header of height n + 1 - dstState, err := chains[dst].QueryConnection(hs[dst].Height - 1) + dstState, err := chains[dst].QueryConnection(hs[dst].Header.Height - 1) if err != nil { return err } // We are querying the state of the client for src on dst and finding the height - dstClientState, err := chains[dst].QueryClientState() + dstClientStateResponse, err := chains[dst].QueryClientState() if err != nil { return err } - dstCsHeight := int64(dstClientState.ClientState.GetLatestHeight()) + dstClientState, _ := clientTypes.UnpackClientState(dstClientStateResponse.ClientState) + dstCsHeight := int64(dstClientState.GetLatestHeight()) // Then we need to query the consensus state for src at that height on dst - dstConsState, err := chains[dst].QueryClientConsensusState(hs[dst].Height-1, dstCsHeight) + dstConsState, err := chains[dst].QueryClientConsensusState(uint64(dstCsHeight)) if err != nil { return err } @@ -282,7 +288,7 @@ func connConfirm() *cobra.Command { // NOTE: We query connection at height - 1 because of the way tendermint returns // proofs the commit for height n is contained in the header of height n + 1 - dstState, err := chains[dst].QueryConnection(hs[dst].Height - 1) + dstState, err := chains[dst].QueryConnection(hs[dst].Header.Height - 1) if err != nil { return err } @@ -397,7 +403,7 @@ func chanTry() *cobra.Command { return err } - dstChanState, err := chains[dst].QueryChannel(dstHeader.Height - 1) + dstChanState, err := chains[dst].QueryChannel(dstHeader.Header.Height - 1) if err != nil { return err } @@ -439,7 +445,7 @@ func chanAck() *cobra.Command { return err } - dstChanState, err := chains[dst].QueryChannel(dstHeader.Height - 1) + dstChanState, err := chains[dst].QueryChannel(dstHeader.Header.Height - 1) if err != nil { return err } @@ -481,7 +487,7 @@ func chanConfirm() *cobra.Command { return err } - dstChanState, err := chains[dst].QueryChannel(dstHeader.Height - 1) + dstChanState, err := chains[dst].QueryChannel(dstHeader.Header.Height - 1) if err != nil { return err } @@ -588,7 +594,7 @@ func chanCloseConfirm() *cobra.Command { return err } - dstChanState, err := chains[dst].QueryChannel(dstHeader.Height - 1) + dstChanState, err := chains[dst].QueryChannel(dstHeader.Header.Height - 1) if err != nil { return err } diff --git a/cmd/root.go b/cmd/root.go index f0b3d63e2..29d164bbe 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -22,7 +22,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" - codecstd "github.com/cosmos/cosmos-sdk/std" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -37,8 +36,8 @@ var ( debug bool config *Config defaultHome = os.ExpandEnv("$HOME/.relayer") - cdc *codec.Codec - appCodec *codecstd.Codec + cdc *codec.LegacyAmino + appCodec *codec.JSONMarshaler // Default identifiers for dummy usage dcli = "defaultclientid" diff --git a/cmd/tx.go b/cmd/tx.go index db8a2df4f..33bc35957 100644 --- a/cmd/tx.go +++ b/cmd/tx.go @@ -16,7 +16,6 @@ limitations under the License. package cmd import ( - "fmt" "strings" "github.com/cosmos/cosmos-sdk/client/flags" @@ -47,7 +46,7 @@ func transactionCmd() *cobra.Command { closeChannelCmd(), flags.LineBreak, rawTransactionCmd(), - sendPacketCmd(), + // sendPacketCmd(), ) return cmd @@ -198,13 +197,13 @@ func relayMsgsCmd() *cobra.Command { return err } - sp, err := relayer.UnrelayedSequences(c[src], c[dst], sh) + path := config.Paths.MustGet(args[0]) + strategy, err := GetStrategyWithOptions(cmd, path.MustGetStrategy()) if err != nil { return err } - path := config.Paths.MustGet(args[0]) - strategy, err := GetStrategyWithOptions(cmd, path.MustGetStrategy()) + sp, err := strategy.UnrelayedSequencesOrdered(c[src], c[dst], sh) if err != nil { return err } @@ -220,41 +219,42 @@ func relayMsgsCmd() *cobra.Command { return strategyFlag(cmd) } -func sendPacketCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "send-packet [src-chain-id] [dst-chain-id] [packet-data]", - Aliases: []string{"pkt", "sp"}, - Short: "send a raw packet from a source chain to a destination chain", - Long: "This sends packet-data (default: stdin) from a relayer's configured wallet on chain src to chain dst", - Args: cobra.RangeArgs(2, 3), - RunE: func(cmd *cobra.Command, args []string) error { - src, dst := args[0], args[1] - c, err := config.Chains.Gets(src, dst) - if err != nil { - return err - } - - pth, err := cmd.Flags().GetString(flagPath) - if err != nil { - return err - } - - if _, err = setPathsFromArgs(c[src], c[dst], pth); err != nil { - return err - } - - var packetData string - if len(args) < 3 { - // Reading from stdin. - if _, err := fmt.Scanln(&packetData); err != nil { - return err - } - } else { - packetData = args[2] - } - - return c[src].SendPacket(c[dst], []byte(packetData)) - }, - } - return pathFlag(cmd) -} +// TODO: Reimplement send packet +// func sendPacketCmd() *cobra.Command { +// cmd := &cobra.Command{ +// Use: "send-packet [src-chain-id] [dst-chain-id] [packet-data]", +// Aliases: []string{"pkt", "sp"}, +// Short: "send a raw packet from a source chain to a destination chain", +// Long: "This sends packet-data (default: stdin) from a relayer's configured wallet on chain src to chain dst", +// Args: cobra.RangeArgs(2, 3), +// RunE: func(cmd *cobra.Command, args []string) error { +// src, dst := args[0], args[1] +// c, err := config.Chains.Gets(src, dst) +// if err != nil { +// return err +// } + +// pth, err := cmd.Flags().GetString(flagPath) +// if err != nil { +// return err +// } + +// if _, err = setPathsFromArgs(c[src], c[dst], pth); err != nil { +// return err +// } + +// var packetData string +// if len(args) < 3 { +// // Reading from stdin. +// if _, err := fmt.Scanln(&packetData); err != nil { +// return err +// } +// } else { +// packetData = args[2] +// } + +// return c[src].SendPacket(c[dst], []byte(packetData)) +// }, +// } +// return pathFlag(cmd) +// } diff --git a/relayer/query.go b/relayer/query.go index 8d32c5e85..34be06f95 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -77,7 +77,7 @@ func (c *Chain) QueryBalance(keyName string) (sdk.Coins, error) { // QueryConsensusState returns a consensus state for a given chain to be used as a // client in another chain, fetches latest height when passed 0 as arg -func (c *Chain) QueryConsensusState(height int64) (*tmclient.ConsensusState, int64, error) { +func (c *Chain) QueryConsensusState() (*tmclient.ConsensusState, int64, error) { return clientUtils.QueryNodeConsensusState(c.CLIContext()) } From 7e5029f426ee5793d5bd7800718abd4072139ca3 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Sun, 30 Aug 2020 10:34:57 -0700 Subject: [PATCH 08/54] Reimplement connection messages --- cmd/raw.go | 6 +-- relayer/connection-tx.go | 20 ++++++--- relayer/pathEnd.go | 88 ++++++++++++++++++++++++++-------------- relayer/query.go | 10 ++--- 4 files changed, 79 insertions(+), 45 deletions(-) diff --git a/cmd/raw.go b/cmd/raw.go index b95b6c8c4..4457c666a 100644 --- a/cmd/raw.go +++ b/cmd/raw.go @@ -194,8 +194,8 @@ func connTry() *cobra.Command { txs := []sdk.Msg{ chains[src].PathEnd.UpdateClient(hs[dst], chains[src].MustGetAddress()), - chains[src].PathEnd.ConnTry(chains[dst].PathEnd, dstConnState, - dstConsState, dstCsHeight, chains[src].MustGetAddress()), + chains[src].PathEnd.ConnTry(chains[dst].PathEnd, dstClientStateRes, dstConnState, + dstConsState, chains[src].MustGetAddress()), } return sendAndPrint(txs, chains[src], cmd) @@ -251,7 +251,7 @@ func connAck() *cobra.Command { } txs := []sdk.Msg{ - chains[src].PathEnd.ConnAck(dstState, dstConsState, dstCsHeight, chains[src].MustGetAddress()), + chains[src].PathEnd.ConnAck(chains[dst].PathEnd, dstClientStateResponse, dstState, dstConsState, chains[src].MustGetAddress()), chains[src].PathEnd.UpdateClient(hs[dst], chains[src].MustGetAddress()), } diff --git a/relayer/connection-tx.go b/relayer/connection-tx.go index ae81e0afe..d414458e0 100644 --- a/relayer/connection-tx.go +++ b/relayer/connection-tx.go @@ -5,6 +5,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" + clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" ) @@ -100,8 +101,17 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { return nil, err } + srcCS, err := clientTypes.UnpackClientState(cs[scid].ClientState) + if err != nil { + return nil, err + } + dstCS, err := clientTypes.UnpackClientState(cs[dcid].ClientState) + if err != nil { + return nil, err + } + // Store the heights - srcConsH, dstConsH := int64(cs[scid].GetLatestHeight()), int64(cs[dcid].GetLatestHeight()) + srcConsH, dstConsH := int64(srcCS.GetLatestHeight()), int64(dstCS.GetLatestHeight()) // NOTE: We query connection at height - 1 because of the way tendermint returns // proofs the commit for height n is contained in the header of height n + 1 @@ -125,7 +135,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { } out.Src = append(out.Src, c.PathEnd.UpdateClient(hs[dcid], c.MustGetAddress()), - c.PathEnd.ConnTry(dst.PathEnd, conn[dcid], cons[dcid], dstConsH, c.MustGetAddress()), + c.PathEnd.ConnTry(dst.PathEnd, cs[dcid], conn[dcid], cons[dcid], c.MustGetAddress()), ) // Handshake has started on src (1 step done), relay `connOpenTry` and `updateClient` on dst @@ -135,7 +145,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { } out.Dst = append(out.Dst, dst.PathEnd.UpdateClient(hs[scid], dst.MustGetAddress()), - dst.PathEnd.ConnTry(c.PathEnd, conn[scid], cons[scid], srcConsH, dst.MustGetAddress()), + dst.PathEnd.ConnTry(c.PathEnd, cs[scid], conn[scid], cons[scid], dst.MustGetAddress()), ) // Handshake has started on src end (2 steps done), relay `connOpenAck` and `updateClient` to dst end @@ -145,7 +155,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { } out.Dst = append(out.Dst, dst.PathEnd.UpdateClient(hs[scid], dst.MustGetAddress()), - dst.PathEnd.ConnAck(conn[scid], cons[scid], srcConsH, dst.MustGetAddress()), + dst.PathEnd.ConnAck(c.PathEnd, cs[scid], conn[scid], cons[scid], dst.MustGetAddress()), ) // Handshake has started on dst end (2 steps done), relay `connOpenAck` and `updateClient` to src end @@ -155,7 +165,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { } out.Src = append(out.Src, c.PathEnd.UpdateClient(hs[dcid], c.MustGetAddress()), - c.PathEnd.ConnAck(conn[dcid], cons[dcid], dstConsH, c.MustGetAddress()), + c.PathEnd.ConnAck(dst.PathEnd, cs[dcid], conn[dcid], cons[dcid], c.MustGetAddress()), ) // Handshake has confirmed on dst (3 steps done), relay `connOpenConfirm` and `updateClient` to src end diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index 1dfb6e446..1a1a2d5d0 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -86,41 +86,67 @@ func (pe *PathEnd) ConnInit(dst *PathEnd, signer sdk.AccAddress) sdk.Msg { // ConnTry creates a MsgConnectionOpenTry // NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE -// TODO: Need to do some more looking here -func (pe *PathEnd) ConnTry(dst *PathEnd, dstConnState *connTypes.QueryConnectionResponse, - dstConsState *clientTypes.QueryConsensusStateResponse, dstCsHeight int64, signer sdk.AccAddress) sdk.Msg { - return &connTypes.MsgConnectionOpenTry{} - // TODO: reimplement - // return connTypes.NewMsgConnectionOpenTry( - // pe.ConnectionID, - // pe.ClientID, - // dst.ConnectionID, - // dst.ClientID, - // defaultChainPrefix, - // defaultIBCVersions, - // dstConnState.Proof, - // dstConsState.Proof, - // dstConnState.ProofHeight+1, - // uint64(dstCsHeight), - // signer, - // ) +func (pe *PathEnd) ConnTry( + dst *PathEnd, + dstClientState *clientTypes.QueryClientStateResponse, + dstConnState *connTypes.QueryConnectionResponse, + dstConsState *clientTypes.QueryConsensusStateResponse, + signer sdk.AccAddress, +) sdk.Msg { + cs, err := clientTypes.UnpackClientState(dstClientState.ClientState) + if err != nil { + panic(err) + } + css, err := clientTypes.UnpackConsensusState(dstConsState.ConsensusState) + if err != nil { + panic(err) + } + return connTypes.NewMsgConnectionOpenTry( + pe.ConnectionID, + pe.ClientID, + dst.ConnectionID, + dst.ClientID, + cs, + defaultChainPrefix, + defaultIBCVersions, + dstConnState.Proof, + dstClientState.Proof, + dstConsState.Proof, + dstConsState.ProofHeight+1, + css.GetHeight(), + signer, + ) + } // ConnAck creates a MsgConnectionOpenAck // NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE -func (pe *PathEnd) ConnAck(dstConnState *connTypes.QueryConnectionResponse, dstConsState *clientTypes.QueryConsensusStateResponse, - dstCsHeight int64, signer sdk.AccAddress) sdk.Msg { - return &connTypes.MsgConnectionOpenAck{} - // TODO: reimplement - // return connTypes.NewMsgConnectionOpenAck( - // pe.ConnectionID, - // dstConnState.Proof, - // dstConsState.Proof, - // dstConnState.ProofHeight+1, - // uint64(dstCsHeight), - // defaultIBCVersion, - // signer, - // ) +func (pe *PathEnd) ConnAck( + dst *PathEnd, + dstClientState *clientTypes.QueryClientStateResponse, + dstConnState *connTypes.QueryConnectionResponse, + dstConsState *clientTypes.QueryConsensusStateResponse, + signer sdk.AccAddress, +) sdk.Msg { + cs, err := clientTypes.UnpackClientState(dstClientState.ClientState) + if err != nil { + panic(err) + } + css, err := clientTypes.UnpackConsensusState(dstConsState.ConsensusState) + if err != nil { + panic(err) + } + return connTypes.NewMsgConnectionOpenAck( + pe.ConnectionID, + cs, + dstConnState.Proof, + dstClientState.Proof, + dstConsState.Proof, + dstConsState.ProofHeight, + css.GetHeight(), + defaultIBCVersion, + signer, + ) } // ConnConfirm creates a MsgConnectionOpenAck diff --git a/relayer/query.go b/relayer/query.go index 34be06f95..032b7ac68 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -16,7 +16,6 @@ import ( authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" clientUtils "github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/utils" - clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" connUtils "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils" connTypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" @@ -139,14 +138,14 @@ func (c *Chain) QueryClientState() (*clientTypes.QueryClientStateResponse, error type cstates struct { sync.Mutex - Map map[string]clientexported.ClientState + Map map[string]*clientTypes.QueryClientStateResponse Errs errs } // QueryClientStatePair returns a pair of connection responses -func QueryClientStatePair(src, dst *Chain) (map[string]clientexported.ClientState, error) { +func QueryClientStatePair(src, dst *Chain) (map[string]*clientTypes.QueryClientStateResponse, error) { hs := &cstates{ - Map: make(map[string]clientexported.ClientState), + Map: make(map[string]*clientTypes.QueryClientStateResponse), Errs: []error{}, } @@ -163,9 +162,8 @@ func QueryClientStatePair(src, dst *Chain) (map[string]clientexported.ClientStat hs.Errs = append(hs.Errs, err) hs.Unlock() } - cs, _ := clientTypes.UnpackClientState(conn.ClientState) hs.Lock() - hs.Map[c.ChainID] = cs + hs.Map[c.ChainID] = conn hs.Unlock() wg.Done() }(hs, &wg, chain) From 9c04ca599193af78e3645c6a075f53095c88f416 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Sun, 30 Aug 2020 12:11:24 -0700 Subject: [PATCH 09/54] Refactor two-chainz to call one-chain and get dev-env working again --- dev-env | 6 --- docker-compose.yaml | 8 ++-- relayer/query.go | 2 +- scripts/config-relayer | 4 +- scripts/one-chain | 61 ++++++++++++++++++++++++++++++ scripts/three-chainz | 84 +++--------------------------------------- scripts/two-chainz | 71 ++++++----------------------------- test/test_chains.go | 16 ++++++-- test/test_queries.go | 24 +++++++----- test/test_setup.go | 2 +- 10 files changed, 112 insertions(+), 166 deletions(-) create mode 100755 scripts/one-chain diff --git a/dev-env b/dev-env index 0aab77735..bd0ad95a7 100755 --- a/dev-env +++ b/dev-env @@ -17,9 +17,3 @@ cd $RELAYER_DIR rm -rf $RELAYER_CONF &> /dev/null bash scripts/two-chainz "local" "skip" bash scripts/config-relayer "skip" -sleep 2 -rly tx link demo -o 3s -d -rly tx raw xfer-send ibc0 ibc1 10000n0token true $(rly ch addr ibc1) -rly tx raw xfer-send ibc0 ibc1 10000n0token true $(rly ch addr ibc1) -rly tx raw xfer-send ibc1 ibc0 10000n0token true $(rly ch addr ibc0) -rly tx raw xfer-send ibc1 ibc0 10000n0token true $(rly ch addr ibc0) diff --git a/docker-compose.yaml b/docker-compose.yaml index b05a0dadb..136f885c3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,28 +1,28 @@ version: "3.7" services: ibc0: - image: "jackzampolin/gaiatest:master" + image: "jackzampolin/gaiatest:gaiav3.0" ports: - "46657:26657" command: - "ibc0" - "${IBC0ADDR}" ibc1: - image: "jackzampolin/gaiatest:master" + image: "jackzampolin/gaiatest:gaiav3.0" ports: - "46658:26657" command: - "ibc1" - "${IBC1ADDR}" ibc2: - image: "jackzampolin/gaiatest:master" + image: "jackzampolin/gaiatest:gaiav3.0" ports: - "46659:26657" command: - "ibc2" - "${IBC2ADDR}" ibc3: - image: "jackzampolin/gaiatest:master" + image: "jackzampolin/gaiatest:gaiav3.0" ports: - "46660:26657" command: diff --git a/relayer/query.go b/relayer/query.go index 032b7ac68..dcfe95058 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -558,7 +558,7 @@ func (c *Chain) QueryLatestHeader() (out *tmclient.Header, err error) { // QueryHeaderAtHeight returns the header at a given height func (c *Chain) QueryHeaderAtHeight(height int64) (*tmclient.Header, error) { var ( - page int = 0 + page int = 1 perPage int = 100000 ) if height <= 0 { diff --git a/scripts/config-relayer b/scripts/config-relayer index d3e62c801..2f270ac69 100755 --- a/scripts/config-relayer +++ b/scripts/config-relayer @@ -30,8 +30,8 @@ echo "Generating rly configurations..." rly config init rly config add-dir configs/demo/ -SEED0=$(jq -r '.secret' $GAIA_CONF/ibc0/n0/gaiacli/key_seed.json) -SEED1=$(jq -r '.secret' $GAIA_CONF/ibc1/n0/gaiacli/key_seed.json) +SEED0=$(jq -r '.mnemonic' $GAIA_CONF/ibc0/key_seed.json) +SEED1=$(jq -r '.mnemonic' $GAIA_CONF/ibc1/key_seed.json) echo echo "Key $(rly keys restore ibc0 testkey "$SEED0") imported from ibc0 to relayer..." echo "Key $(rly keys restore ibc1 testkey "$SEED1") imported from ibc1 to relayer..." diff --git a/scripts/one-chain b/scripts/one-chain new file mode 100755 index 000000000..47d472076 --- /dev/null +++ b/scripts/one-chain @@ -0,0 +1,61 @@ +#!/bin/sh +# USAGE: ./one-chain test-chain-id ./data 26657 26656 + +CHAINID=$1 +CHAINDIR=$2 +RPCPORT=$3 +P2PPORT=$4 +PROFPORT=$5 +GRPCPORT=$6 + +if [ -z "$1" ]; then + echo "Need to input chain id..." + exit 1 +fi + +if [ -z "$2" ]; then + echo "Need to input directory to create files in..." + exit 1 +fi + +if [ -z "$3" ]; then + echo "Need to input rpc port (e.g. 26657)..." + exit 1 +fi + +if [ -z "$4" ]; then + echo "Need to input p2p port (e.g. 26656)..." + exit 1 +fi + +if [ -z "$5" ]; then + echo "Need to input profiling server port (e.g. 6060)..." + exit 1 +fi + +if [ -z "$6" ]; then + echo "Need to input grpc server port (e.g. 9090)..." + exit 1 +fi + +echo "Creating gaiad instance with home=$CHAINDIR chain-id=$CHAINID p2p=:$P2PPORT rpc=:$RPCPORT..." +# Build genesis file incl account for passed address +coins="100000000000stake,100000000000samoleans" +gaiad --home $CHAINDIR/$CHAINID --chain-id $CHAINID init $CHAINID &> /dev/null +gaiad --home $CHAINDIR/$CHAINID keys add validator --keyring-backend="test" > $CHAINDIR/$CHAINID/validator_seed.json 2> /dev/null +gaiad --home $CHAINDIR/$CHAINID keys add user --keyring-backend="test" --output json > $CHAINDIR/$CHAINID/key_seed.json 2> /dev/null +gaiad --home $CHAINDIR/$CHAINID add-genesis-account validator $coins --keyring-backend="test" &> /dev/null +gaiad --home $CHAINDIR/$CHAINID add-genesis-account user $coins --keyring-backend="test" &> /dev/null +gaiad --home $CHAINDIR/$CHAINID gentx validator --keyring-backend="test" --chain-id $CHAINID &> /dev/null +gaiad --home $CHAINDIR/$CHAINID collect-gentxs &> /dev/null + +# Set proper defaults and change ports +sed -i '' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPCPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml +sed -i '' 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml +sed -i '' 's#"localhost:6060"#"localhost:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml +sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml +sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml +sed -i '' 's/index_all_keys = false/index_all_keys = true/g' $CHAINDIR/$CHAINID/config/config.toml + +# Start the gaia +gaiad --home $CHAINDIR/$CHAINID start --pruning=nothing --grpc.address="0.0.0.0:$GRPCPORT" > $CHAINDIR/$CHAINID.log 2>&1 & diff --git a/scripts/three-chainz b/scripts/three-chainz index fcc838a4d..bd060f453 100755 --- a/scripts/three-chainz +++ b/scripts/three-chainz @@ -9,7 +9,7 @@ if [[ ! -d $GOPATH ]] || [[ ! -d $GOBIN ]] || [[ ! -x "$(which go)" ]]; then fi GAIA_REPO="$GOPATH/src/github.com/cosmos/gaia" -GAIA_BRANCH=goz-phase-2 +GAIA_BRANCH=gaiav3.0 GAIA_DATA="$(pwd)/data" # ARGS: @@ -75,82 +75,8 @@ chainid1=ibc1 chainid2=ibc2 echo "Generating gaia configurations..." -mkdir -p $GAIA_DATA && cd $GAIA_DATA -echo -e "\n" | gaiad testnet -o $chainid0 --v 1 --chain-id $chainid0 --node-dir-prefix n --keyring-backend test &> /dev/null -echo -e "\n" | gaiad testnet -o $chainid1 --v 1 --chain-id $chainid1 --node-dir-prefix n --keyring-backend test &> /dev/null -echo -e "\n" | gaiad testnet -o $chainid2 --v 1 --chain-id $chainid2 --node-dir-prefix n --keyring-backend test &> /dev/null +mkdir -p $GAIA_DATA && cd $GAIA_DATA && cd ../ +./scripts/one-chain $chainid0 ./data 26657 26656 6060 9090 +./scripts/one-chain $chainid1 ./data 26557 26556 6061 9091 +./scripts/one-chain $chainid1 ./data 25557 25556 6062 9092 -cfgpth="n0/gaiad/config/config.toml" -if [ "$(uname)" = "Linux" ]; then - # TODO: Just index *some* specified tags, not all - sed -i 's/index_all_keys = false/index_all_keys = true/g' $chainid0/$cfgpth - sed -i 's/index_all_keys = false/index_all_keys = true/g' $chainid1/$cfgpth - sed -i 's/index_all_keys = false/index_all_keys = true/g' $chainid2/$cfgpth - - # Set proper defaults and change ports - sed -i 's/"leveldb"/"goleveldb"/g' $chainid0/$cfgpth - sed -i 's/"leveldb"/"goleveldb"/g' $chainid1/$cfgpth - sed -i 's/"leveldb"/"goleveldb"/g' $chainid2/$cfgpth - - sed -i 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:26556"#g' $chainid1/$cfgpth - sed -i 's#"tcp://0.0.0.0:26657"#"tcp://0.0.0.0:26557"#g' $chainid1/$cfgpth - sed -i 's#"localhost:6060"#"localhost:6061"#g' $chainid1/$cfgpth - sed -i 's#"tcp://127.0.0.1:26658"#"tcp://127.0.0.1:26558"#g' $chainid1/$cfgpth - - sed -i 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:25556"#g' $chainid2/$cfgpth - sed -i 's#"tcp://0.0.0.0:26657"#"tcp://0.0.0.0:25557"#g' $chainid2/$cfgpth - sed -i 's#"localhost:6060"#"localhost:6062"#g' $chainid2/$cfgpth - sed -i 's#"tcp://127.0.0.1:26658"#"tcp://127.0.0.1:25558"#g' $chainid2/$cfgpth - - # Make blocks run faster than normal - sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $chainid0/$cfgpth - sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $chainid1/$cfgpth - sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $chainid2/$cfgpth - - sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $chainid0/$cfgpth - sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $chainid1/$cfgpth - sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $chainid2/$cfgpth -else - # TODO: Just index *some* specified tags, not all - sed -i '' 's/index_all_keys = false/index_all_keys = true/g' $chainid0/$cfgpth - sed -i '' 's/index_all_keys = false/index_all_keys = true/g' $chainid1/$cfgpth - sed -i '' 's/index_all_keys = false/index_all_keys = true/g' $chainid2/$cfgpth - - # Set proper defaults and change ports - sed -i '' 's/"leveldb"/"goleveldb"/g' $chainid0/$cfgpth - sed -i '' 's/"leveldb"/"goleveldb"/g' $chainid1/$cfgpth - sed -i '' 's/"leveldb"/"goleveldb"/g' $chainid2/$cfgpth - sed -i '' 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:26556"#g' $chainid1/$cfgpth - sed -i '' 's#"tcp://0.0.0.0:26657"#"tcp://0.0.0.0:26557"#g' $chainid1/$cfgpth - sed -i '' 's#"localhost:6060"#"localhost:6061"#g' $chainid1/$cfgpth - sed -i '' 's#"tcp://127.0.0.1:26658"#"tcp://127.0.0.1:26558"#g' $chainid1/$cfgpth - sed -i '' 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:25556"#g' $chainid2/$cfgpth - sed -i '' 's#"tcp://0.0.0.0:26657"#"tcp://0.0.0.0:25557"#g' $chainid2/$cfgpth - sed -i '' 's#"localhost:6060"#"localhost:6062"#g' $chainid2/$cfgpth - sed -i '' 's#"tcp://127.0.0.1:26658"#"tcp://127.0.0.1:25558"#g' $chainid2/$cfgpth - - # Make blocks run faster than normal - sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $chainid0/$cfgpth - sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $chainid1/$cfgpth - sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $chainid2/$cfgpth - - sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $chainid0/$cfgpth - sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $chainid1/$cfgpth - sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $chainid2/$cfgpth -fi - -gclpth="n0/gaiacli/" -gaiacli config --home $chainid0/$gclpth chain-id $chainid0 &> /dev/null -gaiacli config --home $chainid1/$gclpth chain-id $chainid1 &> /dev/null -gaiacli config --home $chainid2/$gclpth chain-id $chainid2 &> /dev/null -gaiacli config --home $chainid0/$gclpth output json &> /dev/null -gaiacli config --home $chainid1/$gclpth output json &> /dev/null -gaiacli config --home $chainid2/$gclpth output json &> /dev/null -gaiacli config --home $chainid0/$gclpth node http://localhost:26657 &> /dev/null -gaiacli config --home $chainid1/$gclpth node http://localhost:26557 &> /dev/null -gaiacli config --home $chainid2/$gclpth node http://localhost:25557 &> /dev/null - -echo "Starting Gaiad instances..." -gaiad --home $GAIA_DATA/$chainid0/n0/gaiad start --pruning=nothing > $chainid0.log 2>&1 & -gaiad --home $GAIA_DATA/$chainid1/n0/gaiad start --pruning=nothing > $chainid1.log 2>&1 & -gaiad --home $GAIA_DATA/$chainid2/n0/gaiad start --pruning=nothing > $chainid2.log 2>&1 & diff --git a/scripts/two-chainz b/scripts/two-chainz index a2e64e768..0bbd94431 100755 --- a/scripts/two-chainz +++ b/scripts/two-chainz @@ -1,5 +1,7 @@ #!/bin/bash +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + # Ensure gopath is set and go is installed if [[ ! -d $GOPATH ]] || [[ ! -d $GOBIN ]] || [[ ! -x "$(which go)" ]]; then echo "Your \$GOPATH is not set or go is not installed," @@ -9,7 +11,7 @@ if [[ ! -d $GOPATH ]] || [[ ! -d $GOBIN ]] || [[ ! -x "$(which go)" ]]; then fi GAIA_REPO="$GOPATH/src/github.com/cosmos/gaia" -GAIA_BRANCH=goz-phase-2 +GAIA_BRANCH=gaiav3.0 GAIA_DATA="$(pwd)/data" # ARGS: @@ -24,8 +26,8 @@ if [[ -d $GAIA_DATA ]] && [[ ! "$2" == "skip" ]]; then fi fi -rm -rf $GAIA_DATA &> /dev/null -killall gaiad &> /dev/null +rm -rf $GAIA_DATA #&> /dev/null +killall gaiad #&> /dev/null set -e @@ -36,12 +38,12 @@ if [[ -d $GAIA_REPO ]]; then # remote build syncs with remote then builds if [[ "$1" == "local" ]]; then echo "Using local version of github.com/cosmos/gaia" - make install &> /dev/null + make install #&> /dev/null else echo "Building github.com/cosmos/gaia@$GAIA_BRANCH..." if [[ ! -n $(git status -s) ]]; then # sync with remote $GAIA_BRANCH - git fetch --all &> /dev/null + git fetch --all #&> /dev/null # ensure the gaia repository successfully pulls the latest $GAIA_BRANCH if [[ -n $(git checkout $GAIA_BRANCH -q) ]] || [[ -n $(git pull origin $GAIA_BRANCH -q) ]]; then @@ -51,7 +53,7 @@ if [[ -d $GAIA_REPO ]]; then fi # install - make install &> /dev/null + make install #&> /dev/null # ensure that built binary has the same version as the repo if [[ ! "$(gaiad version --long 2>&1 | grep "commit:" | sed 's/commit: //g')" == "$(git rev-parse HEAD)" ]]; then @@ -74,57 +76,6 @@ chainid0=ibc0 chainid1=ibc1 echo "Generating gaia configurations..." -mkdir -p $GAIA_DATA && cd $GAIA_DATA -echo -e "\n" | gaiad testnet -o $chainid0 --v 1 --chain-id $chainid0 --node-dir-prefix n --keyring-backend test &> /dev/null -echo -e "\n" | gaiad testnet -o $chainid1 --v 1 --chain-id $chainid1 --node-dir-prefix n --keyring-backend test &> /dev/null - -cfgpth="n0/gaiad/config/config.toml" -if [ "$(uname)" = "Linux" ]; then - # TODO: Just index *some* specified tags, not all - sed -i 's/index_all_keys = false/index_all_keys = true/g' $chainid0/$cfgpth - sed -i 's/index_all_keys = false/index_all_keys = true/g' $chainid1/$cfgpth - - # Set proper defaults and change ports - sed -i 's/"leveldb"/"goleveldb"/g' $chainid0/$cfgpth - sed -i 's/"leveldb"/"goleveldb"/g' $chainid1/$cfgpth - sed -i 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:26556"#g' $chainid1/$cfgpth - sed -i 's#"tcp://0.0.0.0:26657"#"tcp://0.0.0.0:26557"#g' $chainid1/$cfgpth - sed -i 's#"localhost:6060"#"localhost:6061"#g' $chainid1/$cfgpth - sed -i 's#"tcp://127.0.0.1:26658"#"tcp://127.0.0.1:26558"#g' $chainid1/$cfgpth - - # Make blocks run faster than normal - sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $chainid0/$cfgpth - sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $chainid1/$cfgpth - sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $chainid0/$cfgpth - sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $chainid1/$cfgpth -else - # TODO: Just index *some* specified tags, not all - sed -i '' 's/index_all_keys = false/index_all_keys = true/g' $chainid0/$cfgpth - sed -i '' 's/index_all_keys = false/index_all_keys = true/g' $chainid1/$cfgpth - - # Set proper defaults and change ports - sed -i '' 's/"leveldb"/"goleveldb"/g' $chainid0/$cfgpth - sed -i '' 's/"leveldb"/"goleveldb"/g' $chainid1/$cfgpth - sed -i '' 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:26556"#g' $chainid1/$cfgpth - sed -i '' 's#"tcp://0.0.0.0:26657"#"tcp://0.0.0.0:26557"#g' $chainid1/$cfgpth - sed -i '' 's#"localhost:6060"#"localhost:6061"#g' $chainid1/$cfgpth - sed -i '' 's#"tcp://127.0.0.1:26658"#"tcp://127.0.0.1:26558"#g' $chainid1/$cfgpth - - # Make blocks run faster than normal - sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $chainid0/$cfgpth - sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $chainid1/$cfgpth - sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $chainid0/$cfgpth - sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $chainid1/$cfgpth -fi - -gclpth="n0/gaiacli/" -gaiacli config --home $chainid0/$gclpth chain-id $chainid0 &> /dev/null -gaiacli config --home $chainid1/$gclpth chain-id $chainid1 &> /dev/null -gaiacli config --home $chainid0/$gclpth output json &> /dev/null -gaiacli config --home $chainid1/$gclpth output json &> /dev/null -gaiacli config --home $chainid0/$gclpth node http://localhost:26657 &> /dev/null -gaiacli config --home $chainid1/$gclpth node http://localhost:26557 &> /dev/null - -echo "Starting Gaiad instances..." -gaiad --home $GAIA_DATA/$chainid0/n0/gaiad start --pruning=nothing > $chainid0.log 2>&1 & -gaiad --home $GAIA_DATA/$chainid1/n0/gaiad start --pruning=nothing > $chainid1.log 2>&1 & +mkdir -p $GAIA_DATA && cd $GAIA_DATA && cd ../ +./scripts/one-chain $chainid0 ./data 26657 26656 6060 9090 +./scripts/one-chain $chainid1 ./data 26557 26556 6061 9091 diff --git a/test/test_chains.go b/test/test_chains.go index 258f847c0..0c1a25e20 100644 --- a/test/test_chains.go +++ b/test/test_chains.go @@ -7,18 +7,28 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" - "github.com/cosmos/cosmos-sdk/std" + "github.com/cosmos/cosmos-sdk/simapp" "github.com/stretchr/testify/require" ry "github.com/ovrclk/relayer/relayer" ) +func init() { + ec := simapp.MakeEncodingConfig() + cdc = ec.Marshaler + amino = ec.Amino +} + var ( + cdc codec.JSONMarshaler + amino *codec.LegacyAmino // GAIA BLOCK TIMEOUTS on jackzampolin/gaiatest:master // timeout_commit = "1000ms" // timeout_propose = "1000ms" // 3 second relayer timeout works well with these block times gaiaTestConfig = testChainConfig{ + cdc: cdc, + amino: amino, dockerImage: "jackzampolin/gaiatest", dockerTag: "gaiav3.0", timeout: 3 * time.Second, @@ -116,8 +126,8 @@ type ( testChainConfig struct { dockerImage string dockerTag string - cdc *std.Codec - amino *codec.Codec + amino *codec.LegacyAmino + cdc codec.JSONMarshaler rpcPort string timeout time.Duration accountPrefix string diff --git a/test/test_queries.go b/test/test_queries.go index e2c7700f6..d19b337b2 100644 --- a/test/test_queries.go +++ b/test/test_queries.go @@ -3,6 +3,7 @@ package test import ( "testing" + clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" "github.com/stretchr/testify/require" ry "github.com/ovrclk/relayer/relayer" @@ -19,8 +20,10 @@ func testClient(t *testing.T, src, dst *ry.Chain) { client, err := src.QueryClientState() require.NoError(t, err) require.NotNil(t, client) - require.Equal(t, client.ClientState.GetID(), src.PathEnd.ClientID) - require.Equal(t, client.ClientState.ClientType().String(), "tendermint") + cs, err := clientTypes.UnpackClientState(client.ClientState) + require.NoError(t, err) + require.Equal(t, cs.GetChainID(), src.PathEnd.ChainID) + require.Equal(t, cs.ClientType().String(), "tendermint") } // testConnectionPair tests that the only connection on src and dst is between the two chains @@ -34,20 +37,21 @@ func testConnection(t *testing.T, src, dst *ry.Chain) { conns, err := src.QueryConnections(1, 1000) require.NoError(t, err) require.Equal(t, len(conns), 1) - require.Equal(t, conns[0].GetClientID(), src.PathEnd.ClientID) - require.Equal(t, conns[0].GetCounterparty().GetClientID(), dst.PathEnd.ClientID) - require.Equal(t, conns[0].GetCounterparty().GetConnectionID(), dst.PathEnd.ConnectionID) - require.Equal(t, conns[0].GetState().String(), "STATE_OPEN") + // conns[0]. + require.Equal(t, conns[0].ClientId, src.PathEnd.ClientID) + require.Equal(t, conns[0].Counterparty.GetClientID(), dst.PathEnd.ClientID) + require.Equal(t, conns[0].Counterparty.GetConnectionID(), dst.PathEnd.ConnectionID) + require.Equal(t, conns[0].State.String(), "STATE_OPEN") h, err := src.Client.Status() require.NoError(t, err) conn, err := src.QueryConnection(h.SyncInfo.LatestBlockHeight) require.NoError(t, err) - require.Equal(t, conn.Connection.GetClientID(), src.PathEnd.ClientID) + require.Equal(t, conn.Connection.ClientId, src.PathEnd.ClientID) require.Equal(t, conn.Connection.GetCounterparty().GetClientID(), dst.PathEnd.ClientID) require.Equal(t, conn.Connection.GetCounterparty().GetConnectionID(), dst.PathEnd.ConnectionID) - require.Equal(t, conn.Connection.GetState().String(), "STATE_OPEN") + require.Equal(t, conn.Connection.State.String(), "STATE_OPEN") } // testChannelPair tests that the only channel on src and dst is between the two chains @@ -63,7 +67,7 @@ func testChannel(t *testing.T, src, dst *ry.Chain) { require.Equal(t, 1, len(chans)) require.Equal(t, chans[0].Ordering.String(), "ORDER_ORDERED") require.Equal(t, chans[0].State.String(), "STATE_OPEN") - require.Equal(t, chans[0].Counterparty.ChannelID, dst.PathEnd.ChannelID) + require.Equal(t, chans[0].Counterparty.ChannelId, dst.PathEnd.ChannelID) require.Equal(t, chans[0].Counterparty.GetPortID(), dst.PathEnd.PortID) h, err := src.Client.Status() @@ -73,6 +77,6 @@ func testChannel(t *testing.T, src, dst *ry.Chain) { require.NoError(t, err) require.Equal(t, ch.Channel.Ordering.String(), "ORDER_ORDERED") require.Equal(t, ch.Channel.State.String(), "STATE_OPEN") - require.Equal(t, ch.Channel.Counterparty.ChannelID, dst.PathEnd.ChannelID) + require.Equal(t, ch.Channel.Counterparty.ChannelId, dst.PathEnd.ChannelID) require.Equal(t, ch.Channel.Counterparty.GetPortID(), dst.PathEnd.PortID) } diff --git a/test/test_setup.go b/test/test_setup.go index 143db8cca..21be74f57 100644 --- a/test/test_setup.go +++ b/test/test_setup.go @@ -118,7 +118,7 @@ func spinUpTestContainer(t *testing.T, rchan chan<- *dockertest.Resource, } // initialize the chain - require.NoError(t, c.Init(dir, tc.t.cdc, tc.t.amino, tc.t.timeout, debug)) + require.NoError(t, c.Init(dir, tc.t.timeout, debug)) // create the test key require.NoError(t, c.CreateTestKey()) From 0dad18efd8e76a45d5f422e33a5ae40d22534f74 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Mon, 31 Aug 2020 14:12:48 -0700 Subject: [PATCH 10/54] Fix lite client wip client transactions --- cmd/chains.go | 3 +- cmd/flags.go | 4 - cmd/keys.go | 12 +-- cmd/lite.go | 84 +-------------------- cmd/testnets.go | 3 +- cmd/xfer.go | 6 +- dev-env | 2 + go.mod | 8 +- go.sum | 73 ++++++++++++++++-- relayer/chain.go | 46 ++++++------ relayer/client-tx.go | 8 +- relayer/contextual.go | 91 ----------------------- relayer/faucet.go | 4 +- relayer/packet-tx.go | 12 +-- relayer/query.go | 9 ++- relayer/verifier.go | 169 +++++++++++++++++++++++++----------------- scripts/one-chain | 1 + 17 files changed, 224 insertions(+), 311 deletions(-) delete mode 100644 relayer/contextual.go diff --git a/cmd/chains.go b/cmd/chains.go index f1c91db2e..e3d309458 100644 --- a/cmd/chains.go +++ b/cmd/chains.go @@ -52,8 +52,7 @@ func chainsAddrCmd() *cobra.Command { return err } - done := chain.UseSDKContext() - defer done() + chain.UseSDKContext() addr, err := chain.GetAddress() if err != nil { diff --git a/cmd/flags.go b/cmd/flags.go index 2bc122683..ee3bef8ff 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -31,16 +31,12 @@ var ( func liteFlags(cmd *cobra.Command) *cobra.Command { cmd.Flags().Int64(flags.FlagHeight, -1, "Trusted header's height") cmd.Flags().BytesHexP(flagHash, "x", []byte{}, "Trusted header's hash") - cmd.Flags().StringP(flagURL, "u", "", "Optional URL to fetch trusted-hash and trusted-height") if err := viper.BindPFlag(flags.FlagHeight, cmd.Flags().Lookup(flags.FlagHeight)); err != nil { panic(err) } if err := viper.BindPFlag(flagHash, cmd.Flags().Lookup(flagHash)); err != nil { panic(err) } - if err := viper.BindPFlag(flagURL, cmd.Flags().Lookup(flagURL)); err != nil { - panic(err) - } return cmd } diff --git a/cmd/keys.go b/cmd/keys.go index 95360cbe3..7e0d52ec0 100644 --- a/cmd/keys.go +++ b/cmd/keys.go @@ -56,8 +56,7 @@ func keysAddCmd() *cobra.Command { return err } - done := chain.UseSDKContext() - defer done() + chain.UseSDKContext() var keyName string if len(args) == 2 { @@ -108,8 +107,7 @@ func keysRestoreCmd() *cobra.Command { return err } - done := chain.UseSDKContext() - defer done() + chain.UseSDKContext() if chain.KeyExists(keyName) { return errKeyExists(keyName) @@ -180,8 +178,7 @@ func keysListCmd() *cobra.Command { return err } - done := chain.UseSDKContext() - defer done() + chain.UseSDKContext() info, err := chain.Keybase.List() if err != nil { @@ -212,8 +209,7 @@ func keysShowCmd() *cobra.Command { return err } - done := chain.UseSDKContext() - defer done() + chain.UseSDKContext() var keyName string if len(args) == 2 { diff --git a/cmd/lite.go b/cmd/lite.go index fba9c89c7..d113c49b0 100644 --- a/cmd/lite.go +++ b/cmd/lite.go @@ -16,19 +16,13 @@ limitations under the License. package cmd import ( - "encoding/json" "fmt" - "io/ioutil" - "net/http" - neturl "net/url" "strconv" "github.com/cosmos/cosmos-sdk/client/flags" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" - "github.com/spf13/viper" - lite "github.com/tendermint/tendermint/light" ) // chainCmd represents the keys command @@ -54,8 +48,7 @@ func initLiteCmd() *cobra.Command { Short: "Initiate the light client", Long: `Initiate the light client by: 1. passing it a root of trust as a --hash/-x and --height - 2. via --url/-u where trust options can be found - 3. Use --force/-f to initialize from the configured node`, + 2. Use --force/-f to initialize from the configured node`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { chain, err := config.Chains.Get(args[0]) @@ -69,10 +62,6 @@ func initLiteCmd() *cobra.Command { } defer df() - url, err := cmd.Flags().GetString(flagURL) - if err != nil { - return err - } force, err := cmd.Flags().GetBool(flagForce) if err != nil { return err @@ -88,27 +77,12 @@ func initLiteCmd() *cobra.Command { switch { case force: // force initialization from trusted node - _, err = chain.TrustNodeInitClient(db) + _, err = chain.LiteClientWithoutTrust(db) if err != nil { return err } case height > 0 && len(hash) > 0: // height and hash are given - _, err = chain.InitLiteClient(db, chain.TrustOptions(height, hash)) - if err != nil { - return wrapInitFailed(err) - } - case len(url) > 0: // URL is given, query trust options - _, err := neturl.Parse(url) - if err != nil { - return wrapIncorrectURL(err) - } - - to, err := queryTrustOptions(url) - if err != nil { - return err - } - - _, err = chain.InitLiteClient(db, to) + _, err = chain.LiteClientWithTrust(db, chain.TrustOptions(height, hash)) if err != nil { return wrapInitFailed(err) } @@ -139,7 +113,6 @@ func updateLiteCmd() *cobra.Command { return err } - url := viper.GetString(flagURL) height, err := cmd.Flags().GetInt64(flags.FlagHeight) if err != nil { return err @@ -157,28 +130,7 @@ func updateLiteCmd() *cobra.Command { } defer df() - _, err = chain.InitLiteClient(db, chain.TrustOptions(height, hash)) - if err != nil { - return wrapInitFailed(err) - } - case len(url) > 0: // URL is given - _, err := neturl.Parse(url) - if err != nil { - return wrapIncorrectURL(err) - } - - to, err := queryTrustOptions(url) - if err != nil { - return err - } - - db, df, err := chain.NewLiteDB() - if err != nil { - return err - } - defer df() - - _, err = chain.InitLiteClient(db, to) + _, err = chain.LiteClientWithTrust(db, chain.TrustOptions(height, hash)) if err != nil { return wrapInitFailed(err) } @@ -286,31 +238,3 @@ func deleteLiteCmd() *cobra.Command { } return cmd } - -func queryTrustOptions(url string) (out lite.TrustOptions, err error) { - // fetch from URL - res, err := http.Get(url) //nolint:gosec // Potential HTTP request made with variable url - if err != nil { - return - } - - // read in the res body - bz, err := ioutil.ReadAll(res.Body) - if err != nil { - return - } - - // close the response body - err = res.Body.Close() - if err != nil { - return - } - - // unmarshal the data into the trust options hash - err = json.Unmarshal(bz, &out) - if err != nil { - return - } - - return -} diff --git a/cmd/testnets.go b/cmd/testnets.go index 3bc8cd4d1..d6a3ba4fa 100644 --- a/cmd/testnets.go +++ b/cmd/testnets.go @@ -41,8 +41,7 @@ func faucetRequestCmd() *cobra.Command { return err } - done := chain.UseSDKContext() - defer done() + chain.UseSDKContext() urlString, err := cmd.Flags().GetString(flagURL) if err != nil { diff --git a/cmd/xfer.go b/cmd/xfer.go index ecb034d88..ac6748374 100644 --- a/cmd/xfer.go +++ b/cmd/xfer.go @@ -44,12 +44,11 @@ func xfersend() *cobra.Command { return err } - done := c[dst].UseSDKContext() + c[dst].UseSDKContext() dstAddr, err := sdk.AccAddressFromBech32(args[4]) if err != nil { return err } - done() return c[src].SendTransferMsg(c[dst], amount, dstAddr, source) }, @@ -90,12 +89,11 @@ func transferCmd() *cobra.Command { return err } - done := c[dst].UseSDKContext() + c[dst].UseSDKContext() dstAddr, err := sdk.AccAddressFromBech32(args[4]) if err != nil { return err } - done() return c[src].SendTransferBothSides(c[dst], amount, dstAddr, source) }, diff --git a/dev-env b/dev-env index bd0ad95a7..451ffcd98 100755 --- a/dev-env +++ b/dev-env @@ -17,3 +17,5 @@ cd $RELAYER_DIR rm -rf $RELAYER_CONF &> /dev/null bash scripts/two-chainz "local" "skip" bash scripts/config-relayer "skip" + +rly tx full-path demo -d \ No newline at end of file diff --git a/go.mod b/go.mod index 0ba806391..d9457b78f 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,10 @@ module github.com/ovrclk/relayer go 1.14 require ( - github.com/DataDog/datadog-go v3.7.1+incompatible 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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200825201020-d9fd4d2ca9a3 + github.com/cosmos/cosmos-sdk v0.34.4-0.20200831210936-b13e0195729e github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 @@ -15,12 +14,11 @@ require ( github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.6.1 github.com/tendermint/tendermint v0.34.0-rc3 - github.com/tendermint/tm-db v0.6.1 + github.com/tendermint/tm-db v0.6.2 + golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e gopkg.in/yaml.v2 v2.3.0 ) replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 - -replace github.com/cosmos/cosmos-sdk => /Users/johnzampolin/go/src/github.com/cosmos/cosmos-sdk diff --git a/go.sum b/go.sum index a409a7aca..5412e5d14 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,6 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/DataDog/datadog-go v3.7.1+incompatible h1:HmA9qHVrHIAqpSvoCYJ+c6qst0lgqEhNW6/KwfkHbS8= -github.com/DataDog/datadog-go v3.7.1+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.4.1 h1:3oxKN3wbHibqx897utPC2LTQU4J+IHWWJO+glkAkpFM= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= @@ -75,6 +73,8 @@ github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d h1:xG8Pj6Y6J760xwETN github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BRcvO8T0UEPu53cnw4IbV63x1bEjildYhO0= github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= +github.com/btcsuite/btcd v0.21.0-beta h1:At9hIZdJW0s9E/fAz28nrz6AmcNlSVucCH796ZteX1M= +github.com/btcsuite/btcd v0.21.0-beta/go.mod h1:ZSWyehm27aAuS9bvkATT+Xte3hjHZ+MRgMY/8NJ7K94= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a h1:RQMUrEILyYJEoAT34XS/kLu40vC0+po/UfxrBBA4qZE= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= @@ -84,7 +84,9 @@ github.com/btcsuite/btcutil v1.0.2 h1:9iZ1Terx9fMIOtq1VrwdqfsATL9MC2l8ZrUY6YZ2ut github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= @@ -106,9 +108,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/confio/ics23/go v0.0.0-20200610201322-18c7bd6b2dd3/go.mod h1:W1I3XC8d9N8OTu/ct5VJ84ylcOunZwMXsWkd27nvVts= -github.com/confio/ics23/go v0.0.0-20200804135932-65ad804e8539 h1:4AuX7KNUVdNa/am9yCQRqWMfdDJ86EtFJk/xwf6ntgc= -github.com/confio/ics23/go v0.0.0-20200804135932-65ad804e8539/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= +github.com/confio/ics23/go v0.0.0-20200817220745-f173e6211efb h1:+7FsS1gZ1Km5LRjGV2hztpier/5i6ngNjvNpxbWP5I0= +github.com/confio/ics23/go v0.0.0-20200817220745-f173e6211efb/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.0.0-20200228182428-0f16d7a0959c h1:8ahmSVELW1wghbjerVAyuEYD5+Dio66RYvSS0iGfL1M= @@ -123,10 +124,11 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200831210936-b13e0195729e/go.mod h1:NUfsL2rXjFdO3GCHutCGWWKrRyL7MaSyDj86YbVBgGQ= 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/iavl v0.15.0-rc2 h1:4HI/LYLjWUnou8dehPD+NqEsDc8uamJOU2yHcqdTKv8= -github.com/cosmos/iavl v0.15.0-rc2/go.mod h1:bXLXbwmww0kYtAYRCYNXR/k44lWaK8rIZJlCmqSK8lQ= +github.com/cosmos/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= +github.com/cosmos/iavl v0.15.0-rc3/go.mod h1:rQ2zK/LuivThMjve3Yr6VkjvCqCXl+fgHCY7quiUA68= 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= @@ -141,10 +143,15 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/dgraph-io/badger/v2 v2.0.3 h1:inzdf6VF/NZ+tJ8RwwYMjJMvsOALTHYdozn0qSl6XJI= github.com/dgraph-io/badger/v2 v2.0.3/go.mod h1:3KY8+bsP8wI0OEnQJAKpd4wIJW/Mm32yw2j/9FUVnIM= +github.com/dgraph-io/badger/v2 v2.2007.1 h1:t36VcBCpo4SsmAD5M8wVv1ieVzcALyGfaJ92z4ccULM= +github.com/dgraph-io/badger/v2 v2.2007.1/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= github.com/dgraph-io/ristretto v0.0.2-0.20200115201040-8f368f2f2ab3 h1:MQLRM35Pp0yAyBYksjbj1nZI/w6eyRY/mWoM1sFf4kU= github.com/dgraph-io/ristretto v0.0.2-0.20200115201040-8f368f2f2ab3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de h1:t0UHb5vdojIDUqktM6+xJAfScFBsVpXZmqC9dsgJmeA= +github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= @@ -184,8 +191,11 @@ github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVB github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0 h1:dXFJfIHVvUcpSgDOV+Ne6t7jXri8Tfv2uOLHUZ2XNuo= @@ -265,6 +275,7 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.2.1/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= @@ -313,8 +324,10 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d h1:/WZQPMZNsjZ7IlCpsLGdQBINg5bxKQ1K1sh6awxLtkA= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= @@ -356,6 +369,8 @@ github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0Q github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.2 h1:znVR8Q4g7/WlcvsxLBRWvo+vtFJUAbDn3w+Yak2xVMI= +github.com/magiconair/properties v1.8.2/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -396,6 +411,8 @@ github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -404,9 +421,16 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo= github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= +github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= @@ -566,6 +590,8 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d h1:gZZadD8H+fF+n9CmNhYL1Y0dJB+kLOmKd7FbPJLeGHs= github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= +github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca h1:Ld/zXl5t4+D69SiV4JoN7kkfvJdOWlPpfxrzxpLMoUk= +github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s= @@ -574,11 +600,12 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ= github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= github.com/tendermint/tm-db v0.6.1 h1:w3X87itMPXopcRPlFiqspEKhw4FXihPk2rnFFkP0zGk= github.com/tendermint/tm-db v0.6.1/go.mod h1:m3x9kRP4UFd7JODJL0yBAZqE7wTw+S37uAE90cTx7OA= +github.com/tendermint/tm-db v0.6.2 h1:DOn8jwCdjJblrCFJbtonEIPD1IuJWpbRUUdR8GWE4RM= +github.com/tendermint/tm-db v0.6.2/go.mod h1:GYtQ67SUvATOcoY8/+x6ylk8Qo02BQyLrAs+yAcLvGI= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= @@ -623,14 +650,18 @@ golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200406173513-056763e48d71 h1:DOmugCavvUtnUD114C1Wh+UgTgQZ4pMLzXxi1pSt+/Y= golang.org/x/crypto v0.0.0-20200406173513-056763e48d71/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 h1:DZhuSZLsGlFL4CmhA8BcRA0mnthyA/nZ00AqCUo7vHg= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 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= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -645,6 +676,8 @@ golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCc golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -668,8 +701,12 @@ golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20191003171128-d98b1b443823/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc h1:zK/HqS5bZxDptfPJNq8v7vJfXtkU7r9TLIoSr1bXaP4= +golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -679,6 +716,7 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -702,6 +740,10 @@ golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -710,13 +752,19 @@ golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed h1:J22ig1FUekjjkmZUM7pTKixYm8DvrYsvrBZdunYeIuQ= +golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -745,10 +793,13 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200110213125-a7a6caa82ab2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= @@ -774,9 +825,12 @@ google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBr google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a h1:Ob5/580gVHBJZgXnff1cZDbG+xLtMVE5mDRTe+nIsX4= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200324203455-a04cca1dde73/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987 h1:PDIOdWxZ8eRizhKa1AAvY53xsvLB1cWorMjslvY3VA8= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/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= @@ -791,8 +845,11 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.31.0 h1:T7P4R73V3SSDPhH7WW7ATbfViLtmamH0DKrP3f9AuDI= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1 h1:SfXqXS5hkufcdZ/mHtYCh53P2b+92WQq/DZcKLgsFRs= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/relayer/chain.go b/relayer/chain.go index 6d873f139..f99c44d64 100644 --- a/relayer/chain.go +++ b/relayer/chain.go @@ -14,6 +14,7 @@ import ( sdkCtx "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" tx "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/hd" keys "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/simapp" @@ -42,12 +43,12 @@ type Chain struct { TrustingPeriod string `yaml:"trusting-period" json:"trusting-period"` // TODO: make these private - HomePath string `yaml:"-" json:"-"` - PathEnd *PathEnd `yaml:"-" json:"-"` - Keybase keys.Keyring `yaml:"-" json:"-"` - Client rpcclient.Client `yaml:"-" json:"-"` - Cdc *contextualStdCodec `yaml:"-" json:"-"` - Amino *contextualAminoCodec `yaml:"-" json:"-"` + HomePath string `yaml:"-" json:"-"` + PathEnd *PathEnd `yaml:"-" json:"-"` + Keybase keys.Keyring `yaml:"-" json:"-"` + Client rpcclient.Client `yaml:"-" json:"-"` + Cdc codec.JSONMarshaler `yaml:"-" json:"-"` + Amino *codec.LegacyAmino `yaml:"-" json:"-"` address sdk.AccAddress logger log.Logger @@ -151,8 +152,8 @@ func (c *Chain) Init(homePath string, timeout time.Duration, debug bool) error { c.Keybase = keybase c.Client = client - c.Cdc = newContextualStdCodec(encodingConfig.Marshaler, c.UseSDKContext) - c.Amino = newContextualAminoCodec(encodingConfig.Amino, c.UseSDKContext) + c.Cdc = encodingConfig.Marshaler + c.Amino = encodingConfig.Amino c.HomePath = homePath c.logger = defaultChainLogger() c.timeout = timeout @@ -209,8 +210,7 @@ func (c *Chain) SendMsg(datagram sdk.Msg) (*sdk.TxResponse, error) { // SendMsgs wraps the msgs in a stdtx, signs and sends it func (c *Chain) SendMsgs(msgs []sdk.Msg) (res *sdk.TxResponse, err error) { - done := c.UseSDKContext() - defer done() + c.UseSDKContext() // Instantiate the client context ctx := c.CLIContext() @@ -267,6 +267,8 @@ func (c *Chain) CLIContext() sdkCtx.Context { WithKeyring(c.Keybase). WithOutputFormat("json"). WithFrom(c.Key). + WithFromName(c.Key). + WithFromAddress(c.MustGetAddress()). WithSkipConfirmation(true). WithNodeURI(c.RPCAddr) } @@ -350,30 +352,30 @@ func (c *Chain) MustGetAddress() sdk.AccAddress { var sdkContextMutex sync.Mutex // UseSDKContext uses a custom Bech32 account prefix and returns a restore func -func (c *Chain) UseSDKContext() func() { +func (c *Chain) UseSDKContext() { // Ensure we're the only one using the global context. - sdkContextMutex.Lock() - defer sdkContextMutex.Unlock() + // defer sdkContextMutex.Unlock() + // sdkContextMutex.Lock() sdkConf := sdk.GetConfig() - account := sdkConf.GetBech32AccountAddrPrefix() - pubaccount := sdkConf.GetBech32AccountPubPrefix() + // account := sdkConf.GetBech32AccountAddrPrefix() + // pubaccount := sdkConf.GetBech32AccountPubPrefix() // Mutate the sdkConf sdkConf.SetBech32PrefixForAccount(c.AccountPrefix, c.AccountPrefix+"pub") // Return a function that resets and unlocks. - return func() { - sdkContextMutex.Lock() - defer sdkContextMutex.Unlock() + // return func() { + // sdkContextMutex.Lock() + // defer sdkContextMutex.Unlock() - sdkConf.SetBech32PrefixForAccount(account, pubaccount) - } + // sdkConf.SetBech32PrefixForAccount(account, pubaccount) + // } } func (c *Chain) String() string { - done := c.UseSDKContext() - defer done() + c.UseSDKContext() + // defer done() out, _ := json.Marshal(c) return string(out) diff --git a/relayer/client-tx.go b/relayer/client-tx.go index 13d86843a..d5ebeb058 100644 --- a/relayer/client-tx.go +++ b/relayer/client-tx.go @@ -13,9 +13,7 @@ func (c *Chain) CreateClients(dst *Chain) (err error) { // Create client for the destination chain on the source chain if it doesn't exist var srcCs, dstCs *clientTypes.QueryClientStateResponse - if srcCs, err = c.QueryClientState(); err != nil { - return err - } else if srcCs == nil { + if srcCs, err = c.QueryClientState(); err != nil && srcCs == nil { dstH, err := dst.UpdateLiteWithHeader() if err != nil { return err @@ -27,9 +25,7 @@ func (c *Chain) CreateClients(dst *Chain) (err error) { } // Create client for the source chain on destination chain if it doesn't exist - if dstCs, err = dst.QueryClientState(); err != nil { - return err - } else if dstCs == nil { + if dstCs, err = dst.QueryClientState(); err != nil && dstCs == nil { srcH, err := c.UpdateLiteWithHeader() if err != nil { return err diff --git a/relayer/contextual.go b/relayer/contextual.go deleted file mode 100644 index e32f38baa..000000000 --- a/relayer/contextual.go +++ /dev/null @@ -1,91 +0,0 @@ -package relayer - -import ( - "github.com/cosmos/cosmos-sdk/codec" -) - -type contextualStdCodec struct { - codec.JSONMarshaler - useContext func() func() -} - -type contextualAminoCodec struct { - *codec.LegacyAmino - useContext func() func() -} - -// newContextualCodec creates a codec that sets and resets context -func newContextualStdCodec(cdc codec.JSONMarshaler, useContext func() func()) *contextualStdCodec { - return &contextualStdCodec{ - JSONMarshaler: cdc, - useContext: useContext, - } -} - -// MarshalJSON marshals with the original codec and new context -func (cdc *contextualStdCodec) MarshalJSON(ptr interface{}) ([]byte, error) { - done := cdc.useContext() - defer done() - - return cdc.MarshalJSON(ptr) -} - -// UnmarshalJSON unmarshals with the original codec and new context -func (cdc *contextualStdCodec) UnmarshalJSON(bz []byte, ptr interface{}) error { - done := cdc.useContext() - defer done() - - return cdc.UnmarshalJSON(bz, ptr) -} - -func (cdc *contextualStdCodec) MarshalBinaryBare(ptr codec.ProtoMarshaler) ([]byte, error) { - done := cdc.useContext() - defer done() - - return cdc.MarshalBinaryBare(ptr) -} - -func (cdc *contextualStdCodec) UnmarshalBinaryBare(bz []byte, ptr codec.ProtoMarshaler) error { - done := cdc.useContext() - defer done() - - return cdc.UnmarshalBinaryBare(bz, ptr) -} - -// newContextualCodec creates a codec that sets and resets context -func newContextualAminoCodec(cdc *codec.LegacyAmino, useContext func() func()) *contextualAminoCodec { - return &contextualAminoCodec{ - LegacyAmino: cdc, - useContext: useContext, - } -} - -// MarshalJSON marshals with the original codec and new context -func (cdc *contextualAminoCodec) MarshalJSON(ptr interface{}) ([]byte, error) { - done := cdc.useContext() - defer done() - - return cdc.MarshalJSON(ptr) -} - -// UnmarshalJSON unmarshals with the original codec and new context -func (cdc *contextualAminoCodec) UnmarshalJSON(bz []byte, ptr interface{}) error { - done := cdc.useContext() - defer done() - - return cdc.UnmarshalJSON(bz, ptr) -} - -func (cdc *contextualAminoCodec) MarshalBinaryBare(ptr interface{}) ([]byte, error) { - done := cdc.useContext() - defer done() - - return cdc.MarshalBinaryBare(ptr) -} - -func (cdc *contextualAminoCodec) UnmarshalBinaryBare(bz []byte, ptr interface{}) error { - done := cdc.useContext() - defer done() - - return cdc.UnmarshalBinaryBare(bz, ptr) -} diff --git a/relayer/faucet.go b/relayer/faucet.go index a7122b3ee..a0bc0e6b2 100644 --- a/relayer/faucet.go +++ b/relayer/faucet.go @@ -53,8 +53,8 @@ func (c *Chain) FaucetHandler(fromKey sdk.AccAddress, amounts sdk.Coins) func(w return } - done := c.UseSDKContext() - defer done() + c.UseSDKContext() + // defer done() if err := c.faucetSend(fromKey, fr.addr(), amounts); err != nil { c.Error(err) diff --git a/relayer/packet-tx.go b/relayer/packet-tx.go index 4845787ef..f3b0cebf4 100644 --- a/relayer/packet-tx.go +++ b/relayer/packet-tx.go @@ -43,9 +43,8 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, timeoutHeight := dstHeader.GetHeight() + uint64(defaultPacketTimeout) // Properly render the address string - done := dst.UseSDKContext() + dst.UseSDKContext() dstAddrString := dstAddr.String() - done() // MsgTransfer will call SendPacket on src chain // TODO: FIX @@ -96,13 +95,11 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, } // Properly render the source and destination address strings - done = c.UseSDKContext() + c.UseSDKContext() srcAddrString := c.MustGetAddress().String() - done() - done = dst.UseSDKContext() + dst.UseSDKContext() dstAddrString = dstAddr.String() - done() // reconstructing packet data here instead of retrieving from an indexed node xferPacket := c.PathEnd.XferPacket( @@ -149,9 +146,8 @@ func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringe } // Properly render the address string - done := dst.UseSDKContext() + dst.UseSDKContext() dstAddrString := dstAddr.String() - done() // MsgTransfer will call SendPacket on src chain // TODO: FIX diff --git a/relayer/query.go b/relayer/query.go index dcfe95058..b17553f70 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -100,6 +100,7 @@ type chh struct { // QueryClientConsensusStatePair allows for the querying of multiple client states at the same time func QueryClientConsensusStatePair(src, dst *Chain, srcH, dstH, srcClientConsH, dstClientConsH int64) (map[string]*clientTypes.QueryConsensusStateResponse, error) { + fmt.Println("QueryClientConsensusStatePair") hs := &csstates{ Map: make(map[string]*clientTypes.QueryConsensusStateResponse), Errs: []error{}, @@ -144,6 +145,7 @@ type cstates struct { // QueryClientStatePair returns a pair of connection responses func QueryClientStatePair(src, dst *Chain) (map[string]*clientTypes.QueryClientStateResponse, error) { + fmt.Println("QueryClientStatePair") hs := &cstates{ Map: make(map[string]*clientTypes.QueryClientStateResponse), Errs: []error{}, @@ -225,6 +227,7 @@ type chpair struct { // QueryConnectionPair returns a pair of connection responses func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (map[string]*connTypes.QueryConnectionResponse, error) { + fmt.Println("QueryConnectionPair") hs := &conns{ Map: make(map[string]*connTypes.QueryConnectionResponse), Errs: []error{}, @@ -286,6 +289,7 @@ type chans struct { // QueryChannelPair returns a pair of channel responses func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (map[string]*chanTypes.QueryChannelResponse, error) { + fmt.Println("QueryChannelPair") hs := &chans{ Map: make(map[string]*chanTypes.QueryChannelResponse), Errs: []error{}, @@ -527,7 +531,6 @@ func QueryLatestHeights(chains ...*Chain) (map[string]int64, error) { wg.Add(1) go func(hs *heights, wg *sync.WaitGroup, chain *Chain) { height, err := chain.QueryLatestHeight() - if err != nil { hs.Lock() hs.Errs = append(hs.Errs, err) @@ -639,7 +642,7 @@ func (c *Chain) formatTxResults(resTxs []*ctypes.ResultTx, // formatTxResult parses a tx into a TxResponse object func (c *Chain) formatTxResult(resTx *ctypes.ResultTx, resBlock *ctypes.ResultBlock) (*sdk.TxResponse, error) { - tx, err := parseTx(c.Cdc.JSONMarshaler, resTx.Tx) + tx, err := parseTx(c.Amino, resTx.Tx) if err != nil { return &sdk.TxResponse{}, err } @@ -648,7 +651,7 @@ func (c *Chain) formatTxResult(resTx *ctypes.ResultTx, resBlock *ctypes.ResultBl } // Takes some bytes and a codec and returns an sdk.Tx -func parseTx(cdc codec.JSONMarshaler, txBytes []byte) (sdk.Tx, error) { +func parseTx(cdc *codec.LegacyAmino, txBytes []byte) (sdk.Tx, error) { var tx authTypes.StdTx err := cdc.UnmarshalJSON(txBytes, &tx) if err != nil { diff --git a/relayer/verifier.go b/relayer/verifier.go index f3a5db5eb..805acbdb6 100644 --- a/relayer/verifier.go +++ b/relayer/verifier.go @@ -1,6 +1,7 @@ package relayer import ( + "context" "errors" "fmt" "io/ioutil" @@ -21,8 +22,15 @@ import ( dbs "github.com/tendermint/tendermint/light/store/db" ctypes "github.com/tendermint/tendermint/rpc/core/types" tmtypes "github.com/tendermint/tendermint/types" + "golang.org/x/sync/errgroup" ) +// NOTE: currently we are discarding the very noisy lite client logs +// it would be nice if we could add a setting the chain or otherwise +// that allowed users to enable lite client logging. (maybe as a hidden prop +// on the Chain struct that users could pass in the config??) +var logger = lite.Logger(log.NewTMLogger(log.NewSyncWriter(ioutil.Discard))) + type header struct { sync.Mutex Map map[string]*tmclient.Header @@ -32,6 +40,7 @@ type header struct { func (h *header) err() error { var out error for _, err := range h.Errs { + fmt.Println("in verifier") out = fmt.Errorf("err: %w", err) } return out @@ -58,6 +67,43 @@ func UpdatesWithHeaders(chains ...*Chain) (map[string]*tmclient.Header, error) { return hs.Map, hs.err() } +type hu struct { + h *tmclient.Header + c string +} + +// UpdatesWithHeadersAlt uses sync.Errorgroup to manage the goroutines +func UpdatesWithHeadersAlt(chains ...*Chain) (map[string]*tmclient.Header, error) { + hs := make(map[string]*tmclient.Header) + hchan := make(chan hu) + eg, _ := errgroup.WithContext(context.Background()) + eg.Go(func() error { + for h := range hchan { + hs[h.c] = h.h + if len(hs) == len(chains) { + close(hchan) + return nil + } + } + return nil + }) + for _, c := range chains { + eg.Go(func() error { + header, err := c.UpdateLiteWithHeader() + if err != nil { + return err + } + hchan <- hu{h: header, c: c.ChainID} + return nil + }) + } + err := eg.Wait() + if err != nil { + return nil, err + } + return hs, nil +} + func liteError(err error) error { return fmt.Errorf("lite client: %w", err) } // UpdateLiteWithHeader calls client.Update and then . @@ -69,7 +115,7 @@ func (c *Chain) UpdateLiteWithHeader() (*tmclient.Header, error) { } defer df() - client, err := c.LiteClientWithoutTrust(db) + client, err := c.LiteClient(db) if err != nil { return nil, liteError(err) } @@ -99,6 +145,7 @@ func (c *Chain) UpdateLiteWithHeader() (*tmclient.Header, error) { return &tmclient.Header{SignedHeader: sh.ToProto(), ValidatorSet: protoVal}, nil } +// UpdateLiteWithHeaderHeight updates the lite client database to the given height func (c *Chain) UpdateLiteWithHeaderHeight(height int64) (*tmclient.Header, error) { // create database connection db, df, err := c.NewLiteDB() @@ -130,64 +177,23 @@ func (c *Chain) UpdateLiteWithHeaderHeight(height int64) (*tmclient.Header, erro return &tmclient.Header{SignedHeader: sh.ToProto(), ValidatorSet: protoVal}, nil } -// LiteClientWithoutTrust reads the trusted period off of the chain. -func (c *Chain) LiteClientWithoutTrust(db dbm.DB) (*lite.Client, error) { - httpProvider, err := litehttp.New(c.ChainID, c.RPCAddr) +// LiteHTTP returns the http client for lite clients +func (c *Chain) LiteHTTP() litep.Provider { + cl, err := litehttp.New(c.ChainID, c.RPCAddr) if err != nil { - return nil, err + panic(err) } - - // NOTE: currently we are discarding the very noisy lite client logs - // it would be nice if we could add a setting the chain or otherwise - // that allowed users to enable lite client logging. (maybe as a hidden prop - // on the Chain struct that users could pass in the config??) - logger := log.NewTMLogger(log.NewSyncWriter(ioutil.Discard)) - - // TODO: provide actual witnesses! - return lite.NewClientFromTrustedStore(c.ChainID, c.GetTrustingPeriod(), httpProvider, - []litep.Provider{httpProvider}, dbs.New(db, ""), - lite.Logger(logger)) + return cl } -// LiteClient initializes the lite client for a given chain. -func (c *Chain) LiteClient(db dbm.DB, trustOpts lite.TrustOptions) (*lite.Client, error) { - httpProvider, err := litehttp.New(c.ChainID, c.RPCAddr) - if err != nil { - return nil, err - } - - // NOTE: currently we are discarding the very noisy lite client logs - // it would be nice if we could add a setting the chain or otherwise - // that allowed users to enable lite client logging. (maybe as a hidden prop - // on the Chain struct that users could pass in the config??) - logger := log.NewTMLogger(log.NewSyncWriter(ioutil.Discard)) - - // TODO: provide actual witnesses! - return lite.NewClient(c.ChainID, trustOpts, httpProvider, - []litep.Provider{httpProvider}, dbs.New(db, ""), - lite.Logger(logger)) -} - -// InitLiteClient instantantiates the lite client object and calls update -func (c *Chain) InitLiteClient(db dbm.DB, trustOpts lite.TrustOptions) (*lite.Client, error) { - lc, err := c.LiteClient(db, trustOpts) - if err != nil { - return nil, err - } - _, err = lc.Update(time.Now()) - if err != nil { - return nil, err - } - return lc, err -} - -// TrustNodeInitClient trusts the configured node and initializes the lite client -func (c *Chain) TrustNodeInitClient(db dbm.DB) (*lite.Client, error) { - // fetch latest height from configured node +// LiteClientWithoutTrust querys the latest header from the chain and initializes a new lite client +// database using that header. This should only be called when first initializing the lite client +func (c *Chain) LiteClientWithoutTrust(db dbm.DB) (*lite.Client, error) { var ( height int64 err error ) + prov := c.LiteHTTP() if err := retry.Do(func() error { height, err = c.QueryLatestHeight() @@ -199,23 +205,54 @@ func (c *Chain) TrustNodeInitClient(db dbm.DB) (*lite.Client, error) { return nil, err } - // fetch header from configured node - header, err := c.QueryHeaderAtHeight(height) - if err != nil { - return nil, err - } - - lc, err := c.LiteClient(db, c.TrustOptions(height, header.Header.AppHash)) + header, err := prov.SignedHeader(height) if err != nil { return nil, err } + return lite.NewClient( + c.ChainID, + lite.TrustOptions{ + Period: c.GetTrustingPeriod(), + Height: height, + Hash: header.Hash(), + }, + prov, + // TODO: provide actual witnesses! + // NOTE: This requires adding them to the chain config + []litep.Provider{prov}, + dbs.New(db, ""), + logger) +} - _, err = lc.Update(time.Now()) - if err != nil { - return nil, err - } +// LiteClientWithTrust takes a header from the chain and attempts to add that header to the lite +// database. +func (c *Chain) LiteClientWithTrust(db dbm.DB, to lite.TrustOptions) (*lite.Client, error) { + prov := c.LiteHTTP() + return lite.NewClient( + c.ChainID, + to, + prov, + // TODO: provide actual witnesses! + // NOTE: This requires adding them to the chain config + []litep.Provider{prov}, + dbs.New(db, ""), + logger) +} - return lc, nil +// LiteClient initializes the lite client for a given chain from the trusted store in the database +// this should be call for all other lite client usage +func (c *Chain) LiteClient(db dbm.DB) (*lite.Client, error) { + prov := c.LiteHTTP() + return lite.NewClientFromTrustedStore( + c.ChainID, + c.GetTrustingPeriod(), + prov, + // TODO: provide actual witnesses! + // NOTE: This requires adding them to the chain config + []litep.Provider{prov}, + dbs.New(db, ""), + logger, + ) } // NewLiteDB returns a new instance of the liteclient database connection @@ -286,7 +323,7 @@ func (c *Chain) GetLatestLiteHeight() (int64, error) { } defer df() - client, err := c.LiteClientWithoutTrust(db) + client, err := c.LiteClient(db) if err != nil { return -1, err } @@ -303,7 +340,7 @@ func (c *Chain) GetLiteSignedHeaderAtHeight(height int64) (*tmclient.Header, err } defer df() - client, err := c.LiteClientWithoutTrust(db) + client, err := c.LiteClient(db) if err != nil { return nil, err } @@ -335,7 +372,7 @@ func (c *Chain) ForceInitLite() error { if err != nil { return err } - _, err = c.TrustNodeInitClient(db) + _, err = c.LiteClientWithoutTrust(db) if err != nil { return err } diff --git a/scripts/one-chain b/scripts/one-chain index 47d472076..121874d64 100755 --- a/scripts/one-chain +++ b/scripts/one-chain @@ -50,6 +50,7 @@ gaiad --home $CHAINDIR/$CHAINID gentx validator --keyring-backend="test" --chain gaiad --home $CHAINDIR/$CHAINID collect-gentxs &> /dev/null # Set proper defaults and change ports +# TODO: sed for linux sed -i '' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPCPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml sed -i '' 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml sed -i '' 's#"localhost:6060"#"localhost:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml From 1dcd598ca47bce7d231269a72dcb5f7b7dcae564 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Tue, 1 Sep 2020 16:19:03 -0700 Subject: [PATCH 11/54] Update to latest SDK and refactor create client msgs --- cmd/paths.go | 4 ++-- go.mod | 2 +- go.sum | 3 ++- relayer/pathEnd.go | 33 ++++++++++++++++++++++----------- relayer/query.go | 2 -- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/cmd/paths.go b/cmd/paths.go index 0ffe81e9a..3fbe08fcd 100644 --- a/cmd/paths.go +++ b/cmd/paths.go @@ -102,7 +102,7 @@ func pathsGenCmd() *cobra.Command { for _, c := range srcClients { // TODO: support other client types through a switch here as they become available clnt, _ := clientTypes.UnpackClientState(c.ClientState) - if clnt.GetLatestHeight() != 0 && !clnt.IsFrozen() && clnt.GetChainID() == dst { + if clnt.GetLatestHeight() != 0 && !clnt.IsFrozen() { // TODO: re-enable this check && clnt.GetChainID() == dst { path.Src.ClientID = c.ClientId } } @@ -115,7 +115,7 @@ func pathsGenCmd() *cobra.Command { for _, c := range dstClients { // TODO: support other client types through a switch here as they become available clnt, _ := clientTypes.UnpackClientState(c.ClientState) - if clnt.GetLatestHeight() != 0 && !clnt.IsFrozen() && clnt.GetChainID() == src { + if clnt.GetLatestHeight() != 0 && !clnt.IsFrozen() { // TODO: re-enable this check && clnt.GetChainID() == src { path.Dst.ClientID = c.ClientId } } diff --git a/go.mod b/go.mod index d9457b78f..43e742574 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200831210936-b13e0195729e + github.com/cosmos/cosmos-sdk v0.34.4-0.20200901224407-b043797a0794 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 diff --git a/go.sum b/go.sum index 5412e5d14..207aaa5cd 100644 --- a/go.sum +++ b/go.sum @@ -124,7 +124,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200831210936-b13e0195729e/go.mod h1:NUfsL2rXjFdO3GCHutCGWWKrRyL7MaSyDj86YbVBgGQ= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200901224407-b043797a0794 h1:EYw3ZQXN+Rm+48C4TwkRHCAB+6DeJgN4JuwFk+szsb4= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200901224407-b043797a0794/go.mod h1:NUfsL2rXjFdO3GCHutCGWWKrRyL7MaSyDj86YbVBgGQ= 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/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index 1a1a2d5d0..74822b0be 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -11,6 +11,7 @@ import ( chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" + "github.com/tendermint/tendermint/light" ) // TODO: add Order chanTypes.Order as a property and wire it up in validation @@ -46,30 +47,40 @@ func (pe *PathEnd) getOrder() chanTypes.Order { // UpdateClient creates an sdk.Msg to update the client on src with data pulled from dst func (pe *PathEnd) UpdateClient(dstHeader *tmclient.Header, signer sdk.AccAddress) sdk.Msg { - return tmclient.NewMsgUpdateClient( + if err := dstHeader.ValidateBasic(); err != nil { + panic(err) + } + msg, err := clientTypes.NewMsgUpdateClient( pe.ClientID, dstHeader, signer, ) + if err != nil { + panic(err) + } + return msg } // CreateClient creates an sdk.Msg to update the client on src with consensus state from dst -func (pe *PathEnd) CreateClient(dstHeader *tmclient.Header, trustingPeriod time.Duration, - signer sdk.AccAddress) sdk.Msg { - if err := dstHeader.ValidateBasic(dstHeader.Header.ChainID); err != nil { +func (pe *PathEnd) CreateClient(dstHeader *tmclient.Header, trustingPeriod time.Duration, signer sdk.AccAddress) sdk.Msg { + if err := dstHeader.ValidateBasic(); err != nil { panic(err) } + + clientState := tmclient.NewClientState( + dstHeader.GetHeader().GetChainID(), tmclient.NewFractionFromTm(light.DefaultTrustLevel), trustingPeriod, trustingPeriod*2, time.Minute*1, clientTypes.NewHeight(0, dstHeader.GetHeight()), commitmenttypes.GetSDKSpecs(), + ) // TODO: figure out how to dynmaically set unbonding time - return tmclient.NewMsgCreateClient( + msg, err := clientTypes.NewMsgCreateClient( pe.ClientID, - dstHeader, - tmclient.DefaultTrustLevel, - trustingPeriod, - defaultUnbondingTime, - defaultMaxClockDrift, - commitmenttypes.GetSDKSpecs(), + clientState, + dstHeader.ConsensusState(), signer, ) + if err != nil { + panic(err) + } + return msg } // ConnInit creates a MsgConnectionOpenInit diff --git a/relayer/query.go b/relayer/query.go index b17553f70..5811e2bc5 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -145,7 +145,6 @@ type cstates struct { // QueryClientStatePair returns a pair of connection responses func QueryClientStatePair(src, dst *Chain) (map[string]*clientTypes.QueryClientStateResponse, error) { - fmt.Println("QueryClientStatePair") hs := &cstates{ Map: make(map[string]*clientTypes.QueryClientStateResponse), Errs: []error{}, @@ -227,7 +226,6 @@ type chpair struct { // QueryConnectionPair returns a pair of connection responses func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (map[string]*connTypes.QueryConnectionResponse, error) { - fmt.Println("QueryConnectionPair") hs := &conns{ Map: make(map[string]*connTypes.QueryConnectionResponse), Errs: []error{}, From acf795dcad18e3970fe02ea1a01ac9323c43e415 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Wed, 2 Sep 2020 16:25:44 -0700 Subject: [PATCH 12/54] Working client creation --- cmd/paths.go | 4 ++-- cmd/query.go | 2 +- cmd/raw.go | 4 ++-- dev-env | 5 ++++- go.mod | 2 +- go.sum | 6 ++++++ relayer/client-tx.go | 4 ++-- relayer/connection-tx.go | 2 +- relayer/headers.go | 13 ++++++++++++- relayer/packet-tx.go | 4 ++-- relayer/pathEnd.go | 40 +++++++++++++++++++++++++++------------- relayer/query.go | 3 +-- relayer/relayPackets.go | 4 ++-- 13 files changed, 63 insertions(+), 30 deletions(-) diff --git a/cmd/paths.go b/cmd/paths.go index 3fbe08fcd..db3fec57f 100644 --- a/cmd/paths.go +++ b/cmd/paths.go @@ -102,7 +102,7 @@ func pathsGenCmd() *cobra.Command { for _, c := range srcClients { // TODO: support other client types through a switch here as they become available clnt, _ := clientTypes.UnpackClientState(c.ClientState) - if clnt.GetLatestHeight() != 0 && !clnt.IsFrozen() { // TODO: re-enable this check && clnt.GetChainID() == dst { + if relayer.MustGetHeight(clnt.GetLatestHeight()) != 0 && !clnt.IsFrozen() { // TODO: re-enable this check && clnt.GetChainID() == dst { path.Src.ClientID = c.ClientId } } @@ -115,7 +115,7 @@ func pathsGenCmd() *cobra.Command { for _, c := range dstClients { // TODO: support other client types through a switch here as they become available clnt, _ := clientTypes.UnpackClientState(c.ClientState) - if clnt.GetLatestHeight() != 0 && !clnt.IsFrozen() { // TODO: re-enable this check && clnt.GetChainID() == src { + if relayer.MustGetHeight(clnt.GetLatestHeight()) != 0 && !clnt.IsFrozen() { // TODO: re-enable this check && clnt.GetChainID() == src { path.Dst.ClientID = c.ClientId } } diff --git a/cmd/query.go b/cmd/query.go index d2eccfc87..ef03280c5 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -107,7 +107,7 @@ documents its respective events under 'cosmos-sdk/x/{module}/spec/xx_events.md'. return err } - txs, err := chain.QueryTxs(h.GetHeight(), page, limit, events) + txs, err := chain.QueryTxs(relayer.MustGetHeight(h.GetHeight()), page, limit, events) if err != nil { return err } diff --git a/cmd/raw.go b/cmd/raw.go index 4457c666a..a55e5d3d1 100644 --- a/cmd/raw.go +++ b/cmd/raw.go @@ -184,7 +184,7 @@ func connTry() *cobra.Command { if err != nil { return err } - dstCsHeight := int64(dstClientState.GetLatestHeight()) + dstCsHeight := int64(relayer.MustGetHeight(dstClientState.GetLatestHeight())) // Then we need to query the consensus state for src at that height on dst dstConsState, err := chains[dst].QueryClientConsensusState(uint64(dstCsHeight)) @@ -242,7 +242,7 @@ func connAck() *cobra.Command { return err } dstClientState, _ := clientTypes.UnpackClientState(dstClientStateResponse.ClientState) - dstCsHeight := int64(dstClientState.GetLatestHeight()) + dstCsHeight := int64(relayer.MustGetHeight(dstClientState.GetLatestHeight())) // Then we need to query the consensus state for src at that height on dst dstConsState, err := chains[dst].QueryClientConsensusState(uint64(dstCsHeight)) diff --git a/dev-env b/dev-env index 451ffcd98..42ed39237 100755 --- a/dev-env +++ b/dev-env @@ -18,4 +18,7 @@ rm -rf $RELAYER_CONF &> /dev/null bash scripts/two-chainz "local" "skip" bash scripts/config-relayer "skip" -rly tx full-path demo -d \ No newline at end of file +echo "waiting for blocks..." +sleep 5 + +rly tx full-path demo -d -o 3s \ No newline at end of file diff --git a/go.mod b/go.mod index 43e742574..405d6d3ee 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200901224407-b043797a0794 + github.com/cosmos/cosmos-sdk v0.34.4-0.20200902231530-7602b5a5fb7e github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 diff --git a/go.sum b/go.sum index 207aaa5cd..b5332db7b 100644 --- a/go.sum +++ b/go.sum @@ -126,6 +126,11 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/cosmos-sdk v0.34.4-0.20200901224407-b043797a0794 h1:EYw3ZQXN+Rm+48C4TwkRHCAB+6DeJgN4JuwFk+szsb4= github.com/cosmos/cosmos-sdk v0.34.4-0.20200901224407-b043797a0794/go.mod h1:NUfsL2rXjFdO3GCHutCGWWKrRyL7MaSyDj86YbVBgGQ= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200901232145-2d1a2b2110ef h1:gmJ2pgLUU077KiNFJF/JG5qsI4BzkOQ3HuB95StMpBQ= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200901232145-2d1a2b2110ef/go.mod h1:NUfsL2rXjFdO3GCHutCGWWKrRyL7MaSyDj86YbVBgGQ= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200902231530-7602b5a5fb7e h1:eE/zxGG0pdP0cayzxG2o1haiowTztNX9UVBm37iZxio= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200902231530-7602b5a5fb7e/go.mod h1:NUfsL2rXjFdO3GCHutCGWWKrRyL7MaSyDj86YbVBgGQ= +github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac= 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/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= @@ -601,6 +606,7 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ= github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= github.com/tendermint/tm-db v0.6.1 h1:w3X87itMPXopcRPlFiqspEKhw4FXihPk2rnFFkP0zGk= diff --git a/relayer/client-tx.go b/relayer/client-tx.go index d5ebeb058..3126aa7bf 100644 --- a/relayer/client-tx.go +++ b/relayer/client-tx.go @@ -19,7 +19,7 @@ func (c *Chain) CreateClients(dst *Chain) (err error) { return err } if c.debug { - c.logCreateClient(dst, dstH.GetHeight()) + c.logCreateClient(dst, MustGetHeight(dstH.GetHeight())) } clients.Src = append(clients.Src, c.PathEnd.CreateClient(dstH, dst.GetTrustingPeriod(), c.MustGetAddress())) } @@ -31,7 +31,7 @@ func (c *Chain) CreateClients(dst *Chain) (err error) { return err } if dst.debug { - dst.logCreateClient(c, srcH.GetHeight()) + dst.logCreateClient(c, MustGetHeight(srcH.GetHeight())) } clients.Dst = append(clients.Dst, dst.PathEnd.CreateClient(srcH, c.GetTrustingPeriod(), dst.MustGetAddress())) } diff --git a/relayer/connection-tx.go b/relayer/connection-tx.go index d414458e0..99a52ffec 100644 --- a/relayer/connection-tx.go +++ b/relayer/connection-tx.go @@ -111,7 +111,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { } // Store the heights - srcConsH, dstConsH := int64(srcCS.GetLatestHeight()), int64(dstCS.GetLatestHeight()) + srcConsH, dstConsH := int64(MustGetHeight(srcCS.GetLatestHeight())), int64(MustGetHeight(dstCS.GetLatestHeight())) // NOTE: We query connection at height - 1 because of the way tendermint returns // proofs the commit for height n is contained in the header of height n + 1 diff --git a/relayer/headers.go b/relayer/headers.go index 9ce7aeee1..5f89f01f7 100644 --- a/relayer/headers.go +++ b/relayer/headers.go @@ -3,7 +3,9 @@ package relayer import ( "sync" + clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" + clientExported "github.com/cosmos/cosmos-sdk/x/ibc/exported" ) // NewSyncHeaders returns a new instance of map[string]*tmclient.Header that can be easily @@ -47,5 +49,14 @@ func (uh *SyncHeaders) GetHeader(chainID string) *tmclient.Header { func (uh *SyncHeaders) GetHeight(chainID string) uint64 { uh.Lock() defer uh.Unlock() - return uh.hds[chainID].GetHeight() + return MustGetHeight(uh.hds[chainID].GetHeight()) +} + +// MustGetHeight takes the height inteface and returns the actual height +func MustGetHeight(h clientExported.Height) uint64 { + height, ok := h.(clientTypes.Height) + if !ok { + panic("height is not an instance of height! wtf") + } + return height.EpochHeight } diff --git a/relayer/packet-tx.go b/relayer/packet-tx.go index f3b0cebf4..6378d74e1 100644 --- a/relayer/packet-tx.go +++ b/relayer/packet-tx.go @@ -40,7 +40,7 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, return err } - timeoutHeight := dstHeader.GetHeight() + uint64(defaultPacketTimeout) + timeoutHeight := MustGetHeight(dstHeader.GetHeight()) + uint64(defaultPacketTimeout) // Properly render the address string dst.UseSDKContext() @@ -121,7 +121,7 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, defaultPacketTimeoutStamp(), xferPacket, srcCommitRes.Proof, - srcCommitRes.ProofHeight, + MustGetHeight(srcCommitRes.ProofHeight), dst.MustGetAddress(), ), }, diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index 74822b0be..057b671ae 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -1,6 +1,7 @@ package relayer import ( + "fmt" "strings" "time" @@ -67,19 +68,32 @@ func (pe *PathEnd) CreateClient(dstHeader *tmclient.Header, trustingPeriod time. panic(err) } + // Blank Client State + // TODO: figure out how to dynmaically set unbonding time clientState := tmclient.NewClientState( - dstHeader.GetHeader().GetChainID(), tmclient.NewFractionFromTm(light.DefaultTrustLevel), trustingPeriod, trustingPeriod*2, time.Minute*1, clientTypes.NewHeight(0, dstHeader.GetHeight()), commitmenttypes.GetSDKSpecs(), + dstHeader.GetHeader().GetChainID(), + tmclient.NewFractionFromTm(light.DefaultTrustLevel), + trustingPeriod, + trustingPeriod*2, + time.Minute*1, + dstHeader.GetHeight().(clientTypes.Height), + commitmenttypes.GetSDKSpecs(), ) - // TODO: figure out how to dynmaically set unbonding time + msg, err := clientTypes.NewMsgCreateClient( pe.ClientID, clientState, dstHeader.ConsensusState(), signer, ) + if err != nil { panic(err) } + if err = msg.ValidateBasic(); err != nil { + fmt.Printf("%#v\n", dstHeader) + panic(err) + } return msg } @@ -123,8 +137,8 @@ func (pe *PathEnd) ConnTry( dstConnState.Proof, dstClientState.Proof, dstConsState.Proof, - dstConsState.ProofHeight+1, - css.GetHeight(), + dstConsState.ProofHeight.Increment(), + css.GetHeight().(clientTypes.Height), signer, ) @@ -154,7 +168,7 @@ func (pe *PathEnd) ConnAck( dstClientState.Proof, dstConsState.Proof, dstConsState.ProofHeight, - css.GetHeight(), + css.GetHeight().(clientTypes.Height), defaultIBCVersion, signer, ) @@ -166,7 +180,7 @@ func (pe *PathEnd) ConnConfirm(dstConnState *connTypes.QueryConnectionResponse, return connTypes.NewMsgConnectionOpenConfirm( pe.ConnectionID, dstConnState.Proof, - dstConnState.ProofHeight+1, + dstConnState.ProofHeight.Increment(), signer, ) } @@ -197,7 +211,7 @@ func (pe *PathEnd) ChanTry(dst *PathEnd, dstChanState *chanTypes.QueryChannelRes dst.ChannelID, dstChanState.Channel.Version, dstChanState.Proof, - dstChanState.ProofHeight+1, + dstChanState.ProofHeight.Increment(), signer, ) } @@ -209,7 +223,7 @@ func (pe *PathEnd) ChanAck(dstChanState *chanTypes.QueryChannelResponse, signer pe.ChannelID, dstChanState.Channel.Version, dstChanState.Proof, - dstChanState.ProofHeight+1, + dstChanState.ProofHeight.Increment(), signer, ) } @@ -220,7 +234,7 @@ func (pe *PathEnd) ChanConfirm(dstChanState *chanTypes.QueryChannelResponse, sig pe.PortID, pe.ChannelID, dstChanState.Proof, - dstChanState.ProofHeight+1, + dstChanState.ProofHeight.Increment(), signer, ) } @@ -240,7 +254,7 @@ func (pe *PathEnd) ChanCloseConfirm(dstChanState *chanTypes.QueryChannelResponse pe.PortID, pe.ChannelID, dstChanState.Proof, - dstChanState.ProofHeight+1, + dstChanState.ProofHeight.Increment(), signer, ) } @@ -314,7 +328,7 @@ func (pe *PathEnd) MsgTransfer(dst *PathEnd, amount sdk.Coin, dstAddr string, amount, signer, dstAddr, - timeoutHeight, + clientTypes.NewHeight(timeoutHeight, timeoutHeight), timeoutTimestamp, ) } @@ -340,7 +354,7 @@ func (pe *PathEnd) NewPacket(dst *PathEnd, sequence uint64, packetData []byte, pe.ChannelID, dst.PortID, dst.ChannelID, - timeoutHeight, + clientTypes.NewHeight(timeoutHeight, timeoutHeight), timeoutStamp, ) } @@ -365,7 +379,7 @@ func (c *Chain) PacketMsg(dst *Chain, xferPacket []byte, timeout, timeoutStamp u timeoutStamp, xferPacket, dstCommitRes.Proof, - dstCommitRes.ProofHeight, + MustGetHeight(dstCommitRes.ProofHeight), c.MustGetAddress(), ) } diff --git a/relayer/query.go b/relayer/query.go index 5811e2bc5..690a4c5b8 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -82,7 +82,7 @@ func (c *Chain) QueryConsensusState() (*tmclient.ConsensusState, int64, error) { // QueryClientConsensusState retrevies the latest consensus state for a client in state at a given height func (c *Chain) QueryClientConsensusState(clientConsHeight uint64) (*clientTypes.QueryConsensusStateResponse, error) { - return clientUtils.QueryConsensusStateABCI(c.CLIContext(), c.PathEnd.ClientID, clientConsHeight) + return clientUtils.QueryConsensusStateABCI(c.CLIContext(), c.PathEnd.ClientID, clientTypes.NewHeight(0, clientConsHeight)) } type csstates struct { @@ -100,7 +100,6 @@ type chh struct { // QueryClientConsensusStatePair allows for the querying of multiple client states at the same time func QueryClientConsensusStatePair(src, dst *Chain, srcH, dstH, srcClientConsH, dstClientConsH int64) (map[string]*clientTypes.QueryConsensusStateResponse, error) { - fmt.Println("QueryClientConsensusStatePair") hs := &csstates{ Map: make(map[string]*clientTypes.QueryConsensusStateResponse), Errs: []error{}, diff --git a/relayer/relayPackets.go b/relayer/relayPackets.go index f4c119583..808de6f23 100644 --- a/relayer/relayPackets.go +++ b/relayer/relayPackets.go @@ -72,7 +72,7 @@ func (rp *relayMsgTimeout) Msg(src, dst *Chain) sdk.Msg { rp.timeout, rp.timeoutStamp, rp.dstRecvRes.Proof, - rp.dstRecvRes.ProofHeight, + MustGetHeight(rp.dstRecvRes.ProofHeight), src.MustGetAddress(), ) } @@ -169,7 +169,7 @@ func (rp *relayMsgPacketAck) Msg(src, dst *Chain) sdk.Msg { rp.ack, rp.packetData, rp.dstComRes.Proof, - rp.dstComRes.ProofHeight, + MustGetHeight(rp.dstComRes.ProofHeight), src.MustGetAddress(), ) } From 97553d5ac493f1eb88391455f4686ebf7a2bbc23 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Fri, 4 Sep 2020 07:36:28 -0700 Subject: [PATCH 13/54] Pull in latest sdk --- go.mod | 2 +- go.sum | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 405d6d3ee..2b9f28828 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200902231530-7602b5a5fb7e + github.com/cosmos/cosmos-sdk v0.34.4-0.20200904115902-e9a0e82895f2 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 diff --git a/go.sum b/go.sum index b5332db7b..1d7d6ab81 100644 --- a/go.sum +++ b/go.sum @@ -124,13 +124,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200901224407-b043797a0794 h1:EYw3ZQXN+Rm+48C4TwkRHCAB+6DeJgN4JuwFk+szsb4= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200901224407-b043797a0794/go.mod h1:NUfsL2rXjFdO3GCHutCGWWKrRyL7MaSyDj86YbVBgGQ= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200901232145-2d1a2b2110ef h1:gmJ2pgLUU077KiNFJF/JG5qsI4BzkOQ3HuB95StMpBQ= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200901232145-2d1a2b2110ef/go.mod h1:NUfsL2rXjFdO3GCHutCGWWKrRyL7MaSyDj86YbVBgGQ= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200902231530-7602b5a5fb7e h1:eE/zxGG0pdP0cayzxG2o1haiowTztNX9UVBm37iZxio= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200902231530-7602b5a5fb7e/go.mod h1:NUfsL2rXjFdO3GCHutCGWWKrRyL7MaSyDj86YbVBgGQ= -github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200904115902-e9a0e82895f2 h1:yZFBwwKiCuvDf0zFHSCAk+I92zCqLljuJ3dE3E9FXTo= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200904115902-e9a0e82895f2/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= 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/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= @@ -288,6 +283,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.14.7 h1:Nk5kuHrnWUTf/0GL1a/vchH/om9Ap2/HnVna+jYZgTY= github.com/grpc-ecosystem/grpc-gateway v1.14.7/go.mod h1:oYZKL012gGh6LMyg/xA7Q2yq6j8bu0wa+9w14EEthWU= +github.com/grpc-ecosystem/grpc-gateway v1.14.8 h1:hXClj+iFpmLM8i3lkO6i4Psli4P2qObQuQReiII26U8= +github.com/grpc-ecosystem/grpc-gateway v1.14.8/go.mod h1:NZE8t6vs6TnwLL/ITkaK8W3ecMLGAbh2jXTclvpiwYo= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= @@ -606,7 +603,6 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ= github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= github.com/tendermint/tm-db v0.6.1 h1:w3X87itMPXopcRPlFiqspEKhw4FXihPk2rnFFkP0zGk= From a7caf168c9e977b2e0311f12c0b13671e5cb0be1 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Mon, 7 Sep 2020 08:38:04 -0700 Subject: [PATCH 14/54] Update relayer to latest version of sdk --- cmd/query.go | 24 ++++++++++++++++++++++-- go.mod | 2 +- go.sum | 3 +++ relayer/pathEnd.go | 2 ++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/cmd/query.go b/cmd/query.go index ef03280c5..f18457338 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -2,12 +2,15 @@ package cmd import ( "context" + "encoding/json" + "fmt" "strconv" "strings" "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" @@ -276,7 +279,18 @@ func queryClientCmd() *cobra.Command { return err } - return chain.Print(res, false, false) + cs, err := clienttypes.UnpackClientState(res.ClientState) + if err != nil { + return err + } + + out, err := json.Marshal(cs) + if err != nil { + return err + } + + fmt.Println(out) + return nil }, } @@ -310,7 +324,13 @@ func queryClientsCmd() *cobra.Command { return err } - return chain.Print(res, false, false) + out, err := json.Marshal(res) + if err != nil { + return err + } + + fmt.Println(string(out)) + return nil }, } diff --git a/go.mod b/go.mod index 2b9f28828..24028d16b 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200904115902-e9a0e82895f2 + github.com/cosmos/cosmos-sdk v0.34.4-0.20200907144712-64b6bb5270e1 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 diff --git a/go.sum b/go.sum index 1d7d6ab81..cb1c7b407 100644 --- a/go.sum +++ b/go.sum @@ -126,6 +126,9 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/cosmos-sdk v0.34.4-0.20200904115902-e9a0e82895f2 h1:yZFBwwKiCuvDf0zFHSCAk+I92zCqLljuJ3dE3E9FXTo= github.com/cosmos/cosmos-sdk v0.34.4-0.20200904115902-e9a0e82895f2/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200907144712-64b6bb5270e1 h1:VUBzclmQcIiURFnjNSc6GCp494B5Jbe1HcK1htE1rUQ= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200907144712-64b6bb5270e1/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= +github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac= 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/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index 057b671ae..d87955918 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -78,6 +78,8 @@ func (pe *PathEnd) CreateClient(dstHeader *tmclient.Header, trustingPeriod time. time.Minute*1, dstHeader.GetHeight().(clientTypes.Height), commitmenttypes.GetSDKSpecs(), + false, + false, ) msg, err := clientTypes.NewMsgCreateClient( From d1b253eace2ee785e9bff79717eeed2cd0cd9383 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Mon, 7 Sep 2020 12:37:24 -0700 Subject: [PATCH 15/54] Prepare to fix update-client --- go.mod | 4 +++- go.sum | 6 +----- relayer/pathEnd.go | 9 ++++++--- relayer/verifier.go | 5 ++++- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 24028d16b..98b857852 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200907144712-64b6bb5270e1 + github.com/cosmos/cosmos-sdk v0.34.4-0.20200907170811-2539f6e4885d github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 @@ -22,3 +22,5 @@ require ( replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 + +replace github.com/cosmos/cosmos-sdk => /Users/johnzampolin/go/src/github.com/cosmos/cosmos-sdk diff --git a/go.sum b/go.sum index cb1c7b407..9d62f872d 100644 --- a/go.sum +++ b/go.sum @@ -124,11 +124,6 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200904115902-e9a0e82895f2 h1:yZFBwwKiCuvDf0zFHSCAk+I92zCqLljuJ3dE3E9FXTo= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200904115902-e9a0e82895f2/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200907144712-64b6bb5270e1 h1:VUBzclmQcIiURFnjNSc6GCp494B5Jbe1HcK1htE1rUQ= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200907144712-64b6bb5270e1/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= -github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac= 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/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= @@ -606,6 +601,7 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ= github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= github.com/tendermint/tm-db v0.6.1 h1:w3X87itMPXopcRPlFiqspEKhw4FXihPk2rnFFkP0zGk= diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index d87955918..a5f37ddf1 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -128,14 +128,14 @@ func (pe *PathEnd) ConnTry( if err != nil { panic(err) } - return connTypes.NewMsgConnectionOpenTry( + msg := connTypes.NewMsgConnectionOpenTry( pe.ConnectionID, pe.ClientID, dst.ConnectionID, dst.ClientID, cs, defaultChainPrefix, - defaultIBCVersions, + connTypes.GetCompatibleEncodedVersions(), dstConnState.Proof, dstClientState.Proof, dstConsState.Proof, @@ -143,7 +143,10 @@ func (pe *PathEnd) ConnTry( css.GetHeight().(clientTypes.Height), signer, ) - + if err = msg.ValidateBasic(); err != nil { + panic(err) + } + return msg } // ConnAck creates a MsgConnectionOpenAck diff --git a/relayer/verifier.go b/relayer/verifier.go index 805acbdb6..18beb69f4 100644 --- a/relayer/verifier.go +++ b/relayer/verifier.go @@ -142,7 +142,10 @@ func (c *Chain) UpdateLiteWithHeader() (*tmclient.Header, error) { return nil, err } - return &tmclient.Header{SignedHeader: sh.ToProto(), ValidatorSet: protoVal}, nil + return &tmclient.Header{ + SignedHeader: sh.ToProto(), + ValidatorSet: protoVal, + }, nil } // UpdateLiteWithHeaderHeight updates the lite client database to the given height From 5a6b12ff10c47f645e5891d8706009b6b6ee370e Mon Sep 17 00:00:00 2001 From: Aditya Sripal Date: Mon, 7 Sep 2020 18:16:01 -0400 Subject: [PATCH 16/54] add inject fields method --- go.mod | 2 -- go.sum | 2 ++ relayer/headers.go | 33 +++++++++++++++++++++++++++++++++ relayer/query.go | 40 ++++++++++++++++++++++++++++++++++++++++ test/test_queries.go | 1 - test/test_setup.go | 3 +-- 6 files changed, 76 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 98b857852..efce40b8b 100644 --- a/go.mod +++ b/go.mod @@ -22,5 +22,3 @@ require ( replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 - -replace github.com/cosmos/cosmos-sdk => /Users/johnzampolin/go/src/github.com/cosmos/cosmos-sdk diff --git a/go.sum b/go.sum index 9d62f872d..41b572276 100644 --- a/go.sum +++ b/go.sum @@ -124,6 +124,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200907170811-2539f6e4885d h1:SY01N8C0OlGGEZ3nYGkEr5jUPQypdLbLKcFu5CqA6rw= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200907170811-2539f6e4885d/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= 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/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= diff --git a/relayer/headers.go b/relayer/headers.go index 5f89f01f7..51818c464 100644 --- a/relayer/headers.go +++ b/relayer/headers.go @@ -1,6 +1,7 @@ package relayer import ( + "fmt" "sync" clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" @@ -52,6 +53,38 @@ func (uh *SyncHeaders) GetHeight(chainID string) uint64 { return MustGetHeight(uh.hds[chainID].GetHeight()) } +// GetTrustedHeaderForChain returns the latest header for the chain specified by the chainID +// with the trusted fields injected for the given destination chain (ie chain that receives UpdateClient +// msg). The TrustedHeight will be the current height of the src client stored on the dst chain. And the +// TrustedVals will be the src validators at the trusted height +func InjectTrustedFields(srcChain, dstChain *Chain, srcHeader *tmclient.Header) (*tmclient.Header, error) { + // make copy of header stored in mop + h := *(srcHeader) + // check that dstChain PathEnd set correctly + if dstChain.PathEnd.ChainID != h.Header.ChainID { + return nil, fmt.Errorf("counterparty chain has incorrect PathEnd. expected chainID: %s, got: %s", dstChain.PathEnd.ChainID, h.Header.ChainID) + } + // retrieve counterparty client from dst chain + counterpartyClientRes, err := dstChain.QueryClientState() + if err != nil { + return nil, err + } + cs, err := clientTypes.UnpackClientState(counterpartyClientRes.ClientState) + if err != nil { + panic(err) + } + // inject TrustedHeight as latest height stored on counterparty client + h.TrustedHeight = cs.GetLatestHeight().(clientTypes.Height) + // query TrustedValidators at Trusted Height from srcChain + valSet, err := srcChain.QueryValsetAtHeight(h.TrustedHeight) + if err != nil { + return nil, err + } + // inject TrustedValidators into header + h.TrustedValidators = valSet + return &h, nil +} + // MustGetHeight takes the height inteface and returns the actual height func MustGetHeight(h clientExported.Height) uint64 { height, ok := h.(clientTypes.Height) diff --git a/relayer/query.go b/relayer/query.go index 690a4c5b8..d8ef814ac 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -23,7 +23,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" rpcclient "github.com/tendermint/tendermint/rpc/client" ctypes "github.com/tendermint/tendermint/rpc/core/types" tmtypes "github.com/tendermint/tendermint/types" @@ -331,6 +333,44 @@ func (c *Chain) QueryChannels(offset, limit uint64) ([]*chanTypes.IdentifiedChan return res.Channels, err } +// /////////////////////////////////// +// STAKING -> HistoricalInfo // +// /////////////////////////////////// + +func (c *Chain) QueryHistoricalInfo(height clientTypes.Height) (*stakingTypes.QueryHistoricalInfoResponse, error) { + //TODO: use epoch number in query once SDK gets updated + params := stakingTypes.QueryHistoricalInfoRequest{ + Height: int64(height.EpochHeight), + } + + queryClient := stakingTypes.NewQueryClient(c.CLIContext()) + + res, err := queryClient.HistoricalInfo(context.Background(), ¶ms) + if err != nil { + return nil, err + } + + return res, nil +} + +func (c *Chain) QueryValsetAtHeight(height clientTypes.Height) (*tmproto.ValidatorSet, error) { + res, err := c.QueryHistoricalInfo(height) + if err != nil { + return nil, err + } + + // create tendermint ValidatorSet from SDK Validators + tmVals := stakingTypes.Validators(res.Hist.Valset).ToTmValidators() + tmValSet := &tmtypes.ValidatorSet{ + Validators: tmVals, + } + tmProtoSet, err := tmValSet.ToProto() + if err != nil { + return nil, err + } + return tmProtoSet, nil +} + // WaitForNBlocks blocks until the next block on a given chain func (c *Chain) WaitForNBlocks(n int64) error { var initial int64 diff --git a/test/test_queries.go b/test/test_queries.go index d19b337b2..7ef89eb36 100644 --- a/test/test_queries.go +++ b/test/test_queries.go @@ -22,7 +22,6 @@ func testClient(t *testing.T, src, dst *ry.Chain) { require.NotNil(t, client) cs, err := clientTypes.UnpackClientState(client.ClientState) require.NoError(t, err) - require.Equal(t, cs.GetChainID(), src.PathEnd.ChainID) require.Equal(t, cs.ClientType().String(), "tendermint") } diff --git a/test/test_setup.go b/test/test_setup.go index 21be74f57..3a646a891 100644 --- a/test/test_setup.go +++ b/test/test_setup.go @@ -137,8 +137,7 @@ func spinUpTestContainer(t *testing.T, rchan chan<- *dockertest.Resource, func() { // Ensure our address is encoded properly. - done := c.UseSDKContext() - defer done() + c.UseSDKContext() dockerOpts.Cmd = []string{c.ChainID, c.MustGetAddress().String()} dockerOpts.Labels = make(map[string]string) From e3018a357cc6ebb3fcdc02e4d8e2b766c84e7dc3 Mon Sep 17 00:00:00 2001 From: Aditya Sripal Date: Mon, 7 Sep 2020 18:19:05 -0400 Subject: [PATCH 17/54] fix godoc --- relayer/headers.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/relayer/headers.go b/relayer/headers.go index 51818c464..84157e429 100644 --- a/relayer/headers.go +++ b/relayer/headers.go @@ -53,10 +53,11 @@ func (uh *SyncHeaders) GetHeight(chainID string) uint64 { return MustGetHeight(uh.hds[chainID].GetHeight()) } -// GetTrustedHeaderForChain returns the latest header for the chain specified by the chainID -// with the trusted fields injected for the given destination chain (ie chain that receives UpdateClient -// msg). The TrustedHeight will be the current height of the src client stored on the dst chain. And the -// TrustedVals will be the src validators at the trusted height +// InjectTrustedFields injects the necessary trusted fields for a srcHeader coming from a srcChain +// destined for an IBC client stored on the dstChain +// TrustedHeight is the latest height of the IBC client on dstChain +// TrustedValidators is the validator set of srcChain at the TrustedHeight +// InjectTrustedFields returns a copy of the header with TrustedFields modified func InjectTrustedFields(srcChain, dstChain *Chain, srcHeader *tmclient.Header) (*tmclient.Header, error) { // make copy of header stored in mop h := *(srcHeader) From 85e4593d6ea68305c372347fe571b70ff914f174 Mon Sep 17 00:00:00 2001 From: Aditya Sripal Date: Mon, 7 Sep 2020 19:30:30 -0400 Subject: [PATCH 18/54] fix UpdateClient --- cmd/raw.go | 48 ++++++++++++++++++++++++++++++++------- relayer/channel-tx.go | 38 +++++++++++++++++++++++-------- relayer/connection-tx.go | 26 ++++++++++++++++----- relayer/headers.go | 14 ++++++++---- relayer/naive-strategy.go | 20 +++++++++++++--- relayer/packet-tx.go | 6 ++++- relayer/query.go | 1 + 7 files changed, 121 insertions(+), 32 deletions(-) diff --git a/cmd/raw.go b/cmd/raw.go index a55e5d3d1..b52d0c6dd 100644 --- a/cmd/raw.go +++ b/cmd/raw.go @@ -79,7 +79,11 @@ func updateClientCmd() *cobra.Command { } } - return sendAndPrint([]sdk.Msg{chains[src].PathEnd.UpdateClient(dstHeader, chains[src].MustGetAddress())}, + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], dstHeader) + if err != nil { + return err + } + return sendAndPrint([]sdk.Msg{chains[src].PathEnd.UpdateClient(updateHeader, chains[src].MustGetAddress())}, chains[src], cmd) }, } @@ -192,8 +196,12 @@ func connTry() *cobra.Command { return err } + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], hs[dst]) + if err != nil { + return err + } txs := []sdk.Msg{ - chains[src].PathEnd.UpdateClient(hs[dst], chains[src].MustGetAddress()), + chains[src].PathEnd.UpdateClient(updateHeader, chains[src].MustGetAddress()), chains[src].PathEnd.ConnTry(chains[dst].PathEnd, dstClientStateRes, dstConnState, dstConsState, chains[src].MustGetAddress()), } @@ -250,9 +258,13 @@ func connAck() *cobra.Command { return err } + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], hs[dst]) + if err != nil { + return err + } txs := []sdk.Msg{ chains[src].PathEnd.ConnAck(chains[dst].PathEnd, dstClientStateResponse, dstState, dstConsState, chains[src].MustGetAddress()), - chains[src].PathEnd.UpdateClient(hs[dst], chains[src].MustGetAddress()), + chains[src].PathEnd.UpdateClient(updateHeader, chains[src].MustGetAddress()), } return sendAndPrint(txs, chains[src], cmd) @@ -293,9 +305,13 @@ func connConfirm() *cobra.Command { return err } + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], hs[dst]) + if err != nil { + return err + } txs := []sdk.Msg{ chains[src].PathEnd.ConnConfirm(dstState, chains[src].MustGetAddress()), - chains[src].PathEnd.UpdateClient(hs[dst], chains[src].MustGetAddress()), + chains[src].PathEnd.UpdateClient(updateHeader, chains[src].MustGetAddress()), } return sendAndPrint(txs, chains[src], cmd) @@ -408,8 +424,12 @@ func chanTry() *cobra.Command { return err } + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], dstHeader) + if err != nil { + return err + } txs := []sdk.Msg{ - chains[src].PathEnd.UpdateClient(dstHeader, chains[src].MustGetAddress()), + chains[src].PathEnd.UpdateClient(updateHeader, chains[src].MustGetAddress()), chains[src].PathEnd.ChanTry(chains[dst].PathEnd, dstChanState, chains[src].MustGetAddress()), } @@ -450,8 +470,12 @@ func chanAck() *cobra.Command { return err } + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], dstHeader) + if err != nil { + return err + } txs := []sdk.Msg{ - chains[src].PathEnd.UpdateClient(dstHeader, chains[src].MustGetAddress()), + chains[src].PathEnd.UpdateClient(updateHeader, chains[src].MustGetAddress()), chains[src].PathEnd.ChanAck(dstChanState, chains[src].MustGetAddress()), } @@ -492,8 +516,12 @@ func chanConfirm() *cobra.Command { return err } + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], dstHeader) + if err != nil { + return err + } txs := []sdk.Msg{ - chains[src].PathEnd.UpdateClient(dstHeader, chains[src].MustGetAddress()), + chains[src].PathEnd.UpdateClient(updateHeader, chains[src].MustGetAddress()), chains[src].PathEnd.ChanConfirm(dstChanState, chains[src].MustGetAddress()), } @@ -599,8 +627,12 @@ func chanCloseConfirm() *cobra.Command { return err } + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], dstHeader) + if err != nil { + return err + } txs := []sdk.Msg{ - chains[src].PathEnd.UpdateClient(dstHeader, chains[src].MustGetAddress()), + chains[src].PathEnd.UpdateClient(updateHeader, chains[src].MustGetAddress()), chains[src].PathEnd.ChanCloseConfirm(dstChanState, chains[src].MustGetAddress()), } diff --git a/relayer/channel-tx.go b/relayer/channel-tx.go index 2608f46d9..5cc5007ea 100644 --- a/relayer/channel-tx.go +++ b/relayer/channel-tx.go @@ -86,6 +86,15 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM if err != nil { return nil, err } + // create the UpdateHeaders for src and dest Chains + srcUpdateHeader, err := InjectTrustedFields(c, dst, hs[scid]) + if err != nil { + return nil, err + } + dstUpdateHeader, err := InjectTrustedFields(dst, c, hs[dcid]) + if err != nil { + return nil, err + } chans, err := QueryChannelPair(c, dst, hs[scid].Header.Height-1, hs[dcid].Header.Height-1) if err != nil { @@ -108,7 +117,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM logChannelStates(c, dst, chans) } out.Src = append(out.Src, - c.PathEnd.UpdateClient(hs[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ChanTry(dst.PathEnd, chans[dcid], c.MustGetAddress()), ) @@ -118,7 +127,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM logChannelStates(dst, c, chans) } out.Dst = append(out.Dst, - dst.PathEnd.UpdateClient(hs[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), dst.PathEnd.ChanTry(c.PathEnd, chans[scid], dst.MustGetAddress()), ) @@ -128,7 +137,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM logChannelStates(dst, c, chans) } out.Dst = append(out.Dst, - dst.PathEnd.UpdateClient(hs[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), dst.PathEnd.ChanAck(chans[scid], dst.MustGetAddress()), ) @@ -138,7 +147,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM logChannelStates(c, dst, chans) } out.Src = append(out.Src, - c.PathEnd.UpdateClient(hs[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ChanAck(chans[dcid], c.MustGetAddress()), ) @@ -148,7 +157,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM logChannelStates(c, dst, chans) } out.Src = append(out.Src, - c.PathEnd.UpdateClient(hs[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ChanConfirm(chans[dcid], c.MustGetAddress()), ) out.last = true @@ -159,7 +168,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM logChannelStates(dst, c, chans) } out.Dst = append(out.Dst, - dst.PathEnd.UpdateClient(hs[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), dst.PathEnd.ChanConfirm(chans[scid], dst.MustGetAddress()), ) out.last = true @@ -221,6 +230,15 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { if err != nil { return nil, err } + // create the UpdateHeaders for src and dest Chains + srcUpdateHeader, err := InjectTrustedFields(c, dst, hs[scid]) + if err != nil { + return nil, err + } + dstUpdateHeader, err := InjectTrustedFields(dst, c, hs[dcid]) + if err != nil { + return nil, err + } chans, err := QueryChannelPair(c, dst, hs[scid].Header.Height-1, hs[dcid].Header.Height-1) if err != nil { @@ -237,7 +255,7 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { logChannelStates(c, dst, chans) } out.Src = append(out.Src, - c.PathEnd.UpdateClient(hs[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ChanCloseInit(c.MustGetAddress()), ) } else if chans[dcid].Channel.State != chantypes.UNINITIALIZED { @@ -245,7 +263,7 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { logChannelStates(dst, c, chans) } out.Dst = append(out.Dst, - dst.PathEnd.UpdateClient(hs[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), dst.PathEnd.ChanCloseInit(dst.MustGetAddress()), ) } @@ -257,7 +275,7 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { logChannelStates(dst, c, chans) } out.Dst = append(out.Dst, - dst.PathEnd.UpdateClient(hs[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), dst.PathEnd.ChanCloseConfirm(chans[scid], dst.MustGetAddress()), ) out.last = true @@ -270,7 +288,7 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { logChannelStates(c, dst, chans) } out.Src = append(out.Src, - c.PathEnd.UpdateClient(hs[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ChanCloseConfirm(chans[dcid], c.MustGetAddress()), ) out.last = true diff --git a/relayer/connection-tx.go b/relayer/connection-tx.go index 99a52ffec..f9b1f715e 100644 --- a/relayer/connection-tx.go +++ b/relayer/connection-tx.go @@ -81,6 +81,20 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { scid, dcid := c.ChainID, dst.ChainID + // create the UpdateHeaders for src and dest Chains + srcUpdateHeader, err := InjectTrustedFields(c, dst, hs[scid]) + if err != nil { + fmt.Printf("%#v\n", dst.PathEnd) + fmt.Println("SRC") + fmt.Println(scid) + return nil, err + } + dstUpdateHeader, err := InjectTrustedFields(dst, c, hs[dcid]) + if err != nil { + fmt.Println("DST") + return nil, err + } + // Query Connection data from src and dst // NOTE: We query connection at height - 1 because of the way tendermint returns // proofs the commit for height n is contained in the header of height n + 1 @@ -134,7 +148,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { logConnectionStates(c, dst, conn) } out.Src = append(out.Src, - c.PathEnd.UpdateClient(hs[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ConnTry(dst.PathEnd, cs[dcid], conn[dcid], cons[dcid], c.MustGetAddress()), ) @@ -144,7 +158,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { logConnectionStates(dst, c, conn) } out.Dst = append(out.Dst, - dst.PathEnd.UpdateClient(hs[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), dst.PathEnd.ConnTry(c.PathEnd, cs[scid], conn[scid], cons[scid], dst.MustGetAddress()), ) @@ -154,7 +168,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { logConnectionStates(dst, c, conn) } out.Dst = append(out.Dst, - dst.PathEnd.UpdateClient(hs[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), dst.PathEnd.ConnAck(c.PathEnd, cs[scid], conn[scid], cons[scid], dst.MustGetAddress()), ) @@ -164,7 +178,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { logConnectionStates(c, dst, conn) } out.Src = append(out.Src, - c.PathEnd.UpdateClient(hs[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ConnAck(dst.PathEnd, cs[dcid], conn[dcid], cons[dcid], c.MustGetAddress()), ) @@ -174,7 +188,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { logConnectionStates(c, dst, conn) } out.Src = append(out.Src, - c.PathEnd.UpdateClient(hs[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ConnConfirm(conn[dcid], c.MustGetAddress()), ) out.last = true @@ -185,7 +199,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { logConnectionStates(dst, c, conn) } out.Dst = append(out.Dst, - dst.PathEnd.UpdateClient(hs[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), dst.PathEnd.ConnConfirm(conn[scid], dst.MustGetAddress()), ) out.last = true diff --git a/relayer/headers.go b/relayer/headers.go index 84157e429..715d61375 100644 --- a/relayer/headers.go +++ b/relayer/headers.go @@ -1,7 +1,6 @@ package relayer import ( - "fmt" "sync" clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" @@ -46,6 +45,13 @@ func (uh *SyncHeaders) GetHeader(chainID string) *tmclient.Header { return uh.hds[chainID] } +// GetUpdateHeader returns a header to be used to UpdateClient of dstChain stored on srcChain +func (uh *SyncHeaders) GetUpdateHeader(srcChain, dstChain *Chain) (*tmclient.Header, error) { + h := uh.GetHeader(srcChain.ChainID) + + return InjectTrustedFields(srcChain, dstChain, h) +} + // GetHeight returns the latest height for a given chainID func (uh *SyncHeaders) GetHeight(chainID string) uint64 { uh.Lock() @@ -62,9 +68,9 @@ func InjectTrustedFields(srcChain, dstChain *Chain, srcHeader *tmclient.Header) // make copy of header stored in mop h := *(srcHeader) // check that dstChain PathEnd set correctly - if dstChain.PathEnd.ChainID != h.Header.ChainID { - return nil, fmt.Errorf("counterparty chain has incorrect PathEnd. expected chainID: %s, got: %s", dstChain.PathEnd.ChainID, h.Header.ChainID) - } + // if dstChain.PathEnd.ChainID != h.Header.ChainID { + // return nil, fmt.Errorf("counterparty chain has incorrect PathEnd. expected chainID: %s, got: %s", dstChain.PathEnd.ChainID, h.Header.ChainID) + // } // retrieve counterparty client from dst chain counterpartyClientRes, err := dstChain.QueryClientState() if err != nil { diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index 83c0fe301..e53e18ce7 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -162,10 +162,14 @@ func (nrs *NaiveStrategy) sendTxFromEventPackets(src, dst *Chain, rlyPackets []r // send the transaction, retrying if not successful if err := retry.Do(func() error { + updateHeader, err := sh.GetUpdateHeader(src, dst) + if err != nil { + return err + } // instantiate the RelayMsgs with the appropriate update client txs := &RelayMsgs{ Src: []sdk.Msg{ - src.PathEnd.UpdateClient(sh.GetHeader(dst.ChainID), src.MustGetAddress()), + src.PathEnd.UpdateClient(updateHeader, src.MustGetAddress()), }, Dst: []sdk.Msg{}, MaxTxSize: nrs.MaxTxSize, @@ -244,10 +248,20 @@ func (nrs *NaiveStrategy) RelayPacketsOrderedChan(src, dst *Chain, sp *RelaySequ // Prepend non-empty msg lists with UpdateClient if len(msgs.Dst) != 0 { - msgs.Dst = append([]sdk.Msg{dst.PathEnd.UpdateClient(sh.GetHeader(src.ChainID), dst.MustGetAddress())}, msgs.Dst...) + // Sending an update from src to dst + updateHeader, err := sh.GetUpdateHeader(src, dst) + if err != nil { + return err + } + msgs.Dst = append([]sdk.Msg{dst.PathEnd.UpdateClient(updateHeader, dst.MustGetAddress())}, msgs.Dst...) } if len(msgs.Src) != 0 { - msgs.Src = append([]sdk.Msg{src.PathEnd.UpdateClient(sh.GetHeader(dst.ChainID), src.MustGetAddress())}, msgs.Src...) + // Sending an update from dst to src + updateHeader, err := sh.GetUpdateHeader(dst, src) + if err != nil { + return err + } + msgs.Src = append([]sdk.Msg{src.PathEnd.UpdateClient(updateHeader, src.MustGetAddress())}, msgs.Src...) } // TODO: increase the amount of gas as the number of messages increases diff --git a/relayer/packet-tx.go b/relayer/packet-tx.go index 6378d74e1..a2a05d02c 100644 --- a/relayer/packet-tx.go +++ b/relayer/packet-tx.go @@ -108,12 +108,16 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, dstAddrString, ) + updateHeader, err := InjectTrustedFields(c, dst, hs[c.ChainID]) + if err != nil { + return err + } // Debugging by simply passing in the packet information that we know was sent earlier in the SendPacket // part of the command. In a real relayer, this would be a separate command that retrieved the packet // information from an indexing node txs = RelayMsgs{ Dst: []sdk.Msg{ - dst.PathEnd.UpdateClient(hs[c.ChainID], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(updateHeader, dst.MustGetAddress()), dst.PathEnd.MsgRecvPacket( c.PathEnd, seqRecv.NextSequenceReceive, diff --git a/relayer/query.go b/relayer/query.go index d8ef814ac..ba5f7427b 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -363,6 +363,7 @@ func (c *Chain) QueryValsetAtHeight(height clientTypes.Height) (*tmproto.Validat tmVals := stakingTypes.Validators(res.Hist.Valset).ToTmValidators() tmValSet := &tmtypes.ValidatorSet{ Validators: tmVals, + Proposer: tmVals[0], } tmProtoSet, err := tmValSet.ToProto() if err != nil { From 4d441eb097487d75fc3f23abf41f27e55d20d195 Mon Sep 17 00:00:00 2001 From: Aditya Sripal Date: Mon, 7 Sep 2020 19:48:25 -0400 Subject: [PATCH 19/54] fix clientstate bug --- cmd/raw.go | 7 ++++++- relayer/client-tx.go | 13 +++++++++++-- relayer/pathEnd.go | 4 ++-- relayer/query.go | 14 ++++++++++++++ 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/cmd/raw.go b/cmd/raw.go index b52d0c6dd..1290eccfd 100644 --- a/cmd/raw.go +++ b/cmd/raw.go @@ -112,8 +112,13 @@ func createClientCmd() *cobra.Command { return err } + ubdPeriod, err := chains[dst].QueryUnbondingPeriod() + if err != nil { + return err + } + return sendAndPrint([]sdk.Msg{chains[src].PathEnd.CreateClient(dstHeader, - chains[dst].GetTrustingPeriod(), chains[src].MustGetAddress())}, + chains[dst].GetTrustingPeriod(), ubdPeriod, chains[src].MustGetAddress())}, chains[src], cmd) }, } diff --git a/relayer/client-tx.go b/relayer/client-tx.go index 3126aa7bf..9e12eecad 100644 --- a/relayer/client-tx.go +++ b/relayer/client-tx.go @@ -21,7 +21,11 @@ func (c *Chain) CreateClients(dst *Chain) (err error) { if c.debug { c.logCreateClient(dst, MustGetHeight(dstH.GetHeight())) } - clients.Src = append(clients.Src, c.PathEnd.CreateClient(dstH, dst.GetTrustingPeriod(), c.MustGetAddress())) + ubdPeriod, err := dst.QueryUnbondingPeriod() + if err != nil { + return err + } + clients.Src = append(clients.Src, c.PathEnd.CreateClient(dstH, dst.GetTrustingPeriod(), ubdPeriod, c.MustGetAddress())) } // Create client for the source chain on destination chain if it doesn't exist @@ -33,7 +37,12 @@ func (c *Chain) CreateClients(dst *Chain) (err error) { if dst.debug { dst.logCreateClient(c, MustGetHeight(srcH.GetHeight())) } - clients.Dst = append(clients.Dst, dst.PathEnd.CreateClient(srcH, c.GetTrustingPeriod(), dst.MustGetAddress())) + ubdPeriod, err := c.QueryUnbondingPeriod() + if err != nil { + return err + } + + clients.Dst = append(clients.Dst, dst.PathEnd.CreateClient(srcH, c.GetTrustingPeriod(), ubdPeriod, dst.MustGetAddress())) } // Send msgs to both chains diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index a5f37ddf1..c76d64d53 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -63,7 +63,7 @@ func (pe *PathEnd) UpdateClient(dstHeader *tmclient.Header, signer sdk.AccAddres } // CreateClient creates an sdk.Msg to update the client on src with consensus state from dst -func (pe *PathEnd) CreateClient(dstHeader *tmclient.Header, trustingPeriod time.Duration, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) CreateClient(dstHeader *tmclient.Header, trustingPeriod, ubdPeriod time.Duration, signer sdk.AccAddress) sdk.Msg { if err := dstHeader.ValidateBasic(); err != nil { panic(err) } @@ -74,7 +74,7 @@ func (pe *PathEnd) CreateClient(dstHeader *tmclient.Header, trustingPeriod time. dstHeader.GetHeader().GetChainID(), tmclient.NewFractionFromTm(light.DefaultTrustLevel), trustingPeriod, - trustingPeriod*2, + ubdPeriod, time.Minute*1, dstHeader.GetHeight().(clientTypes.Height), commitmenttypes.GetSDKSpecs(), diff --git a/relayer/query.go b/relayer/query.go index ba5f7427b..a556986c0 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -372,6 +372,20 @@ func (c *Chain) QueryValsetAtHeight(height clientTypes.Height) (*tmproto.Validat return tmProtoSet, nil } +// QueryUnbondingPeriod returns the unbonding period of the chain +func (c *Chain) QueryUnbondingPeriod() (time.Duration, error) { + req := stakingTypes.QueryParamsRequest{} + + queryClient := stakingTypes.NewQueryClient(c.CLIContext()) + + res, err := queryClient.Params(context.Background(), &req) + if err != nil { + return 0, err + } + + return res.Params.UnbondingTime, nil +} + // WaitForNBlocks blocks until the next block on a given chain func (c *Chain) WaitForNBlocks(n int64) error { var initial int64 From 014793807eb61c19ecc37cab8b78e1238e893b5d Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Mon, 7 Sep 2020 17:30:48 -0700 Subject: [PATCH 20/54] Update to latest sdk --- go.mod | 2 +- go.sum | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index efce40b8b..f38d3a45b 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200907170811-2539f6e4885d + github.com/cosmos/cosmos-sdk v0.34.4-0.20200907214423-d61fa4310856 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 diff --git a/go.sum b/go.sum index 41b572276..f9f6b7fe5 100644 --- a/go.sum +++ b/go.sum @@ -124,8 +124,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200907170811-2539f6e4885d h1:SY01N8C0OlGGEZ3nYGkEr5jUPQypdLbLKcFu5CqA6rw= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200907170811-2539f6e4885d/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200907214423-d61fa4310856 h1:KxLY8erDufFosizSJqJHO+fLzm30C04sCq41YyYced8= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200907214423-d61fa4310856/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= 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/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= @@ -603,7 +603,6 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ= github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= github.com/tendermint/tm-db v0.6.1 h1:w3X87itMPXopcRPlFiqspEKhw4FXihPk2rnFFkP0zGk= From 98785d0978f5082606dcad950e09654a4cf87198 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Tue, 8 Sep 2020 08:30:49 -0700 Subject: [PATCH 21/54] Update to latest sdk --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f38d3a45b..571bf1557 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200907214423-d61fa4310856 + github.com/cosmos/cosmos-sdk v0.34.4-0.20200908140454-fcf51867171d github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 diff --git a/go.sum b/go.sum index f9f6b7fe5..511d42274 100644 --- a/go.sum +++ b/go.sum @@ -124,8 +124,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200907214423-d61fa4310856 h1:KxLY8erDufFosizSJqJHO+fLzm30C04sCq41YyYced8= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200907214423-d61fa4310856/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200908140454-fcf51867171d h1:Nj7MttK7jcY3uZkpQNRn+WjTZsKEE4iTd4guH+Av3eY= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200908140454-fcf51867171d/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= 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/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= From 25b9e0c309bf606fe9d03f63dda9098851decf6b Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Tue, 8 Sep 2020 11:31:45 -0700 Subject: [PATCH 22/54] Concurrency refactor and query refactor --- cmd/paths.go | 8 +- cmd/query.go | 10 +- cmd/raw.go | 26 ++-- go.mod | 2 +- go.sum | 3 + relayer/chain.go | 24 +++- relayer/channel-tx.go | 116 +++++++--------- relayer/client-tx.go | 66 +++++---- relayer/connection-tx.go | 132 +++++++++--------- relayer/headers.go | 8 +- relayer/log-tx.go | 22 +-- relayer/packet-tx.go | 10 +- relayer/pathEnd.go | 18 ++- relayer/query.go | 284 ++++++++++++--------------------------- relayer/relayMsgs.go | 5 + relayer/relayPackets.go | 12 +- relayer/verifier.go | 91 ++++--------- 17 files changed, 343 insertions(+), 494 deletions(-) diff --git a/cmd/paths.go b/cmd/paths.go index db3fec57f..a2aca2c8c 100644 --- a/cmd/paths.go +++ b/cmd/paths.go @@ -348,8 +348,8 @@ func pathsListCmd() *cobra.Command { continue } - srcCs, err := ch[src].QueryClientState() - dstCs, _ := ch[dst].QueryClientState() + srcCs, err := ch[src].QueryClientState(0) + dstCs, _ := ch[dst].QueryClientState(0) if err == nil && srcCs != nil && dstCs != nil { clients = check } else { @@ -463,8 +463,8 @@ func pathsShowCmd() *cobra.Command { } } - srcCs, err := ch[src].QueryClientState() - dstCs, _ := ch[dst].QueryClientState() + srcCs, err := ch[src].QueryClientState(srch) + dstCs, _ := ch[dst].QueryClientState(dsth) if err == nil && srcCs != nil && dstCs != nil { clients = true } diff --git a/cmd/query.go b/cmd/query.go index f18457338..147896ae6 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -138,7 +138,7 @@ func queryAccountCmd() *cobra.Command { return err } - res, err := types.NewQueryClient(chain.CLIContext()).Account( + res, err := types.NewQueryClient(chain.CLIContext(0)).Account( context.Background(), &types.QueryAccountRequest{ Address: addr, @@ -246,7 +246,7 @@ func queryNodeStateCmd() *cobra.Command { return err } - csRes, _, err := chain.QueryConsensusState() + csRes, _, err := chain.QueryConsensusState(0) if err != nil { return err } @@ -274,7 +274,7 @@ func queryClientCmd() *cobra.Command { return err } - res, err := chain.QueryClientState() + res, err := chain.QueryClientState(0) if err != nil { return err } @@ -592,7 +592,7 @@ func queryPacketCommitment() *cobra.Command { return err } - res, err := chain.QueryPacketCommitment(seq) + res, err := chain.QueryPacketCommitment(0, seq) if err != nil { return err } @@ -624,7 +624,7 @@ func queryPacketAck() *cobra.Command { return err } - res, err := chain.QueryPacketCommitment(seq) + res, err := chain.QueryPacketCommitment(0, seq) if err != nil { return err } diff --git a/cmd/raw.go b/cmd/raw.go index 1290eccfd..b52209708 100644 --- a/cmd/raw.go +++ b/cmd/raw.go @@ -172,20 +172,20 @@ func connTry() *cobra.Command { return err } - hs, err := relayer.UpdatesWithHeaders(chains[src], chains[dst]) + _, dsth, err := relayer.UpdatesWithHeaders(chains[src], chains[dst]) if err != nil { return err } // NOTE: We query connection at height - 1 because of the way tendermint returns // proofs the commit for height n is contained in the header of height n + 1 - dstConnState, err := chains[dst].QueryConnection(hs[dst].Header.Height - 1) + dstConnState, err := chains[dst].QueryConnection(dsth.Header.Height - 1) if err != nil { return err } // We are querying the state of the client for src on dst and finding the height - dstClientStateRes, err := chains[dst].QueryClientState() + dstClientStateRes, err := chains[dst].QueryClientState(dsth.Header.Height) if err != nil { return err } @@ -196,12 +196,12 @@ func connTry() *cobra.Command { dstCsHeight := int64(relayer.MustGetHeight(dstClientState.GetLatestHeight())) // Then we need to query the consensus state for src at that height on dst - dstConsState, err := chains[dst].QueryClientConsensusState(uint64(dstCsHeight)) + dstConsState, err := chains[dst].QueryClientConsensusState(dsth.Header.Height, dstCsHeight) if err != nil { return err } - updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], hs[dst]) + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], dsth) if err != nil { return err } @@ -237,20 +237,20 @@ func connAck() *cobra.Command { return err } - hs, err := relayer.UpdatesWithHeaders(chains[src], chains[dst]) + _, dsth, err := relayer.UpdatesWithHeaders(chains[src], chains[dst]) if err != nil { return err } // NOTE: We query connection at height - 1 because of the way tendermint returns // proofs the commit for height n is contained in the header of height n + 1 - dstState, err := chains[dst].QueryConnection(hs[dst].Header.Height - 1) + dstState, err := chains[dst].QueryConnection(dsth.Header.Height - 1) if err != nil { return err } // We are querying the state of the client for src on dst and finding the height - dstClientStateResponse, err := chains[dst].QueryClientState() + dstClientStateResponse, err := chains[dst].QueryClientState(dsth.Header.Height) if err != nil { return err } @@ -258,12 +258,12 @@ func connAck() *cobra.Command { dstCsHeight := int64(relayer.MustGetHeight(dstClientState.GetLatestHeight())) // Then we need to query the consensus state for src at that height on dst - dstConsState, err := chains[dst].QueryClientConsensusState(uint64(dstCsHeight)) + dstConsState, err := chains[dst].QueryClientConsensusState(dsth.Header.Height, dstCsHeight) if err != nil { return err } - updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], hs[dst]) + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], dsth) if err != nil { return err } @@ -298,19 +298,19 @@ func connConfirm() *cobra.Command { return err } - hs, err := relayer.UpdatesWithHeaders(chains[src], chains[dst]) + _, dsth, err := relayer.UpdatesWithHeaders(chains[src], chains[dst]) if err != nil { return err } // NOTE: We query connection at height - 1 because of the way tendermint returns // proofs the commit for height n is contained in the header of height n + 1 - dstState, err := chains[dst].QueryConnection(hs[dst].Header.Height - 1) + dstState, err := chains[dst].QueryConnection(dsth.Header.Height - 1) if err != nil { return err } - updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], hs[dst]) + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], dsth) if err != nil { return err } diff --git a/go.mod b/go.mod index 571bf1557..7a3f3108d 100644 --- a/go.mod +++ b/go.mod @@ -21,4 +21,4 @@ require ( replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 -replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 +replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 \ No newline at end of file diff --git a/go.sum b/go.sum index 511d42274..41e4a4d1c 100644 --- a/go.sum +++ b/go.sum @@ -126,6 +126,7 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/cosmos-sdk v0.34.4-0.20200908140454-fcf51867171d h1:Nj7MttK7jcY3uZkpQNRn+WjTZsKEE4iTd4guH+Av3eY= github.com/cosmos/cosmos-sdk v0.34.4-0.20200908140454-fcf51867171d/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= +github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac= 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/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= @@ -603,6 +604,7 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ= github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= github.com/tendermint/tm-db v0.6.1 h1:w3X87itMPXopcRPlFiqspEKhw4FXihPk2rnFFkP0zGk= @@ -721,6 +723,7 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/relayer/chain.go b/relayer/chain.go index f99c44d64..6bf8e4be2 100644 --- a/relayer/chain.go +++ b/relayer/chain.go @@ -59,6 +59,17 @@ type Chain struct { faucetAddrs map[string]time.Time } +// ValidatePaths takes two chains and validates their paths +func ValidatePaths(src, dst *Chain) error { + if err := src.PathEnd.Validate(); err != nil { + return src.ErrCantSetPath(err) + } + if err := dst.PathEnd.Validate(); err != nil { + return dst.ErrCantSetPath(err) + } + return nil +} + // ListenRPCEmitJSON listens for tx and block events from a chain and outputs them as JSON to stdout func (c *Chain) ListenRPCEmitJSON(tx, block, data bool) func() { doneChan := make(chan struct{}) @@ -213,10 +224,10 @@ func (c *Chain) SendMsgs(msgs []sdk.Msg) (res *sdk.TxResponse, err error) { c.UseSDKContext() // Instantiate the client context - ctx := c.CLIContext() + ctx := c.CLIContext(0) // Query account details - txf, err := tx.PrepareFactory(ctx, c.TxFactory()) + txf, err := tx.PrepareFactory(ctx, c.TxFactory(0)) if err != nil { return nil, err } @@ -254,7 +265,7 @@ func (c *Chain) SendMsgs(msgs []sdk.Msg) (res *sdk.TxResponse, err error) { } // CLIContext returns an instance of client.Context derived from Chain -func (c *Chain) CLIContext() sdkCtx.Context { +func (c *Chain) CLIContext(height int64) sdkCtx.Context { encodingConfig := simapp.MakeEncodingConfig() return sdkCtx.Context{}. WithJSONMarshaler(encodingConfig.Marshaler). @@ -270,12 +281,13 @@ func (c *Chain) CLIContext() sdkCtx.Context { WithFromName(c.Key). WithFromAddress(c.MustGetAddress()). WithSkipConfirmation(true). - WithNodeURI(c.RPCAddr) + WithNodeURI(c.RPCAddr). + WithHeight(height) } // TxFactory returns an instance of tx.Factory derived from -func (c *Chain) TxFactory() tx.Factory { - ctx := c.CLIContext() +func (c *Chain) TxFactory(height int64) tx.Factory { + ctx := c.CLIContext(height) return tx.Factory{}. WithAccountRetriever(ctx.AccountRetriever). WithChainID(c.ChainID). diff --git a/relayer/channel-tx.go b/relayer/channel-tx.go index 5cc5007ea..a593df073 100644 --- a/relayer/channel-tx.go +++ b/relayer/channel-tx.go @@ -36,12 +36,12 @@ func (c *Chain) CreateChannel(dst *Chain, ordered bool, to time.Duration) error // In the case of success and this being the last transaction // debug logging, log created connection and break case chanSteps.success && chanSteps.last: - chans, err := QueryChannelPair(c, dst, 0, 0) + srcChan, dstChan, err := QueryChannelPair(c, dst, 0, 0) if err != nil { return err } if c.debug { - logChannelStates(c, dst, chans) + logChannelStates(c, dst, srcChan, dstChan) } c.Log(fmt.Sprintf("★ Channel created: [%s]chan{%s}port{%s} -> [%s]chan{%s}port{%s}", c.ChainID, c.PathEnd.ChannelID, c.PathEnd.PortID, @@ -69,10 +69,7 @@ func (c *Chain) CreateChannel(dst *Chain, ordered bool, to time.Duration) error // identifiers between chains src and dst. If the handshake hasn't started, then CreateChannelStep // will begin the handshake on the src chain func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayMsgs, error) { - var ( - out = &RelayMsgs{Src: []sdk.Msg{}, Dst: []sdk.Msg{}, last: false} - scid, dcid = c.ChainID, dst.ChainID - ) + var out = &RelayMsgs{Src: []sdk.Msg{}, Dst: []sdk.Msg{}, last: false} if err := c.PathEnd.Validate(); err != nil { return nil, c.ErrCantSetPath(err) @@ -82,94 +79,91 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM return nil, dst.ErrCantSetPath(err) } - hs, err := UpdatesWithHeaders(c, dst) + srch, dsth, err := UpdatesWithHeaders(c, dst) if err != nil { return nil, err } + // create the UpdateHeaders for src and dest Chains - srcUpdateHeader, err := InjectTrustedFields(c, dst, hs[scid]) - if err != nil { - return nil, err - } - dstUpdateHeader, err := InjectTrustedFields(dst, c, hs[dcid]) + srcUpdateHeader, dstUpdateHeader, err := InjectTrustedFieldsHeaders(c, dst, srch, dsth) if err != nil { return nil, err } - chans, err := QueryChannelPair(c, dst, hs[scid].Header.Height-1, hs[dcid].Header.Height-1) + srcChan, dstChan, err := QueryChannelPair(c, dst, srch.Header.Height, dsth.Header.Height) if err != nil { return nil, err } switch { // Handshake hasn't been started on src or dst, relay `chanOpenInit` to src - case chans[scid].Channel.State == chantypes.UNINITIALIZED && chans[dcid].Channel.State == chantypes.UNINITIALIZED: + case srcChan.Channel.State == chantypes.UNINITIALIZED && dstChan.Channel.State == chantypes.UNINITIALIZED: if c.debug { - logChannelStates(c, dst, chans) + logChannelStates(c, dst, srcChan, dstChan) } out.Src = append(out.Src, c.PathEnd.ChanInit(dst.PathEnd, c.MustGetAddress()), ) // Handshake has started on dst (1 step done), relay `chanOpenTry` and `updateClient` to src - case chans[scid].Channel.State == chantypes.UNINITIALIZED && chans[dcid].Channel.State == chantypes.INIT: + case srcChan.Channel.State == chantypes.UNINITIALIZED && dstChan.Channel.State == chantypes.INIT: if c.debug { - logChannelStates(c, dst, chans) + logChannelStates(c, dst, srcChan, dstChan) } out.Src = append(out.Src, c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), - c.PathEnd.ChanTry(dst.PathEnd, chans[dcid], c.MustGetAddress()), + c.PathEnd.ChanTry(dst.PathEnd, dstChan, c.MustGetAddress()), ) // Handshake has started on src (1 step done), relay `chanOpenTry` and `updateClient` to dst - case chans[scid].Channel.State == chantypes.INIT && chans[dcid].Channel.State == chantypes.UNINITIALIZED: + case srcChan.Channel.State == chantypes.INIT && dstChan.Channel.State == chantypes.UNINITIALIZED: if dst.debug { - logChannelStates(dst, c, chans) + logChannelStates(dst, c, dstChan, srcChan) } out.Dst = append(out.Dst, dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), - dst.PathEnd.ChanTry(c.PathEnd, chans[scid], dst.MustGetAddress()), + dst.PathEnd.ChanTry(c.PathEnd, srcChan, dst.MustGetAddress()), ) // Handshake has started on src (2 steps done), relay `chanOpenAck` and `updateClient` to dst - case chans[scid].Channel.State == chantypes.TRYOPEN && chans[dcid].Channel.State == chantypes.INIT: + case srcChan.Channel.State == chantypes.TRYOPEN && dstChan.Channel.State == chantypes.INIT: if dst.debug { - logChannelStates(dst, c, chans) + logChannelStates(dst, c, dstChan, srcChan) } out.Dst = append(out.Dst, dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), - dst.PathEnd.ChanAck(chans[scid], dst.MustGetAddress()), + dst.PathEnd.ChanAck(srcChan, dst.MustGetAddress()), ) // Handshake has started on dst (2 steps done), relay `chanOpenAck` and `updateClient` to src - case chans[scid].Channel.State == chantypes.INIT && chans[dcid].Channel.State == chantypes.TRYOPEN: + case srcChan.Channel.State == chantypes.INIT && dstChan.Channel.State == chantypes.TRYOPEN: if c.debug { - logChannelStates(c, dst, chans) + logChannelStates(c, dst, srcChan, dstChan) } out.Src = append(out.Src, c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), - c.PathEnd.ChanAck(chans[dcid], c.MustGetAddress()), + c.PathEnd.ChanAck(dstChan, c.MustGetAddress()), ) // Handshake has confirmed on dst (3 steps done), relay `chanOpenConfirm` and `updateClient` to src - case chans[scid].Channel.State == chantypes.TRYOPEN && chans[dcid].Channel.State == chantypes.OPEN: + case srcChan.Channel.State == chantypes.TRYOPEN && dstChan.Channel.State == chantypes.OPEN: if c.debug { - logChannelStates(c, dst, chans) + logChannelStates(c, dst, srcChan, dstChan) } out.Src = append(out.Src, c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), - c.PathEnd.ChanConfirm(chans[dcid], c.MustGetAddress()), + c.PathEnd.ChanConfirm(dstChan, c.MustGetAddress()), ) out.last = true // Handshake has confirmed on src (3 steps done), relay `chanOpenConfirm` and `updateClient` to dst - case chans[scid].Channel.State == chantypes.OPEN && chans[dcid].Channel.State == chantypes.TRYOPEN: + case srcChan.Channel.State == chantypes.OPEN && dstChan.Channel.State == chantypes.TRYOPEN: if dst.debug { - logChannelStates(dst, c, chans) + logChannelStates(dst, c, dstChan, srcChan) } out.Dst = append(out.Dst, dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), - dst.PathEnd.ChanConfirm(chans[scid], dst.MustGetAddress()), + dst.PathEnd.ChanConfirm(srcChan, dst.MustGetAddress()), ) out.last = true } @@ -193,12 +187,12 @@ func (c *Chain) CloseChannel(dst *Chain, to time.Duration) error { } if closeSteps.Send(c, dst); closeSteps.success && closeSteps.last { - chans, err := QueryChannelPair(c, dst, 0, 0) + srcChan, dstChan, err := QueryChannelPair(c, dst, 0, 0) if err != nil { return err } if c.debug { - logChannelStates(c, dst, chans) + logChannelStates(c, dst, srcChan, dstChan) } c.Log(fmt.Sprintf("★ Closed channel between [%s]chan{%s}port{%s} -> [%s]chan{%s}port{%s}", c.ChainID, c.PathEnd.ChannelID, c.PathEnd.PortID, @@ -213,54 +207,42 @@ func (c *Chain) CloseChannel(dst *Chain, to time.Duration) error { // identifiers between chains src and dst. If the closing handshake hasn't started, then CloseChannelStep // will begin the handshake on the src chain func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { - var ( - out = &RelayMsgs{Src: []sdk.Msg{}, Dst: []sdk.Msg{}, last: false} - scid, dcid = c.ChainID, dst.ChainID - ) - - if err := c.PathEnd.Validate(); err != nil { - return nil, c.ErrCantSetPath(err) - } - - if err := dst.PathEnd.Validate(); err != nil { - return nil, dst.ErrCantSetPath(err) + var out = &RelayMsgs{Src: []sdk.Msg{}, Dst: []sdk.Msg{}, last: false} + if err := ValidatePaths(c, dst); err != nil { + return nil, err } - hs, err := UpdatesWithHeaders(c, dst) + srch, dsth, err := UpdatesWithHeaders(c, dst) if err != nil { return nil, err } // create the UpdateHeaders for src and dest Chains - srcUpdateHeader, err := InjectTrustedFields(c, dst, hs[scid]) - if err != nil { - return nil, err - } - dstUpdateHeader, err := InjectTrustedFields(dst, c, hs[dcid]) + srcUpdateHeader, dstUpdateHeader, err := InjectTrustedFieldsHeaders(c, dst, srch, dsth) if err != nil { return nil, err } - chans, err := QueryChannelPair(c, dst, hs[scid].Header.Height-1, hs[dcid].Header.Height-1) + srcChan, dstChan, err := QueryChannelPair(c, dst, srch.Header.Height, dsth.Header.Height) if err != nil { return nil, err } - logChannelStates(c, dst, chans) + logChannelStates(c, dst, srcChan, dstChan) switch { // Closing handshake has not started, relay `updateClient` and `chanCloseInit` to src or dst according // to the channel state - case chans[scid].Channel.State != chantypes.CLOSED && chans[dcid].Channel.State != chantypes.CLOSED: - if chans[scid].Channel.State != chantypes.UNINITIALIZED { + case srcChan.Channel.State != chantypes.CLOSED && dstChan.Channel.State != chantypes.CLOSED: + if srcChan.Channel.State != chantypes.UNINITIALIZED { if c.debug { - logChannelStates(c, dst, chans) + logChannelStates(c, dst, srcChan, dstChan) } out.Src = append(out.Src, c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ChanCloseInit(c.MustGetAddress()), ) - } else if chans[dcid].Channel.State != chantypes.UNINITIALIZED { + } else if dstChan.Channel.State != chantypes.UNINITIALIZED { if dst.debug { - logChannelStates(dst, c, chans) + logChannelStates(dst, c, dstChan, srcChan) } out.Dst = append(out.Dst, dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), @@ -269,27 +251,27 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { } // Closing handshake has started on src, relay `updateClient` and `chanCloseConfirm` to dst - case chans[scid].Channel.State == chantypes.CLOSED && chans[dcid].Channel.State != chantypes.CLOSED: - if chans[dcid].Channel.State != chantypes.UNINITIALIZED { + case srcChan.Channel.State == chantypes.CLOSED && dstChan.Channel.State != chantypes.CLOSED: + if dstChan.Channel.State != chantypes.UNINITIALIZED { if dst.debug { - logChannelStates(dst, c, chans) + logChannelStates(dst, c, dstChan, srcChan) } out.Dst = append(out.Dst, dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), - dst.PathEnd.ChanCloseConfirm(chans[scid], dst.MustGetAddress()), + dst.PathEnd.ChanCloseConfirm(srcChan, dst.MustGetAddress()), ) out.last = true } // Closing handshake has started on dst, relay `updateClient` and `chanCloseConfirm` to src - case chans[dcid].Channel.State == chantypes.CLOSED && chans[scid].Channel.State != chantypes.CLOSED: - if chans[scid].Channel.State != chantypes.UNINITIALIZED { + case dstChan.Channel.State == chantypes.CLOSED && srcChan.Channel.State != chantypes.CLOSED: + if srcChan.Channel.State != chantypes.UNINITIALIZED { if c.debug { - logChannelStates(c, dst, chans) + logChannelStates(c, dst, srcChan, dstChan) } out.Src = append(out.Src, c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), - c.PathEnd.ChanCloseConfirm(chans[dcid], c.MustGetAddress()), + c.PathEnd.ChanCloseConfirm(dstChan, c.MustGetAddress()), ) out.last = true } diff --git a/relayer/client-tx.go b/relayer/client-tx.go index 9e12eecad..d00e03dc0 100644 --- a/relayer/client-tx.go +++ b/relayer/client-tx.go @@ -4,45 +4,53 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" + "golang.org/x/sync/errgroup" ) // CreateClients creates clients for src on dst and dst on src given the configured paths func (c *Chain) CreateClients(dst *Chain) (err error) { - clients := &RelayMsgs{Src: []sdk.Msg{}, Dst: []sdk.Msg{}} + var ( + clients = &RelayMsgs{Src: []sdk.Msg{}, Dst: []sdk.Msg{}} + eg = new(errgroup.Group) + ) - // Create client for the destination chain on the source chain if it doesn't exist - var srcCs, dstCs *clientTypes.QueryClientStateResponse - if srcCs, err = c.QueryClientState(); err != nil && srcCs == nil { - dstH, err := dst.UpdateLiteWithHeader() - if err != nil { - return err - } - if c.debug { - c.logCreateClient(dst, MustGetHeight(dstH.GetHeight())) - } - ubdPeriod, err := dst.QueryUnbondingPeriod() - if err != nil { - return err - } - clients.Src = append(clients.Src, c.PathEnd.CreateClient(dstH, dst.GetTrustingPeriod(), ubdPeriod, c.MustGetAddress())) + srcH, dstH, err := UpdatesWithHeaders(c, dst) + if err != nil { + return err } - // Create client for the source chain on destination chain if it doesn't exist - if dstCs, err = dst.QueryClientState(); err != nil && dstCs == nil { - srcH, err := c.UpdateLiteWithHeader() - if err != nil { - return err - } - if dst.debug { - dst.logCreateClient(c, MustGetHeight(srcH.GetHeight())) + // Create client for the destination chain on the source chain if it doesn't exist + eg.Go(func() error { + if srcCs, err := c.QueryClientState(srcH.Header.Height); err != nil && srcCs == nil { + if c.debug { + c.logCreateClient(dst, dstH.Header.Height) + } + ubdPeriod, err := dst.QueryUnbondingPeriod() + if err != nil { + return err + } + clients.Src = append(clients.Src, c.PathEnd.CreateClient(dstH, dst.GetTrustingPeriod(), ubdPeriod, c.MustGetAddress())) } - ubdPeriod, err := c.QueryUnbondingPeriod() - if err != nil { - return err + return nil + }) + + eg.Go(func() error { + // Create client for the source chain on destination chain if it doesn't exist + if dstCs, err := dst.QueryClientState(dstH.Header.Height); err != nil && dstCs == nil { + if dst.debug { + dst.logCreateClient(c, srcH.Header.Height) + } + ubdPeriod, err := c.QueryUnbondingPeriod() + if err != nil { + return err + } + clients.Dst = append(clients.Dst, dst.PathEnd.CreateClient(srcH, c.GetTrustingPeriod(), ubdPeriod, dst.MustGetAddress())) } + return nil + }) - clients.Dst = append(clients.Dst, dst.PathEnd.CreateClient(srcH, c.GetTrustingPeriod(), ubdPeriod, dst.MustGetAddress())) + if err := eg.Wait(); err != nil { + return err } // Send msgs to both chains diff --git a/relayer/connection-tx.go b/relayer/connection-tx.go index f9b1f715e..e989dcad0 100644 --- a/relayer/connection-tx.go +++ b/relayer/connection-tx.go @@ -4,9 +4,12 @@ import ( "fmt" "time" - sdk "github.com/cosmos/cosmos-sdk/types" clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" + connTypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" + tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" + ibcExported "github.com/cosmos/cosmos-sdk/x/ibc/exported" + "golang.org/x/sync/errgroup" ) // CreateConnection runs the connection creation messages on timeout until they pass @@ -31,11 +34,11 @@ func (c *Chain) CreateConnection(dst *Chain, to time.Duration) error { // debug logging, log created connection and break case connSteps.success && connSteps.last: if c.debug { - conns, err := QueryConnectionPair(c, dst, 0, 0) + srcConn, dstConn, err := QueryConnectionPair(c, dst, 0, 0) if err != nil { return err } - logConnectionStates(c, dst, conns) + logConnectionStates(c, dst, srcConn, dstConn) } c.Log(fmt.Sprintf("★ Connection created: [%s]client{%s}conn{%s} -> [%s]client{%s}conn{%s}", @@ -64,63 +67,54 @@ func (c *Chain) CreateConnection(dst *Chain, to time.Duration) error { // with the given identifier between chains src and dst. If handshake hasn't started, // CreateConnetionStep will start the handshake on src func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { - out := &RelayMsgs{Src: []sdk.Msg{}, Dst: []sdk.Msg{}, last: false} - - if err := c.PathEnd.Validate(); err != nil { - return nil, c.ErrCantSetPath(err) - } - - if err := dst.PathEnd.Validate(); err != nil { - return nil, dst.ErrCantSetPath(err) + out := NewRelayMsgs() + if err := ValidatePaths(c, dst); err != nil { + return nil, err } - hs, err := UpdatesWithHeaders(c, dst) + // First, update the light clients to the latest header and return the header + srch, dsth, err := UpdatesWithHeaders(c, dst) if err != nil { return nil, err } - scid, dcid := c.ChainID, dst.ChainID + // Query a number of things all at once + var ( + eg = new(errgroup.Group) + srcUpdateHeader, dstUpdateHeader *tmclient.Header + srcConn, dstConn *connTypes.QueryConnectionResponse + srcCsRes, dstCsRes *clientTypes.QueryClientStateResponse + srcCS, dstCS ibcExported.ClientState + ) // create the UpdateHeaders for src and dest Chains - srcUpdateHeader, err := InjectTrustedFields(c, dst, hs[scid]) - if err != nil { - fmt.Printf("%#v\n", dst.PathEnd) - fmt.Println("SRC") - fmt.Println(scid) - return nil, err - } - dstUpdateHeader, err := InjectTrustedFields(dst, c, hs[dcid]) - if err != nil { - fmt.Println("DST") - return nil, err - } + eg.Go(func() error { + srcUpdateHeader, dstUpdateHeader, err = InjectTrustedFieldsHeaders(c, dst, srch, dsth) + return err + }) // Query Connection data from src and dst - // NOTE: We query connection at height - 1 because of the way tendermint returns - // proofs the commit for height n is contained in the header of height n + 1 - conn, err := QueryConnectionPair(c, dst, hs[scid].Header.Height-1, hs[dcid].Header.Height-1) - if err != nil { - return nil, err - } - - // NOTE: We query connection at height - 1 because of the way tendermint returns - // proofs the commit for height n is contained in the header of height n + 1 - cs, err := QueryClientStatePair(c, dst) - if err != nil { - return nil, err - } + eg.Go(func() error { + srcConn, dstConn, err = QueryConnectionPair(c, dst, srch.Header.Height, dsth.Header.Height) + return err + + }) + // Query client state from each chain's client + eg.Go(func() error { + srcCsRes, dstCsRes, err = QueryClientStatePair(c, dst, srch.Header.Height, dsth.Header.Height) + if err != nil && (srcCsRes == nil || dstCsRes == nil) { + return err + } + srcCS, err = clientTypes.UnpackClientState(srcCsRes.ClientState) + if err != nil { + return err + } + dstCS, err = clientTypes.UnpackClientState(dstCsRes.ClientState) + return err + }) // TODO: log these heights or something about client state? debug? - if cs[scid] == nil || cs[dcid] == nil { - return nil, err - } - - srcCS, err := clientTypes.UnpackClientState(cs[scid].ClientState) - if err != nil { - return nil, err - } - dstCS, err := clientTypes.UnpackClientState(cs[dcid].ClientState) - if err != nil { + if err = eg.Wait(); err != nil { return nil, err } @@ -129,78 +123,78 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { // NOTE: We query connection at height - 1 because of the way tendermint returns // proofs the commit for height n is contained in the header of height n + 1 - cons, err := QueryClientConsensusStatePair(c, dst, hs[scid].Header.Height-1, hs[dcid].Header.Height-1, srcConsH, dstConsH) + srcCons, dstCons, err := QueryClientConsensusStatePair(c, dst, srch.Header.Height, dsth.Header.Height, srcConsH, dstConsH) if err != nil { return nil, err } switch { // Handshake hasn't been started on src or dst, relay `connOpenInit` to src - case conn[scid].Connection.State == ibctypes.UNINITIALIZED && conn[dcid].Connection.State == ibctypes.UNINITIALIZED: + case srcConn.Connection.State == ibctypes.UNINITIALIZED && dstConn.Connection.State == ibctypes.UNINITIALIZED: if c.debug { - logConnectionStates(c, dst, conn) + logConnectionStates(c, dst, srcConn, dstConn) } out.Src = append(out.Src, c.PathEnd.ConnInit(dst.PathEnd, c.MustGetAddress())) // Handshake has started on dst (1 stepdone), relay `connOpenTry` and `updateClient` on src - case conn[scid].Connection.State == ibctypes.UNINITIALIZED && conn[dcid].Connection.State == ibctypes.INIT: + case srcConn.Connection.State == ibctypes.UNINITIALIZED && dstConn.Connection.State == ibctypes.INIT: if c.debug { - logConnectionStates(c, dst, conn) + logConnectionStates(c, dst, srcConn, dstConn) } out.Src = append(out.Src, c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), - c.PathEnd.ConnTry(dst.PathEnd, cs[dcid], conn[dcid], cons[dcid], c.MustGetAddress()), + c.PathEnd.ConnTry(dst.PathEnd, srcCsRes, dstConn, dstCons, c.MustGetAddress()), ) // Handshake has started on src (1 step done), relay `connOpenTry` and `updateClient` on dst - case conn[scid].Connection.State == ibctypes.INIT && conn[dcid].Connection.State == ibctypes.UNINITIALIZED: + case srcConn.Connection.State == ibctypes.INIT && dstConn.Connection.State == ibctypes.UNINITIALIZED: if dst.debug { - logConnectionStates(dst, c, conn) + logConnectionStates(dst, c, dstConn, srcConn) } out.Dst = append(out.Dst, dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), - dst.PathEnd.ConnTry(c.PathEnd, cs[scid], conn[scid], cons[scid], dst.MustGetAddress()), + dst.PathEnd.ConnTry(c.PathEnd, srcCsRes, srcConn, srcCons, dst.MustGetAddress()), ) // Handshake has started on src end (2 steps done), relay `connOpenAck` and `updateClient` to dst end - case conn[scid].Connection.State == ibctypes.TRYOPEN && conn[dcid].Connection.State == ibctypes.INIT: + case srcConn.Connection.State == ibctypes.TRYOPEN && dstConn.Connection.State == ibctypes.INIT: if dst.debug { - logConnectionStates(dst, c, conn) + logConnectionStates(dst, c, dstConn, srcConn) } out.Dst = append(out.Dst, dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), - dst.PathEnd.ConnAck(c.PathEnd, cs[scid], conn[scid], cons[scid], dst.MustGetAddress()), + dst.PathEnd.ConnAck(c.PathEnd, srcCsRes, srcConn, srcCons, dst.MustGetAddress()), ) // Handshake has started on dst end (2 steps done), relay `connOpenAck` and `updateClient` to src end - case conn[scid].Connection.State == ibctypes.INIT && conn[dcid].Connection.State == ibctypes.TRYOPEN: + case srcConn.Connection.State == ibctypes.INIT && dstConn.Connection.State == ibctypes.TRYOPEN: if c.debug { - logConnectionStates(c, dst, conn) + logConnectionStates(c, dst, srcConn, dstConn) } out.Src = append(out.Src, c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), - c.PathEnd.ConnAck(dst.PathEnd, cs[dcid], conn[dcid], cons[dcid], c.MustGetAddress()), + c.PathEnd.ConnAck(dst.PathEnd, dstCsRes, dstConn, dstCons, c.MustGetAddress()), ) // Handshake has confirmed on dst (3 steps done), relay `connOpenConfirm` and `updateClient` to src end - case conn[scid].Connection.State == ibctypes.TRYOPEN && conn[dcid].Connection.State == ibctypes.OPEN: + case srcConn.Connection.State == ibctypes.TRYOPEN && dstConn.Connection.State == ibctypes.OPEN: if c.debug { - logConnectionStates(c, dst, conn) + logConnectionStates(c, dst, srcConn, dstConn) } out.Src = append(out.Src, c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), - c.PathEnd.ConnConfirm(conn[dcid], c.MustGetAddress()), + c.PathEnd.ConnConfirm(dstConn, c.MustGetAddress()), ) out.last = true // Handshake has confirmed on src (3 steps done), relay `connOpenConfirm` and `updateClient` to dst end - case conn[scid].Connection.State == ibctypes.OPEN && conn[dcid].Connection.State == ibctypes.TRYOPEN: + case srcConn.Connection.State == ibctypes.OPEN && dstConn.Connection.State == ibctypes.TRYOPEN: if dst.debug { - logConnectionStates(dst, c, conn) + logConnectionStates(dst, c, dstConn, srcConn) } out.Dst = append(out.Dst, dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), - dst.PathEnd.ConnConfirm(conn[scid], dst.MustGetAddress()), + dst.PathEnd.ConnConfirm(srcConn, dst.MustGetAddress()), ) out.last = true } diff --git a/relayer/headers.go b/relayer/headers.go index 715d61375..1d2db6b71 100644 --- a/relayer/headers.go +++ b/relayer/headers.go @@ -10,12 +10,12 @@ import ( // NewSyncHeaders returns a new instance of map[string]*tmclient.Header that can be easily // kept "reasonably up to date" -func NewSyncHeaders(chains ...*Chain) (*SyncHeaders, error) { - mp, err := UpdatesWithHeaders(chains...) +func NewSyncHeaders(src, dst *Chain) (*SyncHeaders, error) { + srch, dsth, err := UpdatesWithHeaders(src, dst) if err != nil { return nil, err } - return &SyncHeaders{hds: mp}, nil + return &SyncHeaders{hds: map[string]*tmclient.Header{src.ChainID: srch, dst.ChainID: dsth}}, nil } // SyncHeaders is an instance of map[string]*tmclient.Header @@ -72,7 +72,7 @@ func InjectTrustedFields(srcChain, dstChain *Chain, srcHeader *tmclient.Header) // return nil, fmt.Errorf("counterparty chain has incorrect PathEnd. expected chainID: %s, got: %s", dstChain.PathEnd.ChainID, h.Header.ChainID) // } // retrieve counterparty client from dst chain - counterpartyClientRes, err := dstChain.QueryClientState() + counterpartyClientRes, err := dstChain.QueryClientState(0) if err != nil { return nil, err } diff --git a/relayer/log-tx.go b/relayer/log-tx.go index e9936d6df..32511da0d 100644 --- a/relayer/log-tx.go +++ b/relayer/log-tx.go @@ -42,34 +42,34 @@ func (c *Chain) logPacketsRelayed(dst *Chain, num int) { num, dst.ChainID, dst.PathEnd.PortID, c.ChainID, c.PathEnd.PortID)) } -func logChannelStates(src, dst *Chain, conn map[string]*chanTypes.QueryChannelResponse) { +func logChannelStates(src, dst *Chain, srcChan, dstChan *chanTypes.QueryChannelResponse) { // TODO: replace channelID with portID? src.Log(fmt.Sprintf("- [%s]@{%d}chan(%s)-{%s} : [%s]@{%d}chan(%s)-{%s}", src.ChainID, - conn[src.ChainID].ProofHeight, + srcChan.ProofHeight, src.PathEnd.ChannelID, - conn[src.ChainID].Channel.State, + srcChan.Channel.State, dst.ChainID, - conn[dst.ChainID].ProofHeight, + dstChan.ProofHeight, dst.PathEnd.ChannelID, - conn[dst.ChainID].Channel.State, + dstChan.Channel.State, )) } -func logConnectionStates(src, dst *Chain, conn map[string]*connTypes.QueryConnectionResponse) { +func logConnectionStates(src, dst *Chain, srcConn, dstConn *connTypes.QueryConnectionResponse) { src.Log(fmt.Sprintf("- [%s]@{%d}conn(%s)-{%s} : [%s]@{%d}conn(%s)-{%s}", src.ChainID, - conn[src.ChainID].ProofHeight, + srcConn.ProofHeight, src.PathEnd.ConnectionID, - conn[src.ChainID].Connection.State, + srcConn.Connection.State, dst.ChainID, - conn[dst.ChainID].ProofHeight, + dstConn.ProofHeight, dst.PathEnd.ConnectionID, - conn[dst.ChainID].Connection.State, + dstConn.Connection.State, )) } -func (c *Chain) logCreateClient(dst *Chain, dstH uint64) { +func (c *Chain) logCreateClient(dst *Chain, dstH int64) { c.Log(fmt.Sprintf("- [%s] -> creating client (%s) for [%s]header-height{%d} trust-period(%s)", c.ChainID, c.PathEnd.ClientID, dst.ChainID, dstH, dst.GetTrustingPeriod())) } diff --git a/relayer/packet-tx.go b/relayer/packet-tx.go index a2a05d02c..095e83388 100644 --- a/relayer/packet-tx.go +++ b/relayer/packet-tx.go @@ -63,24 +63,24 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, // Working on DST chain :point_down: var ( - hs map[string]*tmclient.Header + srch, dsth *tmclient.Header seqRecv *chanTypes.QueryNextSequenceReceiveResponse seqSend uint64 srcCommitRes *chanTypes.QueryPacketCommitmentResponse ) if err = retry.Do(func() error { - hs, err = UpdatesWithHeaders(c, dst) + srch, dsth, err = UpdatesWithHeaders(c, dst) if err != nil { return err } - seqRecv, err = dst.QueryNextSeqRecv(hs[dst.ChainID].Header.Height) + seqRecv, err = dst.QueryNextSeqRecv(dsth.Header.Height) if err != nil { return err } - srcCommitRes, err = c.QueryPacketCommitment(seqSend - 1) + srcCommitRes, err = c.QueryPacketCommitment(srch.Header.Height, seqSend-1) if err != nil { return err } @@ -108,7 +108,7 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, dstAddrString, ) - updateHeader, err := InjectTrustedFields(c, dst, hs[c.ChainID]) + updateHeader, err := InjectTrustedFields(c, dst, srch) if err != nil { return err } diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index c76d64d53..44ab198cf 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -1,7 +1,6 @@ package relayer import ( - "fmt" "strings" "time" @@ -63,7 +62,7 @@ func (pe *PathEnd) UpdateClient(dstHeader *tmclient.Header, signer sdk.AccAddres } // CreateClient creates an sdk.Msg to update the client on src with consensus state from dst -func (pe *PathEnd) CreateClient(dstHeader *tmclient.Header, trustingPeriod, ubdPeriod time.Duration, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) CreateClient(dstHeader *tmclient.Header, trustingPeriod, unbondingPeriod time.Duration, signer sdk.AccAddress) sdk.Msg { if err := dstHeader.ValidateBasic(); err != nil { panic(err) } @@ -74,7 +73,7 @@ func (pe *PathEnd) CreateClient(dstHeader *tmclient.Header, trustingPeriod, ubdP dstHeader.GetHeader().GetChainID(), tmclient.NewFractionFromTm(light.DefaultTrustLevel), trustingPeriod, - ubdPeriod, + unbondingPeriod, time.Minute*1, dstHeader.GetHeight().(clientTypes.Height), commitmenttypes.GetSDKSpecs(), @@ -93,7 +92,6 @@ func (pe *PathEnd) CreateClient(dstHeader *tmclient.Header, trustingPeriod, ubdP panic(err) } if err = msg.ValidateBasic(); err != nil { - fmt.Printf("%#v\n", dstHeader) panic(err) } return msg @@ -139,7 +137,7 @@ func (pe *PathEnd) ConnTry( dstConnState.Proof, dstClientState.Proof, dstConsState.Proof, - dstConsState.ProofHeight.Increment(), + dstConsState.ProofHeight, css.GetHeight().(clientTypes.Height), signer, ) @@ -185,7 +183,7 @@ func (pe *PathEnd) ConnConfirm(dstConnState *connTypes.QueryConnectionResponse, return connTypes.NewMsgConnectionOpenConfirm( pe.ConnectionID, dstConnState.Proof, - dstConnState.ProofHeight.Increment(), + dstConnState.ProofHeight, signer, ) } @@ -216,7 +214,7 @@ func (pe *PathEnd) ChanTry(dst *PathEnd, dstChanState *chanTypes.QueryChannelRes dst.ChannelID, dstChanState.Channel.Version, dstChanState.Proof, - dstChanState.ProofHeight.Increment(), + dstChanState.ProofHeight, signer, ) } @@ -228,7 +226,7 @@ func (pe *PathEnd) ChanAck(dstChanState *chanTypes.QueryChannelResponse, signer pe.ChannelID, dstChanState.Channel.Version, dstChanState.Proof, - dstChanState.ProofHeight.Increment(), + dstChanState.ProofHeight, signer, ) } @@ -239,7 +237,7 @@ func (pe *PathEnd) ChanConfirm(dstChanState *chanTypes.QueryChannelResponse, sig pe.PortID, pe.ChannelID, dstChanState.Proof, - dstChanState.ProofHeight.Increment(), + dstChanState.ProofHeight, signer, ) } @@ -259,7 +257,7 @@ func (pe *PathEnd) ChanCloseConfirm(dstChanState *chanTypes.QueryChannelResponse pe.PortID, pe.ChannelID, dstChanState.Proof, - dstChanState.ProofHeight.Increment(), + dstChanState.ProofHeight, signer, ) } diff --git a/relayer/query.go b/relayer/query.go index a556986c0..92ff98bba 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -29,6 +29,7 @@ import ( rpcclient "github.com/tendermint/tendermint/rpc/client" ctypes "github.com/tendermint/tendermint/rpc/core/types" tmtypes "github.com/tendermint/tendermint/types" + "golang.org/x/sync/errgroup" ) var eventFormat = "{eventType}.{eventAttribute}={value}" @@ -62,7 +63,7 @@ func (c *Chain) QueryBalance(keyName string) (sdk.Coins, error) { CountTotal: false, }) - queryClient := bankTypes.NewQueryClient(c.CLIContext()) + queryClient := bankTypes.NewQueryClient(c.CLIContext(0)) res, err := queryClient.AllBalances(context.Background(), params) if err != nil { @@ -78,105 +79,57 @@ func (c *Chain) QueryBalance(keyName string) (sdk.Coins, error) { // QueryConsensusState returns a consensus state for a given chain to be used as a // client in another chain, fetches latest height when passed 0 as arg -func (c *Chain) QueryConsensusState() (*tmclient.ConsensusState, int64, error) { - return clientUtils.QueryNodeConsensusState(c.CLIContext()) +func (c *Chain) QueryConsensusState(height int64) (*tmclient.ConsensusState, int64, error) { + return clientUtils.QueryNodeConsensusState(c.CLIContext(height)) } // QueryClientConsensusState retrevies the latest consensus state for a client in state at a given height -func (c *Chain) QueryClientConsensusState(clientConsHeight uint64) (*clientTypes.QueryConsensusStateResponse, error) { - return clientUtils.QueryConsensusStateABCI(c.CLIContext(), c.PathEnd.ClientID, clientTypes.NewHeight(0, clientConsHeight)) -} - -type csstates struct { - sync.Mutex - Map map[string]*clientTypes.QueryConsensusStateResponse - Errs errs -} - -type chh struct { - c *Chain - h int64 - csh int64 +func (c *Chain) QueryClientConsensusState(height, dstClientConsHeight int64) (*clientTypes.QueryConsensusStateResponse, error) { + return clientUtils.QueryConsensusStateABCI( + c.CLIContext(int64(height)), + c.PathEnd.ClientID, + clientTypes.NewHeight(0, uint64(dstClientConsHeight)), + ) } // QueryClientConsensusStatePair allows for the querying of multiple client states at the same time -func QueryClientConsensusStatePair(src, dst *Chain, - srcH, dstH, srcClientConsH, dstClientConsH int64) (map[string]*clientTypes.QueryConsensusStateResponse, error) { - hs := &csstates{ - Map: make(map[string]*clientTypes.QueryConsensusStateResponse), - Errs: []error{}, - } - - var wg sync.WaitGroup - - chps := []chh{ - {src, srcH, srcClientConsH}, - {dst, dstH, dstClientConsH}, - } - - for _, chain := range chps { - wg.Add(1) - go func(hs *csstates, wg *sync.WaitGroup, chp chh) { - conn, err := chp.c.QueryClientConsensusState(uint64(chp.csh)) - if err != nil { - hs.Lock() - hs.Errs = append(hs.Errs, err) - hs.Unlock() - } - hs.Lock() - hs.Map[chp.c.ChainID] = conn - hs.Unlock() - wg.Done() - }(hs, &wg, chain) - } - wg.Wait() - return hs.Map, hs.Errs.err() +func QueryClientConsensusStatePair(src, dst *Chain, srch, dsth, srcClientConsH, dstClientConsH int64) (srcCsRes, dstCsRes *clientTypes.QueryConsensusStateResponse, err error) { + var eg = new(errgroup.Group) + eg.Go(func() error { + srcCsRes, err = src.QueryClientConsensusState(srch, srcClientConsH) + return err + }) + eg.Go(func() error { + dstCsRes, err = dst.QueryClientConsensusState(dsth, dstClientConsH) + return err + }) + err = eg.Wait() + return } // QueryClientState retrevies the latest consensus state for a client in state at a given height -func (c *Chain) QueryClientState() (*clientTypes.QueryClientStateResponse, error) { - return clientUtils.QueryClientStateABCI(c.CLIContext(), c.PathEnd.ClientID) -} - -type cstates struct { - sync.Mutex - Map map[string]*clientTypes.QueryClientStateResponse - Errs errs +func (c *Chain) QueryClientState(height int64) (*clientTypes.QueryClientStateResponse, error) { + return clientUtils.QueryClientStateABCI(c.CLIContext(height), c.PathEnd.ClientID) } // QueryClientStatePair returns a pair of connection responses -func QueryClientStatePair(src, dst *Chain) (map[string]*clientTypes.QueryClientStateResponse, error) { - hs := &cstates{ - Map: make(map[string]*clientTypes.QueryClientStateResponse), - Errs: []error{}, - } - - var wg sync.WaitGroup - - chps := []*Chain{src, dst} - - for _, chain := range chps { - wg.Add(1) - go func(hs *cstates, wg *sync.WaitGroup, c *Chain) { - conn, err := c.QueryClientState() - if err != nil { - hs.Lock() - hs.Errs = append(hs.Errs, err) - hs.Unlock() - } - hs.Lock() - hs.Map[c.ChainID] = conn - hs.Unlock() - wg.Done() - }(hs, &wg, chain) - } - wg.Wait() - return hs.Map, hs.Errs.err() +func QueryClientStatePair(src, dst *Chain, srch, dsth int64) (srcCsRes, dstCsRes *clientTypes.QueryClientStateResponse, err error) { + var eg = new(errgroup.Group) + eg.Go(func() error { + srcCsRes, err = src.QueryClientState(srch) + return err + }) + eg.Go(func() error { + dstCsRes, err = dst.QueryClientState(dsth) + return err + }) + err = eg.Wait() + return } // QueryClients queries all the clients! func (c *Chain) QueryClients(offset, limit uint64) ([]*clientTypes.IdentifiedClientState, error) { - res, err := clientTypes.NewQueryClient(c.CLIContext()).ClientStates(context.Background(), &clientTypes.QueryClientStatesRequest{ + res, err := clientTypes.NewQueryClient(c.CLIContext(0)).ClientStates(context.Background(), &clientTypes.QueryClientStatesRequest{ Pagination: &query.PageRequest{ Key: []byte(""), Offset: offset, @@ -193,7 +146,7 @@ func (c *Chain) QueryClients(offset, limit uint64) ([]*clientTypes.IdentifiedCli // QueryConnections gets any connections on a chain func (c *Chain) QueryConnections(offset, limit uint64) (conns []*connTypes.IdentifiedConnection, err error) { - res, err := connTypes.NewQueryClient(c.CLIContext()).Connections(context.Background(), &connTypes.QueryConnectionsRequest{ + res, err := connTypes.NewQueryClient(c.CLIContext(0)).Connections(context.Background(), &connTypes.QueryConnectionsRequest{ Pagination: &query.PageRequest{ Key: []byte(""), Offset: offset, @@ -206,56 +159,27 @@ func (c *Chain) QueryConnections(offset, limit uint64) (conns []*connTypes.Ident // QueryConnectionsUsingClient gets any connections that exist between chain and counterparty func (c *Chain) QueryConnectionsUsingClient(height int64) (clientConns *connTypes.QueryClientConnectionsResponse, err error) { - return connUtils.QueryClientConnections(c.CLIContext(), c.PathEnd.ClientID, true) + return connUtils.QueryClientConnections(c.CLIContext(height), c.PathEnd.ClientID, true) } // QueryConnection returns the remote end of a given connection func (c *Chain) QueryConnection(height int64) (*connTypes.QueryConnectionResponse, error) { - return connUtils.QueryConnection(c.CLIContext(), c.PathEnd.ConnectionID, true) -} - -type conns struct { - sync.Mutex - Map map[string]*connTypes.QueryConnectionResponse - Errs errs -} - -type chpair struct { - c *Chain - h int64 + return connUtils.QueryConnection(c.CLIContext(height), c.PathEnd.ConnectionID, true) } // QueryConnectionPair returns a pair of connection responses -func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (map[string]*connTypes.QueryConnectionResponse, error) { - hs := &conns{ - Map: make(map[string]*connTypes.QueryConnectionResponse), - Errs: []error{}, - } - - var wg sync.WaitGroup - - chps := []chpair{ - {src, srcH}, - {dst, dstH}, - } - - for _, chain := range chps { - wg.Add(1) - go func(hs *conns, wg *sync.WaitGroup, chp chpair) { - conn, err := chp.c.QueryConnection(chp.h) - if err != nil { - hs.Lock() - hs.Errs = append(hs.Errs, err) - hs.Unlock() - } - hs.Lock() - hs.Map[chp.c.ChainID] = conn - hs.Unlock() - wg.Done() - }(hs, &wg, chain) - } - wg.Wait() - return hs.Map, hs.Errs.err() +func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (srcConn, dstConn *connTypes.QueryConnectionResponse, err error) { + var eg = new(errgroup.Group) + eg.Go(func() error { + srcConn, err = src.QueryConnection(srcH) + return err + }) + eg.Go(func() error { + dstConn, err = dst.QueryConnection(dstH) + return err + }) + err = eg.Wait() + return } // //////////////////////////// @@ -264,7 +188,7 @@ func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (map[string]*connTyp // QueryConnectionChannels queries the channels associated with a connection func (c *Chain) QueryConnectionChannels(connectionID string, offset, limit uint64) ([]*chanTypes.IdentifiedChannel, error) { - res, err := chanTypes.NewQueryClient(c.CLIContext()).ConnectionChannels(context.Background(), &chanTypes.QueryConnectionChannelsRequest{ + res, err := chanTypes.NewQueryClient(c.CLIContext(0)).ConnectionChannels(context.Background(), &chanTypes.QueryConnectionChannelsRequest{ Pagination: &query.PageRequest{ Key: []byte(""), Offset: offset, @@ -277,52 +201,27 @@ func (c *Chain) QueryConnectionChannels(connectionID string, offset, limit uint6 // QueryChannel returns the channel associated with a channelID func (c *Chain) QueryChannel(height int64) (chanRes *chanTypes.QueryChannelResponse, err error) { - return chanUtils.QueryChannel(c.CLIContext(), c.PathEnd.PortID, c.PathEnd.ChannelID, true) -} - -type chans struct { - sync.Mutex - Map map[string]*chanTypes.QueryChannelResponse - Errs errs + return chanUtils.QueryChannel(c.CLIContext(height), c.PathEnd.PortID, c.PathEnd.ChannelID, true) } // QueryChannelPair returns a pair of channel responses -func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (map[string]*chanTypes.QueryChannelResponse, error) { - fmt.Println("QueryChannelPair") - hs := &chans{ - Map: make(map[string]*chanTypes.QueryChannelResponse), - Errs: []error{}, - } - - var wg sync.WaitGroup - - chps := []chpair{ - {src, srcH}, - {dst, dstH}, - } - - for _, chain := range chps { - wg.Add(1) - go func(hs *chans, wg *sync.WaitGroup, chp chpair) { - conn, err := chp.c.QueryChannel(chp.h) - if err != nil { - hs.Lock() - hs.Errs = append(hs.Errs, err) - hs.Unlock() - } - hs.Lock() - hs.Map[chp.c.ChainID] = conn - hs.Unlock() - wg.Done() - }(hs, &wg, chain) - } - wg.Wait() - return hs.Map, hs.Errs.err() +func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (srcChan, dstChan *chanTypes.QueryChannelResponse, err error) { + var eg = new(errgroup.Group) + eg.Go(func() error { + srcChan, err = src.QueryChannel(srcH) + return err + }) + eg.Go(func() error { + srcChan, err = src.QueryChannel(srcH) + return err + }) + err = eg.Wait() + return } // QueryChannels returns all the channels that are registered on a chain func (c *Chain) QueryChannels(offset, limit uint64) ([]*chanTypes.IdentifiedChannel, error) { - res, err := types.NewQueryClient(c.CLIContext()).Channels(context.Background(), &types.QueryChannelsRequest{ + res, err := types.NewQueryClient(c.CLIContext(0)).Channels(context.Background(), &types.QueryChannelsRequest{ Pagination: &query.PageRequest{ Key: []byte(""), Offset: offset, @@ -343,7 +242,7 @@ func (c *Chain) QueryHistoricalInfo(height clientTypes.Height) (*stakingTypes.Qu Height: int64(height.EpochHeight), } - queryClient := stakingTypes.NewQueryClient(c.CLIContext()) + queryClient := stakingTypes.NewQueryClient(c.CLIContext(int64(height.EpochHeight))) res, err := queryClient.HistoricalInfo(context.Background(), ¶ms) if err != nil { @@ -376,7 +275,7 @@ func (c *Chain) QueryValsetAtHeight(height clientTypes.Height) (*tmproto.Validat func (c *Chain) QueryUnbondingPeriod() (time.Duration, error) { req := stakingTypes.QueryParamsRequest{} - queryClient := stakingTypes.NewQueryClient(c.CLIContext()) + queryClient := stakingTypes.NewQueryClient(c.CLIContext(0)) res, err := queryClient.Params(context.Background(), &req) if err != nil { @@ -411,17 +310,17 @@ func (c *Chain) WaitForNBlocks(n int64) error { // QueryNextSeqRecv returns the next seqRecv for a configured channel func (c *Chain) QueryNextSeqRecv(height int64) (recvRes *chanTypes.QueryNextSequenceReceiveResponse, err error) { - return chanUtils.QueryNextSequenceReceive(c.CLIContext(), c.PathEnd.PortID, c.PathEnd.ChannelID, true) + return chanUtils.QueryNextSequenceReceive(c.CLIContext(height), c.PathEnd.PortID, c.PathEnd.ChannelID, true) } // QueryPacketCommitment returns the packet commitment proof at a given height -func (c *Chain) QueryPacketCommitment(seq uint64) (comRes *chanTypes.QueryPacketCommitmentResponse, err error) { - return chanUtils.QueryPacketCommitment(c.CLIContext(), c.PathEnd.PortID, c.PathEnd.ChannelID, seq, true) +func (c *Chain) QueryPacketCommitment(height int64, seq uint64) (comRes *chanTypes.QueryPacketCommitmentResponse, err error) { + return chanUtils.QueryPacketCommitment(c.CLIContext(height), c.PathEnd.PortID, c.PathEnd.ChannelID, seq, true) } // QueryPacketCommitments returns an array of packet commitment proofs func (c *Chain) QueryPacketCommitments(limit, offset uint64) (comRes []*chanTypes.PacketAckCommitment, err error) { - res, err := chanTypes.NewQueryClient(c.CLIContext()).PacketCommitments(context.Background(), &types.QueryPacketCommitmentsRequest{ + res, err := chanTypes.NewQueryClient(c.CLIContext(0)).PacketCommitments(context.Background(), &types.QueryPacketCommitmentsRequest{ PortId: c.PathEnd.PortID, ChannelId: c.PathEnd.ChannelID, Pagination: &query.PageRequest{ @@ -576,26 +475,18 @@ func (e errs) err() error { } // QueryLatestHeights returns the heights of multiple chains at once -func QueryLatestHeights(chains ...*Chain) (map[string]int64, error) { - hs := &heights{Map: make(map[string]int64), Errs: []error{}} - var wg sync.WaitGroup - for _, chain := range chains { - wg.Add(1) - go func(hs *heights, wg *sync.WaitGroup, chain *Chain) { - height, err := chain.QueryLatestHeight() - if err != nil { - hs.Lock() - hs.Errs = append(hs.Errs, err) - hs.Unlock() - } - hs.Lock() - hs.Map[chain.ChainID] = height - hs.Unlock() - wg.Done() - }(hs, &wg, chain) - } - wg.Wait() - return hs.Map, hs.Errs.err() +func QueryLatestHeights(src, dst *Chain) (srch, dsth int64, err error) { + var eg = new(errgroup.Group) + eg.Go(func() error { + srch, err = src.QueryLatestHeight() + return err + }) + eg.Go(func() error { + dsth, err = dst.QueryLatestHeight() + return err + }) + err = eg.Wait() + return } // QueryLatestHeader returns the latest header from the chain @@ -604,10 +495,7 @@ func (c *Chain) QueryLatestHeader() (out *tmclient.Header, err error) { if h, err = c.QueryLatestHeight(); err != nil { return nil, err } - if out, err = c.QueryHeaderAtHeight(h); err != nil { - return nil, err - } - return out, nil + return c.QueryHeaderAtHeight(h) } // QueryHeaderAtHeight returns the header at a given height diff --git a/relayer/relayMsgs.go b/relayer/relayMsgs.go index d1f7f2aaa..e0e063115 100644 --- a/relayer/relayMsgs.go +++ b/relayer/relayMsgs.go @@ -20,6 +20,11 @@ type RelayMsgs struct { success bool } +// NewRelayMsgs returns an initialized version of relay messages +func NewRelayMsgs() *RelayMsgs { + return &RelayMsgs{Src: []sdk.Msg{}, Dst: []sdk.Msg{}, last: false, success: false} +} + // Ready returns true if there are messages to relay func (r *RelayMsgs) Ready() bool { if r == nil { diff --git a/relayer/relayPackets.go b/relayer/relayPackets.go index 808de6f23..f90555451 100644 --- a/relayer/relayPackets.go +++ b/relayer/relayPackets.go @@ -44,12 +44,12 @@ func (rp *relayMsgTimeout) FetchCommitResponse(src, dst *Chain, sh *SyncHeaders) // retry getting commit response until it succeeds if err = retry.Do(func() error { // NOTE: Timeouts currently only work with ORDERED channels for nwo - dstRecvRes, err = dst.QueryPacketCommitment(rp.seq) + dstRecvRes, err = dst.QueryPacketCommitment(sh.GetHeader(dst.ChainID).Header.Height, rp.seq) if err != nil { return err } else if dstRecvRes.Proof == nil { return fmt.Errorf("- [%s]@{%d} - Packet Commitment Proof is nil seq(%d)", - dst.ChainID, int64(sh.GetHeight(dst.ChainID)-1), rp.seq) + dst.ChainID, int64(sh.GetHeight(dst.ChainID)), rp.seq) } return nil }); err != nil { @@ -115,12 +115,12 @@ func (rp *relayMsgRecvPacket) FetchCommitResponse(src, dst *Chain, sh *SyncHeade // retry getting commit response until it succeeds if err = retry.Do(func() error { - dstCommitRes, err = dst.QueryPacketCommitment(rp.seq) + dstCommitRes, err = dst.QueryPacketCommitment(sh.GetHeader(dst.ChainID).Header.Height, rp.seq) if err != nil { return err } else if dstCommitRes.Proof == nil { return fmt.Errorf("- [%s]@{%d} - Packet Commitment Proof is nil seq(%d)", - dst.ChainID, int64(sh.GetHeight(dst.ChainID)-1), rp.seq) + dst.ChainID, int64(sh.GetHeight(dst.ChainID)), rp.seq) } return nil }); err != nil { @@ -177,12 +177,12 @@ func (rp *relayMsgPacketAck) Msg(src, dst *Chain) sdk.Msg { func (rp *relayMsgPacketAck) FetchCommitResponse(src, dst *Chain, sh *SyncHeaders) (err error) { var dstCommitRes *chanTypes.QueryPacketCommitmentResponse if err = retry.Do(func() error { - dstCommitRes, err = dst.QueryPacketCommitment(rp.seq) + dstCommitRes, err = dst.QueryPacketCommitment(sh.GetHeader(dst.ChainID).Header.Height, rp.seq) if err != nil { return err } else if dstCommitRes.Proof == nil { return fmt.Errorf("- [%s]@{%d} - Packet Ack Proof is nil seq(%d)", - dst.ChainID, int64(sh.GetHeight(dst.ChainID)-1), rp.seq) + dst.ChainID, int64(sh.GetHeight(dst.ChainID)), rp.seq) } return nil }); err != nil { diff --git a/relayer/verifier.go b/relayer/verifier.go index 18beb69f4..6d248de2c 100644 --- a/relayer/verifier.go +++ b/relayer/verifier.go @@ -1,13 +1,11 @@ package relayer import ( - "context" "errors" "fmt" "io/ioutil" "os" "path/filepath" - "sync" "time" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" @@ -31,77 +29,38 @@ import ( // on the Chain struct that users could pass in the config??) var logger = lite.Logger(log.NewTMLogger(log.NewSyncWriter(ioutil.Discard))) -type header struct { - sync.Mutex - Map map[string]*tmclient.Header - Errs []error -} - -func (h *header) err() error { - var out error - for _, err := range h.Errs { - fmt.Println("in verifier") - out = fmt.Errorf("err: %w", err) +// InjectTrustedFieldsHeaders takes the headers and enriches them +func InjectTrustedFieldsHeaders(src, dst *Chain, srch, dsth *tmclient.Header) (srcho *tmclient.Header, dstho *tmclient.Header, err error) { + var eg = new(errgroup.Group) + eg.Go(func() error { + srcho, err = InjectTrustedFields(src, dst, srch) + return err + }) + eg.Go(func() error { + dstho, err = InjectTrustedFields(dst, src, dsth) + return err + }) + if err = eg.Wait(); err != nil { + return } - return out + return } // UpdatesWithHeaders calls UpdateLiteWithHeader on the passed chains concurrently -func UpdatesWithHeaders(chains ...*Chain) (map[string]*tmclient.Header, error) { - hs := &header{Map: make(map[string]*tmclient.Header), Errs: []error{}} - var wg sync.WaitGroup - for _, chain := range chains { - wg.Add(1) - go func(hs *header, wg *sync.WaitGroup, chain *Chain) { - defer wg.Done() - header, err := chain.UpdateLiteWithHeader() - hs.Lock() - hs.Map[chain.ChainID] = header - if err != nil { - hs.Errs = append(hs.Errs, err) - } - hs.Unlock() - }(hs, &wg, chain) - } - wg.Wait() - return hs.Map, hs.err() -} - -type hu struct { - h *tmclient.Header - c string -} - -// UpdatesWithHeadersAlt uses sync.Errorgroup to manage the goroutines -func UpdatesWithHeadersAlt(chains ...*Chain) (map[string]*tmclient.Header, error) { - hs := make(map[string]*tmclient.Header) - hchan := make(chan hu) - eg, _ := errgroup.WithContext(context.Background()) +func UpdatesWithHeaders(src, dst *Chain) (srch, dsth *tmclient.Header, err error) { + var eg = new(errgroup.Group) eg.Go(func() error { - for h := range hchan { - hs[h.c] = h.h - if len(hs) == len(chains) { - close(hchan) - return nil - } - } - return nil + srch, err = src.QueryLatestHeader() + return err }) - for _, c := range chains { - eg.Go(func() error { - header, err := c.UpdateLiteWithHeader() - if err != nil { - return err - } - hchan <- hu{h: header, c: c.ChainID} - return nil - }) - } - err := eg.Wait() - if err != nil { - return nil, err + eg.Go(func() error { + dsth, err = dst.QueryLatestHeader() + return err + }) + if err := eg.Wait(); err != nil { + return nil, nil, err } - return hs, nil + return srch, dsth, nil } func liteError(err error) error { return fmt.Errorf("lite client: %w", err) } From 233bd555311f6eccceb657af2fa69f76b8590980 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Tue, 8 Sep 2020 12:12:21 -0700 Subject: [PATCH 23/54] Latest debugging --- go.mod | 2 +- relayer/channel-tx.go | 68 ++++++++++++++++++++++++++-------------- relayer/connection-tx.go | 16 ++++++++-- relayer/query.go | 2 +- 4 files changed, 60 insertions(+), 28 deletions(-) diff --git a/go.mod b/go.mod index 7a3f3108d..571bf1557 100644 --- a/go.mod +++ b/go.mod @@ -21,4 +21,4 @@ require ( replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 -replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 \ No newline at end of file +replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 diff --git a/relayer/channel-tx.go b/relayer/channel-tx.go index a593df073..d40aa5790 100644 --- a/relayer/channel-tx.go +++ b/relayer/channel-tx.go @@ -4,8 +4,10 @@ import ( "fmt" "time" - sdk "github.com/cosmos/cosmos-sdk/types" + chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" chantypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" + tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" + "golang.org/x/sync/errgroup" ) // CreateChannel runs the channel creation messages on timeout until they pass @@ -69,14 +71,9 @@ func (c *Chain) CreateChannel(dst *Chain, ordered bool, to time.Duration) error // identifiers between chains src and dst. If the handshake hasn't started, then CreateChannelStep // will begin the handshake on the src chain func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayMsgs, error) { - var out = &RelayMsgs{Src: []sdk.Msg{}, Dst: []sdk.Msg{}, last: false} - - if err := c.PathEnd.Validate(); err != nil { - return nil, c.ErrCantSetPath(err) - } - - if err := dst.PathEnd.Validate(); err != nil { - return nil, dst.ErrCantSetPath(err) + out := NewRelayMsgs() + if err := ValidatePaths(c, dst); err != nil { + return nil, err } srch, dsth, err := UpdatesWithHeaders(c, dst) @@ -84,14 +81,24 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM return nil, err } - // create the UpdateHeaders for src and dest Chains - srcUpdateHeader, dstUpdateHeader, err := InjectTrustedFieldsHeaders(c, dst, srch, dsth) - if err != nil { - return nil, err - } + // Query a number of things all at once + var ( + eg = new(errgroup.Group) + srcUpdateHeader, dstUpdateHeader *tmclient.Header + srcChan, dstChan *chanTypes.QueryChannelResponse + ) - srcChan, dstChan, err := QueryChannelPair(c, dst, srch.Header.Height, dsth.Header.Height) - if err != nil { + eg.Go(func() error { + srcUpdateHeader, dstUpdateHeader, err = InjectTrustedFieldsHeaders(c, dst, srch, dsth) + return err + }) + + eg.Go(func() error { + srcChan, dstChan, err = QueryChannelPair(c, dst, srch.Header.Height, dsth.Header.Height) + return err + }) + + if err = eg.Wait(); err != nil { return nil, err } @@ -207,7 +214,7 @@ func (c *Chain) CloseChannel(dst *Chain, to time.Duration) error { // identifiers between chains src and dst. If the closing handshake hasn't started, then CloseChannelStep // will begin the handshake on the src chain func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { - var out = &RelayMsgs{Src: []sdk.Msg{}, Dst: []sdk.Msg{}, last: false} + out := NewRelayMsgs() if err := ValidatePaths(c, dst); err != nil { return nil, err } @@ -216,16 +223,29 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { if err != nil { return nil, err } - // create the UpdateHeaders for src and dest Chains - srcUpdateHeader, dstUpdateHeader, err := InjectTrustedFieldsHeaders(c, dst, srch, dsth) - if err != nil { - return nil, err - } - srcChan, dstChan, err := QueryChannelPair(c, dst, srch.Header.Height, dsth.Header.Height) - if err != nil { + // Query a number of things all at once + var ( + eg = new(errgroup.Group) + srcUpdateHeader, dstUpdateHeader *tmclient.Header + srcChan, dstChan *chanTypes.QueryChannelResponse + ) + + eg.Go(func() error { + // create the UpdateHeaders for src and dest Chains + srcUpdateHeader, dstUpdateHeader, err = InjectTrustedFieldsHeaders(c, dst, srch, dsth) + return err + }) + + eg.Go(func() error { + srcChan, dstChan, err = QueryChannelPair(c, dst, srch.Header.Height, dsth.Header.Height) + return err + }) + + if err = eg.Wait(); err != nil { return nil, err } + logChannelStates(c, dst, srcChan, dstChan) switch { diff --git a/relayer/connection-tx.go b/relayer/connection-tx.go index e989dcad0..915041ad7 100644 --- a/relayer/connection-tx.go +++ b/relayer/connection-tx.go @@ -113,7 +113,6 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { return err }) - // TODO: log these heights or something about client state? debug? if err = eg.Wait(); err != nil { return nil, err } @@ -128,6 +127,19 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { return nil, err } + fmt.Println("src header", srch.Header.Height) + fmt.Println("src trusted header", srcUpdateHeader.TrustedHeight) + fmt.Println("dst header", dsth.Header.Height) + fmt.Println("dst trusted header", dstUpdateHeader.TrustedHeight) + fmt.Println("src conn proof height", srcConn.ProofHeight) + fmt.Println("dst conn proof height", dstConn.ProofHeight) + fmt.Println("src client state proof height", srcCsRes.ProofHeight) + fmt.Println("src client state height", srcConsH) + fmt.Println("dst client state proof height", dstCsRes.ProofHeight) + fmt.Println("dst client state height", dstConsH) + fmt.Println("src client consensus state proof height", srcCons.ProofHeight) + fmt.Println("dst client consensus state proof height", dstCons.ProofHeight) + switch { // Handshake hasn't been started on src or dst, relay `connOpenInit` to src case srcConn.Connection.State == ibctypes.UNINITIALIZED && dstConn.Connection.State == ibctypes.UNINITIALIZED: @@ -143,7 +155,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { } out.Src = append(out.Src, c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), - c.PathEnd.ConnTry(dst.PathEnd, srcCsRes, dstConn, dstCons, c.MustGetAddress()), + c.PathEnd.ConnTry(dst.PathEnd, dstCsRes, dstConn, dstCons, c.MustGetAddress()), ) // Handshake has started on src (1 step done), relay `connOpenTry` and `updateClient` on dst diff --git a/relayer/query.go b/relayer/query.go index 92ff98bba..3599d4f51 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -86,7 +86,7 @@ func (c *Chain) QueryConsensusState(height int64) (*tmclient.ConsensusState, int // QueryClientConsensusState retrevies the latest consensus state for a client in state at a given height func (c *Chain) QueryClientConsensusState(height, dstClientConsHeight int64) (*clientTypes.QueryConsensusStateResponse, error) { return clientUtils.QueryConsensusStateABCI( - c.CLIContext(int64(height)), + c.CLIContext(height), c.PathEnd.ClientID, clientTypes.NewHeight(0, uint64(dstClientConsHeight)), ) From 9e0a9f2ab8a6c38877c71a4927b2aeaed37c1e1e Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Tue, 8 Sep 2020 12:21:40 -0700 Subject: [PATCH 24/54] remove unused code --- relayer/chain.go | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/relayer/chain.go b/relayer/chain.go index 6bf8e4be2..39e34ee15 100644 --- a/relayer/chain.go +++ b/relayer/chain.go @@ -8,7 +8,6 @@ import ( "os" "path" "strconv" - "sync" "time" sdkCtx "github.com/cosmos/cosmos-sdk/client" @@ -361,28 +360,10 @@ func (c *Chain) MustGetAddress() sdk.AccAddress { return srcAddr } -var sdkContextMutex sync.Mutex - // UseSDKContext uses a custom Bech32 account prefix and returns a restore func func (c *Chain) UseSDKContext() { - // Ensure we're the only one using the global context. - // defer sdkContextMutex.Unlock() - // sdkContextMutex.Lock() - sdkConf := sdk.GetConfig() - // account := sdkConf.GetBech32AccountAddrPrefix() - // pubaccount := sdkConf.GetBech32AccountPubPrefix() - - // Mutate the sdkConf sdkConf.SetBech32PrefixForAccount(c.AccountPrefix, c.AccountPrefix+"pub") - - // Return a function that resets and unlocks. - // return func() { - // sdkContextMutex.Lock() - // defer sdkContextMutex.Unlock() - - // sdkConf.SetBech32PrefixForAccount(account, pubaccount) - // } } func (c *Chain) String() string { From 3144e72e1a64f12a676482ca687ad82358fea385 Mon Sep 17 00:00:00 2001 From: Aditya Sripal Date: Tue, 8 Sep 2020 17:53:27 -0400 Subject: [PATCH 25/54] fix TRY query --- relayer/connection-tx.go | 81 +++++++++++++++++++++++----------------- relayer/pathEnd.go | 2 +- relayer/query.go | 2 + 3 files changed, 50 insertions(+), 35 deletions(-) diff --git a/relayer/connection-tx.go b/relayer/connection-tx.go index 915041ad7..2c53706d1 100644 --- a/relayer/connection-tx.go +++ b/relayer/connection-tx.go @@ -85,6 +85,8 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { srcConn, dstConn *connTypes.QueryConnectionResponse srcCsRes, dstCsRes *clientTypes.QueryClientStateResponse srcCS, dstCS ibcExported.ClientState + srcCons, dstCons *clientTypes.QueryConsensusStateResponse + srcConsH, dstConsH int64 ) // create the UpdateHeaders for src and dest Chains @@ -95,50 +97,57 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { // Query Connection data from src and dst eg.Go(func() error { - srcConn, dstConn, err = QueryConnectionPair(c, dst, srch.Header.Height, dsth.Header.Height) + srcConn, dstConn, err = QueryConnectionPair(c, dst, srch.Header.Height-1, dsth.Header.Height-1) return err }) - // Query client state from each chain's client - eg.Go(func() error { - srcCsRes, dstCsRes, err = QueryClientStatePair(c, dst, srch.Header.Height, dsth.Header.Height) - if err != nil && (srcCsRes == nil || dstCsRes == nil) { - return err - } - srcCS, err = clientTypes.UnpackClientState(srcCsRes.ClientState) - if err != nil { - return err - } - dstCS, err = clientTypes.UnpackClientState(dstCsRes.ClientState) - return err - }) if err = eg.Wait(); err != nil { return nil, err } - // Store the heights - srcConsH, dstConsH := int64(MustGetHeight(srcCS.GetLatestHeight())), int64(MustGetHeight(dstCS.GetLatestHeight())) + if !(srcConn.Connection.State == ibctypes.UNINITIALIZED && dstConn.Connection.State == ibctypes.UNINITIALIZED) { + // Query client state from each chain's client + eg.Go(func() error { + srcCsRes, dstCsRes, err = QueryClientStatePair(c, dst, srch.Header.Height-1, dsth.Header.Height-1) + if err != nil && (srcCsRes == nil || dstCsRes == nil) { + return err + } + srcCS, err = clientTypes.UnpackClientState(srcCsRes.ClientState) + if err != nil { + return err + } + dstCS, err = clientTypes.UnpackClientState(dstCsRes.ClientState) - // NOTE: We query connection at height - 1 because of the way tendermint returns - // proofs the commit for height n is contained in the header of height n + 1 - srcCons, dstCons, err := QueryClientConsensusStatePair(c, dst, srch.Header.Height, dsth.Header.Height, srcConsH, dstConsH) - if err != nil { - return nil, err - } + return err + }) + + if err = eg.Wait(); err != nil { + return nil, err + } - fmt.Println("src header", srch.Header.Height) - fmt.Println("src trusted header", srcUpdateHeader.TrustedHeight) - fmt.Println("dst header", dsth.Header.Height) - fmt.Println("dst trusted header", dstUpdateHeader.TrustedHeight) - fmt.Println("src conn proof height", srcConn.ProofHeight) - fmt.Println("dst conn proof height", dstConn.ProofHeight) - fmt.Println("src client state proof height", srcCsRes.ProofHeight) - fmt.Println("src client state height", srcConsH) - fmt.Println("dst client state proof height", dstCsRes.ProofHeight) - fmt.Println("dst client state height", dstConsH) - fmt.Println("src client consensus state proof height", srcCons.ProofHeight) - fmt.Println("dst client consensus state proof height", dstCons.ProofHeight) + // Store the heights + srcConsH, dstConsH = int64(MustGetHeight(srcCS.GetLatestHeight())), int64(MustGetHeight(dstCS.GetLatestHeight())) + + // NOTE: We query connection at height - 1 because of the way tendermint returns + // proofs the commit for height n is contained in the header of height n + 1 + srcCons, dstCons, err = QueryClientConsensusStatePair(c, dst, srch.Header.Height-1, dsth.Header.Height-1, srcConsH, dstConsH) + if err != nil { + return nil, err + } + + fmt.Println("src header", srch.Header.Height) + fmt.Printf("src header hash: %X\n", srch.Header.AppHash) + fmt.Println("dst header", dsth.Header.Height) + fmt.Println("src conn proof height", srcConn.ProofHeight) + fmt.Println("dst conn proof height", dstConn.ProofHeight) + fmt.Println("src client state proof height", srcCsRes.ProofHeight) + fmt.Println("src client state height", srcConsH) + fmt.Println("dst client state proof height", dstCsRes.ProofHeight) + fmt.Println("dst client state height", dstConsH) + fmt.Println("src client consensus state proof height", srcCons.ProofHeight) + fmt.Println("dst client consensus state proof height", dstCons.ProofHeight) + } switch { // Handshake hasn't been started on src or dst, relay `connOpenInit` to src @@ -153,6 +162,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { if c.debug { logConnectionStates(c, dst, srcConn, dstConn) } + out.Src = append(out.Src, c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ConnTry(dst.PathEnd, dstCsRes, dstConn, dstCons, c.MustGetAddress()), @@ -163,6 +173,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { if dst.debug { logConnectionStates(dst, c, dstConn, srcConn) } + out.Dst = append(out.Dst, dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), dst.PathEnd.ConnTry(c.PathEnd, srcCsRes, srcConn, srcCons, dst.MustGetAddress()), @@ -173,6 +184,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { if dst.debug { logConnectionStates(dst, c, dstConn, srcConn) } + fmt.Println("DST IS SRC") out.Dst = append(out.Dst, dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), dst.PathEnd.ConnAck(c.PathEnd, srcCsRes, srcConn, srcCons, dst.MustGetAddress()), @@ -183,6 +195,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { if c.debug { logConnectionStates(c, dst, srcConn, dstConn) } + fmt.Println("SRC IS SRC") out.Src = append(out.Src, c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ConnAck(dst.PathEnd, dstCsRes, dstConn, dstCons, c.MustGetAddress()), diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index 44ab198cf..48dc44404 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -137,7 +137,7 @@ func (pe *PathEnd) ConnTry( dstConnState.Proof, dstClientState.Proof, dstConsState.Proof, - dstConsState.ProofHeight, + dstConnState.ProofHeight, css.GetHeight().(clientTypes.Height), signer, ) diff --git a/relayer/query.go b/relayer/query.go index 3599d4f51..ec0c1694e 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -117,10 +117,12 @@ func QueryClientStatePair(src, dst *Chain, srch, dsth int64) (srcCsRes, dstCsRes var eg = new(errgroup.Group) eg.Go(func() error { srcCsRes, err = src.QueryClientState(srch) + fmt.Println("srccs err") return err }) eg.Go(func() error { dstCsRes, err = dst.QueryClientState(dsth) + fmt.Println("dstcs err") return err }) err = eg.Wait() From 22f405d5fe3aabca196da40698ca3f570bd1c0ed Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Tue, 8 Sep 2020 16:33:14 -0700 Subject: [PATCH 26/54] WORKING CHANNEL CREATION --- configs/demo/demo.json | 2 +- relayer/channel-tx.go | 2 +- relayer/connection-tx.go | 39 ++++++++++----------------------------- relayer/pathEnd.go | 2 +- relayer/query.go | 4 +--- 5 files changed, 14 insertions(+), 35 deletions(-) diff --git a/configs/demo/demo.json b/configs/demo/demo.json index 070cf3655..027014e07 100644 --- a/configs/demo/demo.json +++ b/configs/demo/demo.json @@ -1 +1 @@ -{"src":{"chain-id":"ibc0","client-id":"ibconeclient","connection-id":"ibconeconnection","channel-id":"ibconexfer","port-id":"transfer","order":"ordered"},"dst":{"chain-id":"ibc1","client-id":"ibczeroclient","connection-id":"ibczeroconnection","channel-id":"ibczeroxfer","port-id":"transfer","order":"ordered"},"strategy":{"type":"naive"}} \ No newline at end of file +{"src":{"chain-id":"ibc0","client-id":"ibconeclient","connection-id":"ibconeconnection","channel-id":"ibconexfer","port-id":"transfer","order":"unordered"},"dst":{"chain-id":"ibc1","client-id":"ibczeroclient","connection-id":"ibczeroconnection","channel-id":"ibczeroxfer","port-id":"transfer","order":"unordered"},"strategy":{"type":"naive"}} \ No newline at end of file diff --git a/relayer/channel-tx.go b/relayer/channel-tx.go index d40aa5790..78a041306 100644 --- a/relayer/channel-tx.go +++ b/relayer/channel-tx.go @@ -94,7 +94,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM }) eg.Go(func() error { - srcChan, dstChan, err = QueryChannelPair(c, dst, srch.Header.Height, dsth.Header.Height) + srcChan, dstChan, err = QueryChannelPair(c, dst, srch.Header.Height-1, dsth.Header.Height-1) return err }) diff --git a/relayer/connection-tx.go b/relayer/connection-tx.go index 2c53706d1..00cff35ca 100644 --- a/relayer/connection-tx.go +++ b/relayer/connection-tx.go @@ -108,21 +108,16 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { if !(srcConn.Connection.State == ibctypes.UNINITIALIZED && dstConn.Connection.State == ibctypes.UNINITIALIZED) { // Query client state from each chain's client - eg.Go(func() error { - srcCsRes, dstCsRes, err = QueryClientStatePair(c, dst, srch.Header.Height-1, dsth.Header.Height-1) - if err != nil && (srcCsRes == nil || dstCsRes == nil) { - return err - } - srcCS, err = clientTypes.UnpackClientState(srcCsRes.ClientState) - if err != nil { - return err - } - dstCS, err = clientTypes.UnpackClientState(dstCsRes.ClientState) - - return err - }) - - if err = eg.Wait(); err != nil { + srcCsRes, dstCsRes, err = QueryClientStatePair(c, dst, srch.Header.Height-1, dsth.Header.Height-1) + if err != nil && (srcCsRes == nil || dstCsRes == nil) { + return nil, err + } + srcCS, err = clientTypes.UnpackClientState(srcCsRes.ClientState) + if err != nil { + return nil, err + } + dstCS, err = clientTypes.UnpackClientState(dstCsRes.ClientState) + if err != nil { return nil, err } @@ -135,18 +130,6 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { if err != nil { return nil, err } - - fmt.Println("src header", srch.Header.Height) - fmt.Printf("src header hash: %X\n", srch.Header.AppHash) - fmt.Println("dst header", dsth.Header.Height) - fmt.Println("src conn proof height", srcConn.ProofHeight) - fmt.Println("dst conn proof height", dstConn.ProofHeight) - fmt.Println("src client state proof height", srcCsRes.ProofHeight) - fmt.Println("src client state height", srcConsH) - fmt.Println("dst client state proof height", dstCsRes.ProofHeight) - fmt.Println("dst client state height", dstConsH) - fmt.Println("src client consensus state proof height", srcCons.ProofHeight) - fmt.Println("dst client consensus state proof height", dstCons.ProofHeight) } switch { @@ -184,7 +167,6 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { if dst.debug { logConnectionStates(dst, c, dstConn, srcConn) } - fmt.Println("DST IS SRC") out.Dst = append(out.Dst, dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), dst.PathEnd.ConnAck(c.PathEnd, srcCsRes, srcConn, srcCons, dst.MustGetAddress()), @@ -195,7 +177,6 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { if c.debug { logConnectionStates(c, dst, srcConn, dstConn) } - fmt.Println("SRC IS SRC") out.Src = append(out.Src, c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ConnAck(dst.PathEnd, dstCsRes, dstConn, dstCons, c.MustGetAddress()), diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index 48dc44404..bdb9b0d6d 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -172,7 +172,7 @@ func (pe *PathEnd) ConnAck( dstConsState.Proof, dstConsState.ProofHeight, css.GetHeight().(clientTypes.Height), - defaultIBCVersion, + connTypes.GetCompatibleEncodedVersions()[0], signer, ) } diff --git a/relayer/query.go b/relayer/query.go index ec0c1694e..de2541181 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -117,12 +117,10 @@ func QueryClientStatePair(src, dst *Chain, srch, dsth int64) (srcCsRes, dstCsRes var eg = new(errgroup.Group) eg.Go(func() error { srcCsRes, err = src.QueryClientState(srch) - fmt.Println("srccs err") return err }) eg.Go(func() error { dstCsRes, err = dst.QueryClientState(dsth) - fmt.Println("dstcs err") return err }) err = eg.Wait() @@ -214,7 +212,7 @@ func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (srcChan, dstChan *chan return err }) eg.Go(func() error { - srcChan, err = src.QueryChannel(srcH) + dstChan, err = dst.QueryChannel(dstH) return err }) err = eg.Wait() From 3952033ade8a7b8d3aa486933da2288a581f67ae Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Tue, 8 Sep 2020 16:57:11 -0700 Subject: [PATCH 27/54] fix tests --- test/test_chains.go | 3 ++- test/test_queries.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test_chains.go b/test/test_chains.go index 0c1a25e20..85744bd57 100644 --- a/test/test_chains.go +++ b/test/test_chains.go @@ -30,7 +30,7 @@ var ( cdc: cdc, amino: amino, dockerImage: "jackzampolin/gaiatest", - dockerTag: "gaiav3.0", + dockerTag: "jack_gaiav3.0", timeout: 3 * time.Second, rpcPort: "26657", accountPrefix: "cosmos", @@ -150,6 +150,7 @@ func newTestChain(t *testing.T, tc testChain) *ry.Chain { AccountPrefix: tc.t.accountPrefix, Gas: tc.t.gas, GasPrices: tc.t.gasPrices, + GasAdjustment: 1.0, DefaultDenom: tc.t.defaultDenom, TrustingPeriod: tc.t.trustingPeriod, } diff --git a/test/test_queries.go b/test/test_queries.go index 7ef89eb36..01366d355 100644 --- a/test/test_queries.go +++ b/test/test_queries.go @@ -17,7 +17,7 @@ func testClientPair(t *testing.T, src, dst *ry.Chain) { // testClient queries client for existence of dst on src func testClient(t *testing.T, src, dst *ry.Chain) { - client, err := src.QueryClientState() + client, err := src.QueryClientState(0) require.NoError(t, err) require.NotNil(t, client) cs, err := clientTypes.UnpackClientState(client.ClientState) From f5e20ce686e22a57b5d35a05e5806ad59c4fe50d Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Tue, 8 Sep 2020 21:10:36 -0700 Subject: [PATCH 28/54] MOAR tests --- test/test_queries.go | 8 ++++---- test/test_setup.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_queries.go b/test/test_queries.go index 01366d355..625e7a464 100644 --- a/test/test_queries.go +++ b/test/test_queries.go @@ -33,7 +33,7 @@ func testConnectionPair(t *testing.T, src, dst *ry.Chain) { // testConnection tests that the only connection on src has a counterparty that is the connection on dst func testConnection(t *testing.T, src, dst *ry.Chain) { - conns, err := src.QueryConnections(1, 1000) + conns, err := src.QueryConnections(0, 1000) require.NoError(t, err) require.Equal(t, len(conns), 1) // conns[0]. @@ -61,10 +61,10 @@ func testChannelPair(t *testing.T, src, dst *ry.Chain) { // testChannel tests that the only channel on src is a counterparty of dst func testChannel(t *testing.T, src, dst *ry.Chain) { - chans, err := src.QueryChannels(1, 1000) + chans, err := src.QueryChannels(0, 1000) require.NoError(t, err) require.Equal(t, 1, len(chans)) - require.Equal(t, chans[0].Ordering.String(), "ORDER_ORDERED") + require.Equal(t, chans[0].Ordering.String(), "ORDER_UNORDERED") require.Equal(t, chans[0].State.String(), "STATE_OPEN") require.Equal(t, chans[0].Counterparty.ChannelId, dst.PathEnd.ChannelID) require.Equal(t, chans[0].Counterparty.GetPortID(), dst.PathEnd.PortID) @@ -74,7 +74,7 @@ func testChannel(t *testing.T, src, dst *ry.Chain) { ch, err := src.QueryChannel(h.SyncInfo.LatestBlockHeight) require.NoError(t, err) - require.Equal(t, ch.Channel.Ordering.String(), "ORDER_ORDERED") + require.Equal(t, ch.Channel.Ordering.String(), "ORDER_UNORDERED") require.Equal(t, ch.Channel.State.String(), "STATE_OPEN") require.Equal(t, ch.Channel.Counterparty.ChannelId, dst.PathEnd.ChannelID) require.Equal(t, ch.Channel.Counterparty.GetPortID(), dst.PathEnd.PortID) diff --git a/test/test_setup.go b/test/test_setup.go index 3a646a891..68470bee3 100644 --- a/test/test_setup.go +++ b/test/test_setup.go @@ -204,7 +204,7 @@ func getLoggingChain(chns []*ry.Chain, rsr *dockertest.Resource) *ry.Chain { } func genTestPathAndSet(src, dst *ry.Chain, srcPort, dstPort string) (*ry.Path, error) { - path := ry.GenPath(src.ChainID, dst.ChainID, srcPort, dstPort, "ORDERED", "ics20-1") + path := ry.GenPath(src.ChainID, dst.ChainID, srcPort, dstPort, "UNORDERED", "ics20-1") if err := src.SetPath(path.Src); err != nil { return nil, err } From 8490c9121f771dfe4c6325cffe88df9dc92b4689 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Wed, 9 Sep 2020 13:55:14 -0700 Subject: [PATCH 29/54] WIP relay unrelayed packets --- cmd/xfer.go | 17 ++-- dev-env | 7 +- relayer/naive-strategy.go | 172 ++++++++++++++++++++++++-------------- relayer/packet-tx.go | 147 +------------------------------- relayer/packetMsgs.go | 68 --------------- relayer/pathEnd.go | 88 +------------------ relayer/query.go | 117 +++++--------------------- relayer/relayPackets.go | 63 +++++++++----- 8 files changed, 192 insertions(+), 487 deletions(-) delete mode 100644 relayer/packetMsgs.go diff --git a/cmd/xfer.go b/cmd/xfer.go index ac6748374..df0b563a6 100644 --- a/cmd/xfer.go +++ b/cmd/xfer.go @@ -14,10 +14,10 @@ import ( func xfersend() *cobra.Command { cmd := &cobra.Command{ - Use: "xfer-send [src-chain-id] [dst-chain-id] [amount] [source] [dst-addr]", + Use: "xfer-send [src-chain-id] [dst-chain-id] [amount] [dst-addr]", Short: "xfer-send", Long: "This sends tokens from a relayers configured wallet on chain src to a dst addr on dst", - Args: cobra.ExactArgs(5), + Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) error { src, dst := args[0], args[1] c, err := config.Chains.Gets(src, dst) @@ -39,18 +39,17 @@ func xfersend() *cobra.Command { return err } - source, err := strconv.ParseBool(args[3]) - if err != nil { - return err - } - + // TODO: add ability to set timeout height and time from flags + // Should be relative to current time and block height + // --timeout-height-offset=1000 + // --timeout-time-offset=2h c[dst].UseSDKContext() - dstAddr, err := sdk.AccAddressFromBech32(args[4]) + dstAddr, err := sdk.AccAddressFromBech32(args[3]) if err != nil { return err } - return c[src].SendTransferMsg(c[dst], amount, dstAddr, source) + return c[src].SendTransferMsg(c[dst], amount, dstAddr) }, } return pathFlag(cmd) diff --git a/dev-env b/dev-env index 42ed39237..a8b631e5e 100755 --- a/dev-env +++ b/dev-env @@ -21,4 +21,9 @@ bash scripts/config-relayer "skip" echo "waiting for blocks..." sleep 5 -rly tx full-path demo -d -o 3s \ No newline at end of file +rly tx full-path demo -d -o 3s +rly tx raw xfer-send ibc0 ibc1 10000000samoleans $(rly k s ibc1) +rly tx raw xfer-send ibc0 ibc1 10000000samoleans $(rly k s ibc1) +rly tx raw xfer-send ibc1 ibc0 10000000samoleans $(rly k s ibc0) +rly tx raw xfer-send ibc1 ibc0 10000000samoleans $(rly k s ibc0) +rly tx relay demo -d \ No newline at end of file diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index e53e18ce7..22d9195dc 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -3,10 +3,13 @@ package relayer import ( "fmt" "strconv" + "strings" "time" retry "github.com/avast/retry-go" sdk "github.com/cosmos/cosmos-sdk/types" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + "golang.org/x/sync/errgroup" ) var _ Strategy = &NaiveStrategy{} @@ -32,14 +35,62 @@ func (nrs *NaiveStrategy) GetType() string { // UnrelayedSequencesOrdered returns the unrelayed sequence numbers between two chains func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHeaders) (*RelaySequences, error) { - // TODO: Implement - return &RelaySequences{}, nil + var ( + eg = new(errgroup.Group) + srcPacketSeq = []uint64{} + dstPacketSeq = []uint64{} + rs = &RelaySequences{Src: []uint64{}, Dst: []uint64{}} + ) + eg.Go(func() error { + res, err := src.QueryPacketCommitments(0, 1000, sh.GetHeight(src.ChainID)) + if err != nil { + return err + } + for _, pc := range res { + srcPacketSeq = append(srcPacketSeq, pc.Sequence) + } + return nil + }) + eg.Go(func() error { + res, err := dst.QueryPacketCommitments(0, 1000, sh.GetHeight(dst.ChainID)) + if err != nil { + return err + } + for _, pc := range res { + dstPacketSeq = append(dstPacketSeq, pc.Sequence) + } + return nil + }) + + if err := eg.Wait(); err != nil { + return nil, err + } + + eg.Go(func() error { + res, err := src.QueryUnrelayedPackets(sh.GetHeight(src.ChainID), srcPacketSeq, false) + if len(res) > 0 { + rs.Src = res + } + return err + }) + eg.Go(func() error { + res, err := dst.QueryUnrelayedPackets(sh.GetHeight(dst.ChainID), dstPacketSeq, false) + if len(res) > 0 { + rs.Dst = res + } + return err + }) + + if err := eg.Wait(); err != nil { + return nil, err + } + + return rs, nil } // UnrelayedSequencesUnordered returns the unrelayed sequence numbers between two chains func (nrs *NaiveStrategy) UnrelayedSequencesUnordered(src, dst *Chain, sh *SyncHeaders) (*RelaySequences, error) { - // TODO: Implement - return &RelaySequences{}, nil + return nrs.UnrelayedSequencesOrdered(src, dst, sh) } // HandleEvents defines how the relayer will handle block and transaction events as they are emitted @@ -193,8 +244,8 @@ func (nrs *NaiveStrategy) sendTxFromEventPackets(src, dst *Chain, rlyPackets []r // RelaySequences represents unrelayed packets on src and dst type RelaySequences struct { - Src []uint64 - Dst []uint64 + Src []uint64 `json:"src"` + Dst []uint64 `json:"dst"` } // RelayPacketsUnorderedChan creates transactions to relay un-relayed messages @@ -215,6 +266,7 @@ func (nrs *NaiveStrategy) RelayPacketsOrderedChan(src, dst *Chain, sp *RelaySequ } // add messages for src -> dst + for _, seq := range sp.Src { chain, msg, err := packetMsgFromTxQuery(src, dst, sh, seq) if err != nil { @@ -285,17 +337,17 @@ func packetMsgFromTxQuery(src, dst *Chain, sh *SyncHeaders, seq uint64) (*Chain, return nil, nil, err } - tx, err := src.QueryTxs(sh.GetHeight(src.ChainID), 1, 1000, eveSend) + txs, err := src.QueryTxs(sh.GetHeight(src.ChainID), 1, 1000, eveSend) switch { case err != nil: return nil, nil, err - case tx.Count == 0: + case len(txs) == 0: return nil, nil, fmt.Errorf("no transactions returned with query") - case tx.Count > 1: + case len(txs) > 1: return nil, nil, fmt.Errorf("more than one transaction returned with query") } - rcvPackets, timeoutPackets, err := relayPacketFromQueryResponse(src.PathEnd, dst.PathEnd, tx.Txs[0], sh) + rcvPackets, timeoutPackets, err := relayPacketFromQueryResponse(src.PathEnd, dst.PathEnd, txs[0], sh) switch { case err != nil: return nil, nil, err @@ -344,64 +396,62 @@ func packetMsgFromTxQuery(src, dst *Chain, sh *SyncHeaders, seq uint64) (*Chain, // relayPacketFromQueryResponse looks through the events in a sdk.Response // and returns relayPackets with the appropriate data -func relayPacketFromQueryResponse(src, dst *PathEnd, res *sdk.TxResponse, +func relayPacketFromQueryResponse(src, dst *PathEnd, res *ctypes.ResultTx, sh *SyncHeaders) (rcvPackets []relayPacket, timeoutPackets []relayPacket, err error) { - for _, l := range res.Logs { - for _, e := range l.Events { - if e.Type == "send_packet" { - // NOTE: Src and Dst are switched here - rp := &relayMsgRecvPacket{pass: false} - for _, p := range e.Attributes { - if p.Key == "packet_src_channel" { - if p.Value != src.ChannelID { - rp.pass = true - continue - } - } - if p.Key == "packet_dst_channel" { - if p.Value != dst.ChannelID { - rp.pass = true - continue - } - } - if p.Key == "packet_src_port" { - if p.Value != src.PortID { - rp.pass = true - continue - } - } - if p.Key == "packet_dst_port" { - if p.Value != dst.PortID { - rp.pass = true - continue - } - } - if p.Key == "packet_data" { - rp.packetData = []byte(p.Value) + for _, e := range res.TxResult.Events { + if e.Type == "send_packet" { + // NOTE: Src and Dst are switched here + rp := &relayMsgRecvPacket{pass: false} + for _, p := range e.Attributes { + if string(p.Key) == "packet_src_channel" { + if string(p.Value) != src.ChannelID { + rp.pass = true + continue } - if p.Key == "packet_timeout_height" { - timeout, _ := strconv.ParseUint(p.Value, 10, 64) - rp.timeout = timeout + } + if string(p.Key) == "packet_dst_channel" { + if string(p.Value) != dst.ChannelID { + rp.pass = true + continue } - if p.Key == "packet_timeout_timestamp" { - timeout, _ := strconv.ParseUint(p.Value, 10, 64) - rp.timeoutStamp = timeout + } + if string(p.Key) == "packet_src_port" { + if string(p.Value) != src.PortID { + rp.pass = true + continue } - if p.Key == "packet_sequence" { - seq, _ := strconv.ParseUint(p.Value, 10, 64) - rp.seq = seq + } + if string(p.Key) == "packet_dst_port" { + if string(p.Value) != dst.PortID { + rp.pass = true + continue } } - - // if we have decided not to relay this packet, don't add it - switch { - case sh.GetHeight(src.ChainID) >= rp.timeout: - timeoutPackets = append(timeoutPackets, rp.timeoutPacket()) - case rp.timeoutStamp != 0 && time.Now().UnixNano() >= int64(rp.timeoutStamp): - timeoutPackets = append(timeoutPackets, rp.timeoutPacket()) - case !rp.pass: - rcvPackets = append(rcvPackets, rp) + if string(p.Key) == "packet_data" { + rp.packetData = []byte(p.Value) + } + if string(p.Key) == "packet_timeout_height" { + timeout, _ := strconv.ParseUint(strings.Split(string(p.Value), "-")[0], 10, 64) + rp.timeout = timeout + } + if string(p.Key) == "packet_timeout_timestamp" { + timeout, _ := strconv.ParseUint(string(p.Value), 10, 64) + rp.timeoutStamp = timeout } + if string(p.Key) == "packet_sequence" { + seq, _ := strconv.ParseUint(string(p.Value), 10, 64) + rp.seq = seq + } + } + + // if we have decided not to relay this packet, don't add it + switch { + case sh.GetHeight(src.ChainID) >= rp.timeout: + timeoutPackets = append(timeoutPackets, rp.timeoutPacket()) + case rp.timeoutStamp != 0 && time.Now().UnixNano() >= int64(rp.timeoutStamp): + timeoutPackets = append(timeoutPackets, rp.timeoutPacket()) + case !rp.pass: + rcvPackets = append(rcvPackets, rp) } } } diff --git a/relayer/packet-tx.go b/relayer/packet-tx.go index 095e83388..a2458d60f 100644 --- a/relayer/packet-tx.go +++ b/relayer/packet-tx.go @@ -4,10 +4,7 @@ import ( "fmt" "time" - retry "github.com/avast/retry-go" sdk "github.com/cosmos/cosmos-sdk/types" - chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" - tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" commitmentypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ) @@ -29,122 +26,12 @@ func defaultPacketTimeoutStamp() uint64 { // SendTransferBothSides sends a ICS20 packet from src to dst func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringer, source bool) error { - if source { - amount.Denom = fmt.Sprintf("%s/%s/%s", dst.PathEnd.PortID, dst.PathEnd.ChannelID, amount.Denom) - } else { - amount.Denom = fmt.Sprintf("%s/%s/%s", c.PathEnd.PortID, c.PathEnd.ChannelID, amount.Denom) - } - - dstHeader, err := dst.UpdateLiteWithHeader() - if err != nil { - return err - } - - timeoutHeight := MustGetHeight(dstHeader.GetHeight()) + uint64(defaultPacketTimeout) - - // Properly render the address string - dst.UseSDKContext() - dstAddrString := dstAddr.String() - - // MsgTransfer will call SendPacket on src chain - // TODO: FIX - txs := RelayMsgs{ - Src: []sdk.Msg{c.PathEnd.MsgTransfer( - dst.PathEnd, amount, dstAddrString, c.MustGetAddress(), 1, 1, - )}, - Dst: []sdk.Msg{}, - } - - if txs.Send(c, dst); !txs.Success() { - return fmt.Errorf("failed to send first transaction") - } - - // Working on SRC chain :point_up: - // Working on DST chain :point_down: - - var ( - srch, dsth *tmclient.Header - seqRecv *chanTypes.QueryNextSequenceReceiveResponse - seqSend uint64 - srcCommitRes *chanTypes.QueryPacketCommitmentResponse - ) - - if err = retry.Do(func() error { - srch, dsth, err = UpdatesWithHeaders(c, dst) - if err != nil { - return err - } - - seqRecv, err = dst.QueryNextSeqRecv(dsth.Header.Height) - if err != nil { - return err - } - - srcCommitRes, err = c.QueryPacketCommitment(srch.Header.Height, seqSend-1) - if err != nil { - return err - } - - if srcCommitRes.Proof == nil { - return fmt.Errorf("proof nil, retrying") - } - - return nil - }); err != nil { - return err - } - - // Properly render the source and destination address strings - c.UseSDKContext() - srcAddrString := c.MustGetAddress().String() - - dst.UseSDKContext() - dstAddrString = dstAddr.String() - - // reconstructing packet data here instead of retrieving from an indexed node - xferPacket := c.PathEnd.XferPacket( - amount, - srcAddrString, - dstAddrString, - ) - - updateHeader, err := InjectTrustedFields(c, dst, srch) - if err != nil { - return err - } - // Debugging by simply passing in the packet information that we know was sent earlier in the SendPacket - // part of the command. In a real relayer, this would be a separate command that retrieved the packet - // information from an indexing node - txs = RelayMsgs{ - Dst: []sdk.Msg{ - dst.PathEnd.UpdateClient(updateHeader, dst.MustGetAddress()), - dst.PathEnd.MsgRecvPacket( - c.PathEnd, - seqRecv.NextSequenceReceive, - timeoutHeight, - defaultPacketTimeoutStamp(), - xferPacket, - srcCommitRes.Proof, - MustGetHeight(srcCommitRes.ProofHeight), - dst.MustGetAddress(), - ), - }, - Src: []sdk.Msg{}, - } - - txs.Send(c, dst) return nil } // SendTransferMsg initiates an ibs20 transfer from src to dst with the specified args -func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringer, source bool) error { - if source { - amount.Denom = fmt.Sprintf("%s/%s/%s", dst.PathEnd.PortID, dst.PathEnd.ChannelID, amount.Denom) - } else { - amount.Denom = fmt.Sprintf("%s/%s/%s", c.PathEnd.PortID, c.PathEnd.ChannelID, amount.Denom) - } - - _, err := dst.UpdateLiteWithHeader() +func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringer) error { + h, err := dst.UpdateLiteWithHeader() if err != nil { return err } @@ -154,10 +41,10 @@ func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringe dstAddrString := dstAddr.String() // MsgTransfer will call SendPacket on src chain - // TODO: FIX + // TODO: Add ability to specify timeout time or height via command line flags txs := RelayMsgs{ Src: []sdk.Msg{c.PathEnd.MsgTransfer( - dst.PathEnd, amount, dstAddrString, c.MustGetAddress(), 1, 1, + dst.PathEnd, amount, dstAddrString, c.MustGetAddress(), uint64(h.Header.Height+1000), 0, )}, Dst: []sdk.Msg{}, } @@ -167,29 +54,3 @@ func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringe } return nil } - -// TODO: reimplement -// // SendPacket sends arbitrary bytes from src to dst -// func (c *Chain) SendPacket(dst *Chain, packetData []byte) error { -// dstHeader, err := dst.UpdateLiteWithHeader() -// if err != nil { -// return err -// } - -// // MsgSendPacket will call SendPacket on src chain -// txs := RelayMsgs{ -// Src: []sdk.Msg{c.PathEnd.MsgSendPacket( -// dst.PathEnd, -// packetData, -// dstHeader.GetHeight()+uint64(defaultPacketTimeout), -// defaultPacketTimeoutStamp(), -// c.MustGetAddress(), -// )}, -// Dst: []sdk.Msg{}, -// } - -// if txs.Send(c, dst); !txs.success { -// return fmt.Errorf("failed to send packet") -// } -// return nil -// } diff --git a/relayer/packetMsgs.go b/relayer/packetMsgs.go deleted file mode 100644 index 84b68cb75..000000000 --- a/relayer/packetMsgs.go +++ /dev/null @@ -1,68 +0,0 @@ -package relayer - -// import ( -// "github.com/cosmos/cosmos-sdk/codec" - -// sdk "github.com/cosmos/cosmos-sdk/types" -// sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - -// chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" -// ) - -// var ModuleCdc *codec.LegacyAmino - -// func RegisterCodec(cdc *codec.LegacyAmino) { -// if ModuleCdc != nil { -// return -// } -// cdc.RegisterConcrete(MsgSendPacket{}, "swingset/SendPacket", nil) -// ModuleCdc = cdc -// } - -// // MsgSendPacket sends an outgoing IBC packet -// type MsgSendPacket struct { -// Packet chanTypes.Packet `json:"packet" yaml:"packet"` -// Sender sdk.AccAddress `json:"sender" yaml:"sender"` // the sender address -// } - -// // TODO: Implement ProtoMessage method -// var _ sdk.Msg = MsgSendPacket{} - -// // NewMsgSendPacket returns a new send request -// func NewMsgSendPacket(packet chanTypes.Packet, sender sdk.AccAddress) MsgSendPacket { -// return MsgSendPacket{ -// Packet: packet, -// Sender: sender, -// } -// } - -// // Route implements sdk.Msg -// func (msg MsgSendPacket) Route() string { -// // FIXME: Do we need this if we are only sending? -// return "swingset" -// } - -// // ValidateBasic implements sdk.Msg -// func (msg MsgSendPacket) ValidateBasic() error { -// if msg.Sender.Empty() { -// return sdkerrors.ErrInvalidAddress -// } - -// return msg.Packet.ValidateBasic() -// } - -// // GetSignBytes implements sdk.Msg -// func (msg MsgSendPacket) GetSignBytes() []byte { -// // FIXME: What do we need here? -// return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) -// } - -// // GetSigners implements sdk.Msg -// func (msg MsgSendPacket) GetSigners() []sdk.AccAddress { -// return []sdk.AccAddress{msg.Sender} -// } - -// // Type implements sdk.Msg -// func (msg MsgSendPacket) Type() string { -// return "sendpacket" -// } diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index bdb9b0d6d..367e7564a 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -262,66 +262,6 @@ func (pe *PathEnd) ChanCloseConfirm(dstChanState *chanTypes.QueryChannelResponse ) } -// MsgRecvPacket creates a MsgPacket -// TODO: need to do some more looking here -func (pe *PathEnd) MsgRecvPacket(dst *PathEnd, sequence, timeoutHeight, timeoutStamp uint64, - packetData []byte, proof []byte, proofHeight uint64, signer sdk.AccAddress) sdk.Msg { - return &connTypes.MsgConnectionOpenAck{} - // TODO: reimplement - // return chanTypes.NewMsgPacket( - // dst.NewPacket( - // pe, - // sequence, - // packetData, - // timeoutHeight, - // timeoutStamp, - // ), - // proof, - // proofHeight+1, - // signer, - // ) -} - -// MsgTimeout creates MsgTimeout -func (pe *PathEnd) MsgTimeout(dst *PathEnd, packetData []byte, seq, timeout, timeoutStamp uint64, - proof []byte, proofHeight uint64, signer sdk.AccAddress) sdk.Msg { - return &connTypes.MsgConnectionOpenAck{} - // TODO: reimplement - // return chanTypes.NewMsgTimeout( - // pe.NewPacket( - // dst, - // seq, - // packetData, - // timeout, - // timeoutStamp, - // ), - // seq, - // proof, - // proofHeight+1, - // signer, - // ) -} - -// MsgAck creates MsgAck -func (pe *PathEnd) MsgAck(dst *PathEnd, sequence, timeoutHeight, timeoutStamp uint64, ack, packetData []byte, - proof []byte, proofHeight uint64, signer sdk.AccAddress) sdk.Msg { - return &connTypes.MsgConnectionOpenAck{} - // TODO: reimplement - // return chanTypes.NewMsgAcknowledgement( - // pe.NewPacket( - // dst, - // sequence, - // packetData, - // timeoutHeight, - // timeoutStamp, - // ), - // ack, - // proof, - // proofHeight+1, - // signer, - // ) -} - // MsgTransfer creates a new transfer message func (pe *PathEnd) MsgTransfer(dst *PathEnd, amount sdk.Coin, dstAddr string, signer sdk.AccAddress, timeoutHeight, timeoutTimestamp uint64) sdk.Msg { @@ -336,17 +276,6 @@ func (pe *PathEnd) MsgTransfer(dst *PathEnd, amount sdk.Coin, dstAddr string, ) } -// TODO: potentially reimplement -// MsgSendPacket creates a new arbitrary packet message -// func (pe *PathEnd) MsgSendPacket(dst *PathEnd, packetData []byte, relativeTimeout, timeoutStamp uint64, -// signer sdk.AccAddress) sdk.Msg { -// // NOTE: Use this just to pass the packet integrity checks. -// fakeSequence := uint64(1) -// packet := chanTypes.NewPacket(packetData, fakeSequence, pe.PortID, pe.ChannelID, dst.PortID, -// dst.ChannelID, relativeTimeout, timeoutStamp) -// return NewMsgSendPacket(packet, signer) -// } - // NewPacket returns a new packet from src to dist w func (pe *PathEnd) NewPacket(dst *PathEnd, sequence uint64, packetData []byte, timeoutHeight, timeoutStamp uint64) chanTypes.Packet { @@ -357,7 +286,7 @@ func (pe *PathEnd) NewPacket(dst *PathEnd, sequence uint64, packetData []byte, pe.ChannelID, dst.PortID, dst.ChannelID, - clientTypes.NewHeight(timeoutHeight, timeoutHeight), + clientTypes.NewHeight(0, timeoutHeight), timeoutStamp, ) } @@ -371,18 +300,3 @@ func (pe *PathEnd) XferPacket(amount sdk.Coin, sender, receiver string) []byte { receiver, ).GetBytes() } - -// PacketMsg returns a new MsgPacket for forwarding packets from one chain to another -func (c *Chain) PacketMsg(dst *Chain, xferPacket []byte, timeout, timeoutStamp uint64, - seq int64, dstCommitRes *chanTypes.QueryPacketCommitmentResponse) sdk.Msg { - return c.PathEnd.MsgRecvPacket( - dst.PathEnd, - uint64(seq), - timeout, - timeoutStamp, - xferPacket, - dstCommitRes.Proof, - MustGetHeight(dstCommitRes.ProofHeight), - c.MustGetAddress(), - ) -} diff --git a/relayer/query.go b/relayer/query.go index de2541181..7ddc7552c 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -9,11 +9,9 @@ import ( "sync" "time" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/rootmulti" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" clientUtils "github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/utils" clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" @@ -319,12 +317,11 @@ func (c *Chain) QueryPacketCommitment(height int64, seq uint64) (comRes *chanTyp } // QueryPacketCommitments returns an array of packet commitment proofs -func (c *Chain) QueryPacketCommitments(limit, offset uint64) (comRes []*chanTypes.PacketAckCommitment, err error) { - res, err := chanTypes.NewQueryClient(c.CLIContext(0)).PacketCommitments(context.Background(), &types.QueryPacketCommitmentsRequest{ +func (c *Chain) QueryPacketCommitments(offset, limit, height uint64) (comRes []*chanTypes.PacketAckCommitment, err error) { + res, err := chanTypes.NewQueryClient(c.CLIContext(int64(height))).PacketCommitments(context.Background(), &types.QueryPacketCommitmentsRequest{ PortId: c.PathEnd.PortID, ChannelId: c.PathEnd.ChannelID, Pagination: &query.PageRequest{ - Key: []byte(""), Offset: offset, Limit: limit, CountTotal: false, @@ -333,35 +330,30 @@ func (c *Chain) QueryPacketCommitments(limit, offset uint64) (comRes []*chanType return res.Commitments, err } -// QueryTx takes a transaction hash and returns the transaction -func (c *Chain) QueryTx(hashHex string) (*sdk.TxResponse, error) { - hash, err := hex.DecodeString(hashHex) - if err != nil { - return &sdk.TxResponse{}, err - } - - resTx, err := c.Client.Tx(hash, true) - if err != nil { - return &sdk.TxResponse{}, err - } - - // TODO: validate data coming back with local lite client +// QueryUnrelayedPackets returns a list of unrelayed packet commitments +func (c *Chain) QueryUnrelayedPackets(height uint64, seqs []uint64, acks bool) ([]uint64, error) { + res, err := chanTypes.NewQueryClient(c.CLIContext(int64(height))).UnrelayedPackets(context.Background(), &types.QueryUnrelayedPacketsRequest{ + PortId: c.PathEnd.PortID, + ChannelId: c.PathEnd.ChannelID, + PacketCommitmentSequences: seqs, + Acknowledgements: acks, + }) + return res.Sequences, err - resBlocks, err := c.queryBlocksForTxResults([]*ctypes.ResultTx{resTx}) - if err != nil { - return &sdk.TxResponse{}, err - } +} - out, err := c.formatTxResult(resTx, resBlocks[resTx.Height]) +// QueryTx takes a transaction hash and returns the transaction +func (c *Chain) QueryTx(hashHex string) (*ctypes.ResultTx, error) { + hash, err := hex.DecodeString(hashHex) if err != nil { - return out, err + return &ctypes.ResultTx{}, err } - return out, nil + return c.Client.Tx(hash, true) } // QueryTxs returns an array of transactions given a tag -func (c *Chain) QueryTxs(height uint64, page, limit int, events []string) (*sdk.SearchTxsResult, error) { +func (c *Chain) QueryTxs(height uint64, page, limit int, events []string) ([]*ctypes.ResultTx, error) { if len(events) == 0 { return nil, errors.New("must declare at least one event to search") } @@ -374,30 +366,11 @@ func (c *Chain) QueryTxs(height uint64, page, limit int, events []string) (*sdk. return nil, errors.New("limit must greater than 0") } - resTxs, err := c.Client.TxSearch(strings.Join(events, " AND "), true, &page, &limit, "") - if err != nil { - return nil, err - } - - // TODO: Enable lite client validation - // for _, tx := range resTxs.Txs { - // if err = c.ValidateTxResult(tx); err != nil { - // return nil, err - // } - // } - - resBlocks, err := c.queryBlocksForTxResults(resTxs.Txs) - if err != nil { - return nil, err - } - - txs, err := c.formatTxResults(resTxs.Txs, resBlocks) + res, err := c.Client.TxSearch(strings.Join(events, " AND "), true, &page, &limit, "") if err != nil { return nil, err } - - res := sdk.NewSearchTxsResult(resTxs.TotalCount, len(txs), page, limit, txs) - return &res, nil + return res.Txs, nil } // QueryABCI is an affordance for querying the ABCI server associated with a chain @@ -551,56 +524,6 @@ func isQueryStoreWithProof(path string) bool { return false } -// queryBlocksForTxResults returns a map[blockHeight]txResult -func (c *Chain) queryBlocksForTxResults(resTxs []*ctypes.ResultTx) (map[int64]*ctypes.ResultBlock, error) { - resBlocks := make(map[int64]*ctypes.ResultBlock) - for _, resTx := range resTxs { - if _, ok := resBlocks[resTx.Height]; !ok { - resBlock, err := c.Client.Block(&resTx.Height) - if err != nil { - return nil, err - } - resBlocks[resTx.Height] = resBlock - } - } - return resBlocks, nil -} - -// formatTxResults parses the indexed txs into a slice of TxResponse objects. -func (c *Chain) formatTxResults(resTxs []*ctypes.ResultTx, - resBlocks map[int64]*ctypes.ResultBlock) ([]*sdk.TxResponse, error) { - var err error - out := make([]*sdk.TxResponse, len(resTxs)) - for i := range resTxs { - out[i], err = c.formatTxResult(resTxs[i], resBlocks[resTxs[i].Height]) - if err != nil { - return nil, err - } - } - return out, nil -} - -// formatTxResult parses a tx into a TxResponse object -func (c *Chain) formatTxResult(resTx *ctypes.ResultTx, resBlock *ctypes.ResultBlock) (*sdk.TxResponse, error) { - tx, err := parseTx(c.Amino, resTx.Tx) - if err != nil { - return &sdk.TxResponse{}, err - } - - return sdk.NewResponseResultTx(resTx, tx, resBlock.Block.Time.Format(time.RFC3339)), nil -} - -// Takes some bytes and a codec and returns an sdk.Tx -func parseTx(cdc *codec.LegacyAmino, txBytes []byte) (sdk.Tx, error) { - var tx authTypes.StdTx - err := cdc.UnmarshalJSON(txBytes, &tx) - if err != nil { - return nil, err - } - - return tx, nil -} - // ParseEvents takes events in the query format and reutrns func ParseEvents(e string) ([]string, error) { eventsStr := strings.Trim(e, "'") diff --git a/relayer/relayPackets.go b/relayer/relayPackets.go index f90555451..f64b12109 100644 --- a/relayer/relayPackets.go +++ b/relayer/relayPackets.go @@ -5,6 +5,7 @@ import ( retry "github.com/avast/retry-go" sdk "github.com/cosmos/cosmos-sdk/types" + clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ) @@ -40,11 +41,10 @@ func (rp *relayMsgTimeout) Timeout() uint64 { func (rp *relayMsgTimeout) FetchCommitResponse(src, dst *Chain, sh *SyncHeaders) (err error) { var dstRecvRes *chanTypes.QueryPacketCommitmentResponse - // retry getting commit response until it succeeds if err = retry.Do(func() error { // NOTE: Timeouts currently only work with ORDERED channels for nwo - dstRecvRes, err = dst.QueryPacketCommitment(sh.GetHeader(dst.ChainID).Header.Height, rp.seq) + dstRecvRes, err = dst.QueryPacketCommitment(sh.GetHeader(dst.ChainID).Header.Height-1, rp.seq) if err != nil { return err } else if dstRecvRes.Proof == nil { @@ -56,7 +56,6 @@ func (rp *relayMsgTimeout) FetchCommitResponse(src, dst *Chain, sh *SyncHeaders) dst.Error(err) return } - rp.dstRecvRes = dstRecvRes return } @@ -65,14 +64,20 @@ func (rp *relayMsgTimeout) Msg(src, dst *Chain) sdk.Msg { if rp.dstRecvRes == nil { return nil } - return src.PathEnd.MsgTimeout( - dst.PathEnd, - rp.packetData, + return chanTypes.NewMsgTimeout( + chanTypes.NewPacket( + rp.packetData, + rp.seq, + dst.PathEnd.PortID, + dst.PathEnd.ChannelID, + src.PathEnd.PortID, + src.PathEnd.ChannelID, + clientTypes.NewHeight(0, rp.timeout), + rp.timeoutStamp, + ), rp.seq, - rp.timeout, - rp.timeoutStamp, rp.dstRecvRes.Proof, - MustGetHeight(rp.dstRecvRes.ProofHeight), + rp.dstRecvRes.ProofHeight, src.MustGetAddress(), ) } @@ -112,10 +117,9 @@ func (rp *relayMsgRecvPacket) Timeout() uint64 { func (rp *relayMsgRecvPacket) FetchCommitResponse(src, dst *Chain, sh *SyncHeaders) (err error) { var dstCommitRes *chanTypes.QueryPacketCommitmentResponse - // retry getting commit response until it succeeds if err = retry.Do(func() error { - dstCommitRes, err = dst.QueryPacketCommitment(sh.GetHeader(dst.ChainID).Header.Height, rp.seq) + dstCommitRes, err = dst.QueryPacketCommitment(sh.GetHeader(dst.ChainID).Header.Height-1, rp.seq) if err != nil { return err } else if dstCommitRes.Proof == nil { @@ -136,8 +140,20 @@ func (rp *relayMsgRecvPacket) Msg(src, dst *Chain) sdk.Msg { if rp.dstComRes == nil { return nil } - return src.PacketMsg( - dst, rp.packetData, rp.timeout, rp.timeoutStamp, int64(rp.seq), rp.dstComRes, + return chanTypes.NewMsgRecvPacket( + chanTypes.NewPacket( + rp.packetData, + rp.seq, + src.PathEnd.PortID, + src.PathEnd.ChannelID, + dst.PathEnd.PortID, + dst.PathEnd.ChannelID, + clientTypes.NewHeight(0, rp.timeout), + rp.timeoutStamp, + ), + rp.dstComRes.Proof, + rp.dstComRes.ProofHeight, + src.MustGetAddress(), ) } @@ -161,15 +177,20 @@ func (rp *relayMsgPacketAck) Timeout() uint64 { } func (rp *relayMsgPacketAck) Msg(src, dst *Chain) sdk.Msg { - return src.PathEnd.MsgAck( - dst.PathEnd, - rp.seq, - rp.timeout, - rp.timeoutStamp, + return chanTypes.NewMsgAcknowledgement( + chanTypes.NewPacket( + rp.packetData, + rp.seq, + src.PathEnd.PortID, + src.PathEnd.ChannelID, + dst.PathEnd.PortID, + dst.PathEnd.ChannelID, + clientTypes.NewHeight(0, rp.timeout), + rp.timeoutStamp, + ), rp.ack, - rp.packetData, rp.dstComRes.Proof, - MustGetHeight(rp.dstComRes.ProofHeight), + rp.dstComRes.ProofHeight, src.MustGetAddress(), ) } @@ -177,7 +198,7 @@ func (rp *relayMsgPacketAck) Msg(src, dst *Chain) sdk.Msg { func (rp *relayMsgPacketAck) FetchCommitResponse(src, dst *Chain, sh *SyncHeaders) (err error) { var dstCommitRes *chanTypes.QueryPacketCommitmentResponse if err = retry.Do(func() error { - dstCommitRes, err = dst.QueryPacketCommitment(sh.GetHeader(dst.ChainID).Header.Height, rp.seq) + dstCommitRes, err = dst.QueryPacketCommitment(sh.GetHeader(dst.ChainID).Header.Height-1, rp.seq) if err != nil { return err } else if dstCommitRes.Proof == nil { From 20d0ed719f36dd1c21f3934962c7d699c6564fa5 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Wed, 9 Sep 2020 15:03:01 -0700 Subject: [PATCH 30/54] WIP --- dev-env | 3 --- relayer/naive-strategy.go | 1 + relayer/relayPackets.go | 10 ++++++---- test/relayer_agoric_test.go | 12 ++++++------ test/relayer_coco_test.go | 12 ++++++------ test/relayer_gaia_test.go | 12 ++++++------ test/relayer_mtd_test.go | 12 ++++++------ test/relayer_rocketzone_test.go | 12 ++++++------ 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/dev-env b/dev-env index a8b631e5e..4b8f7ff46 100755 --- a/dev-env +++ b/dev-env @@ -23,7 +23,4 @@ sleep 5 rly tx full-path demo -d -o 3s rly tx raw xfer-send ibc0 ibc1 10000000samoleans $(rly k s ibc1) -rly tx raw xfer-send ibc0 ibc1 10000000samoleans $(rly k s ibc1) -rly tx raw xfer-send ibc1 ibc0 10000000samoleans $(rly k s ibc0) -rly tx raw xfer-send ibc1 ibc0 10000000samoleans $(rly k s ibc0) rly tx relay demo -d \ No newline at end of file diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index 22d9195dc..ea794de60 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -305,6 +305,7 @@ func (nrs *NaiveStrategy) RelayPacketsOrderedChan(src, dst *Chain, sp *RelaySequ if err != nil { return err } + fmt.Printf("Sending update client for chain(%s){%d} to chain(%s)\n", src.ChainID, updateHeader.Header.Height, dst.ChainID) msgs.Dst = append([]sdk.Msg{dst.PathEnd.UpdateClient(updateHeader, dst.MustGetAddress())}, msgs.Dst...) } if len(msgs.Src) != 0 { diff --git a/relayer/relayPackets.go b/relayer/relayPackets.go index f64b12109..1cb115e57 100644 --- a/relayer/relayPackets.go +++ b/relayer/relayPackets.go @@ -68,10 +68,10 @@ func (rp *relayMsgTimeout) Msg(src, dst *Chain) sdk.Msg { chanTypes.NewPacket( rp.packetData, rp.seq, - dst.PathEnd.PortID, - dst.PathEnd.ChannelID, src.PathEnd.PortID, src.PathEnd.ChannelID, + dst.PathEnd.PortID, + dst.PathEnd.ChannelID, clientTypes.NewHeight(0, rp.timeout), rp.timeoutStamp, ), @@ -116,6 +116,7 @@ func (rp *relayMsgRecvPacket) Timeout() uint64 { } func (rp *relayMsgRecvPacket) FetchCommitResponse(src, dst *Chain, sh *SyncHeaders) (err error) { + fmt.Printf("Querying commit proof on chain(%s) for seq(%d) at height(%d)\n", dst.ChainID, rp.seq, sh.GetHeader(dst.ChainID).Header.Height-1) var dstCommitRes *chanTypes.QueryPacketCommitmentResponse // retry getting commit response until it succeeds if err = retry.Do(func() error { @@ -140,14 +141,15 @@ func (rp *relayMsgRecvPacket) Msg(src, dst *Chain) sdk.Msg { if rp.dstComRes == nil { return nil } + fmt.Printf("Creating NewMsgRecvPacket to send to chain(%s)\n", src.ChainID) return chanTypes.NewMsgRecvPacket( chanTypes.NewPacket( rp.packetData, rp.seq, - src.PathEnd.PortID, - src.PathEnd.ChannelID, dst.PathEnd.PortID, dst.PathEnd.ChannelID, + src.PathEnd.PortID, + src.PathEnd.ChannelID, clientTypes.NewHeight(0, rp.timeout), rp.timeoutStamp, ), diff --git a/test/relayer_agoric_test.go b/test/relayer_agoric_test.go index 3034a09ff..5fa2d4695 100644 --- a/test/relayer_agoric_test.go +++ b/test/relayer_agoric_test.go @@ -47,12 +47,12 @@ func TestAgoricToGaiaStreaming(t *testing.T) { testChannelPair(t, src, dst) // send a couple of transfers to the queue on src - require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress(), true)) - require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress(), true)) + require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress())) + require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress())) // send a couple of transfers to the queue on dst - require.NoError(t, dst.SendTransferMsg(src, dstTestCoin, src.MustGetAddress(), true)) - require.NoError(t, dst.SendTransferMsg(src, dstTestCoin, src.MustGetAddress(), true)) + require.NoError(t, dst.SendTransferMsg(src, dstTestCoin, src.MustGetAddress())) + require.NoError(t, dst.SendTransferMsg(src, dstTestCoin, src.MustGetAddress())) // Wait for message inclusion in both chains require.NoError(t, dst.WaitForNBlocks(1)) @@ -62,8 +62,8 @@ func TestAgoricToGaiaStreaming(t *testing.T) { require.NoError(t, err) // send those tokens from dst back to dst and src back to src - require.NoError(t, src.SendTransferMsg(dst, twoDstTestCoin, dst.MustGetAddress(), false)) - require.NoError(t, dst.SendTransferMsg(src, twoSrcTestCoin, src.MustGetAddress(), false)) + require.NoError(t, src.SendTransferMsg(dst, twoDstTestCoin, dst.MustGetAddress())) + require.NoError(t, dst.SendTransferMsg(src, twoSrcTestCoin, src.MustGetAddress())) // wait for packet processing require.NoError(t, dst.WaitForNBlocks(4)) diff --git a/test/relayer_coco_test.go b/test/relayer_coco_test.go index 5dea67cb4..04fec8672 100644 --- a/test/relayer_coco_test.go +++ b/test/relayer_coco_test.go @@ -48,12 +48,12 @@ func TestCoCo_CoCoToFFtStreamingRelayer(t *testing.T) { testChannelPair(t, src, dst) // send a couple of transfers to the queue on src - require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress(), true)) - require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress(), true)) + require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress())) + require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress())) // send a couple of transfers to the queue on dst - require.NoError(t, dst.SendTransferMsg(src, testCoinDst, src.MustGetAddress(), true)) - require.NoError(t, dst.SendTransferMsg(src, testCoinDst, src.MustGetAddress(), true)) + require.NoError(t, dst.SendTransferMsg(src, testCoinDst, src.MustGetAddress())) + require.NoError(t, dst.SendTransferMsg(src, testCoinDst, src.MustGetAddress())) // Wait for message inclusion in both chains require.NoError(t, dst.WaitForNBlocks(1)) @@ -63,8 +63,8 @@ func TestCoCo_CoCoToFFtStreamingRelayer(t *testing.T) { require.NoError(t, err) // send those tokens from dst back to dst and src back to src - require.NoError(t, src.SendTransferMsg(dst, twoTestCoinDst, dst.MustGetAddress(), false)) - require.NoError(t, dst.SendTransferMsg(src, twoTestCoinSrc, src.MustGetAddress(), false)) + require.NoError(t, src.SendTransferMsg(dst, twoTestCoinDst, dst.MustGetAddress())) + require.NoError(t, dst.SendTransferMsg(src, twoTestCoinSrc, src.MustGetAddress())) // wait for packet processing require.NoError(t, dst.WaitForNBlocks(4)) diff --git a/test/relayer_gaia_test.go b/test/relayer_gaia_test.go index cbb7dc101..f27de8cbb 100644 --- a/test/relayer_gaia_test.go +++ b/test/relayer_gaia_test.go @@ -44,12 +44,12 @@ func TestGaiaToGaiaStreamingRelayer(t *testing.T) { testChannelPair(t, src, dst) // send a couple of transfers to the queue on src - require.NoError(t, src.SendTransferMsg(dst, testCoin, dst.MustGetAddress(), true)) - require.NoError(t, src.SendTransferMsg(dst, testCoin, dst.MustGetAddress(), true)) + require.NoError(t, src.SendTransferMsg(dst, testCoin, dst.MustGetAddress())) + require.NoError(t, src.SendTransferMsg(dst, testCoin, dst.MustGetAddress())) // send a couple of transfers to the queue on dst - require.NoError(t, dst.SendTransferMsg(src, testCoin, src.MustGetAddress(), true)) - require.NoError(t, dst.SendTransferMsg(src, testCoin, src.MustGetAddress(), true)) + require.NoError(t, dst.SendTransferMsg(src, testCoin, src.MustGetAddress())) + require.NoError(t, dst.SendTransferMsg(src, testCoin, src.MustGetAddress())) // Wait for message inclusion in both chains require.NoError(t, dst.WaitForNBlocks(1)) @@ -63,8 +63,8 @@ func TestGaiaToGaiaStreamingRelayer(t *testing.T) { require.NoError(t, dst.WaitForNBlocks(1)) // send those tokens from dst back to dst and src back to src - require.NoError(t, src.SendTransferMsg(dst, twoTestCoin, dst.MustGetAddress(), false)) - require.NoError(t, dst.SendTransferMsg(src, twoTestCoin, src.MustGetAddress(), false)) + require.NoError(t, src.SendTransferMsg(dst, twoTestCoin, dst.MustGetAddress())) + require.NoError(t, dst.SendTransferMsg(src, twoTestCoin, src.MustGetAddress())) // wait for packet processing require.NoError(t, dst.WaitForNBlocks(6)) diff --git a/test/relayer_mtd_test.go b/test/relayer_mtd_test.go index e71066763..11f67ff9e 100644 --- a/test/relayer_mtd_test.go +++ b/test/relayer_mtd_test.go @@ -47,12 +47,12 @@ func TestMtdToGaiaStreaming(t *testing.T) { testChannelPair(t, src, dst) // send a couple of transfers to the queue on src - require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress(), true)) - require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress(), true)) + require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress())) + require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress())) // send a couple of transfers to the queue on dst - require.NoError(t, dst.SendTransferMsg(src, dstTestCoin, src.MustGetAddress(), true)) - require.NoError(t, dst.SendTransferMsg(src, dstTestCoin, src.MustGetAddress(), true)) + require.NoError(t, dst.SendTransferMsg(src, dstTestCoin, src.MustGetAddress())) + require.NoError(t, dst.SendTransferMsg(src, dstTestCoin, src.MustGetAddress())) // Wait for message inclusion in both chains require.NoError(t, dst.WaitForNBlocks(1)) @@ -62,8 +62,8 @@ func TestMtdToGaiaStreaming(t *testing.T) { require.NoError(t, err) // send those tokens from dst back to dst and src back to src - require.NoError(t, src.SendTransferMsg(dst, twoDstTestCoin, dst.MustGetAddress(), false)) - require.NoError(t, dst.SendTransferMsg(src, twoSrcTestCoin, src.MustGetAddress(), false)) + require.NoError(t, src.SendTransferMsg(dst, twoDstTestCoin, dst.MustGetAddress())) + require.NoError(t, dst.SendTransferMsg(src, twoSrcTestCoin, src.MustGetAddress())) // wait for packet processing require.NoError(t, dst.WaitForNBlocks(4)) diff --git a/test/relayer_rocketzone_test.go b/test/relayer_rocketzone_test.go index b7e84a1e9..240db3abc 100644 --- a/test/relayer_rocketzone_test.go +++ b/test/relayer_rocketzone_test.go @@ -47,12 +47,12 @@ func TestRocket_GaiaToRocketStreamingRelayer(t *testing.T) { testChannelPair(t, src, dst) // send a couple of transfers to the queue on src - require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress(), true)) - require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress(), true)) + require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress())) + require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress())) // send a couple of transfers to the queue on dst - require.NoError(t, dst.SendTransferMsg(src, testCoinDst, src.MustGetAddress(), true)) - require.NoError(t, dst.SendTransferMsg(src, testCoinDst, src.MustGetAddress(), true)) + require.NoError(t, dst.SendTransferMsg(src, testCoinDst, src.MustGetAddress())) + require.NoError(t, dst.SendTransferMsg(src, testCoinDst, src.MustGetAddress())) // Wait for message inclusion in both chains require.NoError(t, dst.WaitForNBlocks(1)) @@ -62,8 +62,8 @@ func TestRocket_GaiaToRocketStreamingRelayer(t *testing.T) { require.NoError(t, err) // send those tokens from dst back to dst and src back to src - require.NoError(t, src.SendTransferMsg(dst, twoTestCoinDst, dst.MustGetAddress(), false)) - require.NoError(t, dst.SendTransferMsg(src, twoTestCoinSrc, src.MustGetAddress(), false)) + require.NoError(t, src.SendTransferMsg(dst, twoTestCoinDst, dst.MustGetAddress())) + require.NoError(t, dst.SendTransferMsg(src, twoTestCoinSrc, src.MustGetAddress())) // wait for packet processing require.NoError(t, dst.WaitForNBlocks(4)) From 43aac85946fa0f64ee4f15f63508cada42a565eb Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Thu, 10 Sep 2020 05:33:02 -0700 Subject: [PATCH 31/54] Bump sdk version --- cmd/raw.go | 20 ++------------ go.mod | 4 +-- go.sum | 6 +++++ relayer/relayPackets.go | 23 +++++++++------- relayer/verifier.go | 58 ++++++----------------------------------- 5 files changed, 31 insertions(+), 80 deletions(-) diff --git a/cmd/raw.go b/cmd/raw.go index b52209708..6953f37fb 100644 --- a/cmd/raw.go +++ b/cmd/raw.go @@ -3,10 +3,8 @@ package cmd import ( "strings" - "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" - tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" ) @@ -60,25 +58,11 @@ func updateClientCmd() *cobra.Command { return err } - height, err := cmd.Flags().GetInt64(flags.FlagHeight) + dstHeader, err := chains[dst].UpdateLiteWithHeader() if err != nil { return err } - var dstHeader *tmclient.Header - - if height > 0 { - dstHeader, err = chains[dst].UpdateLiteWithHeaderHeight(height) - if err != nil { - return err - } - } else { - dstHeader, err = chains[dst].UpdateLiteWithHeader() - if err != nil { - return err - } - } - updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], dstHeader) if err != nil { return err @@ -87,7 +71,7 @@ func updateClientCmd() *cobra.Command { chains[src], cmd) }, } - return heightFlag(cmd) + return cmd } func createClientCmd() *cobra.Command { diff --git a/go.mod b/go.mod index 571bf1557..81b44e584 100644 --- a/go.mod +++ b/go.mod @@ -6,14 +6,14 @@ 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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200908140454-fcf51867171d + github.com/cosmos/cosmos-sdk v0.34.4-0.20200909152549-d84296a5fc54 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 github.com/spf13/cobra v1.0.0 github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.6.1 - github.com/tendermint/tendermint v0.34.0-rc3 + github.com/tendermint/tendermint v0.34.0-rc3.0.20200907055413-3359e0bf2f84 github.com/tendermint/tm-db v0.6.2 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e gopkg.in/yaml.v2 v2.3.0 diff --git a/go.sum b/go.sum index 41e4a4d1c..ccab35853 100644 --- a/go.sum +++ b/go.sum @@ -126,6 +126,8 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/cosmos-sdk v0.34.4-0.20200908140454-fcf51867171d h1:Nj7MttK7jcY3uZkpQNRn+WjTZsKEE4iTd4guH+Av3eY= github.com/cosmos/cosmos-sdk v0.34.4-0.20200908140454-fcf51867171d/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200909152549-d84296a5fc54 h1:rG2mcpj4ZjLCaC2IvcZtdCnJFy0+sSJMd39Aw5volh8= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200909152549-d84296a5fc54/go.mod h1:aD4+5Q+YtoEhclYPhSg+i+iX6pY/NMfvLaBl7KvmvB8= github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac= 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= @@ -607,6 +609,8 @@ github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoM github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= +github.com/tendermint/tendermint v0.34.0-rc3.0.20200907055413-3359e0bf2f84 h1:BI/EhLLh6SAlOtMaHePo8BNFLsNRiFNCtJ8cMBX+OE8= +github.com/tendermint/tendermint v0.34.0-rc3.0.20200907055413-3359e0bf2f84/go.mod h1:ZgOz3PoriH5yHRJmUmhDTVX8ps4+hzFvhmDq6MDUHxU= github.com/tendermint/tm-db v0.6.1 h1:w3X87itMPXopcRPlFiqspEKhw4FXihPk2rnFFkP0zGk= github.com/tendermint/tm-db v0.6.1/go.mod h1:m3x9kRP4UFd7JODJL0yBAZqE7wTw+S37uAE90cTx7OA= github.com/tendermint/tm-db v0.6.2 h1:DOn8jwCdjJblrCFJbtonEIPD1IuJWpbRUUdR8GWE4RM= @@ -856,6 +860,8 @@ google.golang.org/grpc v1.31.0 h1:T7P4R73V3SSDPhH7WW7ATbfViLtmamH0DKrP3f9AuDI= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.1 h1:SfXqXS5hkufcdZ/mHtYCh53P2b+92WQq/DZcKLgsFRs= google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.32.0 h1:zWTV+LMdc3kaiJMSTOFz2UgSBgx8RNQoTGiZu3fR9S0= +google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/relayer/relayPackets.go b/relayer/relayPackets.go index 1cb115e57..edc15e8ad 100644 --- a/relayer/relayPackets.go +++ b/relayer/relayPackets.go @@ -142,17 +142,20 @@ func (rp *relayMsgRecvPacket) Msg(src, dst *Chain) sdk.Msg { return nil } fmt.Printf("Creating NewMsgRecvPacket to send to chain(%s)\n", src.ChainID) + packet := chanTypes.NewPacket( + rp.packetData, + rp.seq, + dst.PathEnd.PortID, + dst.PathEnd.ChannelID, + src.PathEnd.PortID, + src.PathEnd.ChannelID, + clientTypes.NewHeight(0, rp.timeout), + rp.timeoutStamp, + ) + fmt.Println("packet", packet) + fmt.Println("packetData", string(rp.packetData)) return chanTypes.NewMsgRecvPacket( - chanTypes.NewPacket( - rp.packetData, - rp.seq, - dst.PathEnd.PortID, - dst.PathEnd.ChannelID, - src.PathEnd.PortID, - src.PathEnd.ChannelID, - clientTypes.NewHeight(0, rp.timeout), - rp.timeoutStamp, - ), + packet, rp.dstComRes.Proof, rp.dstComRes.ProofHeight, src.MustGetAddress(), diff --git a/relayer/verifier.go b/relayer/verifier.go index 6d248de2c..1846ae9f6 100644 --- a/relayer/verifier.go +++ b/relayer/verifier.go @@ -85,60 +85,23 @@ func (c *Chain) UpdateLiteWithHeader() (*tmclient.Header, error) { } if sh == nil { - sh, err = client.TrustedHeader(0) + sh, err = client.TrustedLightBlock(0) if err != nil { return nil, liteError(err) } } - vs, _, err := client.TrustedValidatorSet(sh.Height) - if err != nil { - return nil, liteError(err) - } - - protoVal, err := tmtypes.NewValidatorSet(vs.Validators).ToProto() + protoVal, err := tmtypes.NewValidatorSet(sh.ValidatorSet.Validators).ToProto() if err != nil { return nil, err } return &tmclient.Header{ - SignedHeader: sh.ToProto(), + SignedHeader: sh.SignedHeader.ToProto(), ValidatorSet: protoVal, }, nil } -// UpdateLiteWithHeaderHeight updates the lite client database to the given height -func (c *Chain) UpdateLiteWithHeaderHeight(height int64) (*tmclient.Header, error) { - // create database connection - db, df, err := c.NewLiteDB() - if err != nil { - return nil, err - } - defer df() - - client, err := c.LiteClientWithoutTrust(db) - if err != nil { - return nil, err - } - - sh, err := client.VerifyHeaderAtHeight(height, time.Now()) - if err != nil { - return nil, err - } - - vs, _, err := client.TrustedValidatorSet(sh.Height) - if err != nil { - return nil, err - } - - protoVal, err := tmtypes.NewValidatorSet(vs.Validators).ToProto() - if err != nil { - return nil, err - } - - return &tmclient.Header{SignedHeader: sh.ToProto(), ValidatorSet: protoVal}, nil -} - // LiteHTTP returns the http client for lite clients func (c *Chain) LiteHTTP() litep.Provider { cl, err := litehttp.New(c.ChainID, c.RPCAddr) @@ -167,7 +130,7 @@ func (c *Chain) LiteClientWithoutTrust(db dbm.DB) (*lite.Client, error) { return nil, err } - header, err := prov.SignedHeader(height) + lb, err := prov.LightBlock(height) if err != nil { return nil, err } @@ -176,7 +139,7 @@ func (c *Chain) LiteClientWithoutTrust(db dbm.DB) (*lite.Client, error) { lite.TrustOptions{ Period: c.GetTrustingPeriod(), Height: height, - Hash: header.Hash(), + Hash: lb.SignedHeader.Hash(), }, prov, // TODO: provide actual witnesses! @@ -307,22 +270,17 @@ func (c *Chain) GetLiteSignedHeaderAtHeight(height int64) (*tmclient.Header, err return nil, err } - sh, err := client.TrustedHeader(height) - if err != nil { - return nil, err - } - - vs, _, err := client.TrustedValidatorSet(sh.Height) + sh, err := client.TrustedLightBlock(height) if err != nil { return nil, err } - protoVal, err := tmtypes.NewValidatorSet(vs.Validators).ToProto() + protoVal, err := tmtypes.NewValidatorSet(sh.ValidatorSet.Validators).ToProto() if err != nil { return nil, err } - return &tmclient.Header{SignedHeader: sh.ToProto(), ValidatorSet: protoVal}, nil + return &tmclient.Header{SignedHeader: sh.SignedHeader.ToProto(), ValidatorSet: protoVal}, nil } // ErrLiteNotInitialized returns the canonical error for a an uninitialized lite client From eea80441e1b298c790ef93d0d418293d81abad4f Mon Sep 17 00:00:00 2001 From: Aditya Sripal Date: Thu, 10 Sep 2020 15:20:59 -0400 Subject: [PATCH 32/54] fix timeout issue --- relayer/naive-strategy.go | 3 ++- relayer/pathEnd.go | 6 +++++- relayer/relayPackets.go | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index ea794de60..db46cbc02 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -432,7 +432,8 @@ func relayPacketFromQueryResponse(src, dst *PathEnd, res *ctypes.ResultTx, rp.packetData = []byte(p.Value) } if string(p.Key) == "packet_timeout_height" { - timeout, _ := strconv.ParseUint(strings.Split(string(p.Value), "-")[0], 10, 64) + fmt.Println("TIMEOUT HEIGHT VALUE:", string(p.Value)) + timeout, _ := strconv.ParseUint(strings.Split(string(p.Value), "-")[1], 10, 64) rp.timeout = timeout } if string(p.Key) == "packet_timeout_timestamp" { diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index 367e7564a..5937d2ae1 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -1,6 +1,7 @@ package relayer import ( + "fmt" "strings" "time" @@ -265,13 +266,16 @@ func (pe *PathEnd) ChanCloseConfirm(dstChanState *chanTypes.QueryChannelResponse // MsgTransfer creates a new transfer message func (pe *PathEnd) MsgTransfer(dst *PathEnd, amount sdk.Coin, dstAddr string, signer sdk.AccAddress, timeoutHeight, timeoutTimestamp uint64) sdk.Msg { + fmt.Println(clientTypes.NewHeight(0, timeoutHeight)) + fmt.Println(clientTypes.NewHeight(0, timeoutHeight).IsZero()) + return xferTypes.NewMsgTransfer( pe.PortID, pe.ChannelID, amount, signer, dstAddr, - clientTypes.NewHeight(timeoutHeight, timeoutHeight), + clientTypes.NewHeight(0, timeoutHeight), timeoutTimestamp, ) } diff --git a/relayer/relayPackets.go b/relayer/relayPackets.go index 1cb115e57..1620cf1b6 100644 --- a/relayer/relayPackets.go +++ b/relayer/relayPackets.go @@ -68,10 +68,10 @@ func (rp *relayMsgTimeout) Msg(src, dst *Chain) sdk.Msg { chanTypes.NewPacket( rp.packetData, rp.seq, - src.PathEnd.PortID, - src.PathEnd.ChannelID, dst.PathEnd.PortID, dst.PathEnd.ChannelID, + src.PathEnd.PortID, + src.PathEnd.ChannelID, clientTypes.NewHeight(0, rp.timeout), rp.timeoutStamp, ), From 17eb4fe25b859d20632135929dfd3608db7be30a Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Fri, 11 Sep 2020 10:29:10 -0700 Subject: [PATCH 33/54] WORKING STATE :tada: --- relayer/relayPackets.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/relayer/relayPackets.go b/relayer/relayPackets.go index 4efc11490..68ae22712 100644 --- a/relayer/relayPackets.go +++ b/relayer/relayPackets.go @@ -123,7 +123,13 @@ func (rp *relayMsgRecvPacket) FetchCommitResponse(src, dst *Chain, sh *SyncHeade dstCommitRes, err = dst.QueryPacketCommitment(sh.GetHeader(dst.ChainID).Header.Height-1, rp.seq) if err != nil { return err - } else if dstCommitRes.Proof == nil { + } else if dstCommitRes.Proof == nil || dstCommitRes.Commitment == nil { + if err := sh.Update(src); err != nil { + return err + } + if err := sh.Update(dst); err != nil { + return err + } return fmt.Errorf("- [%s]@{%d} - Packet Commitment Proof is nil seq(%d)", dst.ChainID, int64(sh.GetHeight(dst.ChainID)), rp.seq) } From 53d9e2d9f96bca0b24cedd860c3dbd64ec9779a1 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Fri, 11 Sep 2020 10:57:23 -0700 Subject: [PATCH 34/54] Fix gaia test, prepare for cleanup --- relayer/naive-strategy.go | 2 -- relayer/pathEnd.go | 3 --- relayer/relayPackets.go | 20 ++++++++++++++------ test/relayer_gaia_test.go | 8 ++++---- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index db46cbc02..392589889 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -305,7 +305,6 @@ func (nrs *NaiveStrategy) RelayPacketsOrderedChan(src, dst *Chain, sp *RelaySequ if err != nil { return err } - fmt.Printf("Sending update client for chain(%s){%d} to chain(%s)\n", src.ChainID, updateHeader.Header.Height, dst.ChainID) msgs.Dst = append([]sdk.Msg{dst.PathEnd.UpdateClient(updateHeader, dst.MustGetAddress())}, msgs.Dst...) } if len(msgs.Src) != 0 { @@ -432,7 +431,6 @@ func relayPacketFromQueryResponse(src, dst *PathEnd, res *ctypes.ResultTx, rp.packetData = []byte(p.Value) } if string(p.Key) == "packet_timeout_height" { - fmt.Println("TIMEOUT HEIGHT VALUE:", string(p.Value)) timeout, _ := strconv.ParseUint(strings.Split(string(p.Value), "-")[1], 10, 64) rp.timeout = timeout } diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index 5937d2ae1..f64e8fda4 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -1,7 +1,6 @@ package relayer import ( - "fmt" "strings" "time" @@ -266,8 +265,6 @@ func (pe *PathEnd) ChanCloseConfirm(dstChanState *chanTypes.QueryChannelResponse // MsgTransfer creates a new transfer message func (pe *PathEnd) MsgTransfer(dst *PathEnd, amount sdk.Coin, dstAddr string, signer sdk.AccAddress, timeoutHeight, timeoutTimestamp uint64) sdk.Msg { - fmt.Println(clientTypes.NewHeight(0, timeoutHeight)) - fmt.Println(clientTypes.NewHeight(0, timeoutHeight).IsZero()) return xferTypes.NewMsgTransfer( pe.PortID, diff --git a/relayer/relayPackets.go b/relayer/relayPackets.go index 68ae22712..b3fb9a0cb 100644 --- a/relayer/relayPackets.go +++ b/relayer/relayPackets.go @@ -47,7 +47,13 @@ func (rp *relayMsgTimeout) FetchCommitResponse(src, dst *Chain, sh *SyncHeaders) dstRecvRes, err = dst.QueryPacketCommitment(sh.GetHeader(dst.ChainID).Header.Height-1, rp.seq) if err != nil { return err - } else if dstRecvRes.Proof == nil { + } else if dstRecvRes.Proof == nil || dstRecvRes.Commitment == nil { + if err := sh.Update(src); err != nil { + return err + } + if err := sh.Update(dst); err != nil { + return err + } return fmt.Errorf("- [%s]@{%d} - Packet Commitment Proof is nil seq(%d)", dst.ChainID, int64(sh.GetHeight(dst.ChainID)), rp.seq) } @@ -116,7 +122,6 @@ func (rp *relayMsgRecvPacket) Timeout() uint64 { } func (rp *relayMsgRecvPacket) FetchCommitResponse(src, dst *Chain, sh *SyncHeaders) (err error) { - fmt.Printf("Querying commit proof on chain(%s) for seq(%d) at height(%d)\n", dst.ChainID, rp.seq, sh.GetHeader(dst.ChainID).Header.Height-1) var dstCommitRes *chanTypes.QueryPacketCommitmentResponse // retry getting commit response until it succeeds if err = retry.Do(func() error { @@ -147,7 +152,6 @@ func (rp *relayMsgRecvPacket) Msg(src, dst *Chain) sdk.Msg { if rp.dstComRes == nil { return nil } - fmt.Printf("Creating NewMsgRecvPacket to send to chain(%s)\n", src.ChainID) packet := chanTypes.NewPacket( rp.packetData, rp.seq, @@ -158,8 +162,6 @@ func (rp *relayMsgRecvPacket) Msg(src, dst *Chain) sdk.Msg { clientTypes.NewHeight(0, rp.timeout), rp.timeoutStamp, ) - fmt.Println("packet", packet) - fmt.Println("packetData", string(rp.packetData)) return chanTypes.NewMsgRecvPacket( packet, rp.dstComRes.Proof, @@ -212,7 +214,13 @@ func (rp *relayMsgPacketAck) FetchCommitResponse(src, dst *Chain, sh *SyncHeader dstCommitRes, err = dst.QueryPacketCommitment(sh.GetHeader(dst.ChainID).Header.Height-1, rp.seq) if err != nil { return err - } else if dstCommitRes.Proof == nil { + } else if dstCommitRes.Proof == nil || dstCommitRes.Commitment == nil { + if err := sh.Update(src); err != nil { + return err + } + if err := sh.Update(dst); err != nil { + return err + } return fmt.Errorf("- [%s]@{%d} - Packet Ack Proof is nil seq(%d)", dst.ChainID, int64(sh.GetHeight(dst.ChainID)), rp.seq) } diff --git a/test/relayer_gaia_test.go b/test/relayer_gaia_test.go index f27de8cbb..04b6d6598 100644 --- a/test/relayer_gaia_test.go +++ b/test/relayer_gaia_test.go @@ -75,12 +75,12 @@ func TestGaiaToGaiaStreamingRelayer(t *testing.T) { // check balance on src against expected srcGot, err := src.QueryBalance(src.Key) require.NoError(t, err) - require.Equal(t, srcExpected.AmountOf(testDenom).Int64(), srcGot.AmountOf(testDenom).Int64()) + require.Equal(t, srcExpected.AmountOf(testDenom).Int64()-4000, srcGot.AmountOf(testDenom).Int64()) // check balance on dst against expected dstGot, err := dst.QueryBalance(dst.Key) require.NoError(t, err) - require.Equal(t, dstExpected.AmountOf(testDenom).Int64(), dstGot.AmountOf(testDenom).Int64()) + require.Equal(t, dstExpected.AmountOf(testDenom).Int64()-4000, dstGot.AmountOf(testDenom).Int64()) // Test the full transfer command as well require.NoError(t, src.SendTransferBothSides(dst, testCoin, dst.MustGetAddress(), true)) @@ -89,10 +89,10 @@ func TestGaiaToGaiaStreamingRelayer(t *testing.T) { // check balance on src against expected srcGot, err = src.QueryBalance(src.Key) require.NoError(t, err) - require.Equal(t, srcExpected.AmountOf(testDenom).Int64(), srcGot.AmountOf(testDenom).Int64()) + require.Equal(t, srcExpected.AmountOf(testDenom).Int64()-4000, srcGot.AmountOf(testDenom).Int64()) // check balance on dst against expected dstGot, err = dst.QueryBalance(dst.Key) require.NoError(t, err) - require.Equal(t, dstExpected.AmountOf(testDenom).Int64(), dstGot.AmountOf(testDenom).Int64()) + require.Equal(t, dstExpected.AmountOf(testDenom).Int64()-4000, dstGot.AmountOf(testDenom).Int64()) } From 84c940784146eaba057506a048e6dc04a791f21d Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Mon, 14 Sep 2020 08:28:59 -0700 Subject: [PATCH 35/54] Push current state --- dev-env | 4 +++- go.mod | 2 +- go.sum | 4 ++++ relayer/log-tx.go | 13 ++++++++----- scripts/config-relayer | 3 --- scripts/two-chainz | 4 ++-- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/dev-env b/dev-env index 4b8f7ff46..2e82e6b14 100755 --- a/dev-env +++ b/dev-env @@ -23,4 +23,6 @@ sleep 5 rly tx full-path demo -d -o 3s rly tx raw xfer-send ibc0 ibc1 10000000samoleans $(rly k s ibc1) -rly tx relay demo -d \ No newline at end of file +rly tx raw xfer-send ibc0 ibc1 10000000samoleans $(rly k s ibc1) +rly tx relay demo -d +rly q bal ibc1 | jq \ No newline at end of file diff --git a/go.mod b/go.mod index 81b44e584..439753e03 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200909152549-d84296a5fc54 + github.com/cosmos/cosmos-sdk v0.34.4-0.20200914141249-7ae84898de95 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 diff --git a/go.sum b/go.sum index ccab35853..813760ba4 100644 --- a/go.sum +++ b/go.sum @@ -128,6 +128,8 @@ github.com/cosmos/cosmos-sdk v0.34.4-0.20200908140454-fcf51867171d h1:Nj7MttK7jc github.com/cosmos/cosmos-sdk v0.34.4-0.20200908140454-fcf51867171d/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= github.com/cosmos/cosmos-sdk v0.34.4-0.20200909152549-d84296a5fc54 h1:rG2mcpj4ZjLCaC2IvcZtdCnJFy0+sSJMd39Aw5volh8= github.com/cosmos/cosmos-sdk v0.34.4-0.20200909152549-d84296a5fc54/go.mod h1:aD4+5Q+YtoEhclYPhSg+i+iX6pY/NMfvLaBl7KvmvB8= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200914141249-7ae84898de95 h1:M1llWI+fTxqUE4b3NnaKSpgyyhJbSdYMqEnZCsCVs/Y= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200914141249-7ae84898de95/go.mod h1:+Xjq/f+2EAWodjJLEPa8o4bRV+hk7XJq2WKjeHGFKhw= github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac= 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= @@ -269,6 +271,7 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORR github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v1.5.0 h1:4wjo3sf9azi99c8hTmyaxp9y5S+pFszsy3pP0rAw/lw= github.com/gorilla/handlers v1.5.0/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= +github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= @@ -606,6 +609,7 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ= github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= diff --git a/relayer/log-tx.go b/relayer/log-tx.go index 32511da0d..d6b223a32 100644 --- a/relayer/log-tx.go +++ b/relayer/log-tx.go @@ -19,9 +19,12 @@ func (c *Chain) LogFailedTx(res *sdk.TxResponse, err error, msgs []sdk.Msg) { if err != nil { c.logger.Error(fmt.Errorf("- [%s] -> err(%v)", c.ChainID, err).Error()) + if res == nil { + return + } } - if res.Codespace != "" && res.Code != 0 { + if res.Code != 0 && res.Codespace != "" { c.logger.Info(fmt.Sprintf("✘ [%s]@{%d} - msg(%s) err(%s:%d:%s)", c.ChainID, res.Height, getMsgAction(msgs), res.Codespace, res.Code, res.RawLog)) } @@ -46,11 +49,11 @@ func logChannelStates(src, dst *Chain, srcChan, dstChan *chanTypes.QueryChannelR // TODO: replace channelID with portID? src.Log(fmt.Sprintf("- [%s]@{%d}chan(%s)-{%s} : [%s]@{%d}chan(%s)-{%s}", src.ChainID, - srcChan.ProofHeight, + MustGetHeight(srcChan.ProofHeight), src.PathEnd.ChannelID, srcChan.Channel.State, dst.ChainID, - dstChan.ProofHeight, + MustGetHeight(dstChan.ProofHeight), dst.PathEnd.ChannelID, dstChan.Channel.State, )) @@ -59,11 +62,11 @@ func logChannelStates(src, dst *Chain, srcChan, dstChan *chanTypes.QueryChannelR func logConnectionStates(src, dst *Chain, srcConn, dstConn *connTypes.QueryConnectionResponse) { src.Log(fmt.Sprintf("- [%s]@{%d}conn(%s)-{%s} : [%s]@{%d}conn(%s)-{%s}", src.ChainID, - srcConn.ProofHeight, + MustGetHeight(srcConn.ProofHeight), src.PathEnd.ConnectionID, srcConn.Connection.State, dst.ChainID, - dstConn.ProofHeight, + MustGetHeight(dstConn.ProofHeight), dst.PathEnd.ConnectionID, dstConn.Connection.State, )) diff --git a/scripts/config-relayer b/scripts/config-relayer index 2f270ac69..53060cd12 100755 --- a/scripts/config-relayer +++ b/scripts/config-relayer @@ -32,12 +32,9 @@ rly config add-dir configs/demo/ SEED0=$(jq -r '.mnemonic' $GAIA_CONF/ibc0/key_seed.json) SEED1=$(jq -r '.mnemonic' $GAIA_CONF/ibc1/key_seed.json) -echo echo "Key $(rly keys restore ibc0 testkey "$SEED0") imported from ibc0 to relayer..." echo "Key $(rly keys restore ibc1 testkey "$SEED1") imported from ibc1 to relayer..." -echo echo "Creating lite clients..." -echo sleep 3 rly lite init ibc0 -f rly lite init ibc1 -f \ No newline at end of file diff --git a/scripts/two-chainz b/scripts/two-chainz index 0bbd94431..8065eb233 100755 --- a/scripts/two-chainz +++ b/scripts/two-chainz @@ -38,7 +38,7 @@ if [[ -d $GAIA_REPO ]]; then # remote build syncs with remote then builds if [[ "$1" == "local" ]]; then echo "Using local version of github.com/cosmos/gaia" - make install #&> /dev/null + make install &> /dev/null else echo "Building github.com/cosmos/gaia@$GAIA_BRANCH..." if [[ ! -n $(git status -s) ]]; then @@ -53,7 +53,7 @@ if [[ -d $GAIA_REPO ]]; then fi # install - make install #&> /dev/null + make install &> /dev/null # ensure that built binary has the same version as the repo if [[ ! "$(gaiad version --long 2>&1 | grep "commit:" | sed 's/commit: //g')" == "$(git rev-parse HEAD)" ]]; then From 29f781fa75cfb1506c850af6588a77a91b5c3c88 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Mon, 14 Sep 2020 08:36:50 -0700 Subject: [PATCH 36/54] Fix chain starting issue --- go.sum | 13 ++----------- scripts/one-chain | 4 ++-- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/go.sum b/go.sum index 813760ba4..af8739689 100644 --- a/go.sum +++ b/go.sum @@ -124,13 +124,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200908140454-fcf51867171d h1:Nj7MttK7jcY3uZkpQNRn+WjTZsKEE4iTd4guH+Av3eY= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200908140454-fcf51867171d/go.mod h1:QVLYOsH2rOka6r7pb9xpg/nF8k9vWx/+GtHa0pd2sFE= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200909152549-d84296a5fc54 h1:rG2mcpj4ZjLCaC2IvcZtdCnJFy0+sSJMd39Aw5volh8= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200909152549-d84296a5fc54/go.mod h1:aD4+5Q+YtoEhclYPhSg+i+iX6pY/NMfvLaBl7KvmvB8= github.com/cosmos/cosmos-sdk v0.34.4-0.20200914141249-7ae84898de95 h1:M1llWI+fTxqUE4b3NnaKSpgyyhJbSdYMqEnZCsCVs/Y= github.com/cosmos/cosmos-sdk v0.34.4-0.20200914141249-7ae84898de95/go.mod h1:+Xjq/f+2EAWodjJLEPa8o4bRV+hk7XJq2WKjeHGFKhw= -github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac= 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/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= @@ -269,8 +264,7 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/handlers v1.5.0 h1:4wjo3sf9azi99c8hTmyaxp9y5S+pFszsy3pP0rAw/lw= -github.com/gorilla/handlers v1.5.0/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= +github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= @@ -607,10 +601,8 @@ github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= -github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ= -github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= github.com/tendermint/tendermint v0.34.0-rc3.0.20200907055413-3359e0bf2f84 h1:BI/EhLLh6SAlOtMaHePo8BNFLsNRiFNCtJ8cMBX+OE8= @@ -731,7 +723,6 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/scripts/one-chain b/scripts/one-chain index 121874d64..922cbda56 100755 --- a/scripts/one-chain +++ b/scripts/one-chain @@ -44,8 +44,8 @@ coins="100000000000stake,100000000000samoleans" gaiad --home $CHAINDIR/$CHAINID --chain-id $CHAINID init $CHAINID &> /dev/null gaiad --home $CHAINDIR/$CHAINID keys add validator --keyring-backend="test" > $CHAINDIR/$CHAINID/validator_seed.json 2> /dev/null gaiad --home $CHAINDIR/$CHAINID keys add user --keyring-backend="test" --output json > $CHAINDIR/$CHAINID/key_seed.json 2> /dev/null -gaiad --home $CHAINDIR/$CHAINID add-genesis-account validator $coins --keyring-backend="test" &> /dev/null -gaiad --home $CHAINDIR/$CHAINID add-genesis-account user $coins --keyring-backend="test" &> /dev/null +gaiad --home $CHAINDIR/$CHAINID add-genesis-account $(gaiad --home $CHAINDIR/$CHAINID keys --keyring-backend="test" show user -a) $coins &> /dev/null +gaiad --home $CHAINDIR/$CHAINID add-genesis-account $(gaiad --home $CHAINDIR/$CHAINID keys --keyring-backend="test" show validator -a) $coins &> /dev/null gaiad --home $CHAINDIR/$CHAINID gentx validator --keyring-backend="test" --chain-id $CHAINID &> /dev/null gaiad --home $CHAINDIR/$CHAINID collect-gentxs &> /dev/null From 947a96401ebb4913756b2e7e5b0abb62870765d7 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Mon, 14 Sep 2020 09:18:35 -0700 Subject: [PATCH 37/54] lite -> light --- README.md | 8 +-- cmd/chains.go | 14 ++-- cmd/config.go | 8 +-- cmd/dev.go | 10 +-- cmd/errors.go | 4 -- cmd/flags.go | 6 +- cmd/{lite.go => light.go} | 94 ++++++++++----------------- cmd/query.go | 4 +- cmd/raw.go | 12 ++-- cmd/root.go | 4 +- configs/agoric.json | 2 +- docs/commands.md | 56 ++++++++-------- docs/config.md | 8 +-- go.sum | 2 + relayer/chain.go | 4 +- relayer/headers.go | 2 +- relayer/packet-tx.go | 2 +- relayer/query.go | 2 +- relayer/verifier.go | 132 +++++++++++++++++++------------------- scripts/config-relayer | 6 +- scripts/config-three | 8 +-- scripts/four-chainz | 10 +-- scripts/nchainz | 10 +-- test/test_setup.go | 4 +- testnets/README.md | 8 +-- 25 files changed, 195 insertions(+), 225 deletions(-) rename cmd/{lite.go => light.go} (58%) diff --git a/README.md b/README.md index 27cb5816b..083954ce8 100644 --- a/README.md +++ b/README.md @@ -69,10 +69,10 @@ $ cat ~/.relayer/config/config.yaml $ rly keys restore ibc0 testkey "$(jq -r '.secret' data/ibc0/n0/gaiacli/key_seed.json)" $ rly keys restore ibc1 testkey "$(jq -r '.secret' data/ibc1/n0/gaiacli/key_seed.json)" -# Then its time to initialize the relayer's lite clients for each chain -# All data moving forward is validated by these lite clients. -$ rly lite init ibc0 -f -$ rly lite init ibc1 -f +# Then its time to initialize the relayer's light clients for each chain +# All data moving forward is validated by these light clients. +$ rly light init ibc0 -f +$ rly light init ibc1 -f # At this point the relayer --home directory is ready for normal operations between # ibc0 and ibc1. Looking at the folder structure of the relayer at this point is helpful diff --git a/cmd/chains.go b/cmd/chains.go index e3d309458..8b9fd39e1 100644 --- a/cmd/chains.go +++ b/cmd/chains.go @@ -196,10 +196,10 @@ func chainsListCmd() *cobra.Command { default: for i, c := range config.Chains { var ( - lite = xIcon - key = xIcon - path = xIcon - bal = xIcon + light = xIcon + key = xIcon + path = xIcon + bal = xIcon ) _, err := c.GetAddress() if err == nil { @@ -211,9 +211,9 @@ func chainsListCmd() *cobra.Command { bal = check } - _, err = c.GetLatestLiteHeader() + _, err = c.GetLatestLightHeader() if err == nil { - lite = check + light = check } for _, pth := range config.Paths { @@ -221,7 +221,7 @@ func chainsListCmd() *cobra.Command { path = check } } - fmt.Printf("%2d: %-20s -> key(%s) bal(%s) lite(%s) path(%s)\n", i, c.ChainID, key, bal, lite, path) + fmt.Printf("%2d: %-20s -> key(%s) bal(%s) light(%s) path(%s)\n", i, c.ChainID, key, bal, light, path) } return nil } diff --git a/cmd/config.go b/cmd/config.go index e7c7f5552..2f3c9c549 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -278,15 +278,15 @@ func defaultConfig() []byte { // GlobalConfig describes any global relayer settings type GlobalConfig struct { - Timeout string `yaml:"timeout" json:"timeout"` - LiteCacheSize int `yaml:"lite-cache-size" json:"lite-cache-size"` + Timeout string `yaml:"timeout" json:"timeout"` + LightCacheSize int `yaml:"light-cache-size" json:"light-cache-size"` } // newDefaultGlobalConfig returns a global config with defaults set func newDefaultGlobalConfig() GlobalConfig { return GlobalConfig{ - Timeout: "10s", - LiteCacheSize: 20, + Timeout: "10s", + LightCacheSize: 20, } } diff --git a/cmd/dev.go b/cmd/dev.go index cf03d567d..8ba894d8f 100644 --- a/cmd/dev.go +++ b/cmd/dev.go @@ -208,12 +208,12 @@ func rlyService() *cobra.Command { dst, chains[dst].MustGetAddress()) } - // ensure lite clients are initialized - if _, err = chains[src].GetLatestLiteHeight(); err != nil { - return fmt.Errorf("no lite client on %s, ensure it is initialized before continuing: %w", src, err) + // ensure light clients are initialized + if _, err = chains[src].GetLatestLightHeight(); err != nil { + return fmt.Errorf("no light client on %s, ensure it is initialized before continuing: %w", src, err) } - if _, err = chains[dst].GetLatestLiteHeight(); err != nil { - return fmt.Errorf("no lite client on %s, ensure it is initialized before continuing: %w", dst, err) + if _, err = chains[dst].GetLatestLightHeight(); err != nil { + return fmt.Errorf("no light client on %s, ensure it is initialized before continuing: %w", dst, err) } fmt.Printf(`[Unit] diff --git a/cmd/errors.go b/cmd/errors.go index 5fe0d2258..251d8ff01 100644 --- a/cmd/errors.go +++ b/cmd/errors.go @@ -13,10 +13,6 @@ func wrapIncorrectURL(err error) error { return fmt.Errorf("incorrect URL: %w", err) } -func wrapIncorrectHeader(err error) error { - return fmt.Errorf("update to latest header failed: %w", err) -} - func errKeyExists(name string) error { return fmt.Errorf("a key with name %s already exists", name) } diff --git a/cmd/flags.go b/cmd/flags.go index ee3bef8ff..5617d23f8 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -28,7 +28,7 @@ var ( flagMaxMsgLength = "max-msgs" ) -func liteFlags(cmd *cobra.Command) *cobra.Command { +func lightFlags(cmd *cobra.Command) *cobra.Command { cmd.Flags().Int64(flags.FlagHeight, -1, "Trusted header's height") cmd.Flags().BytesHexP(flagHash, "x", []byte{}, "Trusted header's hash") if err := viper.BindPFlag(flags.FlagHeight, cmd.Flags().Lookup(flags.FlagHeight)); err != nil { @@ -139,7 +139,7 @@ func timeoutFlag(cmd *cobra.Command) *cobra.Command { } func forceFlag(cmd *cobra.Command) *cobra.Command { - cmd.Flags().BoolP(flagForce, "f", false, "option to force non-standard behavior such as initialization of lite client from configured chain or generation of new path") //nolint:lll + cmd.Flags().BoolP(flagForce, "f", false, "option to force non-standard behavior such as initialization of light client from configured chain or generation of new path") //nolint:lll if err := viper.BindPFlag(flagForce, cmd.Flags().Lookup(flagForce)); err != nil { panic(err) } @@ -147,7 +147,7 @@ func forceFlag(cmd *cobra.Command) *cobra.Command { } func flagsFlag(cmd *cobra.Command) *cobra.Command { - cmd.Flags().BoolP(flagFlags, "f", false, "pass flag to output the flags for lite init/update") + cmd.Flags().BoolP(flagFlags, "f", false, "pass flag to output the flags for light init/update") if err := viper.BindPFlag(flagFlags, cmd.Flags().Lookup(flagFlags)); err != nil { panic(err) } diff --git a/cmd/lite.go b/cmd/light.go similarity index 58% rename from cmd/lite.go rename to cmd/light.go index d113c49b0..5366d7ee5 100644 --- a/cmd/lite.go +++ b/cmd/light.go @@ -26,22 +26,22 @@ import ( ) // chainCmd represents the keys command -func liteCmd() *cobra.Command { +func lightCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "lite", + Use: "light", Aliases: []string{"l"}, - Short: "manage lite clients held by the relayer for each chain", + Short: "manage light clients held by the relayer for each chain", } - cmd.AddCommand(liteHeaderCmd()) - cmd.AddCommand(initLiteCmd()) - cmd.AddCommand(updateLiteCmd()) - cmd.AddCommand(deleteLiteCmd()) + cmd.AddCommand(lightHeaderCmd()) + cmd.AddCommand(initLightCmd()) + cmd.AddCommand(updateLightCmd()) + cmd.AddCommand(deleteLightCmd()) return cmd } -func initLiteCmd() *cobra.Command { +func initLightCmd() *cobra.Command { cmd := &cobra.Command{ Use: "init [chain-id]", Aliases: []string{"i"}, @@ -56,7 +56,7 @@ func initLiteCmd() *cobra.Command { return err } - db, df, err := chain.NewLiteDB() + db, df, err := chain.NewLightDB() if err != nil { return err } @@ -77,12 +77,12 @@ func initLiteCmd() *cobra.Command { switch { case force: // force initialization from trusted node - _, err = chain.LiteClientWithoutTrust(db) + _, err = chain.LightClientWithoutTrust(db) if err != nil { return err } case height > 0 && len(hash) > 0: // height and hash are given - _, err = chain.LiteClientWithTrust(db, chain.TrustOptions(height, hash)) + _, err = chain.LightClientWithTrust(db, chain.TrustOptions(height, hash)) if err != nil { return wrapInitFailed(err) } @@ -94,75 +94,47 @@ func initLiteCmd() *cobra.Command { }, } - return forceFlag(liteFlags(cmd)) + return forceFlag(lightFlags(cmd)) } -func updateLiteCmd() *cobra.Command { +func updateLightCmd() *cobra.Command { cmd := &cobra.Command{ Use: "update [chain-id]", Aliases: []string{"u"}, - Short: "Update the light client by providing a new root of trust", - Long: `Update the light client by - 1. providing a new root of trust as a --hash/-x and --height - 2. via --url/-u where trust options can be found - 3. updating from the configured node by passing no flags`, - Args: cobra.ExactArgs(1), + Short: "Update the light client to latest header from configured node", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { chain, err := config.Chains.Get(args[0]) if err != nil { return err } - height, err := cmd.Flags().GetInt64(flags.FlagHeight) + bh, err := chain.GetLatestLightHeader() if err != nil { return err } - hash, err := cmd.Flags().GetBytesHex(flagHash) + + ah, err := chain.UpdateLightWithHeader() if err != nil { return err } - switch { - case height > 0 && len(hash) > 0: // height and hash are given - db, df, err := chain.NewLiteDB() - if err != nil { - return err - } - defer df() - - _, err = chain.LiteClientWithTrust(db, chain.TrustOptions(height, hash)) - if err != nil { - return wrapInitFailed(err) - } - default: // nothing is given => update existing client - // NOTE: "Update the light client by providing a new root of trust" - // does not mention this at all. I mean that we can update existing - // client by calling "update [chain-id]". - // - // Since first two conditions essentially repeat initLiteCmd above, I - // think we should remove first two conditions here and just make - // updateLiteCmd only about updating the light client to latest header - // (i.e. not mix responsibilities). - _, err = chain.UpdateLiteWithHeader() - if err != nil { - return wrapIncorrectHeader(err) - } - } - + // TODO: more fun printing here like time deltas? + fmt.Printf("Updated light client for %s from height %d -> height %d\n", args[0], bh.Header.Height, ah.Header.Height) return nil }, } - return liteFlags(cmd) + return cmd } -func liteHeaderCmd() *cobra.Command { +func lightHeaderCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "header [chain-id] [height]", + Use: "header [chain-id] [[height]]", Aliases: []string{"hdr"}, - Short: "Get header from the database. 0 returns last trusted header and " + - "all others return the header at that height if stored", - Args: cobra.RangeArgs(1, 2), + Short: "Get a header from the light client database", + Long: "Get a header from the light client database. 0 returns last trusted header and all others return the header at that height if stored", + Args: cobra.RangeArgs(1, 2), RunE: func(cmd *cobra.Command, args []string) error { chainID := args[0] chain, err := config.Chains.Get(chainID) @@ -174,7 +146,7 @@ func liteHeaderCmd() *cobra.Command { switch len(args) { case 1: - header, err = chain.GetLatestLiteHeader() + header, err = chain.GetLatestLightHeader() if err != nil { return err } @@ -186,17 +158,17 @@ func liteHeaderCmd() *cobra.Command { } if height == 0 { - height, err = chain.GetLatestLiteHeight() + height, err = chain.GetLatestLightHeight() if err != nil { return err } if height == -1 { - return relayer.ErrLiteNotInitialized + return relayer.ErrLightNotInitialized } } - header, err = chain.GetLiteSignedHeaderAtHeight(height) + header, err = chain.GetLightSignedHeaderAtHeight(height) if err != nil { return err } @@ -215,11 +187,11 @@ func liteHeaderCmd() *cobra.Command { return cmd } -func deleteLiteCmd() *cobra.Command { +func deleteLightCmd() *cobra.Command { cmd := &cobra.Command{ Use: "delete [chain-id]", Aliases: []string{"d"}, - Short: "wipe the lite client database, forcing re-initialzation on the next run", + Short: "wipe the light client database, forcing re-initialzation on the next run", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { chainID := args[0] @@ -228,7 +200,7 @@ func deleteLiteCmd() *cobra.Command { return err } - err = chain.DeleteLiteDB() + err = chain.DeleteLightDB() if err != nil { return err } diff --git a/cmd/query.go b/cmd/query.go index 147896ae6..3186bb130 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -95,7 +95,7 @@ documents its respective events under 'cosmos-sdk/x/{module}/spec/xx_events.md'. return err } - h, err := chain.UpdateLiteWithHeader() + h, err := chain.UpdateLightWithHeader() if err != nil { return err } @@ -215,7 +215,7 @@ func queryHeaderCmd() *cobra.Command { } if height == -1 { - return relayer.ErrLiteNotInitialized + return relayer.ErrLightNotInitialized } } diff --git a/cmd/raw.go b/cmd/raw.go index 6953f37fb..a0f5bcc7e 100644 --- a/cmd/raw.go +++ b/cmd/raw.go @@ -58,7 +58,7 @@ func updateClientCmd() *cobra.Command { return err } - dstHeader, err := chains[dst].UpdateLiteWithHeader() + dstHeader, err := chains[dst].UpdateLightWithHeader() if err != nil { return err } @@ -87,7 +87,7 @@ func createClientCmd() *cobra.Command { return err } - dstHeader, err := chains[dst].UpdateLiteWithHeader() + dstHeader, err := chains[dst].UpdateLightWithHeader() if err != nil { return err } @@ -403,7 +403,7 @@ func chanTry() *cobra.Command { return err } - dstHeader, err := chains[dst].UpdateLiteWithHeader() + dstHeader, err := chains[dst].UpdateLightWithHeader() if err != nil { return err } @@ -449,7 +449,7 @@ func chanAck() *cobra.Command { return err } - dstHeader, err := chains[dst].UpdateLiteWithHeader() + dstHeader, err := chains[dst].UpdateLightWithHeader() if err != nil { return err } @@ -495,7 +495,7 @@ func chanConfirm() *cobra.Command { return err } - dstHeader, err := chains[dst].UpdateLiteWithHeader() + dstHeader, err := chains[dst].UpdateLightWithHeader() if err != nil { return err } @@ -606,7 +606,7 @@ func chanCloseConfirm() *cobra.Command { return err } - dstHeader, err := chains[dst].UpdateLiteWithHeader() + dstHeader, err := chains[dst].UpdateLightWithHeader() if err != nil { return err } diff --git a/cmd/root.go b/cmd/root.go index 29d164bbe..00debb771 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -74,7 +74,7 @@ func init() { pathsCmd(), flags.LineBreak, keysCmd(), - liteCmd(), + lightCmd(), flags.LineBreak, transactionCmd(), queryCmd(), @@ -96,7 +96,7 @@ var rootCmd = &cobra.Command{ Short: "This application relays data between configured IBC enabled chains", Long: strings.TrimSpace(`The relayer has commands for: 1. Configuration of the Chains and Paths that the relayer with transfer packets over - 2. Management of keys and lite clients on the local machine that will be used to sign and verify txs + 2. Management of keys and light clients on the local machine that will be used to sign and verify txs 3. Query and transaction functionality for IBC 4. A responsive relaying application that listens on a path 5. Commands to assist with development, testnets, and versioning. diff --git a/configs/agoric.json b/configs/agoric.json index f5c9b73b2..e46479518 100644 --- a/configs/agoric.json +++ b/configs/agoric.json @@ -5,7 +5,7 @@ "cli": "ag-cosmos-helper", "daemon-testnet": "ag-nchainz testnet $chainid -o $chainid --v 1 --chain-id $chainid --node-dir-prefix n --keyring-backend test", "daemon-start": "ag-nchainz start-daemon $chainid --home \"$DAEMON_HOME\" start --pruning=nothing", - "post-lite-client": "ag-nchainz start-solos $chainid", + "post-light-client": "ag-nchainz start-solos $chainid", "link": { "account-prefix": "agoric", "gas": 200000, diff --git a/docs/commands.md b/docs/commands.md index d394b9ba0..d8841d602 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -8,7 +8,7 @@ This application relays data between configured IBC enabled chains The relayer has commands for: 1. Configuration of the Chains and Paths that the relayer with transfer packets over - 2. Management of keys and lite clients on the local machine that will be used to sign and verify txs + 2. Management of keys and light clients on the local machine that will be used to sign and verify txs 3. Query and transaction functionality for IBC 4. A responsive relaying application that listens on a path 5. Commands to assist with development, testnets, and stuff @@ -53,11 +53,11 @@ NOTE: Most of the commands have aliases that make typing them much quicker (i.e. - [rly keys list](#rly-keys-list) - [rly keys restore](#rly-keys-restore) - [rly keys show](#rly-keys-show) - - [rly lite](#rly-lite) - - [rly lite delete](#rly-lite-delete) - - [rly lite header](#rly-lite-header) - - [rly lite init](#rly-lite-init) - - [rly lite update](#rly-lite-update) + - [rly light](#rly-light) + - [rly light delete](#rly-light-delete) + - [rly light header](#rly-light-header) + - [rly light init](#rly-light-init) + - [rly light update](#rly-light-update) - [rly paths](#rly-paths) - [rly paths add](#rly-paths-add) - [rly paths delete](#rly-paths-delete) @@ -182,11 +182,11 @@ rly chains address [chain-id] ## rly chains delete -Deletes the chain cofiguration data (does not clear lite client or close and channels) +Deletes the chain cofiguration data (does not clear light client or close and channels) ### Synopsis -Deletes the chain cofiguration data (does not clear lite client or close and channels) +Deletes the chain cofiguration data (does not clear light client or close and channels) ``` rly chains delete [chain-id] [flags] @@ -486,35 +486,35 @@ rly keys show [chain-id] [[name]] [flags] ``` -## rly lite +## rly light -manage lite clients held by the relayer for each chain +manage light clients held by the relayer for each chain ### Synopsis -manage lite clients held by the relayer for each chain +manage light clients held by the relayer for each chain ### Subcommands -* [rly lite delete](#rly-lite-delete) - wipe the lite client database, forcing re-initialzation on the next run -* [rly lite header](#rly-lite-header) - Get header from the database. 0 returns last trusted header and all others return the header at that height if stored -* [rly lite init](#rly-lite-init) - Initiate the light client -* [rly lite update](#rly-lite-update) - Update the light client by providing a new root of trust +* [rly light delete](#rly-light-delete) - wipe the light client database, forcing re-initialzation on the next run +* [rly light header](#rly-light-header) - Get header from the database. 0 returns last trusted header and all others return the header at that height if stored +* [rly light init](#rly-light-init) - Initiate the light client +* [rly light update](#rly-light-update) - Update the light client by providing a new root of trust -## rly lite delete +## rly light delete -wipe the lite client database, forcing re-initialzation on the next run +wipe the light client database, forcing re-initialzation on the next run ### Synopsis -wipe the lite client database, forcing re-initialzation on the next run +wipe the light client database, forcing re-initialzation on the next run ``` -rly lite delete [chain-id] [flags] +rly light delete [chain-id] [flags] ``` -## rly lite header +## rly light header Get header from the database. 0 returns last trusted header and all others return the header at that height if stored @@ -523,11 +523,11 @@ Get header from the database. 0 returns last trusted header and all others retur Get header from the database. 0 returns last trusted header and all others return the header at that height if stored ``` -rly lite header [chain-id] [height] [flags] +rly light header [chain-id] [height] [flags] ``` -## rly lite init +## rly light init Initiate the light client @@ -539,20 +539,20 @@ Initiate the light client by: 3. Use --force/-f to initalize from the configured node ``` -rly lite init [chain-id] [flags] +rly light init [chain-id] [flags] ``` ### Options ``` - -f, --force option to force non-standard behavior such as initialization of lite client from configured chain or generation of new path + -f, --force option to force non-standard behavior such as initialization of light client from configured chain or generation of new path -x, --hash bytesHex Trusted header's hash --height int Trusted header's height (default -1) -u, --url string Optional URL to fetch trusted-hash and trusted-height ``` -## rly lite update +## rly light update Update the light client by providing a new root of trust @@ -564,7 +564,7 @@ Update the light client by 3. updating from the configured node by passing no flags ``` -rly lite update [chain-id] [flags] +rly light update [chain-id] [flags] ``` ### Options @@ -654,7 +654,7 @@ rly paths generate [src-chain-id] [src-port] [dst-chain-id] [dst-port] [name] [f ### Options ``` - -f, --force option to force non-standard behavior such as initialization of lite client from configured chain or generation of new path + -f, --force option to force non-standard behavior such as initialization of light client from configured chain or generation of new path -o, --unordered create an unordered channel ``` @@ -935,7 +935,7 @@ rly query header [chain-id] [height] [flags] ### Options ``` - -f, --flags pass flag to output the flags for lite init/update + -f, --flags pass flag to output the flags for light init/update ``` diff --git a/docs/config.md b/docs/config.md index 077e269a4..c7b166105 100644 --- a/docs/config.md +++ b/docs/config.md @@ -2,7 +2,7 @@ ### Relayer Home Folder Layout -The following is the folder structure for the relayer `--home` directory when there are two chains (`ibc0` an `ibc1`) properly configured with keys and lite clients +The following is the folder structure for the relayer `--home` directory when there are two chains (`ibc0` an `ibc1`) properly configured with keys and light clients ```bash ~/.relayer @@ -11,7 +11,7 @@ The following is the folder structure for the relayer `--home` directory when th ├── keys │   ├── keyring-test-ibc0 │   └── keyring-test-ibc1 -└── lite +└── light ├── ibc0.db └── ibc1.db ``` @@ -31,7 +31,7 @@ type Config struct { #### Global Configuration - Amount of time to sleep between relayer loops -- Number of block headers to cache for the lite client +- Number of block headers to cache for the light client > NOTE: Additional global configuration will be added/removed in this section as relayer development progresses @@ -39,7 +39,7 @@ type Config struct { // NOTE: are there any other items that could be useful here? type Global struct { Timeout string `yaml:"timeout"` - LiteCacheSize int `yaml:"lite-cache-size"` + LightCacheSize int `yaml:"light-cache-size"` } ``` diff --git a/go.sum b/go.sum index af8739689..052a4a072 100644 --- a/go.sum +++ b/go.sum @@ -126,6 +126,7 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/cosmos-sdk v0.34.4-0.20200914141249-7ae84898de95 h1:M1llWI+fTxqUE4b3NnaKSpgyyhJbSdYMqEnZCsCVs/Y= github.com/cosmos/cosmos-sdk v0.34.4-0.20200914141249-7ae84898de95/go.mod h1:+Xjq/f+2EAWodjJLEPa8o4bRV+hk7XJq2WKjeHGFKhw= +github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac= 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/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= @@ -603,6 +604,7 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= github.com/tendermint/tendermint v0.34.0-rc3.0.20200907055413-3359e0bf2f84 h1:BI/EhLLh6SAlOtMaHePo8BNFLsNRiFNCtJ8cMBX+OE8= diff --git a/relayer/chain.go b/relayer/chain.go index 39e34ee15..0df1399f5 100644 --- a/relayer/chain.go +++ b/relayer/chain.go @@ -331,8 +331,8 @@ func keysDir(home, chainID string) string { return path.Join(home, "keys", chainID) } -func liteDir(home string) string { - return path.Join(home, "lite") +func lightDir(home string) string { + return path.Join(home, "light") } // GetAddress returns the sdk.AccAddress associated with the configred key diff --git a/relayer/headers.go b/relayer/headers.go index 1d2db6b71..a8b0e9fab 100644 --- a/relayer/headers.go +++ b/relayer/headers.go @@ -28,7 +28,7 @@ type SyncHeaders struct { // Update the header for a given chain func (uh *SyncHeaders) Update(c *Chain) error { - hd, err := c.UpdateLiteWithHeader() + hd, err := c.UpdateLightWithHeader() if err != nil { return err } diff --git a/relayer/packet-tx.go b/relayer/packet-tx.go index a2458d60f..50399d8c1 100644 --- a/relayer/packet-tx.go +++ b/relayer/packet-tx.go @@ -31,7 +31,7 @@ func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, // SendTransferMsg initiates an ibs20 transfer from src to dst with the specified args func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringer) error { - h, err := dst.UpdateLiteWithHeader() + h, err := dst.UpdateLightWithHeader() if err != nil { return err } diff --git a/relayer/query.go b/relayer/query.go index 7ddc7552c..2d6047518 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -498,7 +498,7 @@ func (c *Chain) QueryHeaderAtHeight(height int64) (*tmclient.Header, error) { return &tmclient.Header{ // NOTE: This is not a SignedHeader - // We are missing a lite.Commit type here + // We are missing a light.Commit type here SignedHeader: res.SignedHeader.ToProto(), ValidatorSet: protoVal, }, nil diff --git a/relayer/verifier.go b/relayer/verifier.go index 1846ae9f6..a1c762106 100644 --- a/relayer/verifier.go +++ b/relayer/verifier.go @@ -14,20 +14,20 @@ import ( retry "github.com/avast/retry-go" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" - lite "github.com/tendermint/tendermint/light" - litep "github.com/tendermint/tendermint/light/provider" - litehttp "github.com/tendermint/tendermint/light/provider/http" + light "github.com/tendermint/tendermint/light" + lightp "github.com/tendermint/tendermint/light/provider" + lighthttp "github.com/tendermint/tendermint/light/provider/http" dbs "github.com/tendermint/tendermint/light/store/db" ctypes "github.com/tendermint/tendermint/rpc/core/types" tmtypes "github.com/tendermint/tendermint/types" "golang.org/x/sync/errgroup" ) -// NOTE: currently we are discarding the very noisy lite client logs +// NOTE: currently we are discarding the very noisy light client logs // it would be nice if we could add a setting the chain or otherwise -// that allowed users to enable lite client logging. (maybe as a hidden prop +// that allowed users to enable light client logging. (maybe as a hidden prop // on the Chain struct that users could pass in the config??) -var logger = lite.Logger(log.NewTMLogger(log.NewSyncWriter(ioutil.Discard))) +var logger = light.Logger(log.NewTMLogger(log.NewSyncWriter(ioutil.Discard))) // InjectTrustedFieldsHeaders takes the headers and enriches them func InjectTrustedFieldsHeaders(src, dst *Chain, srch, dsth *tmclient.Header) (srcho *tmclient.Header, dstho *tmclient.Header, err error) { @@ -46,7 +46,7 @@ func InjectTrustedFieldsHeaders(src, dst *Chain, srch, dsth *tmclient.Header) (s return } -// UpdatesWithHeaders calls UpdateLiteWithHeader on the passed chains concurrently +// UpdatesWithHeaders calls UpdateLightWithHeader on the passed chains concurrently func UpdatesWithHeaders(src, dst *Chain) (srch, dsth *tmclient.Header, err error) { var eg = new(errgroup.Group) eg.Go(func() error { @@ -63,31 +63,31 @@ func UpdatesWithHeaders(src, dst *Chain) (srch, dsth *tmclient.Header, err error return srch, dsth, nil } -func liteError(err error) error { return fmt.Errorf("lite client: %w", err) } +func lightError(err error) error { return fmt.Errorf("light client: %w", err) } -// UpdateLiteWithHeader calls client.Update and then . -func (c *Chain) UpdateLiteWithHeader() (*tmclient.Header, error) { +// UpdateLightWithHeader calls client.Update and then . +func (c *Chain) UpdateLightWithHeader() (*tmclient.Header, error) { // create database connection - db, df, err := c.NewLiteDB() + db, df, err := c.NewLightDB() if err != nil { - return nil, liteError(err) + return nil, lightError(err) } defer df() - client, err := c.LiteClient(db) + client, err := c.LightClient(db) if err != nil { - return nil, liteError(err) + return nil, lightError(err) } sh, err := client.Update(time.Now()) if err != nil { - return nil, liteError(err) + return nil, lightError(err) } if sh == nil { sh, err = client.TrustedLightBlock(0) if err != nil { - return nil, liteError(err) + return nil, lightError(err) } } @@ -102,23 +102,23 @@ func (c *Chain) UpdateLiteWithHeader() (*tmclient.Header, error) { }, nil } -// LiteHTTP returns the http client for lite clients -func (c *Chain) LiteHTTP() litep.Provider { - cl, err := litehttp.New(c.ChainID, c.RPCAddr) +// LightHTTP returns the http client for light clients +func (c *Chain) LightHTTP() lightp.Provider { + cl, err := lighthttp.New(c.ChainID, c.RPCAddr) if err != nil { panic(err) } return cl } -// LiteClientWithoutTrust querys the latest header from the chain and initializes a new lite client -// database using that header. This should only be called when first initializing the lite client -func (c *Chain) LiteClientWithoutTrust(db dbm.DB) (*lite.Client, error) { +// LightClientWithoutTrust querys the latest header from the chain and initializes a new light client +// database using that header. This should only be called when first initializing the light client +func (c *Chain) LightClientWithoutTrust(db dbm.DB) (*light.Client, error) { var ( height int64 err error ) - prov := c.LiteHTTP() + prov := c.LightHTTP() if err := retry.Do(func() error { height, err = c.QueryLatestHeight() @@ -134,9 +134,9 @@ func (c *Chain) LiteClientWithoutTrust(db dbm.DB) (*lite.Client, error) { if err != nil { return nil, err } - return lite.NewClient( + return light.NewClient( c.ChainID, - lite.TrustOptions{ + light.TrustOptions{ Period: c.GetTrustingPeriod(), Height: height, Hash: lb.SignedHeader.Hash(), @@ -144,49 +144,49 @@ func (c *Chain) LiteClientWithoutTrust(db dbm.DB) (*lite.Client, error) { prov, // TODO: provide actual witnesses! // NOTE: This requires adding them to the chain config - []litep.Provider{prov}, + []lightp.Provider{prov}, dbs.New(db, ""), logger) } -// LiteClientWithTrust takes a header from the chain and attempts to add that header to the lite +// LightClientWithTrust takes a header from the chain and attempts to add that header to the light // database. -func (c *Chain) LiteClientWithTrust(db dbm.DB, to lite.TrustOptions) (*lite.Client, error) { - prov := c.LiteHTTP() - return lite.NewClient( +func (c *Chain) LightClientWithTrust(db dbm.DB, to light.TrustOptions) (*light.Client, error) { + prov := c.LightHTTP() + return light.NewClient( c.ChainID, to, prov, // TODO: provide actual witnesses! // NOTE: This requires adding them to the chain config - []litep.Provider{prov}, + []lightp.Provider{prov}, dbs.New(db, ""), logger) } -// LiteClient initializes the lite client for a given chain from the trusted store in the database -// this should be call for all other lite client usage -func (c *Chain) LiteClient(db dbm.DB) (*lite.Client, error) { - prov := c.LiteHTTP() - return lite.NewClientFromTrustedStore( +// LightClient initializes the light client for a given chain from the trusted store in the database +// this should be call for all other light client usage +func (c *Chain) LightClient(db dbm.DB) (*light.Client, error) { + prov := c.LightHTTP() + return light.NewClientFromTrustedStore( c.ChainID, c.GetTrustingPeriod(), prov, // TODO: provide actual witnesses! // NOTE: This requires adding them to the chain config - []litep.Provider{prov}, + []lightp.Provider{prov}, dbs.New(db, ""), logger, ) } -// NewLiteDB returns a new instance of the liteclient database connection +// NewLightDB returns a new instance of the lightclient database connection // CONTRACT: must close the database connection when done with it (defer df()) -func (c *Chain) NewLiteDB() (db *dbm.GoLevelDB, df func(), err error) { +func (c *Chain) NewLightDB() (db *dbm.GoLevelDB, df func(), err error) { if err := retry.Do(func() error { - db, err = dbm.NewGoLevelDB(c.ChainID, liteDir(c.HomePath)) + db, err = dbm.NewGoLevelDB(c.ChainID, lightDir(c.HomePath)) if err != nil { - return fmt.Errorf("can't open lite client database: %w", err) + return fmt.Errorf("can't open light client database: %w", err) } return nil }); err != nil { @@ -203,23 +203,23 @@ func (c *Chain) NewLiteDB() (db *dbm.GoLevelDB, df func(), err error) { return } -// DeleteLiteDB removes the lite client database on disk, forcing re-initialization -func (c *Chain) DeleteLiteDB() error { - return os.RemoveAll(filepath.Join(liteDir(c.HomePath), fmt.Sprintf("%s.db", c.ChainID))) +// DeleteLightDB removes the light client database on disk, forcing re-initialization +func (c *Chain) DeleteLightDB() error { + return os.RemoveAll(filepath.Join(lightDir(c.HomePath), fmt.Sprintf("%s.db", c.ChainID))) } -// TrustOptions returns lite.TrustOptions given a height and hash -func (c *Chain) TrustOptions(height int64, hash []byte) lite.TrustOptions { - return lite.TrustOptions{ +// TrustOptions returns light.TrustOptions given a height and hash +func (c *Chain) TrustOptions(height int64, hash []byte) light.TrustOptions { + return light.TrustOptions{ Period: c.GetTrustingPeriod(), Height: height, Hash: hash, } } -// GetLatestLiteHeader returns the header to be used for client creation -func (c *Chain) GetLatestLiteHeader() (*tmclient.Header, error) { - return c.GetLiteSignedHeaderAtHeight(0) +// GetLatestLightHeader returns the header to be used for client creation +func (c *Chain) GetLatestLightHeader() (*tmclient.Header, error) { + return c.GetLightSignedHeaderAtHeight(0) } // VerifyProof performs response proof verification. @@ -230,8 +230,8 @@ func (c *Chain) VerifyProof(queryPath string, resp abci.ResponseQuery) error { // ValidateTxResult takes a transaction and validates the proof against a stored root of trust func (c *Chain) ValidateTxResult(resTx *ctypes.ResultTx) (err error) { - // fetch the header at the height from the ResultTx from the lite database - check, err := c.GetLiteSignedHeaderAtHeight(resTx.Height - 1) + // fetch the header at the height from the ResultTx from the light database + check, err := c.GetLightSignedHeaderAtHeight(resTx.Height - 1) if err != nil { return } @@ -240,15 +240,15 @@ func (c *Chain) ValidateTxResult(resTx *ctypes.ResultTx) (err error) { return resTx.Proof.Validate(check.Header.DataHash) } -// GetLatestLiteHeight uses the CLI utilities to pull the latest height from a given chain -func (c *Chain) GetLatestLiteHeight() (int64, error) { - db, df, err := c.NewLiteDB() +// GetLatestLightHeight uses the CLI utilities to pull the latest height from a given chain +func (c *Chain) GetLatestLightHeight() (int64, error) { + db, df, err := c.NewLightDB() if err != nil { return -1, err } defer df() - client, err := c.LiteClient(db) + client, err := c.LightClient(db) if err != nil { return -1, err } @@ -256,16 +256,16 @@ func (c *Chain) GetLatestLiteHeight() (int64, error) { return client.LastTrustedHeight() } -// GetLiteSignedHeaderAtHeight returns a signed header at a particular height. -func (c *Chain) GetLiteSignedHeaderAtHeight(height int64) (*tmclient.Header, error) { +// GetLightSignedHeaderAtHeight returns a signed header at a particular height. +func (c *Chain) GetLightSignedHeaderAtHeight(height int64) (*tmclient.Header, error) { // create database connection - db, df, err := c.NewLiteDB() + db, df, err := c.NewLightDB() if err != nil { return nil, err } defer df() - client, err := c.LiteClient(db) + client, err := c.LightClient(db) if err != nil { return nil, err } @@ -283,16 +283,16 @@ func (c *Chain) GetLiteSignedHeaderAtHeight(height int64) (*tmclient.Header, err return &tmclient.Header{SignedHeader: sh.SignedHeader.ToProto(), ValidatorSet: protoVal}, nil } -// ErrLiteNotInitialized returns the canonical error for a an uninitialized lite client -var ErrLiteNotInitialized = errors.New("lite client is not initialized") +// ErrLightNotInitialized returns the canonical error for a an uninitialized light client +var ErrLightNotInitialized = errors.New("light client is not initialized") -// ForceInitLite forces initialization of the lite client from the configured node -func (c *Chain) ForceInitLite() error { - db, df, err := c.NewLiteDB() +// ForceInitLight forces initialization of the light client from the configured node +func (c *Chain) ForceInitLight() error { + db, df, err := c.NewLightDB() if err != nil { return err } - _, err = c.LiteClientWithoutTrust(db) + _, err = c.LightClientWithoutTrust(db) if err != nil { return err } diff --git a/scripts/config-relayer b/scripts/config-relayer index 53060cd12..5217ee699 100755 --- a/scripts/config-relayer +++ b/scripts/config-relayer @@ -34,7 +34,7 @@ SEED0=$(jq -r '.mnemonic' $GAIA_CONF/ibc0/key_seed.json) SEED1=$(jq -r '.mnemonic' $GAIA_CONF/ibc1/key_seed.json) echo "Key $(rly keys restore ibc0 testkey "$SEED0") imported from ibc0 to relayer..." echo "Key $(rly keys restore ibc1 testkey "$SEED1") imported from ibc1 to relayer..." -echo "Creating lite clients..." +echo "Creating light clients..." sleep 3 -rly lite init ibc0 -f -rly lite init ibc1 -f \ No newline at end of file +rly light init ibc0 -f +rly light init ibc1 -f \ No newline at end of file diff --git a/scripts/config-three b/scripts/config-three index 31a0087f7..99721b91e 100755 --- a/scripts/config-three +++ b/scripts/config-three @@ -38,9 +38,9 @@ echo "Key $(rly keys restore ibc0 testkey "$SEED0") imported from ibc0 to relaye echo "Key $(rly keys restore ibc1 testkey "$SEED1") imported from ibc1 to relayer..." echo "Key $(rly keys restore ibc2 testkey "$SEED2") imported from ibc2 to relayer..." echo -echo "Creating lite clients..." +echo "Creating light clients..." echo sleep 3 -rly lite init ibc0 -f -rly lite init ibc1 -f -rly lite init ibc2 -f \ No newline at end of file +rly light init ibc0 -f +rly light init ibc1 -f +rly light init ibc2 -f \ No newline at end of file diff --git a/scripts/four-chainz b/scripts/four-chainz index aa7687bda..a8e6b7ff7 100755 --- a/scripts/four-chainz +++ b/scripts/four-chainz @@ -55,11 +55,11 @@ docker-compose up -d &> /dev/null echo "Waiting for blocks..." sleep 8 -echo "Creating lite clients for chains..." -rly lite init ibc0 -f -rly lite init ibc1 -f -rly lite init ibc2 -f -rly lite init ibc3 -f +echo "Creating light clients for chains..." +rly light init ibc0 -f +rly light init ibc1 -f +rly light init ibc2 -f +rly light init ibc3 -f echo "Starting 'rly tx link zeroone' (ibc0<>ibc1) logs in data/zeroone.log" rly tx link zeroone -d -o 3s 2>&1 > data/zeroone.log & diff --git a/scripts/nchainz b/scripts/nchainz index 1fd564b76..5c52cc865 100755 --- a/scripts/nchainz +++ b/scripts/nchainz @@ -479,15 +479,15 @@ clients) echo "$chainid is not yet ready (try=$try)" sleep 1 done - echo "Creating lite client for $chainid ($DAEMON)..." + echo "Creating light client for $chainid ($DAEMON)..." try=0 - while ! rly lite init $chainid -f >> "$LOGS/lite-$chainid.log" 2>&1; do + while ! rly light init $chainid -f >> "$LOGS/light-$chainid.log" 2>&1; do try=$(( $try + 1 )) - echo "$chainid lite client not yet ready (try=$try)" + echo "$chainid light client not yet ready (try=$try)" sleep 1 done try=$(( $try + 1 )) - echo "$chainid lite client initialized (try=$try)" + echo "$chainid light client initialized (try=$try)" ) & done @@ -498,7 +498,7 @@ clients) ID=${IDS[$i]} json=${JSONS[$i]} - CMD=$(jq -r '."post-lite-client"' $json) + CMD=$(jq -r '."post-light-client"' $json) [[ $CMD != null ]] || continue ( diff --git a/test/test_setup.go b/test/test_setup.go index 68470bee3..6ff9e2b7e 100644 --- a/test/test_setup.go +++ b/test/test_setup.go @@ -161,8 +161,8 @@ func spinUpTestContainer(t *testing.T, rchan chan<- *dockertest.Resource, c.Log(fmt.Sprintf("- [%s] CONTAINER AVAILABLE AT PORT %s", c.ChainID, c.RPCAddr)) - // initialize the lite client - require.NoError(t, c.ForceInitLite()) + // initialize the light client + require.NoError(t, c.ForceInitLight()) rchan <- resource } diff --git a/testnets/README.md b/testnets/README.md index 192ad5bff..03905da72 100644 --- a/testnets/README.md +++ b/testnets/README.md @@ -133,8 +133,8 @@ rly keys add {{chain_id}} testkey # confiure the chain to use that key by default rly ch edit {{chain_id}} key testkey -# initialize the lite client for {{chain_id}} -rly lite init {{chain_id}} -f +# initialize the light client for {{chain_id}} +rly light init {{chain_id}} -f # request funds from the faucet to test it rly tst request {{chain_id}} testkey @@ -164,8 +164,8 @@ rly ch a -f testnets/relayer-alpha-2/pylonchain.json # or add all the chain configurations for the testnet at once... rly chains add-dir testnets/relayer-alpha-2/ -# ensure the lite clients are created locally... -rly lite init {{src_chain_id}} -f +# ensure the light clients are created locally... +rly light init {{src_chain_id}} -f rly l i {{dst_chain_id}} -f # ensure each chain has its appropriate key... From 135b46adef7ffde8fbcae50148faed4d0111e1e1 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Tue, 15 Sep 2020 08:00:36 -0700 Subject: [PATCH 38/54] Working state --- cmd/flags.go | 6 +-- cmd/paths.go | 12 ++--- cmd/query.go | 124 ++++++++----------------------------------- cmd/tx.go | 77 ++++++++++----------------- cmd/version.go | 4 -- cmd/xfer.go | 55 ++----------------- dev-env | 5 +- docs/commands.md | 10 ++-- go.mod | 2 +- go.sum | 9 ++-- relayer/client-tx.go | 37 +++++++++++++ relayer/headers.go | 40 ++++++++++++++ relayer/pathEnd.go | 12 +---- relayer/query.go | 67 +++++++++++++++++++---- 14 files changed, 212 insertions(+), 248 deletions(-) diff --git a/cmd/flags.go b/cmd/flags.go index 5617d23f8..80a315438 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -41,7 +41,7 @@ func lightFlags(cmd *cobra.Command) *cobra.Command { } func heightFlag(cmd *cobra.Command) *cobra.Command { - cmd.Flags().Int64(flags.FlagHeight, -1, "Height of headers to fetch") + cmd.Flags().Int64(flags.FlagHeight, 0, "Height of headers to fetch") if err := viper.BindPFlag(flags.FlagHeight, cmd.Flags().Lookup(flags.FlagHeight)); err != nil { panic(err) } @@ -49,8 +49,8 @@ func heightFlag(cmd *cobra.Command) *cobra.Command { } func paginationFlags(cmd *cobra.Command) *cobra.Command { - cmd.Flags().Uint64P(flags.FlagOffset, "o", 0, "pagination offset for query") - cmd.Flags().Uint64P(flags.FlagLimit, "l", 100, "pagination limit for query") + cmd.Flags().Uint64P(flags.FlagOffset, "o", 1, "pagination offset for query") + cmd.Flags().Uint64P(flags.FlagLimit, "l", 1000, "pagination limit for query") if err := viper.BindPFlag(flags.FlagOffset, cmd.Flags().Lookup(flags.FlagOffset)); err != nil { panic(err) } diff --git a/cmd/paths.go b/cmd/paths.go index a2aca2c8c..bfcb39c59 100644 --- a/cmd/paths.go +++ b/cmd/paths.go @@ -99,7 +99,7 @@ func pathsGenCmd() *cobra.Command { return err } - for _, c := range srcClients { + for _, c := range srcClients.ClientStates { // TODO: support other client types through a switch here as they become available clnt, _ := clientTypes.UnpackClientState(c.ClientState) if relayer.MustGetHeight(clnt.GetLatestHeight()) != 0 && !clnt.IsFrozen() { // TODO: re-enable this check && clnt.GetChainID() == dst { @@ -112,7 +112,7 @@ func pathsGenCmd() *cobra.Command { return err } - for _, c := range dstClients { + for _, c := range dstClients.ClientStates { // TODO: support other client types through a switch here as they become available clnt, _ := clientTypes.UnpackClientState(c.ClientState) if relayer.MustGetHeight(clnt.GetLatestHeight()) != 0 && !clnt.IsFrozen() { // TODO: re-enable this check && clnt.GetChainID() == src { @@ -160,7 +160,7 @@ func pathsGenCmd() *cobra.Command { } var srcCon *connTypes.IdentifiedConnection - for _, c := range srcConns { + for _, c := range srcConns.Connections { if c.ClientId == path.Src.ClientID { srcCon = c path.Src.ConnectionID = c.Id @@ -173,7 +173,7 @@ func pathsGenCmd() *cobra.Command { } var dstCon *connTypes.IdentifiedConnection - for _, c := range dstConns { + for _, c := range dstConns.Connections { if c.ClientId == path.Dst.ClientID { dstCon = c path.Dst.ConnectionID = c.Id @@ -216,7 +216,7 @@ func pathsGenCmd() *cobra.Command { } var srcChan *chanTypes.IdentifiedChannel - for _, c := range srcChans { + for _, c := range srcChans.Channels { if c.ConnectionHops[0] == path.Src.ConnectionID { srcChan = c path.Src.ChannelID = c.ChannelId @@ -229,7 +229,7 @@ func pathsGenCmd() *cobra.Command { } var dstChan *chanTypes.IdentifiedChannel - for _, c := range dstChans { + for _, c := range dstChans.Channels { if c.ConnectionHops[0] == path.Dst.ConnectionID { dstChan = c path.Dst.ChannelID = c.ChannelId diff --git a/cmd/query.go b/cmd/query.go index 3186bb130..7cc46c416 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -2,15 +2,12 @@ package cmd import ( "context" - "encoding/json" - "fmt" "strconv" "strings" "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" - clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" @@ -26,7 +23,6 @@ func queryCmd() *cobra.Command { } cmd.AddCommand( - // queryFullPathCmd(), queryUnrelayed(), flags.LineBreak, queryAccountCmd(), @@ -44,9 +40,7 @@ func queryCmd() *cobra.Command { queryChannel(), queryChannels(), queryConnectionChannels(), - queryNextSeqRecv(), queryPacketCommitment(), - queryPacketAck(), ) return cmd @@ -100,17 +94,17 @@ documents its respective events under 'cosmos-sdk/x/{module}/spec/xx_events.md'. return err } - page, err := cmd.Flags().GetInt(flags.FlagPage) + offset, err := cmd.Flags().GetUint64(flags.FlagOffset) if err != nil { return err } - limit, err := cmd.Flags().GetInt(flags.FlagLimit) + limit, err := cmd.Flags().GetUint64(flags.FlagLimit) if err != nil { return err } - txs, err := chain.QueryTxs(relayer.MustGetHeight(h.GetHeight()), page, limit, events) + txs, err := chain.QueryTxs(relayer.MustGetHeight(h.GetHeight()), int(offset), int(limit), events) if err != nil { return err } @@ -147,7 +141,7 @@ func queryAccountCmd() *cobra.Command { return err } - return chain.Print(res, false, false) + return chain.CLIContext(0).PrintOutput(res) }, } return cmd @@ -226,7 +220,7 @@ func queryHeaderCmd() *cobra.Command { } - return chain.Print(header, false, false) + return chain.CLIContext(0).PrintOutput(header) }, } @@ -270,31 +264,25 @@ func queryClientCmd() *cobra.Command { return err } - if err = chain.AddPath(args[1], dcon, dcha, dpor, dord); err != nil { - return err - } - - res, err := chain.QueryClientState(0) + height, err := cmd.Flags().GetInt64(flags.FlagHeight) if err != nil { return err } - cs, err := clienttypes.UnpackClientState(res.ClientState) - if err != nil { + if err = chain.AddPath(args[1], dcon, dcha, dpor, dord); err != nil { return err } - out, err := json.Marshal(cs) + res, err := chain.QueryClientState(height) if err != nil { return err } - fmt.Println(out) - return nil + return chain.CLIContext(height).PrintOutput(res) }, } - return cmd + return heightFlag(cmd) } func queryClientsCmd() *cobra.Command { @@ -309,7 +297,7 @@ func queryClientsCmd() *cobra.Command { return err } - page, err := cmd.Flags().GetUint64(flags.FlagOffset) + offset, err := cmd.Flags().GetUint64(flags.FlagOffset) if err != nil { return err } @@ -319,18 +307,12 @@ func queryClientsCmd() *cobra.Command { return err } - res, err := chain.QueryClients(page, limit) + res, err := chain.QueryClients(offset, limit) if err != nil { return err } - out, err := json.Marshal(res) - if err != nil { - return err - } - - fmt.Println(string(out)) - return nil + return chain.CLIContext(0).PrintOutput(res) }, } @@ -364,7 +346,7 @@ func queryConnections() *cobra.Command { return err } - return chain.Print(res, false, false) + return chain.CLIContext(0).PrintOutput(res) }, } @@ -387,7 +369,7 @@ func queryConnectionsUsingClient() *cobra.Command { return err } - height, err := chain.QueryLatestHeight() + height, err := cmd.Flags().GetInt64(flags.FlagHeight) if err != nil { return err } @@ -397,11 +379,11 @@ func queryConnectionsUsingClient() *cobra.Command { return err } - return chain.Print(res, false, false) + return chain.CLIContext(height).PrintOutput(res) }, } - return cmd + return heightFlag(cmd) } func queryConnection() *cobra.Command { @@ -430,7 +412,7 @@ func queryConnection() *cobra.Command { return err } - return chain.Print(res, false, false) + return chain.CLIContext(height).PrintOutput(res) }, } @@ -489,7 +471,7 @@ func queryChannel() *cobra.Command { return err } - height, err := chain.QueryLatestHeight() + height, err := cmd.Flags().GetInt64(flags.FlagHeight) if err != nil { return err } @@ -499,11 +481,11 @@ func queryChannel() *cobra.Command { return err } - return chain.Print(res, false, false) + return chain.CLIContext(height).PrintOutput(res) }, } - return cmd + return heightFlag(cmd) } func queryChannels() *cobra.Command { @@ -540,38 +522,6 @@ func queryChannels() *cobra.Command { return paginationFlags(cmd) } -func queryNextSeqRecv() *cobra.Command { - cmd := &cobra.Command{ - Use: "seq-send [chain-id] [channel-id] [port-id]", - Short: "Query the next sequence send for a given channel", - Args: cobra.ExactArgs(3), - RunE: func(cmd *cobra.Command, args []string) error { - chain, err := config.Chains.Get(args[0]) - if err != nil { - return err - } - - if err = chain.AddPath(dcli, dcon, args[1], args[2], dord); err != nil { - return err - } - - height, err := chain.QueryLatestHeight() - if err != nil { - return err - } - - res, err := chain.QueryNextSeqRecv(height) - if err != nil { - return err - } - - return chain.Print(res, false, false) - }, - } - - return cmd -} - func queryPacketCommitment() *cobra.Command { cmd := &cobra.Command{ Use: "packet-commit [chain-id] [channel-id] [port-id] [seq]", @@ -604,38 +554,6 @@ func queryPacketCommitment() *cobra.Command { return cmd } -func queryPacketAck() *cobra.Command { - cmd := &cobra.Command{ - Use: "packet-ack [chain-id] [channel-id] [port-id] [seq]", - Short: "Query for the packet acknoledgement given it's sequence and channel ids", - Args: cobra.ExactArgs(4), - RunE: func(cmd *cobra.Command, args []string) error { - chain, err := config.Chains.Get(args[0]) - if err != nil { - return err - } - - if err = chain.AddPath(dcli, dcon, args[1], args[2], dord); err != nil { - return err - } - - seq, err := strconv.ParseUint(args[3], 10, 64) - if err != nil { - return err - } - - res, err := chain.QueryPacketCommitment(0, seq) - if err != nil { - return err - } - - return chain.Print(res, false, false) - }, - } - - return cmd -} - func queryUnrelayed() *cobra.Command { cmd := &cobra.Command{ Use: "unrelayed [path]", diff --git a/cmd/tx.go b/cmd/tx.go index 33bc35957..952a7dd76 100644 --- a/cmd/tx.go +++ b/cmd/tx.go @@ -36,17 +36,17 @@ func transactionCmd() *cobra.Command { } cmd.AddCommand( - fullPathCmd(), + linkCmd(), relayMsgsCmd(), - transferCmd(), + xfersend(), flags.LineBreak, createClientsCmd(), + updateClientsCmd(), createConnectionCmd(), createChannelCmd(), closeChannelCmd(), flags.LineBreak, rawTransactionCmd(), - // sendPacketCmd(), ) return cmd @@ -57,6 +57,7 @@ func createClientsCmd() *cobra.Command { Use: "clients [path-name]", Aliases: []string{"clnts"}, Short: "create a clients between two configured chains with a configured path", + Long: "Creates a working ibc client for chain configured on each end of the path by querying headers from each chain and then sending the cooresponding create-client messages", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, src, dst, err := config.ChainsFromPath(args[0]) @@ -70,10 +71,29 @@ func createClientsCmd() *cobra.Command { return cmd } +func updateClientsCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-clients [path-name]", + Aliases: []string{"update", "uc"}, + Short: "update a clients between two configured chains with a configured path", + Long: "Updates a working ibc client for chain configured on each end of the path by querying headers from each chain and then sending the cooresponding update-client messages", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + c, src, dst, err := config.ChainsFromPath(args[0]) + if err != nil { + return err + } + + return c[src].UpdateClients(c[dst]) + }, + } + return cmd +} + func createConnectionCmd() *cobra.Command { cmd := &cobra.Command{ Use: "connection [path-name]", - Aliases: []string{"conn"}, + Aliases: []string{"conn", "con"}, Short: "create a connection between two configured chains with a configured path", Long: strings.TrimSpace(`This command is meant to be used to repair or create a connection between two chains with a configured path in the config file`), @@ -99,7 +119,7 @@ func createConnectionCmd() *cobra.Command { func createChannelCmd() *cobra.Command { cmd := &cobra.Command{ Use: "channel [path-name]", - Aliases: []string{"chan"}, + Aliases: []string{"chan", "ch"}, Short: "create a channel between two configured chains with a configured path", Long: strings.TrimSpace(`This command is meant to be used to repair or create a channel between two chains with a configured path in the config file`), @@ -115,8 +135,7 @@ func createChannelCmd() *cobra.Command { return err } - // TODO: read order out of path config - return c[src].CreateChannel(c[dst], true, to) + return c[src].CreateChannel(c[dst], false, to) }, } @@ -148,7 +167,7 @@ func closeChannelCmd() *cobra.Command { return timeoutFlag(cmd) } -func fullPathCmd() *cobra.Command { +func linkCmd() *cobra.Command { cmd := &cobra.Command{ Use: "link [path-name]", Aliases: []string{"full-path", "connect", "path", "pth"}, @@ -183,7 +202,7 @@ func fullPathCmd() *cobra.Command { func relayMsgsCmd() *cobra.Command { cmd := &cobra.Command{ Use: "relay [path-name]", - Aliases: []string{"rly", "queue"}, + Aliases: []string{"rly", "queue", "clear"}, Short: "relay any packets that remain to be relayed on a given path, in both directions", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -218,43 +237,3 @@ func relayMsgsCmd() *cobra.Command { return strategyFlag(cmd) } - -// TODO: Reimplement send packet -// func sendPacketCmd() *cobra.Command { -// cmd := &cobra.Command{ -// Use: "send-packet [src-chain-id] [dst-chain-id] [packet-data]", -// Aliases: []string{"pkt", "sp"}, -// Short: "send a raw packet from a source chain to a destination chain", -// Long: "This sends packet-data (default: stdin) from a relayer's configured wallet on chain src to chain dst", -// Args: cobra.RangeArgs(2, 3), -// RunE: func(cmd *cobra.Command, args []string) error { -// src, dst := args[0], args[1] -// c, err := config.Chains.Gets(src, dst) -// if err != nil { -// return err -// } - -// pth, err := cmd.Flags().GetString(flagPath) -// if err != nil { -// return err -// } - -// if _, err = setPathsFromArgs(c[src], c[dst], pth); err != nil { -// return err -// } - -// var packetData string -// if len(args) < 3 { -// // Reading from stdin. -// if _, err := fmt.Scanln(&packetData); err != nil { -// return err -// } -// } else { -// packetData = args[2] -// } - -// return c[src].SendPacket(c[dst], []byte(packetData)) -// }, -// } -// return pathFlag(cmd) -// } diff --git a/cmd/version.go b/cmd/version.go index 3242620eb..5be6d0da3 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -16,15 +16,12 @@ var ( Commit = "" // SDKCommit defines the CosmosSDK commit hash (defined at compile time) SDKCommit = "" - // GaiaCommit defines the Gaia commit hash (defined at compile time) - GaiaCommit = "" ) type versionInfo struct { Version string `json:"version" yaml:"version"` Commit string `json:"commit" yaml:"commit"` CosmosSDK string `json:"cosmos-sdk" yaml:"cosmos-sdk"` - Gaia string `json:"gaia" yaml:"gaia"` Go string `json:"go" yaml:"go"` } @@ -43,7 +40,6 @@ func getVersionCmd() *cobra.Command { Version: Version, Commit: Commit, CosmosSDK: SDKCommit, - Gaia: GaiaCommit, Go: fmt.Sprintf("%s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH), } diff --git a/cmd/xfer.go b/cmd/xfer.go index df0b563a6..bd29bd44f 100644 --- a/cmd/xfer.go +++ b/cmd/xfer.go @@ -2,7 +2,6 @@ package cmd import ( "fmt" - "strconv" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" @@ -14,10 +13,11 @@ import ( func xfersend() *cobra.Command { cmd := &cobra.Command{ - Use: "xfer-send [src-chain-id] [dst-chain-id] [amount] [dst-addr]", - Short: "xfer-send", - Long: "This sends tokens from a relayers configured wallet on chain src to a dst addr on dst", - Args: cobra.ExactArgs(4), + Use: "transfer [src-chain-id] [dst-chain-id] [amount] [dst-addr]", + Short: "Initiate a transfer from one chain to another", + Aliases: []string{"xfer", "txf"}, + Long: "Sends the first step to transfer tokens in an IBC transfer. The created packet must be relayed to another chain", + Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) error { src, dst := args[0], args[1] c, err := config.Chains.Gets(src, dst) @@ -55,51 +55,6 @@ func xfersend() *cobra.Command { return pathFlag(cmd) } -func transferCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "transfer [src-chain-id] [dst-chain-id] [amount] [source] [dst-chain-addr]", - Aliases: []string{"xfer"}, - Short: "transfer tokens from a source chain to a destination chain in one command", - Long: "This sends tokens from a relayers configured wallet on chain src to a dst addr on dst", - Args: cobra.ExactArgs(5), - RunE: func(cmd *cobra.Command, args []string) error { - src, dst := args[0], args[1] - c, err := config.Chains.Gets(src, dst) - if err != nil { - return err - } - - pth, err := cmd.Flags().GetString(flagPath) - if err != nil { - return err - } - - if _, err = setPathsFromArgs(c[src], c[dst], pth); err != nil { - return err - } - - amount, err := sdk.ParseCoin(args[2]) - if err != nil { - return err - } - - source, err := strconv.ParseBool(args[3]) - if err != nil { - return err - } - - c[dst].UseSDKContext() - dstAddr, err := sdk.AccAddressFromBech32(args[4]) - if err != nil { - return err - } - - return c[src].SendTransferBothSides(c[dst], amount, dstAddr, source) - }, - } - return pathFlag(cmd) -} - func setPathsFromArgs(src, dst *relayer.Chain, name string) (*relayer.Path, error) { // Find any configured paths between the chains paths, err := config.Paths.PathsFromChains(src.ChainID, dst.ChainID) diff --git a/dev-env b/dev-env index 2e82e6b14..034aa1964 100755 --- a/dev-env +++ b/dev-env @@ -22,7 +22,8 @@ echo "waiting for blocks..." sleep 5 rly tx full-path demo -d -o 3s -rly tx raw xfer-send ibc0 ibc1 10000000samoleans $(rly k s ibc1) -rly tx raw xfer-send ibc0 ibc1 10000000samoleans $(rly k s ibc1) +rly tx txf ibc0 ibc1 10000000samoleans $(rly k s ibc1) +rly tx txf ibc0 ibc1 10000000samoleans $(rly k s ibc1) +sleep 1 rly tx relay demo -d rly q bal ibc1 | jq \ No newline at end of file diff --git a/docs/commands.md b/docs/commands.md index d8841d602..341995b64 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -111,7 +111,7 @@ NOTE: Most of the commands have aliases that make typing them much quicker (i.e. - [rly transact raw conn-try](#rly-transact-raw-conn-try) - [rly transact raw connection-step](#rly-transact-raw-connection-step) - [rly transact raw update-client](#rly-transact-raw-update-client) - - [rly transact raw xfer-send](#rly-transact-raw-xfer-send) + - [rly transact raw transfer](#rly-transact-raw-transfer) - [rly transact relay](#rly-transact-relay) - [rly transact send-packet](#rly-transact-send-packet) - [rly transact transfer](#rly-transact-transfer) @@ -1261,7 +1261,7 @@ raw IBC transaction commands * [rly transact raw conn-try](#rly-transact-raw-conn-try) - conn-try * [rly transact raw connection-step](#rly-transact-raw-connection-step) - create a connection between chains, passing in identifiers * [rly transact raw update-client](#rly-transact-raw-update-client) - update client for dst-chain on src-chain -* [rly transact raw xfer-send](#rly-transact-raw-xfer-send) - xfer-send +* [rly transact raw transfer](#rly-transact-raw-transfer) - transfer ## rly transact raw chan-ack @@ -1458,16 +1458,16 @@ rly transact raw update-client [src-chain-id] [dst-chain-id] [client-id] [flags] ``` -## rly transact raw xfer-send +## rly transact raw transfer -xfer-send +transfer ### Synopsis This sends tokens from a relayers configured wallet on chain src to a dst addr on dst ``` -rly transact raw xfer-send [src-chain-id] [dst-chain-id] [amount] [source] [dst-addr] [flags] +rly transact raw transfer [src-chain-id] [dst-chain-id] [amount] [source] [dst-addr] [flags] ``` ### Options diff --git a/go.mod b/go.mod index 439753e03..467d4bcc3 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200914141249-7ae84898de95 + github.com/cosmos/cosmos-sdk v0.34.4-0.20200915112751-5dc434fbca7c github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 diff --git a/go.sum b/go.sum index 052a4a072..87af26796 100644 --- a/go.sum +++ b/go.sum @@ -124,8 +124,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200914141249-7ae84898de95 h1:M1llWI+fTxqUE4b3NnaKSpgyyhJbSdYMqEnZCsCVs/Y= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200914141249-7ae84898de95/go.mod h1:+Xjq/f+2EAWodjJLEPa8o4bRV+hk7XJq2WKjeHGFKhw= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200915112751-5dc434fbca7c h1:MQxBF1W28nI5oi7uYOjRJQcBxO3ijatPZZCpX/BZjLI= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200915112751-5dc434fbca7c/go.mod h1:kO3VV10paWHqHnDJ8GteH2AKGAcv+Lpdy9+oWEKNUn4= github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac= 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= @@ -373,8 +373,8 @@ github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0Q github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.2 h1:znVR8Q4g7/WlcvsxLBRWvo+vtFJUAbDn3w+Yak2xVMI= -github.com/magiconair/properties v1.8.2/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/magiconair/properties v1.8.3 h1:kJSsc6EXkBLgr3SphHk9w5mtjn0bjlR4JYEXKrJ45rQ= +github.com/magiconair/properties v1.8.3/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -604,7 +604,6 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= github.com/tendermint/tendermint v0.34.0-rc3.0.20200907055413-3359e0bf2f84 h1:BI/EhLLh6SAlOtMaHePo8BNFLsNRiFNCtJ8cMBX+OE8= diff --git a/relayer/client-tx.go b/relayer/client-tx.go index d00e03dc0..b11762bcc 100644 --- a/relayer/client-tx.go +++ b/relayer/client-tx.go @@ -63,3 +63,40 @@ func (c *Chain) CreateClients(dst *Chain) (err error) { return nil } + +// UpdateClients updates clients for src on dst and dst on src given the configured paths +func (c *Chain) UpdateClients(dst *Chain) (err error) { + clients := &RelayMsgs{Src: []sdk.Msg{}, Dst: []sdk.Msg{}} + + srcH, dstH, err := UpdatesWithHeaders(c, dst) + if err != nil { + return err + } + + srcUH, dstUH, err := InjectTrustedFieldsHeaders(c, dst, srcH, dstH) + if err != nil { + return err + } + + clients.Src = append(clients.Src, c.PathEnd.UpdateClient(dstUH, c.MustGetAddress())) + clients.Dst = append(clients.Dst, dst.PathEnd.UpdateClient(srcUH, dst.MustGetAddress())) + + // Send msgs to both chains + if clients.Ready() { + if clients.Send(c, dst); clients.success { + c.Log(fmt.Sprintf("★ Clients updated: [%s]client(%s) {%d}->{%d} and [%s]client(%s) {%d}->{%d}", + c.ChainID, + c.PathEnd.ClientID, + MustGetHeight(srcUH.TrustedHeight), + srcUH.Header.Height, + dst.ChainID, + dst.PathEnd.ClientID, + MustGetHeight(dstUH.TrustedHeight), + dstUH.Header.Height, + ), + ) + } + } + + return nil +} diff --git a/relayer/headers.go b/relayer/headers.go index a8b0e9fab..10d857ea4 100644 --- a/relayer/headers.go +++ b/relayer/headers.go @@ -6,6 +6,7 @@ import ( clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" clientExported "github.com/cosmos/cosmos-sdk/x/ibc/exported" + "golang.org/x/sync/errgroup" ) // NewSyncHeaders returns a new instance of map[string]*tmclient.Header that can be easily @@ -38,6 +39,17 @@ func (uh *SyncHeaders) Update(c *Chain) error { return nil } +// Updates updates the headers for a given set of chains +func (uh *SyncHeaders) Updates(c ...*Chain) error { + eg := new(errgroup.Group) + for _, chain := range c { + eg.Go(func() error { + return uh.Update(chain) + }) + } + return eg.Wait() +} + // GetHeader returns the latest header for a given chainID func (uh *SyncHeaders) GetHeader(chainID string) *tmclient.Header { uh.Lock() @@ -59,6 +71,34 @@ func (uh *SyncHeaders) GetHeight(chainID string) uint64 { return MustGetHeight(uh.hds[chainID].GetHeight()) } +// UpdateWithTrustedHeaders updates the latest headers in SyncHeaders +func (uh *SyncHeaders) UpdateWithTrustedHeaders(src, dst *Chain) (srcTh, dstTh *tmclient.Header, err error) { + eg := new(errgroup.Group) + eg.Go(func() error { + return uh.Update(src) + }) + eg.Go(func() error { + return uh.Update(dst) + }) + err = eg.Wait() + return +} + +// GetTrustedHeaders returns the trusted headers for the current headers stored in SyncHeaders +func (uh *SyncHeaders) GetTrustedHeaders(src, dst *Chain) (srcTh, dstTh *tmclient.Header, err error) { + eg := new(errgroup.Group) + eg.Go(func() error { + srcTh, err = InjectTrustedFields(src, dst, uh.GetHeader(src.ChainID)) + return err + }) + eg.Go(func() error { + dstTh, err = InjectTrustedFields(dst, src, uh.GetHeader(dst.ChainID)) + return err + }) + err = eg.Wait() + return +} + // InjectTrustedFields injects the necessary trusted fields for a srcHeader coming from a srcChain // destined for an IBC client stored on the dstChain // TrustedHeight is the latest height of the IBC client on dstChain diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index f64e8fda4..4ad0a4a5f 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -122,10 +122,6 @@ func (pe *PathEnd) ConnTry( if err != nil { panic(err) } - css, err := clientTypes.UnpackConsensusState(dstConsState.ConsensusState) - if err != nil { - panic(err) - } msg := connTypes.NewMsgConnectionOpenTry( pe.ConnectionID, pe.ClientID, @@ -138,7 +134,7 @@ func (pe *PathEnd) ConnTry( dstClientState.Proof, dstConsState.Proof, dstConnState.ProofHeight, - css.GetHeight().(clientTypes.Height), + cs.GetLatestHeight().(clientTypes.Height), signer, ) if err = msg.ValidateBasic(); err != nil { @@ -160,10 +156,6 @@ func (pe *PathEnd) ConnAck( if err != nil { panic(err) } - css, err := clientTypes.UnpackConsensusState(dstConsState.ConsensusState) - if err != nil { - panic(err) - } return connTypes.NewMsgConnectionOpenAck( pe.ConnectionID, cs, @@ -171,7 +163,7 @@ func (pe *PathEnd) ConnAck( dstClientState.Proof, dstConsState.Proof, dstConsState.ProofHeight, - css.GetHeight().(clientTypes.Height), + cs.GetLatestHeight().(clientTypes.Height), connTypes.GetCompatibleEncodedVersions()[0], signer, ) diff --git a/relayer/query.go b/relayer/query.go index 2d6047518..3814e863a 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -21,6 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" + commitTypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -126,7 +127,7 @@ func QueryClientStatePair(src, dst *Chain, srch, dsth int64) (srcCsRes, dstCsRes } // QueryClients queries all the clients! -func (c *Chain) QueryClients(offset, limit uint64) ([]*clientTypes.IdentifiedClientState, error) { +func (c *Chain) QueryClients(offset, limit uint64) (*clientTypes.QueryClientStatesResponse, error) { res, err := clientTypes.NewQueryClient(c.CLIContext(0)).ClientStates(context.Background(), &clientTypes.QueryClientStatesRequest{ Pagination: &query.PageRequest{ Key: []byte(""), @@ -135,7 +136,7 @@ func (c *Chain) QueryClients(offset, limit uint64) ([]*clientTypes.IdentifiedCli CountTotal: false, }, }) - return res.ClientStates, err + return res, err } // //////////////////////////// @@ -143,7 +144,7 @@ func (c *Chain) QueryClients(offset, limit uint64) ([]*clientTypes.IdentifiedCli // //////////////////////////// // QueryConnections gets any connections on a chain -func (c *Chain) QueryConnections(offset, limit uint64) (conns []*connTypes.IdentifiedConnection, err error) { +func (c *Chain) QueryConnections(offset, limit uint64) (conns *connTypes.QueryConnectionsResponse, err error) { res, err := connTypes.NewQueryClient(c.CLIContext(0)).Connections(context.Background(), &connTypes.QueryConnectionsRequest{ Pagination: &query.PageRequest{ Key: []byte(""), @@ -152,7 +153,7 @@ func (c *Chain) QueryConnections(offset, limit uint64) (conns []*connTypes.Ident CountTotal: false, }, }) - return res.Connections, err + return res, err } // QueryConnectionsUsingClient gets any connections that exist between chain and counterparty @@ -162,9 +163,31 @@ func (c *Chain) QueryConnectionsUsingClient(height int64) (clientConns *connType // QueryConnection returns the remote end of a given connection func (c *Chain) QueryConnection(height int64) (*connTypes.QueryConnectionResponse, error) { - return connUtils.QueryConnection(c.CLIContext(height), c.PathEnd.ConnectionID, true) + res, err := connUtils.QueryConnection(c.CLIContext(height), c.PathEnd.ConnectionID, true) + if err != nil && strings.Contains(err.Error(), "not found") { + return emptyConnRes, nil + } else if err != nil { + return nil, err + } + return res, nil } +var emptyConnRes = connTypes.NewQueryConnectionResponse( + "uninitialized", + connTypes.NewConnectionEnd( + connTypes.UNINITIALIZED, + "client", + connTypes.NewCounterparty( + "client", + "connection", + commitTypes.NewMerklePrefix([]byte{}), + ), + []string{}, + ), + []byte{}, + clientTypes.NewHeight(0, 0), +) + // QueryConnectionPair returns a pair of connection responses func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (srcConn, dstConn *connTypes.QueryConnectionResponse, err error) { var eg = new(errgroup.Group) @@ -185,8 +208,9 @@ func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (srcConn, dstConn *c // //////////////////////////// // QueryConnectionChannels queries the channels associated with a connection -func (c *Chain) QueryConnectionChannels(connectionID string, offset, limit uint64) ([]*chanTypes.IdentifiedChannel, error) { +func (c *Chain) QueryConnectionChannels(connectionID string, offset, limit uint64) (*chanTypes.QueryConnectionChannelsResponse, error) { res, err := chanTypes.NewQueryClient(c.CLIContext(0)).ConnectionChannels(context.Background(), &chanTypes.QueryConnectionChannelsRequest{ + Connection: connectionID, Pagination: &query.PageRequest{ Key: []byte(""), Offset: offset, @@ -194,14 +218,37 @@ func (c *Chain) QueryConnectionChannels(connectionID string, offset, limit uint6 CountTotal: false, }, }) - return res.Channels, err + return res, err } // QueryChannel returns the channel associated with a channelID func (c *Chain) QueryChannel(height int64) (chanRes *chanTypes.QueryChannelResponse, err error) { - return chanUtils.QueryChannel(c.CLIContext(height), c.PathEnd.PortID, c.PathEnd.ChannelID, true) + res, err := chanUtils.QueryChannel(c.CLIContext(height), c.PathEnd.PortID, c.PathEnd.ChannelID, true) + if err != nil && strings.Contains(err.Error(), "not found") { + return emptyChannelRes, nil + } else if err != nil { + return nil, err + } + return res, nil } +var emptyChannelRes = chanTypes.NewQueryChannelResponse( + "port", + "channel", + chanTypes.NewChannel( + chanTypes.UNINITIALIZED, + chanTypes.UNORDERED, + chanTypes.NewCounterparty( + "port", + "channel", + ), + []string{}, + "version", + ), + []byte{}, + clientTypes.NewHeight(0, 0), +) + // QueryChannelPair returns a pair of channel responses func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (srcChan, dstChan *chanTypes.QueryChannelResponse, err error) { var eg = new(errgroup.Group) @@ -218,7 +265,7 @@ func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (srcChan, dstChan *chan } // QueryChannels returns all the channels that are registered on a chain -func (c *Chain) QueryChannels(offset, limit uint64) ([]*chanTypes.IdentifiedChannel, error) { +func (c *Chain) QueryChannels(offset, limit uint64) (*chanTypes.QueryChannelsResponse, error) { res, err := types.NewQueryClient(c.CLIContext(0)).Channels(context.Background(), &types.QueryChannelsRequest{ Pagination: &query.PageRequest{ Key: []byte(""), @@ -227,7 +274,7 @@ func (c *Chain) QueryChannels(offset, limit uint64) ([]*chanTypes.IdentifiedChan CountTotal: false, }, }) - return res.Channels, err + return res, err } // /////////////////////////////////// From 2ad2922e5784a2d0ff4aa38fb7d90ebac38610bd Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Tue, 15 Sep 2020 13:49:52 -0700 Subject: [PATCH 39/54] WIP denom support --- cmd/query.go | 38 +++++++++++++++++++++++++ dev-env | 5 +++- go.sum | 1 + relayer/naive-strategy.go | 3 ++ relayer/query.go | 58 +++++++++++++++++++++++++++------------ test/test_queries.go | 24 ++++++++-------- 6 files changed, 98 insertions(+), 31 deletions(-) diff --git a/cmd/query.go b/cmd/query.go index 7cc46c416..aa164af3c 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -2,12 +2,15 @@ package cmd import ( "context" + "fmt" "strconv" "strings" "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + xfertypes "github.com/cosmos/cosmos-sdk/x/ibc-transfer/types" + chantypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" @@ -41,11 +44,46 @@ func queryCmd() *cobra.Command { queryChannels(), queryConnectionChannels(), queryPacketCommitment(), + queryIBCDenom(), ) return cmd } +func queryIBCDenom() *cobra.Command { + cmd := &cobra.Command{ + Use: "ibc-denom [chain-id] [denom-hash]", + Short: "Query transaction by transaction hash", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + chain, err := config.Chains.Get(args[0]) + if err != nil { + return err + } + + trace := xfertypes.ParseDenomTrace(args[1]) + tqc := xfertypes.NewQueryClient(chain.CLIContext(0)) + dtRes, err := tqc.DenomTrace(context.Background(), &xfertypes.QueryDenomTraceRequest{ + Hash: trace.BaseDenom, + }) + + pc := strings.Split(dtRes.DenomTrace.Path, "/") + + cqc := chantypes.NewQueryClient(chain.CLIContext(0)) + cCsRes, err := cqc.ChannelClientState(context.Background(), &chantypes.QueryChannelClientStateRequest{ + PortId: pc[0], + ChannelId: pc[1], + }) + if err != nil { + return err + } + fmt.Println(cCsRes.IdentifiedClientState) + return chain.Print(cqc, false, false) + }, + } + return cmd +} + func queryTx() *cobra.Command { cmd := &cobra.Command{ Use: "tx [chain-id] [tx-hash]", diff --git a/dev-env b/dev-env index 034aa1964..e940a2d35 100755 --- a/dev-env +++ b/dev-env @@ -19,11 +19,14 @@ bash scripts/two-chainz "local" "skip" bash scripts/config-relayer "skip" echo "waiting for blocks..." -sleep 5 +sleep 3 rly tx full-path demo -d -o 3s rly tx txf ibc0 ibc1 10000000samoleans $(rly k s ibc1) rly tx txf ibc0 ibc1 10000000samoleans $(rly k s ibc1) +rly tx txf ibc1 ibc0 10000000samoleans $(rly k s ibc0) +rly tx txf ibc1 ibc0 10000000samoleans $(rly k s ibc0) sleep 1 rly tx relay demo -d +rly q bal ibc0 | jq rly q bal ibc1 | jq \ No newline at end of file diff --git a/go.sum b/go.sum index 87af26796..033fcdba6 100644 --- a/go.sum +++ b/go.sum @@ -604,6 +604,7 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= github.com/tendermint/tendermint v0.34.0-rc3.0.20200907055413-3359e0bf2f84 h1:BI/EhLLh6SAlOtMaHePo8BNFLsNRiFNCtJ8cMBX+OE8= diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index 392589889..2ebae703f 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -41,6 +41,7 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea dstPacketSeq = []uint64{} rs = &RelaySequences{Src: []uint64{}, Dst: []uint64{}} ) + eg.Go(func() error { res, err := src.QueryPacketCommitments(0, 1000, sh.GetHeight(src.ChainID)) if err != nil { @@ -51,6 +52,7 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea } return nil }) + eg.Go(func() error { res, err := dst.QueryPacketCommitments(0, 1000, sh.GetHeight(dst.ChainID)) if err != nil { @@ -73,6 +75,7 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea } return err }) + eg.Go(func() error { res, err := dst.QueryUnrelayedPackets(sh.GetHeight(dst.ChainID), dstPacketSeq, false) if len(res) > 0 { diff --git a/relayer/query.go b/relayer/query.go index 3814e863a..b3c13d36b 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -13,6 +13,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" + xferTypes "github.com/cosmos/cosmos-sdk/x/ibc-transfer/types" clientUtils "github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/utils" clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" connUtils "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils" @@ -277,26 +278,50 @@ func (c *Chain) QueryChannels(offset, limit uint64) (*chanTypes.QueryChannelsRes return res, err } -// /////////////////////////////////// +// QueryChannelClient returns the client state of the client supporting a given channel +func (c *Chain) QueryChannelClient() (*chanTypes.QueryChannelClientStateResponse, error) { + return types.NewQueryClient(c.CLIContext(0)).ChannelClientState(context.Background(), &types.QueryChannelClientStateRequest{ + PortId: c.PathEnd.PortID, + ChannelId: c.PathEnd.ChannelID, + }) +} + +///////////////////////////////////// +// TRANSFER -> Denoms // +///////////////////////////////////// + +// QueryDenomTrace takes a denom from IBC and queries the information about it +func (c *Chain) QueryDenomTrace(denom string) (*xferTypes.QueryDenomTraceResponse, error) { + return xferTypes.NewQueryClient(c.CLIContext(0)).DenomTrace(context.Background(), &xferTypes.QueryDenomTraceRequest{ + Hash: denom, + }) +} + +// QueryDenomTraces returns all the denom traces from a given chain +func (c *Chain) QueryDenomTraces(offset, limit uint64) (*xferTypes.QueryDenomTracesResponse, error) { + return xferTypes.NewQueryClient(c.CLIContext(0)).DenomTraces(context.Background(), &xferTypes.QueryDenomTracesRequest{ + Pagination: &query.PageRequest{ + Key: []byte(""), + Offset: offset, + Limit: limit, + CountTotal: false, + }, + }) +} + +///////////////////////////////////// // STAKING -> HistoricalInfo // -// /////////////////////////////////// +///////////////////////////////////// +// QueryHistoricalInfo returns historical header data func (c *Chain) QueryHistoricalInfo(height clientTypes.Height) (*stakingTypes.QueryHistoricalInfoResponse, error) { //TODO: use epoch number in query once SDK gets updated - params := stakingTypes.QueryHistoricalInfoRequest{ + return stakingTypes.NewQueryClient(c.CLIContext(int64(height.EpochHeight))).HistoricalInfo(context.Background(), &stakingTypes.QueryHistoricalInfoRequest{ Height: int64(height.EpochHeight), - } - - queryClient := stakingTypes.NewQueryClient(c.CLIContext(int64(height.EpochHeight))) - - res, err := queryClient.HistoricalInfo(context.Background(), ¶ms) - if err != nil { - return nil, err - } - - return res, nil + }) } +// QueryValsetAtHeight returns the validator set at a given height func (c *Chain) QueryValsetAtHeight(height clientTypes.Height) (*tmproto.ValidatorSet, error) { res, err := c.QueryHistoricalInfo(height) if err != nil { @@ -309,11 +334,8 @@ func (c *Chain) QueryValsetAtHeight(height clientTypes.Height) (*tmproto.Validat Validators: tmVals, Proposer: tmVals[0], } - tmProtoSet, err := tmValSet.ToProto() - if err != nil { - return nil, err - } - return tmProtoSet, nil + + return tmValSet.ToProto() } // QueryUnbondingPeriod returns the unbonding period of the chain diff --git a/test/test_queries.go b/test/test_queries.go index 625e7a464..3ba5780f0 100644 --- a/test/test_queries.go +++ b/test/test_queries.go @@ -33,14 +33,14 @@ func testConnectionPair(t *testing.T, src, dst *ry.Chain) { // testConnection tests that the only connection on src has a counterparty that is the connection on dst func testConnection(t *testing.T, src, dst *ry.Chain) { - conns, err := src.QueryConnections(0, 1000) + conns, err := src.QueryConnections(1, 1000) require.NoError(t, err) - require.Equal(t, len(conns), 1) - // conns[0]. - require.Equal(t, conns[0].ClientId, src.PathEnd.ClientID) - require.Equal(t, conns[0].Counterparty.GetClientID(), dst.PathEnd.ClientID) - require.Equal(t, conns[0].Counterparty.GetConnectionID(), dst.PathEnd.ConnectionID) - require.Equal(t, conns[0].State.String(), "STATE_OPEN") + require.Equal(t, len(conns.Connections), 1) + // conns.Connections[0]. + require.Equal(t, conns.Connections[0].ClientId, src.PathEnd.ClientID) + require.Equal(t, conns.Connections[0].Counterparty.GetClientID(), dst.PathEnd.ClientID) + require.Equal(t, conns.Connections[0].Counterparty.GetConnectionID(), dst.PathEnd.ConnectionID) + require.Equal(t, conns.Connections[0].State.String(), "STATE_OPEN") h, err := src.Client.Status() require.NoError(t, err) @@ -63,11 +63,11 @@ func testChannelPair(t *testing.T, src, dst *ry.Chain) { func testChannel(t *testing.T, src, dst *ry.Chain) { chans, err := src.QueryChannels(0, 1000) require.NoError(t, err) - require.Equal(t, 1, len(chans)) - require.Equal(t, chans[0].Ordering.String(), "ORDER_UNORDERED") - require.Equal(t, chans[0].State.String(), "STATE_OPEN") - require.Equal(t, chans[0].Counterparty.ChannelId, dst.PathEnd.ChannelID) - require.Equal(t, chans[0].Counterparty.GetPortID(), dst.PathEnd.PortID) + require.Equal(t, 1, len(chans.Channels)) + require.Equal(t, chans.Channels[0].Ordering.String(), "ORDER_UNORDERED") + require.Equal(t, chans.Channels[0].State.String(), "STATE_OPEN") + require.Equal(t, chans.Channels[0].Counterparty.ChannelId, dst.PathEnd.ChannelID) + require.Equal(t, chans.Channels[0].Counterparty.GetPortID(), dst.PathEnd.PortID) h, err := src.Client.Status() require.NoError(t, err) From 853f595854724eefef9fc65a388bd05607f9cb12 Mon Sep 17 00:00:00 2001 From: Aditya Sripal Date: Tue, 15 Sep 2020 17:02:01 -0400 Subject: [PATCH 40/54] fix querying unrelayed sequences --- relayer/naive-strategy.go | 43 +++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index 392589889..4687533d3 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -67,17 +67,48 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea } eg.Go(func() error { - res, err := src.QueryUnrelayedPackets(sh.GetHeight(src.ChainID), srcPacketSeq, false) - if len(res) > 0 { - rs.Src = res + // Query all packets sent by src that have been received by dst + recvd, err := dst.QueryUnrelayedPackets(sh.GetHeight(dst.ChainID), srcPacketSeq, true) + if err != nil { + return err + } + // Iterate over all packets commitment sequences still remaining on dst, + // and add if the sequence has not been processed by dst + for _, packet := range srcPacketSeq { + processed := false + for _, r := range recvd { + if packet == r { + processed = true + } + } + if !processed { + rs.Src = append(rs.Src, packet) + } } + return err }) eg.Go(func() error { - res, err := dst.QueryUnrelayedPackets(sh.GetHeight(dst.ChainID), dstPacketSeq, false) - if len(res) > 0 { - rs.Dst = res + // Query all packets sent by dst that have been received by src + recvd, err := src.QueryUnrelayedPackets(sh.GetHeight(src.ChainID), dstPacketSeq, true) + if err != nil { + return err } + // Iterate over all packets commitment sequences still remaining on dst, + // and add if the sequence has not been processed by dst + for _, packet := range dstPacketSeq { + processed := false + for _, r := range recvd { + if packet == r { + processed = true + } + } + + if !processed { + rs.Dst = append(rs.Dst, packet) + } + } + return err }) From dc7815a84428194a97fb31e45a6498c31ee538f4 Mon Sep 17 00:00:00 2001 From: Aditya Sripal Date: Tue, 15 Sep 2020 17:18:46 -0400 Subject: [PATCH 41/54] cleanup --- relayer/naive-strategy.go | 71 +++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index 3ad99e3c8..cd343cdef 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -38,7 +38,10 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea var ( eg = new(errgroup.Group) srcPacketSeq = []uint64{} + srcRecvd = []uint64{} dstPacketSeq = []uint64{} + dstRecvd = []uint64{} + err error rs = &RelaySequences{Src: []uint64{}, Dst: []uint64{}} ) @@ -70,48 +73,13 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea eg.Go(func() error { // Query all packets sent by src that have been received by dst - recvd, err := dst.QueryUnrelayedPackets(sh.GetHeight(dst.ChainID), srcPacketSeq, true) - if err != nil { - return err - } - // Iterate over all packets commitment sequences still remaining on dst, - // and add if the sequence has not been processed by dst - for _, packet := range srcPacketSeq { - processed := false - for _, r := range recvd { - if packet == r { - processed = true - } - } - if !processed { - rs.Src = append(rs.Src, packet) - } - } - + dstRecvd, err = dst.QueryUnrelayedPackets(sh.GetHeight(dst.ChainID), srcPacketSeq, true) return err }) eg.Go(func() error { // Query all packets sent by dst that have been received by src - recvd, err := src.QueryUnrelayedPackets(sh.GetHeight(src.ChainID), dstPacketSeq, true) - if err != nil { - return err - } - // Iterate over all packets commitment sequences still remaining on dst, - // and add if the sequence has not been processed by dst - for _, packet := range dstPacketSeq { - processed := false - for _, r := range recvd { - if packet == r { - processed = true - } - } - - if !processed { - rs.Dst = append(rs.Dst, packet) - } - } - + srcRecvd, err = src.QueryUnrelayedPackets(sh.GetHeight(src.ChainID), dstPacketSeq, true) return err }) @@ -119,6 +87,35 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea return nil, err } + // Iterate over all packets commitment sequences still remaining on src, + // and add if the sequence has not been processed by dst + for _, packet := range srcPacketSeq { + processed := false + for _, r := range dstRecvd { + if packet == r { + processed = true + } + } + if !processed { + rs.Src = append(rs.Src, packet) + } + } + + // Iterate over all packets commitment sequences still remaining on dst, + // and add if the sequence has not been processed by src + for _, packet := range dstPacketSeq { + processed := false + for _, r := range srcRecvd { + if packet == r { + processed = true + } + } + + if !processed { + rs.Dst = append(rs.Dst, packet) + } + } + return rs, nil } From f414186638a5ab7f745027a24efb947105547bed Mon Sep 17 00:00:00 2001 From: Aditya Sripal Date: Tue, 15 Sep 2020 17:40:06 -0400 Subject: [PATCH 42/54] simplify further --- relayer/naive-strategy.go | 62 +++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index cd343cdef..868f0e598 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -38,9 +38,7 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea var ( eg = new(errgroup.Group) srcPacketSeq = []uint64{} - srcRecvd = []uint64{} dstPacketSeq = []uint64{} - dstRecvd = []uint64{} err error rs = &RelaySequences{Src: []uint64{}, Dst: []uint64{}} ) @@ -73,13 +71,13 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea eg.Go(func() error { // Query all packets sent by src that have been received by dst - dstRecvd, err = dst.QueryUnrelayedPackets(sh.GetHeight(dst.ChainID), srcPacketSeq, true) + rs.Src, err = dst.QueryUnrelayedPackets(sh.GetHeight(dst.ChainID), srcPacketSeq, false) return err }) eg.Go(func() error { // Query all packets sent by dst that have been received by src - srcRecvd, err = src.QueryUnrelayedPackets(sh.GetHeight(src.ChainID), dstPacketSeq, true) + rs.Dst, err = src.QueryUnrelayedPackets(sh.GetHeight(src.ChainID), dstPacketSeq, false) return err }) @@ -87,34 +85,34 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea return nil, err } - // Iterate over all packets commitment sequences still remaining on src, - // and add if the sequence has not been processed by dst - for _, packet := range srcPacketSeq { - processed := false - for _, r := range dstRecvd { - if packet == r { - processed = true - } - } - if !processed { - rs.Src = append(rs.Src, packet) - } - } - - // Iterate over all packets commitment sequences still remaining on dst, - // and add if the sequence has not been processed by src - for _, packet := range dstPacketSeq { - processed := false - for _, r := range srcRecvd { - if packet == r { - processed = true - } - } - - if !processed { - rs.Dst = append(rs.Dst, packet) - } - } + // // Iterate over all packets commitment sequences still remaining on src, + // // and add if the sequence has not been processed by dst + // for _, packet := range srcPacketSeq { + // processed := false + // for _, r := range dstRecvd { + // if packet == r { + // processed = true + // } + // } + // if !processed { + // rs.Src = append(rs.Src, packet) + // } + // } + // + // // Iterate over all packets commitment sequences still remaining on dst, + // // and add if the sequence has not been processed by src + // for _, packet := range dstPacketSeq { + // processed := false + // for _, r := range srcRecvd { + // if packet == r { + // processed = true + // } + // } + // + // if !processed { + // rs.Dst = append(rs.Dst, packet) + // } + // } return rs, nil } From ea145db42f9d3b3f5bcb79597086cd4c10293586 Mon Sep 17 00:00:00 2001 From: Aditya Sripal Date: Tue, 15 Sep 2020 17:44:57 -0400 Subject: [PATCH 43/54] remove commented-out code --- relayer/naive-strategy.go | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index 868f0e598..afabc66b1 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -85,35 +85,6 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea return nil, err } - // // Iterate over all packets commitment sequences still remaining on src, - // // and add if the sequence has not been processed by dst - // for _, packet := range srcPacketSeq { - // processed := false - // for _, r := range dstRecvd { - // if packet == r { - // processed = true - // } - // } - // if !processed { - // rs.Src = append(rs.Src, packet) - // } - // } - // - // // Iterate over all packets commitment sequences still remaining on dst, - // // and add if the sequence has not been processed by src - // for _, packet := range dstPacketSeq { - // processed := false - // for _, r := range srcRecvd { - // if packet == r { - // processed = true - // } - // } - // - // if !processed { - // rs.Dst = append(rs.Dst, packet) - // } - // } - return rs, nil } From 692443a41d8dca977600593b69a9c2ea4be208ea Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Wed, 16 Sep 2020 12:21:16 -0700 Subject: [PATCH 44/54] Added query for IBC denoms --- cmd/flags.go | 2 +- cmd/query.go | 29 ++++++----------------------- relayer/query.go | 14 +++++++------- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/cmd/flags.go b/cmd/flags.go index 80a315438..4954f39a7 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -49,7 +49,7 @@ func heightFlag(cmd *cobra.Command) *cobra.Command { } func paginationFlags(cmd *cobra.Command) *cobra.Command { - cmd.Flags().Uint64P(flags.FlagOffset, "o", 1, "pagination offset for query") + cmd.Flags().Uint64P(flags.FlagOffset, "o", 0, "pagination offset for query") cmd.Flags().Uint64P(flags.FlagLimit, "l", 1000, "pagination limit for query") if err := viper.BindPFlag(flags.FlagOffset, cmd.Flags().Lookup(flags.FlagOffset)); err != nil { panic(err) diff --git a/cmd/query.go b/cmd/query.go index aa164af3c..1e9a44cbb 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -2,15 +2,12 @@ package cmd import ( "context" - "fmt" "strconv" "strings" "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" - xfertypes "github.com/cosmos/cosmos-sdk/x/ibc-transfer/types" - chantypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" @@ -44,41 +41,27 @@ func queryCmd() *cobra.Command { queryChannels(), queryConnectionChannels(), queryPacketCommitment(), - queryIBCDenom(), + queryIBCDenoms(), ) return cmd } -func queryIBCDenom() *cobra.Command { +func queryIBCDenoms() *cobra.Command { cmd := &cobra.Command{ - Use: "ibc-denom [chain-id] [denom-hash]", + Use: "ibc-denoms [chain-id]", Short: "Query transaction by transaction hash", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { chain, err := config.Chains.Get(args[0]) if err != nil { return err } - - trace := xfertypes.ParseDenomTrace(args[1]) - tqc := xfertypes.NewQueryClient(chain.CLIContext(0)) - dtRes, err := tqc.DenomTrace(context.Background(), &xfertypes.QueryDenomTraceRequest{ - Hash: trace.BaseDenom, - }) - - pc := strings.Split(dtRes.DenomTrace.Path, "/") - - cqc := chantypes.NewQueryClient(chain.CLIContext(0)) - cCsRes, err := cqc.ChannelClientState(context.Background(), &chantypes.QueryChannelClientStateRequest{ - PortId: pc[0], - ChannelId: pc[1], - }) + res, err := chain.QueryDenomTraces(0, 1000) if err != nil { return err } - fmt.Println(cCsRes.IdentifiedClientState) - return chain.Print(cqc, false, false) + return chain.CLIContext(0).PrintOutput(res) }, } return cmd diff --git a/relayer/query.go b/relayer/query.go index b3c13d36b..de647b3f6 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -60,7 +60,7 @@ func (c *Chain) QueryBalance(keyName string) (sdk.Coins, error) { Key: []byte(""), Offset: 0, Limit: 1000, - CountTotal: false, + CountTotal: true, }) queryClient := bankTypes.NewQueryClient(c.CLIContext(0)) @@ -134,7 +134,7 @@ func (c *Chain) QueryClients(offset, limit uint64) (*clientTypes.QueryClientStat Key: []byte(""), Offset: offset, Limit: limit, - CountTotal: false, + CountTotal: true, }, }) return res, err @@ -151,7 +151,7 @@ func (c *Chain) QueryConnections(offset, limit uint64) (conns *connTypes.QueryCo Key: []byte(""), Offset: offset, Limit: limit, - CountTotal: false, + CountTotal: true, }, }) return res, err @@ -216,7 +216,7 @@ func (c *Chain) QueryConnectionChannels(connectionID string, offset, limit uint6 Key: []byte(""), Offset: offset, Limit: limit, - CountTotal: false, + CountTotal: true, }, }) return res, err @@ -272,7 +272,7 @@ func (c *Chain) QueryChannels(offset, limit uint64) (*chanTypes.QueryChannelsRes Key: []byte(""), Offset: offset, Limit: limit, - CountTotal: false, + CountTotal: true, }, }) return res, err @@ -304,7 +304,7 @@ func (c *Chain) QueryDenomTraces(offset, limit uint64) (*xferTypes.QueryDenomTra Key: []byte(""), Offset: offset, Limit: limit, - CountTotal: false, + CountTotal: true, }, }) } @@ -393,7 +393,7 @@ func (c *Chain) QueryPacketCommitments(offset, limit, height uint64) (comRes []* Pagination: &query.PageRequest{ Offset: offset, Limit: limit, - CountTotal: false, + CountTotal: true, }, }) return res.Commitments, err From 7b170824373121f4cfa6adfe510c15cfb263169c Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Wed, 16 Sep 2020 14:54:54 -0700 Subject: [PATCH 45/54] Update sdk version to incorporate IBC fixes --- go.mod | 2 +- go.sum | 5 ++--- relayer/strategies.go | 4 ++-- scripts/one-chain | 3 ++- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 467d4bcc3..9c4b3ee48 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200915112751-5dc434fbca7c + github.com/cosmos/cosmos-sdk v0.34.4-0.20200916172701-e4c67eddc7e3 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 diff --git a/go.sum b/go.sum index 033fcdba6..c219b8b68 100644 --- a/go.sum +++ b/go.sum @@ -124,9 +124,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200915112751-5dc434fbca7c h1:MQxBF1W28nI5oi7uYOjRJQcBxO3ijatPZZCpX/BZjLI= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200915112751-5dc434fbca7c/go.mod h1:kO3VV10paWHqHnDJ8GteH2AKGAcv+Lpdy9+oWEKNUn4= -github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200916172701-e4c67eddc7e3 h1:lSH+OZ5w28ctEDtt8Hu6fLfDbEGmpudyw6YsM4jHQEs= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200916172701-e4c67eddc7e3/go.mod h1:kO3VV10paWHqHnDJ8GteH2AKGAcv+Lpdy9+oWEKNUn4= 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/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= diff --git a/relayer/strategies.go b/relayer/strategies.go index c0379adfc..0c69a3215 100644 --- a/relayer/strategies.go +++ b/relayer/strategies.go @@ -8,8 +8,8 @@ import ( ) var ( - txEvents = "tm.event = 'Tx'" - blEvents = "tm.event = 'NewBlock'" + txEvents = "tm.event='Tx'" + blEvents = "tm.event='NewBlock'" ) // Strategy defines diff --git a/scripts/one-chain b/scripts/one-chain index 922cbda56..3cd11129d 100755 --- a/scripts/one-chain +++ b/scripts/one-chain @@ -57,6 +57,7 @@ sed -i '' 's#"localhost:6060"#"localhost:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/con sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml sed -i '' 's/index_all_keys = false/index_all_keys = true/g' $CHAINDIR/$CHAINID/config/config.toml +# sed -i '' 's#index-events = \[\]#index-events = \["message.action","send_packet.packet_src_channel","send_packet.packet_sequence"\]#g' $CHAINDIR/$CHAINID/config/app.toml # Start the gaia -gaiad --home $CHAINDIR/$CHAINID start --pruning=nothing --grpc.address="0.0.0.0:$GRPCPORT" > $CHAINDIR/$CHAINID.log 2>&1 & +gaiad --home $CHAINDIR/$CHAINID start --pruning=nothing --grpc.address="0.0.0.0:$GRPCPORT" > $CHAINDIR/$CHAINID.log 2>&1 & \ No newline at end of file From 00fdbb3f89fa9c575bff85eefad013877d2716c5 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Wed, 16 Sep 2020 16:08:28 -0700 Subject: [PATCH 46/54] lint cleanup --- cmd/errors.go | 4 -- cmd/flags.go | 9 ---- cmd/light.go | 5 +- cmd/paths.go | 4 +- cmd/query.go | 4 +- cmd/raw.go | 6 ++- cmd/root.go | 3 -- cmd/tx.go | 10 ++-- cmd/xfer.go | 5 +- docs/testing.md | 3 -- go.sum | 1 + relayer/chain.go | 7 +-- relayer/channel-tx.go | 37 ++++++++------- relayer/client-tx.go | 18 +++++++- relayer/connection-tx.go | 20 ++++---- relayer/headers.go | 6 +-- relayer/naive-strategy.go | 31 ++++++++----- relayer/packet-tx.go | 16 ------- relayer/path.go | 6 --- relayer/pathEnd.go | 8 +++- relayer/query.go | 81 ++++++++++++++++----------------- relayer/verifier.go | 4 +- test/relayer_agoric_test.go | 4 -- test/relayer_coco_test.go | 4 -- test/relayer_gaia_test.go | 4 -- test/relayer_mtd_test.go | 4 -- test/relayer_rocketzone_test.go | 4 -- test/test_queries.go | 2 +- 28 files changed, 139 insertions(+), 171 deletions(-) diff --git a/cmd/errors.go b/cmd/errors.go index 251d8ff01..d9a4fe362 100644 --- a/cmd/errors.go +++ b/cmd/errors.go @@ -9,10 +9,6 @@ func wrapInitFailed(err error) error { return fmt.Errorf("init failed: %w", err) } -func wrapIncorrectURL(err error) error { - return fmt.Errorf("incorrect URL: %w", err) -} - func errKeyExists(name string) error { return fmt.Errorf("a key with name %s already exists", name) } diff --git a/cmd/flags.go b/cmd/flags.go index 4954f39a7..479ec8011 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -12,7 +12,6 @@ var ( flagHash = "hash" flagURL = "url" flagForce = "force" - flagFlags = "flags" flagTimeout = "timeout" flagConfig = "config" flagJSON = "json" @@ -146,14 +145,6 @@ func forceFlag(cmd *cobra.Command) *cobra.Command { return cmd } -func flagsFlag(cmd *cobra.Command) *cobra.Command { - cmd.Flags().BoolP(flagFlags, "f", false, "pass flag to output the flags for light init/update") - if err := viper.BindPFlag(flagFlags, cmd.Flags().Lookup(flagFlags)); err != nil { - panic(err) - } - return cmd -} - func getTimeout(cmd *cobra.Command) (time.Duration, error) { to, err := cmd.Flags().GetString(flagTimeout) if err != nil { diff --git a/cmd/light.go b/cmd/light.go index 5366d7ee5..27e628279 100644 --- a/cmd/light.go +++ b/cmd/light.go @@ -133,8 +133,9 @@ func lightHeaderCmd() *cobra.Command { Use: "header [chain-id] [[height]]", Aliases: []string{"hdr"}, Short: "Get a header from the light client database", - Long: "Get a header from the light client database. 0 returns last trusted header and all others return the header at that height if stored", - Args: cobra.RangeArgs(1, 2), + Long: "Get a header from the light client database. 0 returns last" + + "trusted header and all others return the header at that height if stored", + Args: cobra.RangeArgs(1, 2), RunE: func(cmd *cobra.Command, args []string) error { chainID := args[0] chain, err := config.Chains.Get(chainID) diff --git a/cmd/paths.go b/cmd/paths.go index bfcb39c59..33df21c3a 100644 --- a/cmd/paths.go +++ b/cmd/paths.go @@ -102,7 +102,7 @@ func pathsGenCmd() *cobra.Command { for _, c := range srcClients.ClientStates { // TODO: support other client types through a switch here as they become available clnt, _ := clientTypes.UnpackClientState(c.ClientState) - if relayer.MustGetHeight(clnt.GetLatestHeight()) != 0 && !clnt.IsFrozen() { // TODO: re-enable this check && clnt.GetChainID() == dst { + if relayer.MustGetHeight(clnt.GetLatestHeight()) != 0 && !clnt.IsFrozen() { path.Src.ClientID = c.ClientId } } @@ -115,7 +115,7 @@ func pathsGenCmd() *cobra.Command { for _, c := range dstClients.ClientStates { // TODO: support other client types through a switch here as they become available clnt, _ := clientTypes.UnpackClientState(c.ClientState) - if relayer.MustGetHeight(clnt.GetLatestHeight()) != 0 && !clnt.IsFrozen() { // TODO: re-enable this check && clnt.GetChainID() == src { + if relayer.MustGetHeight(clnt.GetLatestHeight()) != 0 && !clnt.IsFrozen() { path.Dst.ClientID = c.ClientId } } diff --git a/cmd/query.go b/cmd/query.go index 1e9a44cbb..d9101ab18 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -605,12 +605,12 @@ func queryUnrelayed() *cobra.Command { return err } - strat, err := path.GetStrategy() + strategy, err := path.GetStrategy() if err != nil { return err } - sp, err := strat.UnrelayedSequencesOrdered(c[src], c[dst], sh) + sp, err := strategy.UnrelayedSequencesOrdered(c[src], c[dst], sh) if err != nil { return err } diff --git a/cmd/raw.go b/cmd/raw.go index a0f5bcc7e..128adf8cc 100644 --- a/cmd/raw.go +++ b/cmd/raw.go @@ -252,7 +252,11 @@ func connAck() *cobra.Command { return err } txs := []sdk.Msg{ - chains[src].PathEnd.ConnAck(chains[dst].PathEnd, dstClientStateResponse, dstState, dstConsState, chains[src].MustGetAddress()), + chains[src].PathEnd.ConnAck( + chains[dst].PathEnd, + dstClientStateResponse, + dstState, dstConsState, + chains[src].MustGetAddress()), chains[src].PathEnd.UpdateClient(updateHeader, chains[src].MustGetAddress()), } diff --git a/cmd/root.go b/cmd/root.go index 00debb771..7705efbb1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -21,7 +21,6 @@ import ( "strings" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/codec" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -36,8 +35,6 @@ var ( debug bool config *Config defaultHome = os.ExpandEnv("$HOME/.relayer") - cdc *codec.LegacyAmino - appCodec *codec.JSONMarshaler // Default identifiers for dummy usage dcli = "defaultclientid" diff --git a/cmd/tx.go b/cmd/tx.go index 952a7dd76..50546fa3b 100644 --- a/cmd/tx.go +++ b/cmd/tx.go @@ -57,8 +57,9 @@ func createClientsCmd() *cobra.Command { Use: "clients [path-name]", Aliases: []string{"clnts"}, Short: "create a clients between two configured chains with a configured path", - Long: "Creates a working ibc client for chain configured on each end of the path by querying headers from each chain and then sending the cooresponding create-client messages", - Args: cobra.ExactArgs(1), + Long: "Creates a working ibc client for chain configured on each end of the" + + " path by querying headers from each chain and then sending the corresponding create-client messages", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, src, dst, err := config.ChainsFromPath(args[0]) if err != nil { @@ -76,8 +77,9 @@ func updateClientsCmd() *cobra.Command { Use: "update-clients [path-name]", Aliases: []string{"update", "uc"}, Short: "update a clients between two configured chains with a configured path", - Long: "Updates a working ibc client for chain configured on each end of the path by querying headers from each chain and then sending the cooresponding update-client messages", - Args: cobra.ExactArgs(1), + Long: "Updates a working ibc client for chain configured on each end of the " + + "path by querying headers from each chain and then sending the corresponding update-client messages", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { c, src, dst, err := config.ChainsFromPath(args[0]) if err != nil { diff --git a/cmd/xfer.go b/cmd/xfer.go index bd29bd44f..2bcb2d2f2 100644 --- a/cmd/xfer.go +++ b/cmd/xfer.go @@ -16,8 +16,9 @@ func xfersend() *cobra.Command { Use: "transfer [src-chain-id] [dst-chain-id] [amount] [dst-addr]", Short: "Initiate a transfer from one chain to another", Aliases: []string{"xfer", "txf"}, - Long: "Sends the first step to transfer tokens in an IBC transfer. The created packet must be relayed to another chain", - Args: cobra.ExactArgs(4), + Long: "Sends the first step to transfer tokens in an IBC transfer." + + " The created packet must be relayed to another chain", + Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) error { src, dst := args[0], args[1] c, err := config.Chains.Gets(src, dst) diff --git a/docs/testing.md b/docs/testing.md index 6bea93435..80ed5c81a 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -103,9 +103,6 @@ func TestGaiaToGaiaBasicTransfer(t *testing.T) { // Check if channel has been created, if not create it require.NoError(t, src.CreateChannel(dst, true, src.GetTimeout())) - // Then send the transfer - require.NoError(t, src.SendTransferBothSides(dst, testCoin, dst.MustGetAddress(), true)) - // ...and check the balance dstBal, err := dst.QueryBalance(dst.Key) require.NoError(t, err) diff --git a/go.sum b/go.sum index c219b8b68..11241fda2 100644 --- a/go.sum +++ b/go.sum @@ -126,6 +126,7 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/cosmos-sdk v0.34.4-0.20200916172701-e4c67eddc7e3 h1:lSH+OZ5w28ctEDtt8Hu6fLfDbEGmpudyw6YsM4jHQEs= github.com/cosmos/cosmos-sdk v0.34.4-0.20200916172701-e4c67eddc7e3/go.mod h1:kO3VV10paWHqHnDJ8GteH2AKGAcv+Lpdy9+oWEKNUn4= +github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac= 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/iavl v0.15.0-rc3 h1:rSm60IFfDCD9qDfvXKEmaJhcv0rB5uCbVlBDKsynxqw= diff --git a/relayer/chain.go b/relayer/chain.go index 0df1399f5..27c765504 100644 --- a/relayer/chain.go +++ b/relayer/chain.go @@ -186,11 +186,6 @@ func (c *Chain) KeyExists(name string) bool { return k.GetName() == name } -func (c *Chain) getGasPrices() sdk.DecCoins { - gp, _ := sdk.ParseDecCoins(c.GasPrices) - return gp -} - // GetTrustingPeriod returns the trusting period for the chain func (c *Chain) GetTrustingPeriod() time.Duration { tp, _ := time.ParseDuration(c.TrustingPeriod) @@ -231,7 +226,7 @@ func (c *Chain) SendMsgs(msgs []sdk.Msg) (res *sdk.TxResponse, err error) { return nil, err } - // If users pass gas adjustment, then caclulate gas + // If users pass gas adjustment, then calculate gas // TODO: make all txs estimate/ _, adjusted, err := tx.CalculateGas(ctx.QueryWithData, txf, msgs...) if err != nil { diff --git a/relayer/channel-tx.go b/relayer/channel-tx.go index 78a041306..dac6d0e5b 100644 --- a/relayer/channel-tx.go +++ b/relayer/channel-tx.go @@ -5,7 +5,6 @@ import ( "time" chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" - chantypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" "golang.org/x/sync/errgroup" ) @@ -13,11 +12,11 @@ import ( // CreateChannel runs the channel creation messages on timeout until they pass // TODO: add max retries or something to this function func (c *Chain) CreateChannel(dst *Chain, ordered bool, to time.Duration) error { - var order chantypes.Order + var order chanTypes.Order if ordered { - order = chantypes.ORDERED + order = chanTypes.ORDERED } else { - order = chantypes.UNORDERED + order = chanTypes.UNORDERED } ticker := time.NewTicker(to) @@ -70,7 +69,7 @@ func (c *Chain) CreateChannel(dst *Chain, ordered bool, to time.Duration) error // CreateChannelStep returns the next set of messages for creating a channel with given // identifiers between chains src and dst. If the handshake hasn't started, then CreateChannelStep // will begin the handshake on the src chain -func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayMsgs, error) { +func (c *Chain) CreateChannelStep(dst *Chain, ordering chanTypes.Order) (*RelayMsgs, error) { out := NewRelayMsgs() if err := ValidatePaths(c, dst); err != nil { return nil, err @@ -104,7 +103,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM switch { // Handshake hasn't been started on src or dst, relay `chanOpenInit` to src - case srcChan.Channel.State == chantypes.UNINITIALIZED && dstChan.Channel.State == chantypes.UNINITIALIZED: + case srcChan.Channel.State == chanTypes.UNINITIALIZED && dstChan.Channel.State == chanTypes.UNINITIALIZED: if c.debug { logChannelStates(c, dst, srcChan, dstChan) } @@ -113,7 +112,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM ) // Handshake has started on dst (1 step done), relay `chanOpenTry` and `updateClient` to src - case srcChan.Channel.State == chantypes.UNINITIALIZED && dstChan.Channel.State == chantypes.INIT: + case srcChan.Channel.State == chanTypes.UNINITIALIZED && dstChan.Channel.State == chanTypes.INIT: if c.debug { logChannelStates(c, dst, srcChan, dstChan) } @@ -123,7 +122,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM ) // Handshake has started on src (1 step done), relay `chanOpenTry` and `updateClient` to dst - case srcChan.Channel.State == chantypes.INIT && dstChan.Channel.State == chantypes.UNINITIALIZED: + case srcChan.Channel.State == chanTypes.INIT && dstChan.Channel.State == chanTypes.UNINITIALIZED: if dst.debug { logChannelStates(dst, c, dstChan, srcChan) } @@ -133,7 +132,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM ) // Handshake has started on src (2 steps done), relay `chanOpenAck` and `updateClient` to dst - case srcChan.Channel.State == chantypes.TRYOPEN && dstChan.Channel.State == chantypes.INIT: + case srcChan.Channel.State == chanTypes.TRYOPEN && dstChan.Channel.State == chanTypes.INIT: if dst.debug { logChannelStates(dst, c, dstChan, srcChan) } @@ -143,7 +142,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM ) // Handshake has started on dst (2 steps done), relay `chanOpenAck` and `updateClient` to src - case srcChan.Channel.State == chantypes.INIT && dstChan.Channel.State == chantypes.TRYOPEN: + case srcChan.Channel.State == chanTypes.INIT && dstChan.Channel.State == chanTypes.TRYOPEN: if c.debug { logChannelStates(c, dst, srcChan, dstChan) } @@ -153,7 +152,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM ) // Handshake has confirmed on dst (3 steps done), relay `chanOpenConfirm` and `updateClient` to src - case srcChan.Channel.State == chantypes.TRYOPEN && dstChan.Channel.State == chantypes.OPEN: + case srcChan.Channel.State == chanTypes.TRYOPEN && dstChan.Channel.State == chanTypes.OPEN: if c.debug { logChannelStates(c, dst, srcChan, dstChan) } @@ -164,7 +163,7 @@ func (c *Chain) CreateChannelStep(dst *Chain, ordering chantypes.Order) (*RelayM out.last = true // Handshake has confirmed on src (3 steps done), relay `chanOpenConfirm` and `updateClient` to dst - case srcChan.Channel.State == chantypes.OPEN && dstChan.Channel.State == chantypes.TRYOPEN: + case srcChan.Channel.State == chanTypes.OPEN && dstChan.Channel.State == chanTypes.TRYOPEN: if dst.debug { logChannelStates(dst, c, dstChan, srcChan) } @@ -251,8 +250,8 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { switch { // Closing handshake has not started, relay `updateClient` and `chanCloseInit` to src or dst according // to the channel state - case srcChan.Channel.State != chantypes.CLOSED && dstChan.Channel.State != chantypes.CLOSED: - if srcChan.Channel.State != chantypes.UNINITIALIZED { + case srcChan.Channel.State != chanTypes.CLOSED && dstChan.Channel.State != chanTypes.CLOSED: + if srcChan.Channel.State != chanTypes.UNINITIALIZED { if c.debug { logChannelStates(c, dst, srcChan, dstChan) } @@ -260,7 +259,7 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ChanCloseInit(c.MustGetAddress()), ) - } else if dstChan.Channel.State != chantypes.UNINITIALIZED { + } else if dstChan.Channel.State != chanTypes.UNINITIALIZED { if dst.debug { logChannelStates(dst, c, dstChan, srcChan) } @@ -271,8 +270,8 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { } // Closing handshake has started on src, relay `updateClient` and `chanCloseConfirm` to dst - case srcChan.Channel.State == chantypes.CLOSED && dstChan.Channel.State != chantypes.CLOSED: - if dstChan.Channel.State != chantypes.UNINITIALIZED { + case srcChan.Channel.State == chanTypes.CLOSED && dstChan.Channel.State != chanTypes.CLOSED: + if dstChan.Channel.State != chanTypes.UNINITIALIZED { if dst.debug { logChannelStates(dst, c, dstChan, srcChan) } @@ -284,8 +283,8 @@ func (c *Chain) CloseChannelStep(dst *Chain) (*RelayMsgs, error) { } // Closing handshake has started on dst, relay `updateClient` and `chanCloseConfirm` to src - case dstChan.Channel.State == chantypes.CLOSED && srcChan.Channel.State != chantypes.CLOSED: - if srcChan.Channel.State != chantypes.UNINITIALIZED { + case dstChan.Channel.State == chanTypes.CLOSED && srcChan.Channel.State != chanTypes.CLOSED: + if srcChan.Channel.State != chanTypes.UNINITIALIZED { if c.debug { logChannelStates(c, dst, srcChan, dstChan) } diff --git a/relayer/client-tx.go b/relayer/client-tx.go index b11762bcc..94bfdf976 100644 --- a/relayer/client-tx.go +++ b/relayer/client-tx.go @@ -29,7 +29,14 @@ func (c *Chain) CreateClients(dst *Chain) (err error) { if err != nil { return err } - clients.Src = append(clients.Src, c.PathEnd.CreateClient(dstH, dst.GetTrustingPeriod(), ubdPeriod, c.MustGetAddress())) + clients.Src = append( + clients.Src, + c.PathEnd.CreateClient( + dstH, + dst.GetTrustingPeriod(), + ubdPeriod, + c.MustGetAddress(), + )) } return nil }) @@ -44,7 +51,14 @@ func (c *Chain) CreateClients(dst *Chain) (err error) { if err != nil { return err } - clients.Dst = append(clients.Dst, dst.PathEnd.CreateClient(srcH, c.GetTrustingPeriod(), ubdPeriod, dst.MustGetAddress())) + clients.Dst = append( + clients.Dst, + dst.PathEnd.CreateClient( + srcH, + c.GetTrustingPeriod(), + ubdPeriod, + dst.MustGetAddress(), + )) } return nil }) diff --git a/relayer/connection-tx.go b/relayer/connection-tx.go index 00cff35ca..5a2efacb0 100644 --- a/relayer/connection-tx.go +++ b/relayer/connection-tx.go @@ -6,7 +6,6 @@ import ( clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" connTypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" - ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" ibcExported "github.com/cosmos/cosmos-sdk/x/ibc/exported" "golang.org/x/sync/errgroup" @@ -106,7 +105,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { return nil, err } - if !(srcConn.Connection.State == ibctypes.UNINITIALIZED && dstConn.Connection.State == ibctypes.UNINITIALIZED) { + if !(srcConn.Connection.State == connTypes.UNINITIALIZED && dstConn.Connection.State == connTypes.UNINITIALIZED) { // Query client state from each chain's client srcCsRes, dstCsRes, err = QueryClientStatePair(c, dst, srch.Header.Height-1, dsth.Header.Height-1) if err != nil && (srcCsRes == nil || dstCsRes == nil) { @@ -126,7 +125,8 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { // NOTE: We query connection at height - 1 because of the way tendermint returns // proofs the commit for height n is contained in the header of height n + 1 - srcCons, dstCons, err = QueryClientConsensusStatePair(c, dst, srch.Header.Height-1, dsth.Header.Height-1, srcConsH, dstConsH) + srcCons, dstCons, err = QueryClientConsensusStatePair( + c, dst, srch.Header.Height-1, dsth.Header.Height-1, srcConsH, dstConsH) if err != nil { return nil, err } @@ -134,14 +134,14 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { switch { // Handshake hasn't been started on src or dst, relay `connOpenInit` to src - case srcConn.Connection.State == ibctypes.UNINITIALIZED && dstConn.Connection.State == ibctypes.UNINITIALIZED: + case srcConn.Connection.State == connTypes.UNINITIALIZED && dstConn.Connection.State == connTypes.UNINITIALIZED: if c.debug { logConnectionStates(c, dst, srcConn, dstConn) } out.Src = append(out.Src, c.PathEnd.ConnInit(dst.PathEnd, c.MustGetAddress())) // Handshake has started on dst (1 stepdone), relay `connOpenTry` and `updateClient` on src - case srcConn.Connection.State == ibctypes.UNINITIALIZED && dstConn.Connection.State == ibctypes.INIT: + case srcConn.Connection.State == connTypes.UNINITIALIZED && dstConn.Connection.State == connTypes.INIT: if c.debug { logConnectionStates(c, dst, srcConn, dstConn) } @@ -152,7 +152,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { ) // Handshake has started on src (1 step done), relay `connOpenTry` and `updateClient` on dst - case srcConn.Connection.State == ibctypes.INIT && dstConn.Connection.State == ibctypes.UNINITIALIZED: + case srcConn.Connection.State == connTypes.INIT && dstConn.Connection.State == connTypes.UNINITIALIZED: if dst.debug { logConnectionStates(dst, c, dstConn, srcConn) } @@ -163,7 +163,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { ) // Handshake has started on src end (2 steps done), relay `connOpenAck` and `updateClient` to dst end - case srcConn.Connection.State == ibctypes.TRYOPEN && dstConn.Connection.State == ibctypes.INIT: + case srcConn.Connection.State == connTypes.TRYOPEN && dstConn.Connection.State == connTypes.INIT: if dst.debug { logConnectionStates(dst, c, dstConn, srcConn) } @@ -173,7 +173,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { ) // Handshake has started on dst end (2 steps done), relay `connOpenAck` and `updateClient` to src end - case srcConn.Connection.State == ibctypes.INIT && dstConn.Connection.State == ibctypes.TRYOPEN: + case srcConn.Connection.State == connTypes.INIT && dstConn.Connection.State == connTypes.TRYOPEN: if c.debug { logConnectionStates(c, dst, srcConn, dstConn) } @@ -183,7 +183,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { ) // Handshake has confirmed on dst (3 steps done), relay `connOpenConfirm` and `updateClient` to src end - case srcConn.Connection.State == ibctypes.TRYOPEN && dstConn.Connection.State == ibctypes.OPEN: + case srcConn.Connection.State == connTypes.TRYOPEN && dstConn.Connection.State == connTypes.OPEN: if c.debug { logConnectionStates(c, dst, srcConn, dstConn) } @@ -194,7 +194,7 @@ func (c *Chain) CreateConnectionStep(dst *Chain) (*RelayMsgs, error) { out.last = true // Handshake has confirmed on src (3 steps done), relay `connOpenConfirm` and `updateClient` to dst end - case srcConn.Connection.State == ibctypes.OPEN && dstConn.Connection.State == ibctypes.TRYOPEN: + case srcConn.Connection.State == connTypes.OPEN && dstConn.Connection.State == connTypes.TRYOPEN: if dst.debug { logConnectionStates(dst, c, dstConn, srcConn) } diff --git a/relayer/headers.go b/relayer/headers.go index 10d857ea4..2a3b15e5f 100644 --- a/relayer/headers.go +++ b/relayer/headers.go @@ -43,6 +43,7 @@ func (uh *SyncHeaders) Update(c *Chain) error { func (uh *SyncHeaders) Updates(c ...*Chain) error { eg := new(errgroup.Group) for _, chain := range c { + chain := chain eg.Go(func() error { return uh.Update(chain) }) @@ -107,10 +108,7 @@ func (uh *SyncHeaders) GetTrustedHeaders(src, dst *Chain) (srcTh, dstTh *tmclien func InjectTrustedFields(srcChain, dstChain *Chain, srcHeader *tmclient.Header) (*tmclient.Header, error) { // make copy of header stored in mop h := *(srcHeader) - // check that dstChain PathEnd set correctly - // if dstChain.PathEnd.ChainID != h.Header.ChainID { - // return nil, fmt.Errorf("counterparty chain has incorrect PathEnd. expected chainID: %s, got: %s", dstChain.PathEnd.ChainID, h.Header.ChainID) - // } + // retrieve counterparty client from dst chain counterpartyClientRes, err := dstChain.QueryClientState(0) if err != nil { diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index afabc66b1..42d8882be 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -8,6 +8,7 @@ import ( retry "github.com/avast/retry-go" sdk "github.com/cosmos/cosmos-sdk/types" + chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ctypes "github.com/tendermint/tendermint/rpc/core/types" "golang.org/x/sync/errgroup" ) @@ -44,22 +45,30 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea ) eg.Go(func() error { - res, err := src.QueryPacketCommitments(0, 1000, sh.GetHeight(src.ChainID)) - if err != nil { - return err - } - for _, pc := range res { + var res *chanTypes.QueryPacketCommitmentsResponse + retry.Do(func() error { + res, err = src.QueryPacketCommitments(0, 1000, sh.GetHeight(src.ChainID)) + if err != nil || res == nil { + return err + } + return nil + }) + for _, pc := range res.Commitments { srcPacketSeq = append(srcPacketSeq, pc.Sequence) } return nil }) eg.Go(func() error { - res, err := dst.QueryPacketCommitments(0, 1000, sh.GetHeight(dst.ChainID)) - if err != nil { - return err - } - for _, pc := range res { + var res *chanTypes.QueryPacketCommitmentsResponse + retry.Do(func() error { + res, err = dst.QueryPacketCommitments(0, 1000, sh.GetHeight(dst.ChainID)) + if err != nil || res == nil { + return err + } + return nil + }) + for _, pc := range res.Commitments { dstPacketSeq = append(dstPacketSeq, pc.Sequence) } return nil @@ -428,7 +437,7 @@ func relayPacketFromQueryResponse(src, dst *PathEnd, res *ctypes.ResultTx, } } if string(p.Key) == "packet_data" { - rp.packetData = []byte(p.Value) + rp.packetData = p.Value } if string(p.Key) == "packet_timeout_height" { timeout, _ := strconv.ParseUint(strings.Split(string(p.Value), "-")[1], 10, 64) diff --git a/relayer/packet-tx.go b/relayer/packet-tx.go index 50399d8c1..63255a2e7 100644 --- a/relayer/packet-tx.go +++ b/relayer/packet-tx.go @@ -2,7 +2,6 @@ package relayer import ( "fmt" - "time" sdk "github.com/cosmos/cosmos-sdk/types" commitmentypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" @@ -10,25 +9,10 @@ import ( var ( defaultChainPrefix = commitmentypes.NewMerklePrefix([]byte("ibc")) - defaultIBCVersion = "1.0.0" - defaultIBCVersions = []string{defaultIBCVersion} - defaultUnbondingTime = time.Hour * 504 // 3 weeks in hours - defaultMaxClockDrift = time.Second * 10 - defaultPacketTimeout = 1000 defaultPacketSendQuery = "send_packet.packet_src_channel=%s&send_packet.packet_sequence=%d" // defaultPacketAckQuery = "recv_packet.packet_src_channel=%s&recv_packet.packet_sequence=%d" ) -func defaultPacketTimeoutStamp() uint64 { - return uint64(time.Now().Add(time.Hour * 12).UnixNano()) -} - -// SendTransferBothSides sends a ICS20 packet from src to dst -func (c *Chain) SendTransferBothSides(dst *Chain, amount sdk.Coin, - dstAddr fmt.Stringer, source bool) error { - return nil -} - // SendTransferMsg initiates an ibs20 transfer from src to dst with the specified args func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringer) error { h, err := dst.UpdateLightWithHeader() diff --git a/relayer/path.go b/relayer/path.go index 600b01582..6a8ef50d3 100644 --- a/relayer/path.go +++ b/relayer/path.go @@ -8,12 +8,6 @@ import ( chantypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ) -var ( // Default identifiers for dummy usage - dcon = "defaultconnectionid" - dcha = "defaultchannelid" - dpor = "defaultportid" -) - // Paths represent connection paths between chains type Paths map[string]*Path diff --git a/relayer/pathEnd.go b/relayer/pathEnd.go index 4ad0a4a5f..780998125 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -11,6 +11,7 @@ import ( chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" + "github.com/cosmos/cosmos-sdk/x/ibc/exported" "github.com/tendermint/tendermint/light" ) @@ -46,7 +47,7 @@ func (pe *PathEnd) getOrder() chanTypes.Order { } // UpdateClient creates an sdk.Msg to update the client on src with data pulled from dst -func (pe *PathEnd) UpdateClient(dstHeader *tmclient.Header, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) UpdateClient(dstHeader exported.Header, signer sdk.AccAddress) sdk.Msg { if err := dstHeader.ValidateBasic(); err != nil { panic(err) } @@ -62,7 +63,10 @@ func (pe *PathEnd) UpdateClient(dstHeader *tmclient.Header, signer sdk.AccAddres } // CreateClient creates an sdk.Msg to update the client on src with consensus state from dst -func (pe *PathEnd) CreateClient(dstHeader *tmclient.Header, trustingPeriod, unbondingPeriod time.Duration, signer sdk.AccAddress) sdk.Msg { +func (pe *PathEnd) CreateClient( + dstHeader *tmclient.Header, + trustingPeriod, unbondingPeriod time.Duration, + signer sdk.AccAddress) sdk.Msg { if err := dstHeader.ValidateBasic(); err != nil { panic(err) } diff --git a/relayer/query.go b/relayer/query.go index de647b3f6..7cbd072a8 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "strings" - "sync" "time" "github.com/cosmos/cosmos-sdk/store/rootmulti" @@ -19,7 +18,6 @@ import ( connUtils "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils" connTypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" chanUtils "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/client/utils" - "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" chanTypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" commitTypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" @@ -84,7 +82,8 @@ func (c *Chain) QueryConsensusState(height int64) (*tmclient.ConsensusState, int } // QueryClientConsensusState retrevies the latest consensus state for a client in state at a given height -func (c *Chain) QueryClientConsensusState(height, dstClientConsHeight int64) (*clientTypes.QueryConsensusStateResponse, error) { +func (c *Chain) QueryClientConsensusState( + height, dstClientConsHeight int64) (*clientTypes.QueryConsensusStateResponse, error) { return clientUtils.QueryConsensusStateABCI( c.CLIContext(height), c.PathEnd.ClientID, @@ -93,7 +92,10 @@ func (c *Chain) QueryClientConsensusState(height, dstClientConsHeight int64) (*c } // QueryClientConsensusStatePair allows for the querying of multiple client states at the same time -func QueryClientConsensusStatePair(src, dst *Chain, srch, dsth, srcClientConsH, dstClientConsH int64) (srcCsRes, dstCsRes *clientTypes.QueryConsensusStateResponse, err error) { +func QueryClientConsensusStatePair( + src, dst *Chain, + srch, dsth, srcClientConsH, + dstClientConsH int64) (srcCsRes, dstCsRes *clientTypes.QueryConsensusStateResponse, err error) { var eg = new(errgroup.Group) eg.Go(func() error { srcCsRes, err = src.QueryClientConsensusState(srch, srcClientConsH) @@ -113,7 +115,9 @@ func (c *Chain) QueryClientState(height int64) (*clientTypes.QueryClientStateRes } // QueryClientStatePair returns a pair of connection responses -func QueryClientStatePair(src, dst *Chain, srch, dsth int64) (srcCsRes, dstCsRes *clientTypes.QueryClientStateResponse, err error) { +func QueryClientStatePair( + src, dst *Chain, + srch, dsth int64) (srcCsRes, dstCsRes *clientTypes.QueryClientStateResponse, err error) { var eg = new(errgroup.Group) eg.Go(func() error { srcCsRes, err = src.QueryClientState(srch) @@ -129,7 +133,8 @@ func QueryClientStatePair(src, dst *Chain, srch, dsth int64) (srcCsRes, dstCsRes // QueryClients queries all the clients! func (c *Chain) QueryClients(offset, limit uint64) (*clientTypes.QueryClientStatesResponse, error) { - res, err := clientTypes.NewQueryClient(c.CLIContext(0)).ClientStates(context.Background(), &clientTypes.QueryClientStatesRequest{ + qc := clientTypes.NewQueryClient(c.CLIContext(0)) + res, err := qc.ClientStates(context.Background(), &clientTypes.QueryClientStatesRequest{ Pagination: &query.PageRequest{ Key: []byte(""), Offset: offset, @@ -145,8 +150,10 @@ func (c *Chain) QueryClients(offset, limit uint64) (*clientTypes.QueryClientStat // //////////////////////////// // QueryConnections gets any connections on a chain -func (c *Chain) QueryConnections(offset, limit uint64) (conns *connTypes.QueryConnectionsResponse, err error) { - res, err := connTypes.NewQueryClient(c.CLIContext(0)).Connections(context.Background(), &connTypes.QueryConnectionsRequest{ +func (c *Chain) QueryConnections( + offset, limit uint64) (conns *connTypes.QueryConnectionsResponse, err error) { + qc := connTypes.NewQueryClient(c.CLIContext(0)) + res, err := qc.Connections(context.Background(), &connTypes.QueryConnectionsRequest{ Pagination: &query.PageRequest{ Key: []byte(""), Offset: offset, @@ -158,7 +165,8 @@ func (c *Chain) QueryConnections(offset, limit uint64) (conns *connTypes.QueryCo } // QueryConnectionsUsingClient gets any connections that exist between chain and counterparty -func (c *Chain) QueryConnectionsUsingClient(height int64) (clientConns *connTypes.QueryClientConnectionsResponse, err error) { +func (c *Chain) QueryConnectionsUsingClient( + height int64) (clientConns *connTypes.QueryClientConnectionsResponse, err error) { return connUtils.QueryClientConnections(c.CLIContext(height), c.PathEnd.ClientID, true) } @@ -190,7 +198,9 @@ var emptyConnRes = connTypes.NewQueryConnectionResponse( ) // QueryConnectionPair returns a pair of connection responses -func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (srcConn, dstConn *connTypes.QueryConnectionResponse, err error) { +func QueryConnectionPair( + src, dst *Chain, + srcH, dstH int64) (srcConn, dstConn *connTypes.QueryConnectionResponse, err error) { var eg = new(errgroup.Group) eg.Go(func() error { srcConn, err = src.QueryConnection(srcH) @@ -209,8 +219,11 @@ func QueryConnectionPair(src, dst *Chain, srcH, dstH int64) (srcConn, dstConn *c // //////////////////////////// // QueryConnectionChannels queries the channels associated with a connection -func (c *Chain) QueryConnectionChannels(connectionID string, offset, limit uint64) (*chanTypes.QueryConnectionChannelsResponse, error) { - res, err := chanTypes.NewQueryClient(c.CLIContext(0)).ConnectionChannels(context.Background(), &chanTypes.QueryConnectionChannelsRequest{ +func (c *Chain) QueryConnectionChannels( + connectionID string, + offset, limit uint64) (*chanTypes.QueryConnectionChannelsResponse, error) { + qc := chanTypes.NewQueryClient(c.CLIContext(0)) + return qc.ConnectionChannels(context.Background(), &chanTypes.QueryConnectionChannelsRequest{ Connection: connectionID, Pagination: &query.PageRequest{ Key: []byte(""), @@ -219,7 +232,6 @@ func (c *Chain) QueryConnectionChannels(connectionID string, offset, limit uint6 CountTotal: true, }, }) - return res, err } // QueryChannel returns the channel associated with a channelID @@ -267,7 +279,8 @@ func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (srcChan, dstChan *chan // QueryChannels returns all the channels that are registered on a chain func (c *Chain) QueryChannels(offset, limit uint64) (*chanTypes.QueryChannelsResponse, error) { - res, err := types.NewQueryClient(c.CLIContext(0)).Channels(context.Background(), &types.QueryChannelsRequest{ + qc := chanTypes.NewQueryClient(c.CLIContext(0)) + res, err := qc.Channels(context.Background(), &chanTypes.QueryChannelsRequest{ Pagination: &query.PageRequest{ Key: []byte(""), Offset: offset, @@ -280,7 +293,8 @@ func (c *Chain) QueryChannels(offset, limit uint64) (*chanTypes.QueryChannelsRes // QueryChannelClient returns the client state of the client supporting a given channel func (c *Chain) QueryChannelClient() (*chanTypes.QueryChannelClientStateResponse, error) { - return types.NewQueryClient(c.CLIContext(0)).ChannelClientState(context.Background(), &types.QueryChannelClientStateRequest{ + qc := chanTypes.NewQueryClient(c.CLIContext(0)) + return qc.ChannelClientState(context.Background(), &chanTypes.QueryChannelClientStateRequest{ PortId: c.PathEnd.PortID, ChannelId: c.PathEnd.ChannelID, }) @@ -316,7 +330,8 @@ func (c *Chain) QueryDenomTraces(offset, limit uint64) (*xferTypes.QueryDenomTra // QueryHistoricalInfo returns historical header data func (c *Chain) QueryHistoricalInfo(height clientTypes.Height) (*stakingTypes.QueryHistoricalInfoResponse, error) { //TODO: use epoch number in query once SDK gets updated - return stakingTypes.NewQueryClient(c.CLIContext(int64(height.EpochHeight))).HistoricalInfo(context.Background(), &stakingTypes.QueryHistoricalInfoRequest{ + qc := stakingTypes.NewQueryClient(c.CLIContext(int64(height.EpochHeight))) + return qc.HistoricalInfo(context.Background(), &stakingTypes.QueryHistoricalInfoRequest{ Height: int64(height.EpochHeight), }) } @@ -381,13 +396,16 @@ func (c *Chain) QueryNextSeqRecv(height int64) (recvRes *chanTypes.QueryNextSequ } // QueryPacketCommitment returns the packet commitment proof at a given height -func (c *Chain) QueryPacketCommitment(height int64, seq uint64) (comRes *chanTypes.QueryPacketCommitmentResponse, err error) { +func (c *Chain) QueryPacketCommitment( + height int64, seq uint64) (comRes *chanTypes.QueryPacketCommitmentResponse, err error) { return chanUtils.QueryPacketCommitment(c.CLIContext(height), c.PathEnd.PortID, c.PathEnd.ChannelID, seq, true) } // QueryPacketCommitments returns an array of packet commitment proofs -func (c *Chain) QueryPacketCommitments(offset, limit, height uint64) (comRes []*chanTypes.PacketAckCommitment, err error) { - res, err := chanTypes.NewQueryClient(c.CLIContext(int64(height))).PacketCommitments(context.Background(), &types.QueryPacketCommitmentsRequest{ +func (c *Chain) QueryPacketCommitments( + offset, limit, height uint64) (comRes *chanTypes.QueryPacketCommitmentsResponse, err error) { + qc := chanTypes.NewQueryClient(c.CLIContext(int64(height))) + return qc.PacketCommitments(context.Background(), &chanTypes.QueryPacketCommitmentsRequest{ PortId: c.PathEnd.PortID, ChannelId: c.PathEnd.ChannelID, Pagination: &query.PageRequest{ @@ -396,12 +414,13 @@ func (c *Chain) QueryPacketCommitments(offset, limit, height uint64) (comRes []* CountTotal: true, }, }) - return res.Commitments, err + // return res.Commitments, err } // QueryUnrelayedPackets returns a list of unrelayed packet commitments func (c *Chain) QueryUnrelayedPackets(height uint64, seqs []uint64, acks bool) ([]uint64, error) { - res, err := chanTypes.NewQueryClient(c.CLIContext(int64(height))).UnrelayedPackets(context.Background(), &types.QueryUnrelayedPacketsRequest{ + qc := chanTypes.NewQueryClient(c.CLIContext(int64(height))) + res, err := qc.UnrelayedPackets(context.Background(), &chanTypes.QueryUnrelayedPacketsRequest{ PortId: c.PathEnd.PortID, ChannelId: c.PathEnd.ChannelID, PacketCommitmentSequences: seqs, @@ -500,22 +519,6 @@ func (c *Chain) QueryLatestHeight() (int64, error) { return res.SyncInfo.LatestBlockHeight, nil } -type heights struct { - sync.Mutex - Map map[string]int64 - Errs errs -} - -type errs []error - -func (e errs) err() error { - var out error - for _, err := range e { - out = fmt.Errorf("err: %w ", err) - } - return out -} - // QueryLatestHeights returns the heights of multiple chains at once func QueryLatestHeights(src, dst *Chain) (srch, dsth int64, err error) { var eg = new(errgroup.Group) @@ -623,7 +626,3 @@ func ParseEvents(e string) ([]string, error) { } return tmEvents, nil } - -func prefixClientKey(clientID string, key []byte) []byte { - return append([]byte(fmt.Sprintf("clients/%s/", clientID)), key...) -} diff --git a/relayer/verifier.go b/relayer/verifier.go index a1c762106..322b8fa91 100644 --- a/relayer/verifier.go +++ b/relayer/verifier.go @@ -30,7 +30,9 @@ import ( var logger = light.Logger(log.NewTMLogger(log.NewSyncWriter(ioutil.Discard))) // InjectTrustedFieldsHeaders takes the headers and enriches them -func InjectTrustedFieldsHeaders(src, dst *Chain, srch, dsth *tmclient.Header) (srcho *tmclient.Header, dstho *tmclient.Header, err error) { +func InjectTrustedFieldsHeaders( + src, dst *Chain, + srch, dsth *tmclient.Header) (srcho *tmclient.Header, dstho *tmclient.Header, err error) { var eg = new(errgroup.Group) eg.Go(func() error { srcho, err = InjectTrustedFields(src, dst, srch) diff --git a/test/relayer_agoric_test.go b/test/relayer_agoric_test.go index 5fa2d4695..5d62f8c2b 100644 --- a/test/relayer_agoric_test.go +++ b/test/relayer_agoric_test.go @@ -81,10 +81,6 @@ func TestAgoricToGaiaStreaming(t *testing.T) { require.NoError(t, err) require.Equal(t, dstExpected.AmountOf(dstDenom).Int64(), dstGot.AmountOf(dstDenom).Int64()) - // Test the full transfer command as well - require.NoError(t, src.SendTransferBothSides(dst, srcTestCoin, dst.MustGetAddress(), true)) - require.NoError(t, dst.SendTransferBothSides(src, srcTestCoin, src.MustGetAddress(), false)) - // check balance on src against expected srcGot, err = src.QueryBalance(src.Key) require.NoError(t, err) diff --git a/test/relayer_coco_test.go b/test/relayer_coco_test.go index 04fec8672..9e13790da 100644 --- a/test/relayer_coco_test.go +++ b/test/relayer_coco_test.go @@ -82,10 +82,6 @@ func TestCoCo_CoCoToFFtStreamingRelayer(t *testing.T) { require.NoError(t, err) require.Equal(t, dstExpected.AmountOf(testDenomDst).Int64(), dstGot.AmountOf(testDenomDst).Int64()) - // Test the full transfer command as well - require.NoError(t, src.SendTransferBothSides(dst, testCoinSrc, dst.MustGetAddress(), true)) - require.NoError(t, dst.SendTransferBothSides(src, testCoinSrc, src.MustGetAddress(), false)) - // check balance on src against expected srcGot, err = src.QueryBalance(src.Key) require.NoError(t, err) diff --git a/test/relayer_gaia_test.go b/test/relayer_gaia_test.go index 04b6d6598..731e6a7d3 100644 --- a/test/relayer_gaia_test.go +++ b/test/relayer_gaia_test.go @@ -82,10 +82,6 @@ func TestGaiaToGaiaStreamingRelayer(t *testing.T) { require.NoError(t, err) require.Equal(t, dstExpected.AmountOf(testDenom).Int64()-4000, dstGot.AmountOf(testDenom).Int64()) - // Test the full transfer command as well - require.NoError(t, src.SendTransferBothSides(dst, testCoin, dst.MustGetAddress(), true)) - require.NoError(t, dst.SendTransferBothSides(src, testCoin, src.MustGetAddress(), false)) - // check balance on src against expected srcGot, err = src.QueryBalance(src.Key) require.NoError(t, err) diff --git a/test/relayer_mtd_test.go b/test/relayer_mtd_test.go index 11f67ff9e..c53d83123 100644 --- a/test/relayer_mtd_test.go +++ b/test/relayer_mtd_test.go @@ -81,10 +81,6 @@ func TestMtdToGaiaStreaming(t *testing.T) { require.NoError(t, err) require.Equal(t, dstExpected.AmountOf(dstDenom).Int64(), dstGot.AmountOf(dstDenom).Int64()) - // Test the full transfer command as well - require.NoError(t, src.SendTransferBothSides(dst, srcTestCoin, dst.MustGetAddress(), true)) - require.NoError(t, dst.SendTransferBothSides(src, srcTestCoin, src.MustGetAddress(), false)) - // check balance on src against expected srcGot, err = src.QueryBalance(src.Key) require.NoError(t, err) diff --git a/test/relayer_rocketzone_test.go b/test/relayer_rocketzone_test.go index 240db3abc..f79a756a5 100644 --- a/test/relayer_rocketzone_test.go +++ b/test/relayer_rocketzone_test.go @@ -81,10 +81,6 @@ func TestRocket_GaiaToRocketStreamingRelayer(t *testing.T) { require.NoError(t, err) require.Equal(t, dstExpected.AmountOf(testDenomDst).Int64(), dstGot.AmountOf(testDenomDst).Int64()) - // Test the full transfer command as well - require.NoError(t, src.SendTransferBothSides(dst, testCoinSrc, dst.MustGetAddress(), true)) - require.NoError(t, dst.SendTransferBothSides(src, testCoinSrc, src.MustGetAddress(), false)) - // check balance on src against expected srcGot, err = src.QueryBalance(src.Key) require.NoError(t, err) diff --git a/test/test_queries.go b/test/test_queries.go index 3ba5780f0..150fb4acd 100644 --- a/test/test_queries.go +++ b/test/test_queries.go @@ -33,7 +33,7 @@ func testConnectionPair(t *testing.T, src, dst *ry.Chain) { // testConnection tests that the only connection on src has a counterparty that is the connection on dst func testConnection(t *testing.T, src, dst *ry.Chain) { - conns, err := src.QueryConnections(1, 1000) + conns, err := src.QueryConnections(0, 1000) require.NoError(t, err) require.Equal(t, len(conns.Connections), 1) // conns.Connections[0]. From b915e5eb20558378a4aa6e7a30653995c87647f3 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Wed, 16 Sep 2020 16:11:46 -0700 Subject: [PATCH 47/54] Remove old compatable chains, they will need to be re-added --- .github/workflows/coco-tests.yml | 35 ---------- .github/workflows/mtd-tests.yml | 28 -------- .github/workflows/rocketzone-tests.yml | 35 ---------- Makefile | 12 ---- README.md | 3 - test/relayer_agoric_test.go | 93 ------------------------- test/relayer_coco_test.go | 94 -------------------------- test/relayer_mtd_test.go | 93 ------------------------- test/relayer_rocketzone_test.go | 93 ------------------------- 9 files changed, 486 deletions(-) delete mode 100644 .github/workflows/coco-tests.yml delete mode 100644 .github/workflows/mtd-tests.yml delete mode 100644 .github/workflows/rocketzone-tests.yml delete mode 100644 test/relayer_agoric_test.go delete mode 100644 test/relayer_coco_test.go delete mode 100644 test/relayer_mtd_test.go delete mode 100644 test/relayer_rocketzone_test.go diff --git a/.github/workflows/coco-tests.yml b/.github/workflows/coco-tests.yml deleted file mode 100644 index 4e823dfd9..000000000 --- a/.github/workflows/coco-tests.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: TESTING - coco to ibc integration - -on: - pull_request: - push: - branches: - - master - -jobs: - build: - name: build - runs-on: ubuntu-latest - steps: - # Install and setup go - - name: Set up Go 1.14 - uses: actions/setup-go@v1 - with: - go-version: 1.14 - id: go - - # checkout relayer - - name: checkout relayer - uses: actions/checkout@v2 - - # build cache - - uses: actions/cache@v1 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - # run tests - - name: run coco tests - run: TEST_DEBUG=true make test-coco diff --git a/.github/workflows/mtd-tests.yml b/.github/workflows/mtd-tests.yml deleted file mode 100644 index 43bed8fee..000000000 --- a/.github/workflows/mtd-tests.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: TESTING - mtd to ibc integration - -on: - pull_request: - push: - branches: - - master - -jobs: - build: - name: build - runs-on: ubuntu-latest - steps: - # checkout relayer - - name: checkout relayer - uses: actions/checkout@v2 - - # build cache - - uses: actions/cache@v1 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - # run tests - - name: run mtd tests - run: make test-mtd diff --git a/.github/workflows/rocketzone-tests.yml b/.github/workflows/rocketzone-tests.yml deleted file mode 100644 index 1eea630a9..000000000 --- a/.github/workflows/rocketzone-tests.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: TESTING - rocketzone to ibc integration - -on: - pull_request: - push: - branches: - - master - -jobs: - build: - name: build - runs-on: ubuntu-latest - steps: - # Install and setup go - - name: Set up Go 1.14 - uses: actions/setup-go@v1 - with: - go-version: 1.14 - id: go - - # checkout relayer - - name: checkout relayer - uses: actions/checkout@v2 - - # build cache - - uses: actions/cache@v1 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - # run tests - - name: run rocketzone tests - run: make test-rocketzone diff --git a/Makefile b/Makefile index 9431ba1ec..11e4c261d 100644 --- a/Makefile +++ b/Makefile @@ -44,18 +44,6 @@ test: test-gaia: @TEST_DEBUG=true go test -mod=readonly -v ./test/... -run TestGaia* -test-mtd: - @TEST_DEBUG=true go test -mod=readonly -v ./test/... -run TestMtd* - -test-rocketzone: - @TEST_DEBUG=true go test -mod=readonly -v ./test/... -run TestRocket* - -test-agoric: - @TEST_DEBUG=true go test -mod=readonly -v ./test/... -run TestAgoric* - -test-coco: - @TEST_DEBUG=true go test -mod=readonly -v ./test/... -run TestCoCo* - coverage: @echo "viewing test coverage..." @go tool cover --html=coverage.out diff --git a/README.md b/README.md index 083954ce8..3a5c8e824 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,6 @@ If you would like to join the relayer testnet, please [check out the instruction | chain | tests | supported ports | |-------|--------|----------------| | [`gaia`](https://github.com/cosmos/gaia) | ![gaia](https://github.com/ovrclk/relayer/workflows/TESTING%20-%20gaia%20to%20gaia%20integration/badge.svg) | `transfer` | -| `microtick` | ![microtick](https://github.com/ovrclk/relayer/workflows/TESTING%20-%20mtd%20to%20ibc%20integration/badge.svg) | `transfer` | -| [`rocketzone`](https://github.com/rocket-protocol/rocketzone) | ![rocketzone](https://github.com/ovrclk/relayer/workflows/TESTING%20-%20rocketzone%20to%20ibc%20integration/badge.svg) | `transfer` | -| [`coco`](https://github.com/CosmicCompass/post-chain) | ![coco](https://github.com/CosmicCompass/relayer/workflows/TESTING%20-%20coco%20to%20ibc%20integration/badge.svg) | `transfer` | ## Demoing the Relayer diff --git a/test/relayer_agoric_test.go b/test/relayer_agoric_test.go deleted file mode 100644 index 5d62f8c2b..000000000 --- a/test/relayer_agoric_test.go +++ /dev/null @@ -1,93 +0,0 @@ -package test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ovrclk/relayer/relayer" - "github.com/stretchr/testify/require" -) - -var ( - agoricChains = []testChain{ - {"ibc0", gaiaTestConfig}, - {"ibc1", agoricTestConfig}, - } -) - -func TestAgoricToGaiaStreaming(t *testing.T) { - chains := spinUpTestChains(t, agoricChains...) - - var ( - src = chains.MustGet("ibc0") - dst = chains.MustGet("ibc1") - srcDenom = "samoleans" - dstDenom = "uagstake" - srcTestCoin = sdk.NewCoin(srcDenom, sdk.NewInt(1000)) - dstTestCoin = sdk.NewCoin(dstDenom, sdk.NewInt(1000)) - twoSrcTestCoin = sdk.NewCoin(srcDenom, sdk.NewInt(2000)) - twoDstTestCoin = sdk.NewCoin(dstDenom, sdk.NewInt(2000)) - ) - - path, err := genTestPathAndSet(src, dst, "transfer", "transfer") // FIGME: "relayertesttransfer") - require.NoError(t, err) - - // query initial balances to compare against at the end - srcExpected, err := src.QueryBalance(src.Key) - require.NoError(t, err) - dstExpected, err := dst.QueryBalance(dst.Key) - require.NoError(t, err) - - // create path - require.NoError(t, src.CreateClients(dst)) - testClientPair(t, src, dst) - require.NoError(t, src.CreateConnection(dst, src.GetTimeout())) - testConnectionPair(t, src, dst) - require.NoError(t, src.CreateChannel(dst, true, src.GetTimeout())) - testChannelPair(t, src, dst) - - // send a couple of transfers to the queue on src - require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress())) - require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress())) - - // send a couple of transfers to the queue on dst - require.NoError(t, dst.SendTransferMsg(src, dstTestCoin, src.MustGetAddress())) - require.NoError(t, dst.SendTransferMsg(src, dstTestCoin, src.MustGetAddress())) - - // Wait for message inclusion in both chains - require.NoError(t, dst.WaitForNBlocks(1)) - - // start the relayer process in it's own goroutine - rlyDone, err := relayer.RunStrategy(src, dst, path.MustGetStrategy(), path.Ordered()) - require.NoError(t, err) - - // send those tokens from dst back to dst and src back to src - require.NoError(t, src.SendTransferMsg(dst, twoDstTestCoin, dst.MustGetAddress())) - require.NoError(t, dst.SendTransferMsg(src, twoSrcTestCoin, src.MustGetAddress())) - - // wait for packet processing - require.NoError(t, dst.WaitForNBlocks(4)) - - // kill relayer routine - rlyDone() - - // check balance on src against expected - srcGot, err := src.QueryBalance(src.Key) - require.NoError(t, err) - require.Equal(t, srcExpected.AmountOf(srcDenom).Int64(), srcGot.AmountOf(srcDenom).Int64()) - - // check balance on dst against expected - dstGot, err := dst.QueryBalance(dst.Key) - require.NoError(t, err) - require.Equal(t, dstExpected.AmountOf(dstDenom).Int64(), dstGot.AmountOf(dstDenom).Int64()) - - // check balance on src against expected - srcGot, err = src.QueryBalance(src.Key) - require.NoError(t, err) - require.Equal(t, srcExpected.AmountOf(srcDenom).Int64(), srcGot.AmountOf(srcDenom).Int64()) - - // check balance on dst against expected - dstGot, err = dst.QueryBalance(dst.Key) - require.NoError(t, err) - require.Equal(t, dstExpected.AmountOf(dstDenom).Int64(), dstGot.AmountOf(dstDenom).Int64()) -} diff --git a/test/relayer_coco_test.go b/test/relayer_coco_test.go deleted file mode 100644 index 9e13790da..000000000 --- a/test/relayer_coco_test.go +++ /dev/null @@ -1,94 +0,0 @@ -package test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/ovrclk/relayer/relayer" - "github.com/stretchr/testify/require" -) - -var ( - cocoChains = []testChain{ - {"coco-post-chain", cocoTestConfig}, - {"ibc", gaiaTestConfig}, - } -) - -func TestCoCo_CoCoToFFtStreamingRelayer(t *testing.T) { - chains := spinUpTestChains(t, cocoChains...) - - var ( - src = chains.MustGet("coco-post-chain") - dst = chains.MustGet("ibc") - testDenomSrc = "mdm" - testDenomDst = "samoleans" - testCoinSrc = sdk.NewCoin(testDenomSrc, sdk.NewInt(1000)) - twoTestCoinSrc = sdk.NewCoin(testDenomSrc, sdk.NewInt(2000)) - testCoinDst = sdk.NewCoin(testDenomDst, sdk.NewInt(1000)) - twoTestCoinDst = sdk.NewCoin(testDenomDst, sdk.NewInt(2000)) - ) - - path, err := genTestPathAndSet(src, dst, "transfer", "transfer") - require.NoError(t, err) - - // query initial balances to compare against at the end - srcExpected, err := src.QueryBalance(src.Key) - require.NoError(t, err) - dstExpected, err := dst.QueryBalance(dst.Key) - require.NoError(t, err) - - // create path - require.NoError(t, src.CreateClients(dst)) - testClientPair(t, src, dst) - require.NoError(t, src.CreateConnection(dst, src.GetTimeout())) - testConnectionPair(t, src, dst) - require.NoError(t, src.CreateChannel(dst, true, src.GetTimeout())) - testChannelPair(t, src, dst) - - // send a couple of transfers to the queue on src - require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress())) - require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress())) - - // send a couple of transfers to the queue on dst - require.NoError(t, dst.SendTransferMsg(src, testCoinDst, src.MustGetAddress())) - require.NoError(t, dst.SendTransferMsg(src, testCoinDst, src.MustGetAddress())) - - // Wait for message inclusion in both chains - require.NoError(t, dst.WaitForNBlocks(1)) - - // start the relayer process in it's own goroutine - rlyDone, err := relayer.RunStrategy(src, dst, path.MustGetStrategy(), path.Ordered()) - require.NoError(t, err) - - // send those tokens from dst back to dst and src back to src - require.NoError(t, src.SendTransferMsg(dst, twoTestCoinDst, dst.MustGetAddress())) - require.NoError(t, dst.SendTransferMsg(src, twoTestCoinSrc, src.MustGetAddress())) - - // wait for packet processing - require.NoError(t, dst.WaitForNBlocks(4)) - - // kill relayer routine - rlyDone() - - // check balance on src against expected - srcGot, err := src.QueryBalance(src.Key) - require.NoError(t, err) - require.Equal(t, srcExpected.AmountOf(testDenomSrc).Int64(), srcGot.AmountOf(testDenomSrc).Int64()) - - // check balance on dst against expected - dstGot, err := dst.QueryBalance(dst.Key) - require.NoError(t, err) - require.Equal(t, dstExpected.AmountOf(testDenomDst).Int64(), dstGot.AmountOf(testDenomDst).Int64()) - - // check balance on src against expected - srcGot, err = src.QueryBalance(src.Key) - require.NoError(t, err) - require.Equal(t, srcExpected.AmountOf(testDenomSrc).Int64(), srcGot.AmountOf(testDenomSrc).Int64()) - - // check balance on dst against expected - dstGot, err = dst.QueryBalance(dst.Key) - require.NoError(t, err) - require.Equal(t, dstExpected.AmountOf(testDenomDst).Int64(), dstGot.AmountOf(testDenomDst).Int64()) -} diff --git a/test/relayer_mtd_test.go b/test/relayer_mtd_test.go deleted file mode 100644 index c53d83123..000000000 --- a/test/relayer_mtd_test.go +++ /dev/null @@ -1,93 +0,0 @@ -package test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ovrclk/relayer/relayer" - "github.com/stretchr/testify/require" -) - -var ( - mtdChains = []testChain{ - {"ibc0", gaiaTestConfig}, - {"ibc1", mtdTestConfig}, - } -) - -func TestMtdToGaiaStreaming(t *testing.T) { - chains := spinUpTestChains(t, mtdChains...) - - var ( - src = chains.MustGet("ibc0") - dst = chains.MustGet("ibc1") - srcDenom = "samoleans" - dstDenom = "fox" - srcTestCoin = sdk.NewCoin(srcDenom, sdk.NewInt(1000)) - dstTestCoin = sdk.NewCoin(dstDenom, sdk.NewInt(1000)) - twoSrcTestCoin = sdk.NewCoin(srcDenom, sdk.NewInt(2000)) - twoDstTestCoin = sdk.NewCoin(dstDenom, sdk.NewInt(2000)) - ) - - path, err := genTestPathAndSet(src, dst, "transfer", "transfer") - require.NoError(t, err) - - // query initial balances to compare against at the end - srcExpected, err := src.QueryBalance(src.Key) - require.NoError(t, err) - dstExpected, err := dst.QueryBalance(dst.Key) - require.NoError(t, err) - - // create path - require.NoError(t, src.CreateClients(dst)) - testClientPair(t, src, dst) - require.NoError(t, src.CreateConnection(dst, src.GetTimeout())) - testConnectionPair(t, src, dst) - require.NoError(t, src.CreateChannel(dst, true, src.GetTimeout())) - testChannelPair(t, src, dst) - - // send a couple of transfers to the queue on src - require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress())) - require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress())) - - // send a couple of transfers to the queue on dst - require.NoError(t, dst.SendTransferMsg(src, dstTestCoin, src.MustGetAddress())) - require.NoError(t, dst.SendTransferMsg(src, dstTestCoin, src.MustGetAddress())) - - // Wait for message inclusion in both chains - require.NoError(t, dst.WaitForNBlocks(1)) - - // start the relayer process in it's own goroutine - rlyDone, err := relayer.RunStrategy(src, dst, path.MustGetStrategy(), path.Ordered()) - require.NoError(t, err) - - // send those tokens from dst back to dst and src back to src - require.NoError(t, src.SendTransferMsg(dst, twoDstTestCoin, dst.MustGetAddress())) - require.NoError(t, dst.SendTransferMsg(src, twoSrcTestCoin, src.MustGetAddress())) - - // wait for packet processing - require.NoError(t, dst.WaitForNBlocks(4)) - - // kill relayer routine - rlyDone() - - // check balance on src against expected - srcGot, err := src.QueryBalance(src.Key) - require.NoError(t, err) - require.Equal(t, srcExpected.AmountOf(srcDenom).Int64(), srcGot.AmountOf(srcDenom).Int64()) - - // check balance on dst against expected - dstGot, err := dst.QueryBalance(dst.Key) - require.NoError(t, err) - require.Equal(t, dstExpected.AmountOf(dstDenom).Int64(), dstGot.AmountOf(dstDenom).Int64()) - - // check balance on src against expected - srcGot, err = src.QueryBalance(src.Key) - require.NoError(t, err) - require.Equal(t, srcExpected.AmountOf(srcDenom).Int64(), srcGot.AmountOf(srcDenom).Int64()) - - // check balance on dst against expected - dstGot, err = dst.QueryBalance(dst.Key) - require.NoError(t, err) - require.Equal(t, dstExpected.AmountOf(dstDenom).Int64(), dstGot.AmountOf(dstDenom).Int64()) -} diff --git a/test/relayer_rocketzone_test.go b/test/relayer_rocketzone_test.go deleted file mode 100644 index f79a756a5..000000000 --- a/test/relayer_rocketzone_test.go +++ /dev/null @@ -1,93 +0,0 @@ -package test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ovrclk/relayer/relayer" - "github.com/stretchr/testify/require" -) - -var ( - rocketChains = []testChain{ - {"ibc0", gaiaTestConfig}, - {"ibc1", rocketTestConfig}, - } -) - -func TestRocket_GaiaToRocketStreamingRelayer(t *testing.T) { - chains := spinUpTestChains(t, rocketChains...) - - var ( - src = chains.MustGet("ibc0") - dst = chains.MustGet("ibc1") - testDenomSrc = "samoleans" - testDenomDst = "nitro" - testCoinSrc = sdk.NewCoin(testDenomSrc, sdk.NewInt(1000)) - twoTestCoinSrc = sdk.NewCoin(testDenomSrc, sdk.NewInt(2000)) - testCoinDst = sdk.NewCoin(testDenomDst, sdk.NewInt(1000)) - twoTestCoinDst = sdk.NewCoin(testDenomDst, sdk.NewInt(2000)) - ) - - path, err := genTestPathAndSet(src, dst, "transfer", "transfer") - require.NoError(t, err) - - // query initial balances to compare against at the end - srcExpected, err := src.QueryBalance(src.Key) - require.NoError(t, err) - dstExpected, err := dst.QueryBalance(dst.Key) - require.NoError(t, err) - - // create path - require.NoError(t, src.CreateClients(dst)) - testClientPair(t, src, dst) - require.NoError(t, src.CreateConnection(dst, src.GetTimeout())) - testConnectionPair(t, src, dst) - require.NoError(t, src.CreateChannel(dst, true, src.GetTimeout())) - testChannelPair(t, src, dst) - - // send a couple of transfers to the queue on src - require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress())) - require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress())) - - // send a couple of transfers to the queue on dst - require.NoError(t, dst.SendTransferMsg(src, testCoinDst, src.MustGetAddress())) - require.NoError(t, dst.SendTransferMsg(src, testCoinDst, src.MustGetAddress())) - - // Wait for message inclusion in both chains - require.NoError(t, dst.WaitForNBlocks(1)) - - // start the relayer process in it's own goroutine - rlyDone, err := relayer.RunStrategy(src, dst, path.MustGetStrategy(), path.Ordered()) - require.NoError(t, err) - - // send those tokens from dst back to dst and src back to src - require.NoError(t, src.SendTransferMsg(dst, twoTestCoinDst, dst.MustGetAddress())) - require.NoError(t, dst.SendTransferMsg(src, twoTestCoinSrc, src.MustGetAddress())) - - // wait for packet processing - require.NoError(t, dst.WaitForNBlocks(4)) - - // kill relayer routine - rlyDone() - - // check balance on src against expected - srcGot, err := src.QueryBalance(src.Key) - require.NoError(t, err) - require.Equal(t, srcExpected.AmountOf(testDenomSrc).Int64(), srcGot.AmountOf(testDenomSrc).Int64()) - - // check balance on dst against expected - dstGot, err := dst.QueryBalance(dst.Key) - require.NoError(t, err) - require.Equal(t, dstExpected.AmountOf(testDenomDst).Int64(), dstGot.AmountOf(testDenomDst).Int64()) - - // check balance on src against expected - srcGot, err = src.QueryBalance(src.Key) - require.NoError(t, err) - require.Equal(t, srcExpected.AmountOf(testDenomSrc).Int64(), srcGot.AmountOf(testDenomSrc).Int64()) - - // check balance on dst against expected - dstGot, err = dst.QueryBalance(dst.Key) - require.NoError(t, err) - require.Equal(t, dstExpected.AmountOf(testDenomDst).Int64(), dstGot.AmountOf(testDenomDst).Int64()) -} From acdb1d198f774fc4ff5de038f6b09ec1adc17341 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Wed, 16 Sep 2020 16:13:16 -0700 Subject: [PATCH 48/54] Fix linter version in CI --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9db2a00c4..9a85a3044 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,6 +54,6 @@ jobs: - uses: golangci/golangci-lint-action@master with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.27 + version: v1.28 args: --timeout 10m github-token: ${{ secrets.github_token }} From 144de6c061810d2e4a6abb7346da957a030f4b1c Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Wed, 16 Sep 2020 16:34:53 -0700 Subject: [PATCH 49/54] Clean up chain fields --- cmd/chains.go | 4 +- cmd/dev.go | 4 +- configs/agoric.json | 5 +- configs/demo/ibc0.json | 2 +- configs/demo/ibc1.json | 2 +- configs/four/ibc0.json | 2 +- configs/four/ibc1.json | 2 +- configs/four/ibc2.json | 2 +- configs/four/ibc3.json | 2 +- configs/gaia.json | 5 +- configs/three/ibc0.json | 2 +- configs/three/ibc1.json | 2 +- configs/three/ibc2.json | 2 +- docs/config.md | 4 -- docs/testing.md | 3 -- relayer/chain.go | 29 ------------ relayer/naive-strategy.go | 12 +++-- test/test_chains.go | 96 --------------------------------------- 18 files changed, 22 insertions(+), 158 deletions(-) diff --git a/cmd/chains.go b/cmd/chains.go index 8b9fd39e1..5e06e2d92 100644 --- a/cmd/chains.go +++ b/cmd/chains.go @@ -108,11 +108,9 @@ func chainsShowCmd() *cobra.Command { rpc-addr: %s trusting-period: %s default-denom: %s -gas: %d -gas-prices: %s key: %s account-prefix: %s -`, c.ChainID, c.RPCAddr, c.TrustingPeriod, c.DefaultDenom, c.Gas, c.GasPrices, c.Key, c.AccountPrefix) +`, c.ChainID, c.RPCAddr, c.TrustingPeriod, c.Key, c.AccountPrefix) return nil } }, diff --git a/cmd/dev.go b/cmd/dev.go index 8ba894d8f..e3142600a 100644 --- a/cmd/dev.go +++ b/cmd/dev.go @@ -197,13 +197,13 @@ func rlyService() *cobra.Command { var srcBal, dstBal sdk.Coins if srcBal, err = chains[src].QueryBalance(chains[src].Key); err != nil { return err - } else if srcBal.AmountOf(chains[src].DefaultDenom).IsZero() { + } else if srcBal.Empty() { return fmt.Errorf("no balance on %s, ensure %s has a balance before continuing setup", src, chains[src].MustGetAddress()) } if dstBal, err = chains[dst].QueryBalance(chains[dst].Key); err != nil { return err - } else if dstBal.AmountOf(chains[dst].DefaultDenom).IsZero() { + } else if dstBal.Empty() { return fmt.Errorf("no balance on %s, ensure %s has a balance before continuing setup", dst, chains[dst].MustGetAddress()) } diff --git a/configs/agoric.json b/configs/agoric.json index e46479518..ff23fbe01 100644 --- a/configs/agoric.json +++ b/configs/agoric.json @@ -8,10 +8,7 @@ "post-light-client": "ag-nchainz start-solos $chainid", "link": { "account-prefix": "agoric", - "gas": 200000, - "gas-adjustment":1.0, - "gas-prices": "", - "default-denom": "uagstake", + "gas-adjustment": 1.0, "trusting-period": "336h" } } diff --git a/configs/demo/ibc0.json b/configs/demo/ibc0.json index 1dc8110b2..e1223cb44 100644 --- a/configs/demo/ibc0.json +++ b/configs/demo/ibc0.json @@ -1 +1 @@ -{"key":"testkey","chain-id":"ibc0","rpc-addr":"http://localhost:26657","account-prefix":"cosmos","gas":200000,"gas-adjustment":1.0,"gas-prices":"0.025stake","default-denom":"stake","trusting-period":"336h"} +{"key":"testkey","chain-id":"ibc0","rpc-addr":"http://localhost:26657","account-prefix":"cosmos","gas-adjustment":1.0,"trusting-period":"336h"} diff --git a/configs/demo/ibc1.json b/configs/demo/ibc1.json index 28f5927c1..be5d469e5 100644 --- a/configs/demo/ibc1.json +++ b/configs/demo/ibc1.json @@ -1 +1 @@ -{"key":"testkey","chain-id":"ibc1","rpc-addr":"http://localhost:26557","account-prefix":"cosmos","gas":200000,"gas-adjustment":1.0,"gas-prices":"0.025stake","default-denom":"stake","trusting-period":"336h"} +{"key":"testkey","chain-id":"ibc1","rpc-addr":"http://localhost:26557","account-prefix":"cosmos","gas-adjustment":1.0,"trusting-period":"336h"} diff --git a/configs/four/ibc0.json b/configs/four/ibc0.json index d93b9ee59..77580bdf5 100644 --- a/configs/four/ibc0.json +++ b/configs/four/ibc0.json @@ -1 +1 @@ -{"key":"testkey","chain-id":"ibc0","rpc-addr":"http://localhost:46657","account-prefix":"cosmos","gas":200000,"gas-adjustment":1.0,"gas-prices":"0.025stake","default-denom":"stake","trusting-period":"336h"} +{"key":"testkey","chain-id":"ibc0","rpc-addr":"http://localhost:46657","account-prefix":"cosmos","gas-adjustment":1.0,"trusting-period":"336h"} diff --git a/configs/four/ibc1.json b/configs/four/ibc1.json index f81835b42..7a94cc052 100644 --- a/configs/four/ibc1.json +++ b/configs/four/ibc1.json @@ -1 +1 @@ -{"key":"testkey","chain-id":"ibc1","rpc-addr":"http://localhost:46658","account-prefix":"cosmos","gas":200000,"gas-adjustment":1.0,"gas-prices":"0.025stake","default-denom":"stake","trusting-period":"336h"} \ No newline at end of file +{"key":"testkey","chain-id":"ibc1","rpc-addr":"http://localhost:46658","account-prefix":"cosmos","gas-adjustment":1.0,"trusting-period":"336h"} \ No newline at end of file diff --git a/configs/four/ibc2.json b/configs/four/ibc2.json index fc6dc37f0..ea42ae32b 100644 --- a/configs/four/ibc2.json +++ b/configs/four/ibc2.json @@ -1 +1 @@ -{"key":"testkey","chain-id":"ibc2","rpc-addr":"http://localhost:46659","account-prefix":"cosmos","gas":200000,"gas-adjustment":1.0,"gas-prices":"0.025stake","default-denom":"stake","trusting-period":"336h"} \ No newline at end of file +{"key":"testkey","chain-id":"ibc2","rpc-addr":"http://localhost:46659","account-prefix":"cosmos","gas-adjustment":1.0,"trusting-period":"336h"} \ No newline at end of file diff --git a/configs/four/ibc3.json b/configs/four/ibc3.json index c76f8fbfd..47e943454 100644 --- a/configs/four/ibc3.json +++ b/configs/four/ibc3.json @@ -1 +1 @@ -{"key":"testkey","chain-id":"ibc3","rpc-addr":"http://localhost:46660","account-prefix":"cosmos","gas":200000,"gas-adjustment":1.0,"gas-prices":"0.025stake","default-denom":"stake","trusting-period":"336h"} \ No newline at end of file +{"key":"testkey","chain-id":"ibc3","rpc-addr":"http://localhost:46660","account-prefix":"cosmos","gas-adjustment":1.0,"trusting-period":"336h"} \ No newline at end of file diff --git a/configs/gaia.json b/configs/gaia.json index a504b29b7..92b7ac26e 100644 --- a/configs/gaia.json +++ b/configs/gaia.json @@ -3,10 +3,7 @@ "cli": "gaiacli", "link": { "account-prefix": "cosmos", - "gas": 200000, - "gas-adjustment":1.0, - "gas-prices": "0.025stake", - "default-denom": "stake", + "gas-adjustment": 1.0, "trusting-period": "336h" } } diff --git a/configs/three/ibc0.json b/configs/three/ibc0.json index 1dc8110b2..e1223cb44 100644 --- a/configs/three/ibc0.json +++ b/configs/three/ibc0.json @@ -1 +1 @@ -{"key":"testkey","chain-id":"ibc0","rpc-addr":"http://localhost:26657","account-prefix":"cosmos","gas":200000,"gas-adjustment":1.0,"gas-prices":"0.025stake","default-denom":"stake","trusting-period":"336h"} +{"key":"testkey","chain-id":"ibc0","rpc-addr":"http://localhost:26657","account-prefix":"cosmos","gas-adjustment":1.0,"trusting-period":"336h"} diff --git a/configs/three/ibc1.json b/configs/three/ibc1.json index 28f5927c1..be5d469e5 100644 --- a/configs/three/ibc1.json +++ b/configs/three/ibc1.json @@ -1 +1 @@ -{"key":"testkey","chain-id":"ibc1","rpc-addr":"http://localhost:26557","account-prefix":"cosmos","gas":200000,"gas-adjustment":1.0,"gas-prices":"0.025stake","default-denom":"stake","trusting-period":"336h"} +{"key":"testkey","chain-id":"ibc1","rpc-addr":"http://localhost:26557","account-prefix":"cosmos","gas-adjustment":1.0,"trusting-period":"336h"} diff --git a/configs/three/ibc2.json b/configs/three/ibc2.json index 5717e0715..7caebe9b4 100644 --- a/configs/three/ibc2.json +++ b/configs/three/ibc2.json @@ -1 +1 @@ -{"key":"testkey","chain-id":"ibc2","rpc-addr":"http://localhost:25557","account-prefix":"cosmos","gas":200000,"gas-adjustment":1.0,"gas-prices":"0.025stake","default-denom":"stake","trusting-period":"336h"} +{"key":"testkey","chain-id":"ibc2","rpc-addr":"http://localhost:25557","account-prefix":"cosmos","gas-adjustment":1.0,"trusting-period":"336h"} diff --git a/docs/config.md b/docs/config.md index c7b166105..da808a7a1 100644 --- a/docs/config.md +++ b/docs/config.md @@ -56,11 +56,7 @@ type ChainConfig struct { ChainID string `yaml:"chain-id" json:"chain-id"` RPCAddr string `yaml:"rpc-addr" json:"rpc-addr"` AccountPrefix string `yaml:"account-prefix" json:"account-prefix"` - Gas uint64 `yaml:"gas,omitempty" json:"gas,omitempty"` GasAdjustment float64 `yaml:"gas-adjustment,omitempty" json:"gas-adjustment,omitempty"` - GasPrices string `yaml:"gas-prices,omitempty" json:"gas-prices,omitempty"` - DefaultDenom string `yaml:"default-denom,omitempty" json:"default-denom,omitempty"` - Memo string `yaml:"memo,omitempty" json:"memo,omitempty"` TrustingPeriod string `yaml:"trusting-period" json:"trusting-period"` } ``` diff --git a/docs/testing.md b/docs/testing.md index 80ed5c81a..2d04c3684 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -53,9 +53,6 @@ gaiaTestConfig = testChainConfig{ timeout: 3 * time.Second, rpcPort: "26657", accountPrefix: "cosmos", - gas: 200000, - gasPrices: "0.025stake", - defaultDenom: "stake", trustingPeriod: "330h", } diff --git a/relayer/chain.go b/relayer/chain.go index 27c765504..e3bf12edd 100644 --- a/relayer/chain.go +++ b/relayer/chain.go @@ -7,7 +7,6 @@ import ( "net/url" "os" "path" - "strconv" "time" sdkCtx "github.com/cosmos/cosmos-sdk/client" @@ -34,11 +33,7 @@ type Chain struct { ChainID string `yaml:"chain-id" json:"chain-id"` RPCAddr string `yaml:"rpc-addr" json:"rpc-addr"` AccountPrefix string `yaml:"account-prefix" json:"account-prefix"` - Gas uint64 `yaml:"gas,omitempty" json:"gas,omitempty"` GasAdjustment float64 `yaml:"gas-adjustment,omitempty" json:"gas-adjustment,omitempty"` - GasPrices string `yaml:"gas-prices,omitempty" json:"gas-prices,omitempty"` - DefaultDenom string `yaml:"default-denom,omitempty" json:"default-denom,omitempty"` - Memo string `yaml:"memo,omitempty" json:"memo,omitempty"` TrustingPeriod string `yaml:"trusting-period" json:"trusting-period"` // TODO: make these private @@ -148,11 +143,6 @@ func (c *Chain) Init(homePath string, timeout time.Duration, debug bool) error { return err } - _, err = sdk.ParseDecCoins(c.GasPrices) - if err != nil { - return err - } - _, err = time.ParseDuration(c.TrustingPeriod) if err != nil { return fmt.Errorf("failed to parse trusting period (%s) for chain %s", c.TrustingPeriod, c.ChainID) @@ -287,9 +277,6 @@ func (c *Chain) TxFactory(height int64) tx.Factory { WithChainID(c.ChainID). WithTxConfig(ctx.TxConfig). WithGasAdjustment(c.GasAdjustment). - WithGasPrices(c.GasPrices). - WithGas(c.Gas). - WithMemo(c.Memo). WithKeybase(c.Keybase). WithSignMode(signing.SignMode_SIGN_MODE_DIRECT) } @@ -384,22 +371,6 @@ func (c *Chain) Update(key, value string) (out *Chain, err error) { out.RPCAddr = value case "account-prefix": out.AccountPrefix = value - case "gas": - var gas uint64 - gas, err = strconv.ParseUint(value, 10, 64) - if err != nil { - return - } - out.Gas = gas - case "gas-prices": - if _, err = sdk.ParseDecCoins(value); err != nil { - return - } - out.GasPrices = value - case "default-denom": - out.DefaultDenom = value - case "memo": - out.Memo = value case "trusting-period": if _, err = time.ParseDuration(value); err != nil { return diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index 42d8882be..9acfccd59 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -46,13 +46,15 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea eg.Go(func() error { var res *chanTypes.QueryPacketCommitmentsResponse - retry.Do(func() error { + if err = retry.Do(func() error { res, err = src.QueryPacketCommitments(0, 1000, sh.GetHeight(src.ChainID)) if err != nil || res == nil { return err } return nil - }) + }); err != nil { + return err + } for _, pc := range res.Commitments { srcPacketSeq = append(srcPacketSeq, pc.Sequence) } @@ -61,13 +63,15 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea eg.Go(func() error { var res *chanTypes.QueryPacketCommitmentsResponse - retry.Do(func() error { + if err = retry.Do(func() error { res, err = dst.QueryPacketCommitments(0, 1000, sh.GetHeight(dst.ChainID)) if err != nil || res == nil { return err } return nil - }) + }); err != nil { + return err + } for _, pc := range res.Commitments { dstPacketSeq = append(dstPacketSeq, pc.Sequence) } diff --git a/test/test_chains.go b/test/test_chains.go index 85744bd57..0c1802b0d 100644 --- a/test/test_chains.go +++ b/test/test_chains.go @@ -5,110 +5,23 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" - "github.com/cosmos/cosmos-sdk/simapp" "github.com/stretchr/testify/require" ry "github.com/ovrclk/relayer/relayer" ) -func init() { - ec := simapp.MakeEncodingConfig() - cdc = ec.Marshaler - amino = ec.Amino -} - var ( - cdc codec.JSONMarshaler - amino *codec.LegacyAmino // GAIA BLOCK TIMEOUTS on jackzampolin/gaiatest:master // timeout_commit = "1000ms" // timeout_propose = "1000ms" // 3 second relayer timeout works well with these block times gaiaTestConfig = testChainConfig{ - cdc: cdc, - amino: amino, dockerImage: "jackzampolin/gaiatest", dockerTag: "jack_gaiav3.0", timeout: 3 * time.Second, rpcPort: "26657", accountPrefix: "cosmos", - gas: 200000, - gasPrices: "0.025stake", - defaultDenom: "stake", - trustingPeriod: "330h", - } - - // MTD BLOCK TIMEOUTS on microtick/mtzonetest:ibc-alpha - // timeout_commit = "1000ms" - // timeout_propose = "1000ms" - // 3 second relayer timeout works well with these block times - mtdTestConfig = testChainConfig{ - cdc: cdc, - amino: amino, - dockerImage: "microtick/mtzonetest", - dockerTag: "ibc-alpha", - timeout: 3 * time.Second, - rpcPort: "26657", - accountPrefix: "cosmos", - gas: 200000, - gasPrices: "0.025stake", - defaultDenom: "stake", - trustingPeriod: "330h", - } - - // RocketZone - // timeout_commit = "1000ms" - // timeout_propose = "1000ms" - // 3 second relayer timeout works well with these block times - rocketTestConfig = testChainConfig{ - cdc: cdc, - amino: amino, - dockerImage: "rocketprotocol/rocketzone-relayer-test", - dockerTag: "latest", - timeout: 3 * time.Second, - rpcPort: "26657", - accountPrefix: "cosmos", - gas: 200000, - gasPrices: "0.025ufuel", - defaultDenom: "ufuel", - trustingPeriod: "330h", - } - - // Agoric Chain - // timeout_commit = "1000ms" - // timeout_propose = "1000ms" - // 3 second relayer timeout works well with these block times - agoricTestConfig = testChainConfig{ - cdc: cdc, - amino: amino, - dockerImage: "agoric/agoric-sdk", - dockerTag: "ibc-alpha", - timeout: 3 * time.Second, - rpcPort: "26657", - accountPrefix: "agoric", - gas: 200000, - gasPrices: "", - defaultDenom: "uag", - trustingPeriod: "330h", - } - - // CoCo Chain saisunkari19/coco:ibc-alpha - // timeout_commit = "1000ms" - // timeout_propose = "1000ms" - // 3 second relayer timeout works well with these block times - cocoTestConfig = testChainConfig{ - cdc: cdc, - amino: amino, - dockerImage: "saisunkari19/coco", - dockerTag: "ibc-alpha", - timeout: 3 * time.Second, - rpcPort: "26657", - accountPrefix: "cosmic", - gas: 200000, - gasPrices: "0.025coco", - defaultDenom: "coco", trustingPeriod: "330h", } ) @@ -126,14 +39,9 @@ type ( testChainConfig struct { dockerImage string dockerTag string - amino *codec.LegacyAmino - cdc codec.JSONMarshaler rpcPort string timeout time.Duration accountPrefix string - gas uint64 - gasPrices string - defaultDenom string trustingPeriod string } ) @@ -142,16 +50,12 @@ type ( func newTestChain(t *testing.T, tc testChain) *ry.Chain { _, port, err := server.FreeTCPAddr() require.NoError(t, err) - return &ry.Chain{ Key: "testkey", ChainID: tc.chainID, RPCAddr: fmt.Sprintf("http://localhost:%s", port), AccountPrefix: tc.t.accountPrefix, - Gas: tc.t.gas, - GasPrices: tc.t.gasPrices, GasAdjustment: 1.0, - DefaultDenom: tc.t.defaultDenom, TrustingPeriod: tc.t.trustingPeriod, } } From fa1feca45ba52ca7cd8fded1307277060a207bf4 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Wed, 16 Sep 2020 16:36:08 -0700 Subject: [PATCH 50/54] fix lint --- cmd/chains.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/chains.go b/cmd/chains.go index 5e06e2d92..1f0f1954e 100644 --- a/cmd/chains.go +++ b/cmd/chains.go @@ -107,7 +107,6 @@ func chainsShowCmd() *cobra.Command { fmt.Printf(`chain-id: %s rpc-addr: %s trusting-period: %s -default-denom: %s key: %s account-prefix: %s `, c.ChainID, c.RPCAddr, c.TrustingPeriod, c.Key, c.AccountPrefix) From 6e09550e4fece542c729cca1d5141212dc9b2258 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Thu, 17 Sep 2020 12:35:23 -0700 Subject: [PATCH 51/54] add human readable IBC denoms to bal output --- cmd/query.go | 18 +++++++++++++++++- scripts/two-chainz | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cmd/query.go b/cmd/query.go index d9101ab18..458111e92 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -190,7 +190,23 @@ func queryBalanceCmd() *cobra.Command { return err } - return chain.Print(coins, false, false) + dts, err := chain.QueryDenomTraces(0, 1000) + if err != nil { + return err + } + + out := sdk.Coins{} + for _, c := range coins { + for _, d := range dts.DenomTraces { + if c.Denom == d.IBCDenom() { + out = append(out, sdk.NewCoin(d.GetFullDenomPath(), c.Amount)) + continue + } + out = append(out, c) + } + } + + return chain.Print(out, false, false) }, } return cmd diff --git a/scripts/two-chainz b/scripts/two-chainz index 8065eb233..45dd44019 100755 --- a/scripts/two-chainz +++ b/scripts/two-chainz @@ -11,7 +11,7 @@ if [[ ! -d $GOPATH ]] || [[ ! -d $GOBIN ]] || [[ ! -x "$(which go)" ]]; then fi GAIA_REPO="$GOPATH/src/github.com/cosmos/gaia" -GAIA_BRANCH=gaiav3.0 +GAIA_BRANCH=jack/gaiav3.0 GAIA_DATA="$(pwd)/data" # ARGS: From 9ee0dee8fe26bebd54da4719286931cc66607a9a Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Sun, 20 Sep 2020 15:22:45 -0600 Subject: [PATCH 52/54] Update sdk version --- go.mod | 2 +- go.sum | 5 ++--- relayer/naive-strategy.go | 4 ++-- relayer/query.go | 17 +++++++++++++---- scripts/two-chainz | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 9c4b3ee48..cdf7412ab 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,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-20200228182428-0f16d7a0959c // indirect - github.com/cosmos/cosmos-sdk v0.34.4-0.20200916172701-e4c67eddc7e3 + github.com/cosmos/cosmos-sdk v0.34.4-0.20200918165627-d6357e77b469 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/gorilla/mux v1.8.0 github.com/ory/dockertest/v3 v3.5.5 diff --git a/go.sum b/go.sum index 11241fda2..ad0a05587 100644 --- a/go.sum +++ b/go.sum @@ -124,8 +124,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200916172701-e4c67eddc7e3 h1:lSH+OZ5w28ctEDtt8Hu6fLfDbEGmpudyw6YsM4jHQEs= -github.com/cosmos/cosmos-sdk v0.34.4-0.20200916172701-e4c67eddc7e3/go.mod h1:kO3VV10paWHqHnDJ8GteH2AKGAcv+Lpdy9+oWEKNUn4= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200918165627-d6357e77b469 h1:qHJ4dbun/d8ZuJX/fWFLUpELugiEevTnPgxPES9/byE= +github.com/cosmos/cosmos-sdk v0.34.4-0.20200918165627-d6357e77b469/go.mod h1:3bfA/vO+QD9jYFBt/RmBEvbeFHoM8HQWHfZnGx4lOTc= github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac= 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= @@ -604,7 +604,6 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tendermint v0.33.8 h1:Xxu4QhpqcomSE0iQDw1MqLgfsa8fqtPtWFJK6zZOVso= github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70f0ytWLTQ/Go= github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g= github.com/tendermint/tendermint v0.34.0-rc3.0.20200907055413-3359e0bf2f84 h1:BI/EhLLh6SAlOtMaHePo8BNFLsNRiFNCtJ8cMBX+OE8= diff --git a/relayer/naive-strategy.go b/relayer/naive-strategy.go index 9acfccd59..153b57aa6 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -84,13 +84,13 @@ func (nrs *NaiveStrategy) UnrelayedSequencesOrdered(src, dst *Chain, sh *SyncHea eg.Go(func() error { // Query all packets sent by src that have been received by dst - rs.Src, err = dst.QueryUnrelayedPackets(sh.GetHeight(dst.ChainID), srcPacketSeq, false) + rs.Src, err = dst.QueryUnrecievedPackets(sh.GetHeight(dst.ChainID), srcPacketSeq) return err }) eg.Go(func() error { // Query all packets sent by dst that have been received by src - rs.Dst, err = src.QueryUnrelayedPackets(sh.GetHeight(src.ChainID), dstPacketSeq, false) + rs.Dst, err = src.QueryUnrecievedPackets(sh.GetHeight(src.ChainID), dstPacketSeq) return err }) diff --git a/relayer/query.go b/relayer/query.go index 7cbd072a8..249adc3ec 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -417,17 +417,26 @@ func (c *Chain) QueryPacketCommitments( // return res.Commitments, err } -// QueryUnrelayedPackets returns a list of unrelayed packet commitments -func (c *Chain) QueryUnrelayedPackets(height uint64, seqs []uint64, acks bool) ([]uint64, error) { +// QueryUnrecievedPackets returns a list of unrelayed packet commitments +func (c *Chain) QueryUnrecievedPackets(height uint64, seqs []uint64) ([]uint64, error) { qc := chanTypes.NewQueryClient(c.CLIContext(int64(height))) - res, err := qc.UnrelayedPackets(context.Background(), &chanTypes.QueryUnrelayedPacketsRequest{ + res, err := qc.UnreceivedPackets(context.Background(), &chanTypes.QueryUnreceivedPacketsRequest{ PortId: c.PathEnd.PortID, ChannelId: c.PathEnd.ChannelID, PacketCommitmentSequences: seqs, - Acknowledgements: acks, }) return res.Sequences, err +} +// QueryUnrelayedAcks returns a list of unrelayed packet acks +func (c *Chain) QueryUnrelayedAcks(height uint64, seqs []uint64) ([]uint64, error) { + qc := chanTypes.NewQueryClient(c.CLIContext(int64(height))) + res, err := qc.UnrelayedAcks(context.Background(), &chanTypes.QueryUnrelayedAcksRequest{ + PortId: c.PathEnd.PortID, + ChannelId: c.PathEnd.ChannelID, + PacketCommitmentSequences: seqs, + }) + return res.Sequences, err } // QueryTx takes a transaction hash and returns the transaction diff --git a/scripts/two-chainz b/scripts/two-chainz index 45dd44019..8065eb233 100755 --- a/scripts/two-chainz +++ b/scripts/two-chainz @@ -11,7 +11,7 @@ if [[ ! -d $GOPATH ]] || [[ ! -d $GOBIN ]] || [[ ! -x "$(which go)" ]]; then fi GAIA_REPO="$GOPATH/src/github.com/cosmos/gaia" -GAIA_BRANCH=jack/gaiav3.0 +GAIA_BRANCH=gaiav3.0 GAIA_DATA="$(pwd)/data" # ARGS: From 36cdf0410765ffbffe97115c181ee26af6d5bb9d Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Mon, 21 Sep 2020 07:01:22 -0600 Subject: [PATCH 53/54] Ensure that balance prints when there are no ibc transactions --- cmd/query.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cmd/query.go b/cmd/query.go index 458111e92..027ff9856 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -195,18 +195,21 @@ func queryBalanceCmd() *cobra.Command { return err } - out := sdk.Coins{} - for _, c := range coins { - for _, d := range dts.DenomTraces { - if c.Denom == d.IBCDenom() { - out = append(out, sdk.NewCoin(d.GetFullDenomPath(), c.Amount)) - continue + if len(dts.DenomTraces) > 0 { + out := sdk.Coins{} + for _, c := range coins { + for _, d := range dts.DenomTraces { + if c.Denom == d.IBCDenom() { + out = append(out, sdk.NewCoin(d.GetFullDenomPath(), c.Amount)) + continue + } + out = append(out, c) } - out = append(out, c) } + return chain.Print(out, false, false) } - return chain.Print(out, false, false) + return chain.Print(coins, false, false) }, } return cmd From 74a277438e82d8ba98a207903aec249b5da6f7ce Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Mon, 21 Sep 2020 16:41:27 -0600 Subject: [PATCH 54/54] jack/gaiav3.0 --- cmd/flags.go | 9 +++++++++ cmd/query.go | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cmd/flags.go b/cmd/flags.go index 479ec8011..ad0c37451 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -25,8 +25,17 @@ var ( flagOrder = "unordered" flagMaxTxSize = "max-tx-size" flagMaxMsgLength = "max-msgs" + flagIBCDenoms = "ibc-denoms" ) +func ibcDenomFlags(cmd *cobra.Command) *cobra.Command { + cmd.Flags().BoolP(flagIBCDenoms, "i", false, "Display IBC denominations for sending tokens back to other chains") + if err := viper.BindPFlag(flagIBCDenoms, cmd.Flags().Lookup(flagIBCDenoms)); err != nil { + panic(err) + } + return cmd +} + func lightFlags(cmd *cobra.Command) *cobra.Command { cmd.Flags().Int64(flags.FlagHeight, -1, "Trusted header's height") cmd.Flags().BytesHexP(flagHash, "x", []byte{}, "Trusted header's hash") diff --git a/cmd/query.go b/cmd/query.go index 027ff9856..dbacbcd1d 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -180,6 +180,11 @@ func queryBalanceCmd() *cobra.Command { return err } + showDenoms, err := cmd.Flags().GetBool(flagIBCDenoms) + if err != nil { + return err + } + var coins sdk.Coins if len(args) == 2 { coins, err = chain.QueryBalance(args[1]) @@ -190,6 +195,10 @@ func queryBalanceCmd() *cobra.Command { return err } + if showDenoms { + return chain.Print(coins, false, false) + } + dts, err := chain.QueryDenomTraces(0, 1000) if err != nil { return err @@ -212,7 +221,7 @@ func queryBalanceCmd() *cobra.Command { return chain.Print(coins, false, false) }, } - return cmd + return ibcDenomFlags(cmd) } func queryHeaderCmd() *cobra.Command {