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 }} 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/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..11e4c261d 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,17 @@ 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 ############################################################################### # 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)' @@ -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 10dcf42a6..3a5c8e824 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,10 +29,7 @@ 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` | -| [`coco`](https://github.com/CosmicCompass/post-chain) | ![coco](https://github.com/CosmicCompass/relayer/workflows/TESTING%20-%20coco%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` | ## Demoing the Relayer @@ -69,10 +66,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 28512cefc..1f0f1954e 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 ( @@ -52,8 +52,7 @@ func chainsAddrCmd() *cobra.Command { return err } - done := chain.UseSDKContext() - defer done() + chain.UseSDKContext() addr, err := chain.GetAddress() if err != nil { @@ -108,12 +107,9 @@ func chainsShowCmd() *cobra.Command { fmt.Printf(`chain-id: %s 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 } }, @@ -197,10 +193,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 { @@ -212,9 +208,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 { @@ -222,7 +218,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 93ad2a3dc..2f3c9c549 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" @@ -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, } } @@ -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..e3142600a 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]", @@ -290,23 +197,23 @@ 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()) } - // 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] @@ -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/errors.go b/cmd/errors.go index 5fe0d2258..d9a4fe362 100644 --- a/cmd/errors.go +++ b/cmd/errors.go @@ -9,14 +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 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 82b7f22f0..ad0c37451 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" @@ -26,26 +25,31 @@ var ( flagOrder = "unordered" flagMaxTxSize = "max-tx-size" flagMaxMsgLength = "max-msgs" + flagIBCDenoms = "ibc-denoms" ) -func liteFlags(cmd *cobra.Command) *cobra.Command { +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") - 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 } 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) } @@ -53,9 +57,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", 1000, "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 { @@ -143,21 +147,13 @@ 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) } return cmd } -func flagsFlag(cmd *cobra.Command) *cobra.Command { - cmd.Flags().BoolP(flagFlags, "f", false, "pass flag to output the flags for lite 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/keys.go b/cmd/keys.go index 4d89a1437..7e0d52ec0 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 @@ -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/light.go b/cmd/light.go new file mode 100644 index 000000000..27e628279 --- /dev/null +++ b/cmd/light.go @@ -0,0 +1,213 @@ +/* +Copyright © 2020 Jack Zampolin + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package cmd + +import ( + "fmt" + "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" +) + +// chainCmd represents the keys command +func lightCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "light", + Aliases: []string{"l"}, + Short: "manage light clients held by the relayer for each chain", + } + + cmd.AddCommand(lightHeaderCmd()) + cmd.AddCommand(initLightCmd()) + cmd.AddCommand(updateLightCmd()) + cmd.AddCommand(deleteLightCmd()) + + return cmd +} + +func initLightCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "init [chain-id]", + Aliases: []string{"i"}, + 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. 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]) + if err != nil { + return err + } + + db, df, err := chain.NewLightDB() + if err != nil { + return err + } + defer df() + + force, err := cmd.Flags().GetBool(flagForce) + if err != nil { + return err + } + height, err := cmd.Flags().GetInt64(flags.FlagHeight) + if err != nil { + return err + } + hash, err := cmd.Flags().GetBytesHex(flagHash) + if err != nil { + return err + } + + switch { + case force: // force initialization from trusted node + _, err = chain.LightClientWithoutTrust(db) + if err != nil { + return err + } + case height > 0 && len(hash) > 0: // height and hash are given + _, err = chain.LightClientWithTrust(db, chain.TrustOptions(height, hash)) + if err != nil { + return wrapInitFailed(err) + } + default: // return error + return errInitWrongFlags + } + + return nil + }, + } + + return forceFlag(lightFlags(cmd)) +} + +func updateLightCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update [chain-id]", + Aliases: []string{"u"}, + 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 + } + + bh, err := chain.GetLatestLightHeader() + if err != nil { + return err + } + + ah, err := chain.UpdateLightWithHeader() + if err != nil { + return 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 cmd +} + +func lightHeaderCmd() *cobra.Command { + cmd := &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), + RunE: func(cmd *cobra.Command, args []string) error { + chainID := args[0] + chain, err := config.Chains.Get(chainID) + if err != nil { + return err + } + + var header *tmclient.Header + + switch len(args) { + case 1: + header, err = chain.GetLatestLightHeader() + if err != nil { + return err + } + case 2: + var height int64 + height, err = strconv.ParseInt(args[1], 10, 64) //convert to int64 + if err != nil { + return err + } + + if height == 0 { + height, err = chain.GetLatestLightHeight() + if err != nil { + return err + } + + if height == -1 { + return relayer.ErrLightNotInitialized + } + } + + header, err = chain.GetLightSignedHeaderAtHeight(height) + if err != nil { + return err + } + + } + + out, err := chain.Cdc.MarshalJSON(header) + if err != nil { + return err + } + + fmt.Println(string(out)) + return nil + }, + } + return cmd +} + +func deleteLightCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "delete [chain-id]", + Aliases: []string{"d"}, + 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] + chain, err := config.Chains.Get(chainID) + if err != nil { + return err + } + + err = chain.DeleteLightDB() + if err != nil { + return err + } + + return nil + }, + } + return cmd +} diff --git a/cmd/lite.go b/cmd/lite.go deleted file mode 100644 index 0fa8581c7..000000000 --- a/cmd/lite.go +++ /dev/null @@ -1,316 +0,0 @@ -/* -Copyright © 2020 Jack Zampolin - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -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/iqlusioninc/relayer/relayer" - "github.com/spf13/cobra" - "github.com/spf13/viper" - lite "github.com/tendermint/tendermint/lite2" -) - -// chainCmd represents the keys command -func liteCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "lite", - Aliases: []string{"l"}, - Short: "manage lite clients held by the relayer for each chain", - } - - cmd.AddCommand(liteHeaderCmd()) - cmd.AddCommand(initLiteCmd()) - cmd.AddCommand(updateLiteCmd()) - cmd.AddCommand(deleteLiteCmd()) - - return cmd -} - -func initLiteCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "init [chain-id]", - Aliases: []string{"i"}, - 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`, - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - chain, err := config.Chains.Get(args[0]) - if err != nil { - return err - } - - db, df, err := chain.NewLiteDB() - if err != nil { - return err - } - defer df() - - url, err := cmd.Flags().GetString(flagURL) - if err != nil { - return err - } - force, err := cmd.Flags().GetBool(flagForce) - if err != nil { - return err - } - height, err := cmd.Flags().GetInt64(flags.FlagHeight) - if err != nil { - return err - } - hash, err := cmd.Flags().GetBytesHex(flagHash) - if err != nil { - return err - } - - switch { - case force: // force initialization from trusted node - _, err = chain.TrustNodeInitClient(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) - if err != nil { - return wrapInitFailed(err) - } - default: // return error - return errInitWrongFlags - } - - return nil - }, - } - - return forceFlag(liteFlags(cmd)) -} - -func updateLiteCmd() *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), - RunE: func(cmd *cobra.Command, args []string) error { - chain, err := config.Chains.Get(args[0]) - if err != nil { - return err - } - - url := viper.GetString(flagURL) - height, err := cmd.Flags().GetInt64(flags.FlagHeight) - if err != nil { - return err - } - hash, err := cmd.Flags().GetBytesHex(flagHash) - 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.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) - 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) - } - } - - return nil - }, - } - - return liteFlags(cmd) -} - -func liteHeaderCmd() *cobra.Command { - cmd := &cobra.Command{ - 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), - RunE: func(cmd *cobra.Command, args []string) error { - chainID := args[0] - chain, err := config.Chains.Get(chainID) - if err != nil { - return err - } - - var header *tmclient.Header - - switch len(args) { - case 1: - header, err = chain.GetLatestLiteHeader() - if err != nil { - return err - } - case 2: - var height int64 - height, err = strconv.ParseInt(args[1], 10, 64) //convert to int64 - if err != nil { - return err - } - - if height == 0 { - height, err = chain.GetLatestLiteHeight() - if err != nil { - return err - } - - if height == -1 { - return relayer.ErrLiteNotInitialized - } - } - - header, err = chain.GetLiteSignedHeaderAtHeight(height) - if err != nil { - return err - } - - } - - out, err := chain.Cdc.MarshalJSON(header) - if err != nil { - return err - } - - fmt.Println(string(out)) - return nil - }, - } - return cmd -} - -func deleteLiteCmd() *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", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - chainID := args[0] - chain, err := config.Chains.Get(chainID) - if err != nil { - return err - } - - err = chain.DeleteLiteDB() - if err != nil { - return err - } - - return nil - }, - } - 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/paths.go b/cmd/paths.go index fc6ff24f6..33df21c3a 100644 --- a/cmd/paths.go +++ b/cmd/paths.go @@ -6,13 +6,10 @@ 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/iqlusioninc/relayer/relayer" + "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]", @@ -119,14 +99,11 @@ 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, 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 relayer.MustGetHeight(clnt.GetLatestHeight()) != 0 && !clnt.IsFrozen() { + path.Src.ClientID = c.ClientId } } @@ -135,14 +112,11 @@ 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, 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 relayer.MustGetHeight(clnt.GetLatestHeight()) != 0 && !clnt.IsFrozen() { + path.Dst.ClientID = c.ClientId } } @@ -185,11 +159,11 @@ func pathsGenCmd() *cobra.Command { return err } - var srcCon connTypes.ConnectionEnd - for _, c := range srcConns { - if c.ClientID == path.Src.ClientID { + var srcCon *connTypes.IdentifiedConnection + for _, c := range srcConns.Connections { + 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 - for _, c := range dstConns { - if c.ClientID == path.Dst.ClientID { + var dstCon *connTypes.IdentifiedConnection + for _, c := range dstConns.Connections { + 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 - for _, c := range srcChans { + var srcChan *chanTypes.IdentifiedChannel + for _, c := range srcChans.Channels { 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 - for _, c := range dstChans { + var dstChan *chanTypes.IdentifiedChannel + for _, c := range dstChans.Channels { 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) { @@ -374,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 { @@ -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) @@ -489,21 +463,21 @@ 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 } 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 46e19ce71..dbacbcd1d 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/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" - "github.com/spf13/viper" ) // queryCmd represents the chain command @@ -24,7 +23,6 @@ func queryCmd() *cobra.Command { } cmd.AddCommand( - queryFullPathCmd(), queryUnrelayed(), flags.LineBreak, queryAccountCmd(), @@ -42,14 +40,33 @@ func queryCmd() *cobra.Command { queryChannel(), queryChannels(), queryConnectionChannels(), - queryNextSeqRecv(), queryPacketCommitment(), - queryPacketAck(), + queryIBCDenoms(), ) return cmd } +func queryIBCDenoms() *cobra.Command { + cmd := &cobra.Command{ + Use: "ibc-denoms [chain-id]", + Short: "Query transaction by transaction hash", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + chain, err := config.Chains.Get(args[0]) + if err != nil { + return err + } + res, err := chain.QueryDenomTraces(0, 1000) + if err != nil { + return err + } + return chain.CLIContext(0).PrintOutput(res) + }, + } + return cmd +} + func queryTx() *cobra.Command { cmd := &cobra.Command{ Use: "tx [chain-id] [tx-hash]", @@ -93,22 +110,22 @@ 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 } - 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(h.GetHeight(), page, limit, events) + txs, err := chain.QueryTxs(relayer.MustGetHeight(h.GetHeight()), int(offset), int(limit), events) if err != nil { return err } @@ -136,12 +153,16 @@ func queryAccountCmd() *cobra.Command { return err } - acc, err := auth.NewAccountRetriever(chain.Cdc, chain).GetAccount(addr) + res, err := types.NewQueryClient(chain.CLIContext(0)).Account( + context.Background(), + &types.QueryAccountRequest{ + Address: addr, + }) if err != nil { return err } - return chain.Print(acc, false, false) + return chain.CLIContext(0).PrintOutput(res) }, } return cmd @@ -159,37 +180,48 @@ func queryBalanceCmd() *cobra.Command { return err } - jsn, err := cmd.Flags().GetBool(flagJSON) + showDenoms, err := cmd.Flags().GetBool(flagIBCDenoms) 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) + } + if err != nil { + return err + } + + if showDenoms { + return chain.Print(coins, false, false) } - coins, err := chain.QueryBalance(keyName) + dts, err := chain.QueryDenomTraces(0, 1000) if err != nil { return err } - var out string - if jsn { - byt, err := json.Marshal(coins) - if err != nil { - return err + 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 = string(byt) - } else { - out = coins.String() + return chain.Print(out, false, false) } - fmt.Println(out) - return nil + return chain.Print(coins, false, false) }, } - return jsonFlag(cmd) + return ibcDenomFlags(cmd) } func queryHeaderCmd() *cobra.Command { @@ -226,7 +258,7 @@ func queryHeaderCmd() *cobra.Command { } if height == -1 { - return relayer.ErrLiteNotInitialized + return relayer.ErrLightNotInitialized } } @@ -237,47 +269,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 chain.CLIContext(0).PrintOutput(header) }, } - 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(0) if err != nil { return err } @@ -301,20 +313,25 @@ func queryClientCmd() *cobra.Command { return err } + height, err := cmd.Flags().GetInt64(flags.FlagHeight) + if err != nil { + return err + } + if err = chain.AddPath(args[1], dcon, dcha, dpor, dord); err != nil { return err } - res, err := chain.QueryClientState() + res, err := chain.QueryClientState(height) if err != nil { return err } - return chain.Print(res, false, false) + return chain.CLIContext(height).PrintOutput(res) }, } - return cmd + return heightFlag(cmd) } func queryClientsCmd() *cobra.Command { @@ -329,22 +346,22 @@ func queryClientsCmd() *cobra.Command { 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 } - res, err := chain.QueryClients(page, limit) + res, err := chain.QueryClients(offset, limit) if err != nil { return err } - return chain.Print(res, false, false) + return chain.CLIContext(0).PrintOutput(res) }, } @@ -363,12 +380,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 } @@ -378,7 +395,7 @@ func queryConnections() *cobra.Command { return err } - return chain.Print(res, false, false) + return chain.CLIContext(0).PrintOutput(res) }, } @@ -401,7 +418,7 @@ func queryConnectionsUsingClient() *cobra.Command { return err } - height, err := chain.QueryLatestHeight() + height, err := cmd.Flags().GetInt64(flags.FlagHeight) if err != nil { return err } @@ -411,11 +428,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 { @@ -444,7 +461,7 @@ func queryConnection() *cobra.Command { return err } - return chain.Print(res, false, false) + return chain.CLIContext(height).PrintOutput(res) }, } @@ -466,12 +483,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 } @@ -503,7 +520,7 @@ func queryChannel() *cobra.Command { return err } - height, err := chain.QueryLatestHeight() + height, err := cmd.Flags().GetInt64(flags.FlagHeight) if err != nil { return err } @@ -513,11 +530,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 { @@ -532,12 +549,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 } @@ -554,38 +571,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]", @@ -601,54 +586,12 @@ func queryPacketCommitment() *cobra.Command { return err } - height, err := chain.QueryLatestHeight() - if err != nil { - return err - } - - seq, err := strconv.ParseInt(args[3], 10, 64) - if err != nil { - return err - } - - res, err := chain.QueryPacketCommitment(height, seq) - if err != nil { - return err - } - - return chain.Print(res, false, false) - }, - } - - 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 - } - - height, err := chain.QueryLatestHeight() - if err != nil { - return err - } - - seq, err := strconv.ParseInt(args[3], 10, 64) + seq, err := strconv.ParseUint(args[3], 10, 64) if err != nil { return err } - res, err := chain.QueryPacketAck(height, seq) + res, err := chain.QueryPacketCommitment(0, seq) if err != nil { return err } @@ -690,44 +633,21 @@ func queryUnrelayed() *cobra.Command { return err } - sp, err := relayer.UnrelayedSequences(c[src], c[dst], sh) + strategy, err := path.GetStrategy() 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]) + sp, err := strategy.UnrelayedSequencesOrdered(c[src], c[dst], sh) if err != nil { return err } - src, dst := path.Src.ChainID, path.Dst.ChainID - c, err := config.Chains.Gets(src, dst) - if err != nil { - return err - } - - stat, err := relayer.QueryPathStatus(c[src], c[dst], path) - 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 a9bc5b730..128adf8cc 100644 --- a/cmd/raw.go +++ b/cmd/raw.go @@ -3,10 +3,9 @@ package cmd import ( "strings" - "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" + clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" + "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" ) @@ -59,30 +58,20 @@ func updateClientCmd() *cobra.Command { return err } - height, err := cmd.Flags().GetInt64(flags.FlagHeight) + dstHeader, err := chains[dst].UpdateLightWithHeader() 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 } - - return sendAndPrint([]sdk.Msg{chains[src].PathEnd.UpdateClient(dstHeader, chains[src].MustGetAddress())}, + return sendAndPrint([]sdk.Msg{chains[src].PathEnd.UpdateClient(updateHeader, chains[src].MustGetAddress())}, chains[src], cmd) }, } - return heightFlag(cmd) + return cmd } func createClientCmd() *cobra.Command { @@ -98,7 +87,7 @@ func createClientCmd() *cobra.Command { return err } - dstHeader, err := chains[dst].UpdateLiteWithHeader() + dstHeader, err := chains[dst].UpdateLightWithHeader() if err != nil { return err } @@ -107,8 +96,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) }, } @@ -162,35 +156,43 @@ 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].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 - dstClientState, err := chains[dst].QueryClientState() + dstClientStateRes, err := chains[dst].QueryClientState(dsth.Header.Height) if err != nil { return err } - dstCsHeight := int64(dstClientState.ClientState.GetLatestHeight()) + dstClientState, err := clientTypes.UnpackClientState(dstClientStateRes.ClientState) + if err != nil { + return err + } + 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(hs[dst].Height-1, dstCsHeight) + dstConsState, err := chains[dst].QueryClientConsensusState(dsth.Header.Height, dstCsHeight) if err != nil { return err } + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], dsth) + if err != nil { + return err + } 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.UpdateClient(updateHeader, chains[src].MustGetAddress()), + chains[src].PathEnd.ConnTry(chains[dst].PathEnd, dstClientStateRes, dstConnState, + dstConsState, chains[src].MustGetAddress()), } return sendAndPrint(txs, chains[src], cmd) @@ -219,34 +221,43 @@ 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].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 - dstClientState, err := chains[dst].QueryClientState() + dstClientStateResponse, err := chains[dst].QueryClientState(dsth.Header.Height) if err != nil { return err } - dstCsHeight := int64(dstClientState.ClientState.GetLatestHeight()) + dstClientState, _ := clientTypes.UnpackClientState(dstClientStateResponse.ClientState) + 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(hs[dst].Height-1, dstCsHeight) + dstConsState, err := chains[dst].QueryClientConsensusState(dsth.Header.Height, dstCsHeight) if err != nil { return err } + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], dsth) + if err != nil { + return err + } txs := []sdk.Msg{ - chains[src].PathEnd.ConnAck(dstState, dstConsState, dstCsHeight, chains[src].MustGetAddress()), - chains[src].PathEnd.UpdateClient(hs[dst], chains[src].MustGetAddress()), + chains[src].PathEnd.ConnAck( + chains[dst].PathEnd, + dstClientStateResponse, + dstState, dstConsState, + chains[src].MustGetAddress()), + chains[src].PathEnd.UpdateClient(updateHeader, chains[src].MustGetAddress()), } return sendAndPrint(txs, chains[src], cmd) @@ -275,21 +286,25 @@ 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].Height - 1) + dstState, err := chains[dst].QueryConnection(dsth.Header.Height - 1) if err != nil { return err } + updateHeader, err := relayer.InjectTrustedFields(chains[dst], chains[src], dsth) + 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) @@ -392,18 +407,22 @@ func chanTry() *cobra.Command { return err } - dstHeader, err := chains[dst].UpdateLiteWithHeader() + dstHeader, err := chains[dst].UpdateLightWithHeader() if err != nil { return err } - dstChanState, err := chains[dst].QueryChannel(dstHeader.Height - 1) + dstChanState, err := chains[dst].QueryChannel(dstHeader.Header.Height - 1) if err != nil { 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()), } @@ -434,18 +453,22 @@ func chanAck() *cobra.Command { return err } - dstHeader, err := chains[dst].UpdateLiteWithHeader() + dstHeader, err := chains[dst].UpdateLightWithHeader() if err != nil { return err } - dstChanState, err := chains[dst].QueryChannel(dstHeader.Height - 1) + dstChanState, err := chains[dst].QueryChannel(dstHeader.Header.Height - 1) if err != nil { 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()), } @@ -476,18 +499,22 @@ func chanConfirm() *cobra.Command { return err } - dstHeader, err := chains[dst].UpdateLiteWithHeader() + dstHeader, err := chains[dst].UpdateLightWithHeader() if err != nil { return err } - dstChanState, err := chains[dst].QueryChannel(dstHeader.Height - 1) + dstChanState, err := chains[dst].QueryChannel(dstHeader.Header.Height - 1) if err != nil { 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()), } @@ -583,18 +610,22 @@ func chanCloseConfirm() *cobra.Command { return err } - dstHeader, err := chains[dst].UpdateLiteWithHeader() + dstHeader, err := chains[dst].UpdateLightWithHeader() if err != nil { return err } - dstChanState, err := chains[dst].QueryChannel(dstHeader.Height - 1) + dstChanState, err := chains[dst].QueryChannel(dstHeader.Header.Height - 1) if err != nil { 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/cmd/root.go b/cmd/root.go index 1764b2b88..7705efbb1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -21,9 +21,6 @@ import ( "strings" "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" ) @@ -38,8 +35,6 @@ var ( debug bool config *Config defaultHome = os.ExpandEnv("$HOME/.relayer") - cdc *codec.Codec - appCodec *codecstd.Codec // Default identifiers for dummy usage dcli = "defaultclientid" @@ -76,7 +71,7 @@ func init() { pathsCmd(), flags.LineBreak, keysCmd(), - liteCmd(), + lightCmd(), flags.LineBreak, transactionCmd(), queryCmd(), @@ -88,7 +83,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) } @@ -99,7 +93,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/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..d6a3ba4fa 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" ) @@ -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/tx.go b/cmd/tx.go index c1266fccb..50546fa3b 100644 --- a/cmd/tx.go +++ b/cmd/tx.go @@ -16,11 +16,10 @@ limitations under the License. package cmd import ( - "fmt" "strings" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/iqlusioninc/relayer/relayer" + "github.com/ovrclk/relayer/relayer" "github.com/spf13/cobra" ) @@ -37,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 @@ -58,7 +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", - 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 { @@ -71,10 +72,30 @@ 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 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 { + 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`), @@ -100,7 +121,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`), @@ -116,8 +137,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) }, } @@ -149,7 +169,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"}, @@ -184,7 +204,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 { @@ -198,13 +218,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 } @@ -219,42 +239,3 @@ 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) -} 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 9d7ec37de..2bcb2d2f2 100644 --- a/cmd/xfer.go +++ b/cmd/xfer.go @@ -2,22 +2,23 @@ package cmd import ( "fmt" - "strconv" 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 func xfersend() *cobra.Command { cmd := &cobra.Command{ - Use: "xfer-send [src-chain-id] [dst-chain-id] [amount] [source] [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), + 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) @@ -39,65 +40,17 @@ func xfersend() *cobra.Command { return err } - source, err := strconv.ParseBool(args[3]) + // 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[3]) if err != nil { return err } - done := c[dst].UseSDKContext() - dstAddr, err := sdk.AccAddressFromBech32(args[4]) - if err != nil { - return err - } - done() - - return c[src].SendTransferMsg(c[dst], amount, dstAddr, source) - }, - } - 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 - } - - done := c[dst].UseSDKContext() - dstAddr, err := sdk.AccAddressFromBech32(args[4]) - if err != nil { - return err - } - done() - - return c[src].SendTransferBothSides(c[dst], amount, dstAddr, source) + return c[src].SendTransferMsg(c[dst], amount, dstAddr) }, } return pathFlag(cmd) diff --git a/configs/agoric.json b/configs/agoric.json index f5c9b73b2..ff23fbe01 100644 --- a/configs/agoric.json +++ b/configs/agoric.json @@ -5,13 +5,10 @@ "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, - "gas-adjustment":1.0, - "gas-prices": "", - "default-denom": "uagstake", + "gas-adjustment": 1.0, "trusting-period": "336h" } } 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/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/dev-env b/dev-env index 54d053864..e940a2d35 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" @@ -17,9 +17,16 @@ 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) + +echo "waiting for blocks..." +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/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/docs/commands.md b/docs/commands.md index d394b9ba0..341995b64 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) @@ -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) @@ -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 ``` @@ -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/docs/config.md b/docs/config.md index 077e269a4..da808a7a1 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"` } ``` @@ -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 6bea93435..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", } @@ -103,9 +100,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.mod b/go.mod index a493a0b16..cdf7412ab 100644 --- a/go.mod +++ b/go.mod @@ -1,24 +1,24 @@ -module github.com/iqlusioninc/relayer +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.20200522204605-4a07d536a7cc - github.com/cosmos/gaia v0.0.1-0.20200522222820-2d61264338e5 + 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.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.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 ) 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 diff --git a/go.sum b/go.sum index f3a37d019..ad0a05587 100644 --- a/go.sum +++ b/go.sum @@ -21,17 +21,17 @@ 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.7.1+incompatible h1:HmA9qHVrHIAqpSvoCYJ+c6qst0lgqEhNW6/KwfkHbS8= -github.com/DataDog/datadog-go v3.7.1+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/datadog-go v3.2.0+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= @@ -45,11 +45,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= @@ -69,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= @@ -78,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= @@ -93,11 +101,15 @@ 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/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= @@ -105,26 +117,25 @@ 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= 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/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/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= +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= 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,25 +145,39 @@ 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= 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 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= 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= 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= @@ -160,16 +185,19 @@ 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= 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/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-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= @@ -183,12 +211,9 @@ 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= -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= @@ -196,14 +221,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= @@ -213,6 +237,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 +250,8 @@ 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= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -237,21 +265,27 @@ 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.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= -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= 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= 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= @@ -264,14 +298,18 @@ 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= 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= @@ -290,28 +328,35 @@ 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= 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/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= 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 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= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -328,6 +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.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= @@ -339,6 +386,8 @@ 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= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -356,6 +405,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,19 +413,28 @@ 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/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= 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/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.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/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= @@ -393,8 +452,8 @@ 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= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= @@ -403,11 +462,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 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= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -424,9 +487,9 @@ 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.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.4.0/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,34 +504,46 @@ 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 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= github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= 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= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= @@ -477,14 +552,18 @@ 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= 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.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= +github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= 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= @@ -495,12 +574,10 @@ 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= @@ -511,32 +588,35 @@ 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= 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= 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.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/tm-db v0.4.1/go.mod h1:JsJ6qzYkCGiGwm5GHl/H5GLI9XLb6qZX7PRe425dHAY= -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/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.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= +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= 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 +626,8 @@ 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= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -564,6 +646,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,11 +656,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= @@ -592,6 +682,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= @@ -610,19 +702,27 @@ 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= 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= +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= 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= @@ -632,6 +732,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,25 +742,39 @@ 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-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= 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/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +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= 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= @@ -682,10 +798,14 @@ 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/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= @@ -710,8 +830,16 @@ 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-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= 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 +849,15 @@ 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.1/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.28.1 h1:C1QC6KzgSiLyBabDi87BbjaGreoRgGUF5nOyvfrAZ1k= -google.golang.org/grpc v1.28.1/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/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= @@ -733,12 +866,19 @@ 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 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= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= @@ -754,11 +894,14 @@ 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= @@ -768,7 +911,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/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/relayer/chain.go b/relayer/chain.go index ec9790599..e3bf12edd 100644 --- a/relayer/chain.go +++ b/relayer/chain.go @@ -7,25 +7,24 @@ import ( "net/url" "os" "path" - "strconv" - "sync" "time" - sdkCtx "github.com/cosmos/cosmos-sdk/client/context" - ckeys "github.com/cosmos/cosmos-sdk/client/keys" - aminocodec "github.com/cosmos/cosmos-sdk/codec" + 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" - 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" + "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" 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 @@ -34,20 +33,16 @@ 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 - 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 @@ -58,6 +53,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{}) @@ -126,8 +132,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 @@ -138,21 +143,17 @@ func (c *Chain) Init(homePath string, cdc *codecstd.Codec, amino *aminocodec.Cod 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) } + 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 = encodingConfig.Marshaler + c.Amino = encodingConfig.Amino c.HomePath = homePath c.logger = defaultChainLogger() c.timeout = timeout @@ -175,11 +176,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) @@ -203,46 +199,86 @@ 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 +func (c *Chain) SendMsgs(msgs []sdk.Msg) (res *sdk.TxResponse, err error) { + c.UseSDKContext() + + // Instantiate the client context + ctx := c.CLIContext(0) + + // Query account details + txf, err := tx.PrepareFactory(ctx, c.TxFactory(0)) + if err != nil { + return nil, err + } + + // If users pass gas adjustment, then calculate gas + // TODO: make all txs estimate/ + _, adjusted, err := tx.CalculateGas(ctx.QueryWithData, txf, msgs...) + if err != nil { + return nil, 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) { - done := c.UseSDKContext() - defer done() + // Set the gas amount on the transaction factory + txf = txf.WithGas(adjusted) - // Fetch account and sequence numbers for the account - acc, err := auth.NewAccountRetriever(c.Cdc, c).GetAccount(c.MustGetAddress()) + // Build the transaction builder + txb, err := tx.BuildUnsignedTx(txf, msgs...) if err != nil { return nil, err } - ctx := sdkCtx.CLIContext{Client: c.Client} - 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 - } + + // Attach the signature to the transaction + err = tx.Sign(txf, c.Key, txb) + if err != nil { + return nil, err } - return txBldr.BuildAndSign(c.Key, ckeys.DefaultKeyPass, msgs) -} -// 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) + // 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 +func (c *Chain) CLIContext(height int64) 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). + WithFromName(c.Key). + WithFromAddress(c.MustGetAddress()). + WithSkipConfirmation(true). + WithNodeURI(c.RPCAddr). + WithHeight(height) +} + +// TxFactory returns an instance of tx.Factory derived from +func (c *Chain) TxFactory(height int64) tx.Factory { + ctx := c.CLIContext(height) + return tx.Factory{}. + WithAccountRetriever(ctx.AccountRetriever). + WithChainID(c.ChainID). + WithTxConfig(ctx.TxConfig). + WithGasAdjustment(c.GasAdjustment). + WithKeybase(c.Keybase). + WithSignMode(signing.SignMode_SIGN_MODE_DIRECT) } // Log takes a string and logs the data @@ -277,8 +313,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 @@ -306,33 +342,15 @@ 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() func() { - // Ensure we're the only one using the global context. - sdkContextMutex.Lock() - defer sdkContextMutex.Unlock() - +func (c *Chain) UseSDKContext() { 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 { - done := c.UseSDKContext() - defer done() + c.UseSDKContext() + // defer done() out, _ := json.Marshal(c) return string(out) @@ -353,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/channel-tx.go b/relayer/channel-tx.go index e4f1ac44b..dac6d0e5b 100644 --- a/relayer/channel-tx.go +++ b/relayer/channel-tx.go @@ -4,18 +4,19 @@ import ( "fmt" "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" + 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 // 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) @@ -36,12 +37,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, @@ -68,99 +69,107 @@ 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) { - 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) +func (c *Chain) CreateChannelStep(dst *Chain, ordering chanTypes.Order) (*RelayMsgs, error) { + out := NewRelayMsgs() + 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 } - chans, err := QueryChannelPair(c, dst, hs[scid].Height-1, hs[dcid].Height-1) - 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 { + srcUpdateHeader, dstUpdateHeader, err = InjectTrustedFieldsHeaders(c, dst, srch, dsth) + return err + }) + + eg.Go(func() error { + srcChan, dstChan, err = QueryChannelPair(c, dst, srch.Header.Height-1, dsth.Header.Height-1) + return err + }) + + if err = eg.Wait(); 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 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 == ibctypes.UNINITIALIZED && chans[dcid].Channel.State == ibctypes.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(hs[dcid], c.MustGetAddress()), - c.PathEnd.ChanTry(dst.PathEnd, chans[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, 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 == ibctypes.INIT && chans[dcid].Channel.State == ibctypes.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(hs[scid], dst.MustGetAddress()), - dst.PathEnd.ChanTry(c.PathEnd, chans[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, 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 == ibctypes.TRYOPEN && chans[dcid].Channel.State == ibctypes.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(hs[scid], dst.MustGetAddress()), - dst.PathEnd.ChanAck(chans[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, 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 == ibctypes.INIT && chans[dcid].Channel.State == ibctypes.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(hs[dcid], c.MustGetAddress()), - c.PathEnd.ChanAck(chans[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, 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 == ibctypes.TRYOPEN && chans[dcid].Channel.State == ibctypes.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(hs[dcid], c.MustGetAddress()), - c.PathEnd.ChanConfirm(chans[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, 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 == ibctypes.OPEN && chans[dcid].Channel.State == ibctypes.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(hs[scid], dst.MustGetAddress()), - dst.PathEnd.ChanConfirm(chans[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), + dst.PathEnd.ChanConfirm(srcChan, dst.MustGetAddress()), ) out.last = true } @@ -184,12 +193,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, @@ -204,74 +213,84 @@ 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) + out := NewRelayMsgs() + 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 } - chans, err := QueryChannelPair(c, dst, hs[scid].Height-1, hs[dcid].Height-1) - 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, 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 != ibctypes.CLOSED && chans[dcid].Channel.State != ibctypes.CLOSED: - if chans[scid].Channel.State != ibctypes.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(hs[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), c.PathEnd.ChanCloseInit(c.MustGetAddress()), ) - } else if chans[dcid].Channel.State != ibctypes.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(hs[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), dst.PathEnd.ChanCloseInit(dst.MustGetAddress()), ) } // 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 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(hs[scid], dst.MustGetAddress()), - dst.PathEnd.ChanCloseConfirm(chans[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, 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 == ibctypes.CLOSED && chans[scid].Channel.State != ibctypes.CLOSED: - if chans[scid].Channel.State != ibctypes.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(hs[dcid], c.MustGetAddress()), - c.PathEnd.ChanCloseConfirm(chans[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, c.MustGetAddress()), + c.PathEnd.ChanCloseConfirm(dstChan, c.MustGetAddress()), ) out.last = true } diff --git a/relayer/client-tx.go b/relayer/client-tx.go index 70da5e3dd..94bfdf976 100644 --- a/relayer/client-tx.go +++ b/relayer/client-tx.go @@ -4,40 +4,67 @@ 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.StateResponse - if srcCs, err = c.QueryClientState(); err != nil { + srcH, dstH, err := UpdatesWithHeaders(c, dst) + if err != nil { return err - } else if srcCs == nil { - dstH, err := dst.UpdateLiteWithHeader() - if err != nil { - return err - } - if c.debug { - c.logCreateClient(dst, dstH.GetHeight()) - } - clients.Src = append(clients.Src, c.PathEnd.CreateClient(dstH, dst.GetTrustingPeriod(), c.MustGetAddress())) } - // 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 { - srcH, err := c.UpdateLiteWithHeader() - if err != nil { - return err + // 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(), + )) } - if dst.debug { - dst.logCreateClient(c, srcH.GetHeight()) + 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(), + )) } - clients.Dst = append(clients.Dst, dst.PathEnd.CreateClient(srcH, c.GetTrustingPeriod(), dst.MustGetAddress())) + return nil + }) + + if err := eg.Wait(); err != nil { + return err } // Send msgs to both chains @@ -50,3 +77,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/connection-tx.go b/relayer/connection-tx.go index 2945f1cfd..5a2efacb0 100644 --- a/relayer/connection-tx.go +++ b/relayer/connection-tx.go @@ -4,8 +4,11 @@ import ( "fmt" "time" - sdk "github.com/cosmos/cosmos-sdk/types" - ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" + clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" + connTypes "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 @@ -30,11 +33,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}", @@ -63,120 +66,141 @@ 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 + srcCons, dstCons *clientTypes.QueryConsensusStateResponse + srcConsH, dstConsH int64 + ) + + // create the UpdateHeaders for src and dest Chains + 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].Height-1, hs[dcid].Height-1) - if err != nil { - return nil, err - } + eg.Go(func() error { + srcConn, dstConn, err = QueryConnectionPair(c, dst, srch.Header.Height-1, dsth.Header.Height-1) + 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 - cs, err := QueryClientStatePair(c, dst) - if err != nil { - return nil, err - } + }) - // TODO: log these heights or something about client state? debug? - if cs[scid] == nil || cs[dcid] == nil { + if err = eg.Wait(); err != nil { return nil, err } - // Store the heights - srcConsH, dstConsH := int64(cs[scid].ClientState.GetLatestHeight()), int64(cs[dcid].ClientState.GetLatestHeight()) + 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) { + 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 + } + + // 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 - cons, err := QueryClientConsensusStatePair(c, dst, hs[scid].Height-1, hs[dcid].Height-1, srcConsH, dstConsH) - 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 + srcCons, dstCons, err = QueryClientConsensusStatePair( + c, dst, srch.Header.Height-1, dsth.Header.Height-1, 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 == connTypes.UNINITIALIZED && dstConn.Connection.State == connTypes.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 == connTypes.UNINITIALIZED && dstConn.Connection.State == connTypes.INIT: if c.debug { - logConnectionStates(c, dst, conn) + logConnectionStates(c, dst, srcConn, dstConn) } + 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.UpdateClient(dstUpdateHeader, 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 - case conn[scid].Connection.State == ibctypes.INIT && conn[dcid].Connection.State == ibctypes.UNINITIALIZED: + case srcConn.Connection.State == connTypes.INIT && dstConn.Connection.State == connTypes.UNINITIALIZED: if dst.debug { - logConnectionStates(dst, c, conn) + logConnectionStates(dst, c, dstConn, srcConn) } + 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.UpdateClient(srcUpdateHeader, 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 == connTypes.TRYOPEN && dstConn.Connection.State == connTypes.INIT: if dst.debug { - logConnectionStates(dst, c, conn) + logConnectionStates(dst, c, dstConn, srcConn) } out.Dst = append(out.Dst, - dst.PathEnd.UpdateClient(hs[scid], dst.MustGetAddress()), - dst.PathEnd.ConnAck(conn[scid], cons[scid], srcConsH, dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, 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 == connTypes.INIT && dstConn.Connection.State == connTypes.TRYOPEN: if c.debug { - logConnectionStates(c, dst, conn) + logConnectionStates(c, dst, srcConn, dstConn) } out.Src = append(out.Src, - c.PathEnd.UpdateClient(hs[dcid], c.MustGetAddress()), - c.PathEnd.ConnAck(conn[dcid], cons[dcid], dstConsH, c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, 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 == connTypes.TRYOPEN && dstConn.Connection.State == connTypes.OPEN: if c.debug { - logConnectionStates(c, dst, conn) + logConnectionStates(c, dst, srcConn, dstConn) } out.Src = append(out.Src, - c.PathEnd.UpdateClient(hs[dcid], c.MustGetAddress()), - c.PathEnd.ConnConfirm(conn[dcid], c.MustGetAddress()), + c.PathEnd.UpdateClient(dstUpdateHeader, 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 == connTypes.OPEN && dstConn.Connection.State == connTypes.TRYOPEN: if dst.debug { - logConnectionStates(dst, c, conn) + logConnectionStates(dst, c, dstConn, srcConn) } out.Dst = append(out.Dst, - dst.PathEnd.UpdateClient(hs[scid], dst.MustGetAddress()), - dst.PathEnd.ConnConfirm(conn[scid], dst.MustGetAddress()), + dst.PathEnd.UpdateClient(srcUpdateHeader, dst.MustGetAddress()), + dst.PathEnd.ConnConfirm(srcConn, dst.MustGetAddress()), ) out.last = true } diff --git a/relayer/contextual.go b/relayer/contextual.go deleted file mode 100644 index 464360cf4..000000000 --- a/relayer/contextual.go +++ /dev/null @@ -1,92 +0,0 @@ -package relayer - -import ( - "github.com/cosmos/cosmos-sdk/codec" - stdcodec "github.com/cosmos/cosmos-sdk/std" -) - -type contextualStdCodec struct { - *stdcodec.Codec - useContext func() func() -} - -type contextualAminoCodec struct { - *codec.Codec - useContext func() func() -} - -// newContextualCodec creates a codec that sets and resets context -func newContextualStdCodec(cdc *stdcodec.Codec, useContext func() func()) *contextualStdCodec { - return &contextualStdCodec{ - Codec: 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.Codec.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.Codec.UnmarshalJSON(bz, ptr) -} - -func (cdc *contextualStdCodec) MarshalBinaryBare(ptr codec.ProtoMarshaler) ([]byte, error) { - done := cdc.useContext() - defer done() - - return cdc.Codec.MarshalBinaryBare(ptr) -} - -func (cdc *contextualStdCodec) UnmarshalBinaryBare(bz []byte, ptr codec.ProtoMarshaler) error { - done := cdc.useContext() - defer done() - - return cdc.Codec.UnmarshalBinaryBare(bz, ptr) -} - -// newContextualCodec creates a codec that sets and resets context -func newContextualAminoCodec(cdc *codec.Codec, useContext func() func()) *contextualAminoCodec { - return &contextualAminoCodec{ - Codec: 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.Codec.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.Codec.UnmarshalJSON(bz, ptr) -} - -func (cdc *contextualAminoCodec) MarshalBinaryBare(ptr interface{}) ([]byte, error) { - done := cdc.useContext() - defer done() - - return cdc.Codec.MarshalBinaryBare(ptr) -} - -func (cdc *contextualAminoCodec) UnmarshalBinaryBare(bz []byte, ptr interface{}) error { - done := cdc.useContext() - defer done() - - return cdc.Codec.UnmarshalBinaryBare(bz, ptr) -} diff --git a/relayer/faucet.go b/relayer/faucet.go index f0aa2cd35..a0bc0e6b2 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 @@ -82,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/headers.go b/relayer/headers.go index 9ce7aeee1..2a3b15e5f 100644 --- a/relayer/headers.go +++ b/relayer/headers.go @@ -3,17 +3,20 @@ 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" + "golang.org/x/sync/errgroup" ) // 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 @@ -26,7 +29,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 } @@ -36,6 +39,18 @@ 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 { + chain := chain + 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() @@ -43,9 +58,83 @@ 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() defer uh.Unlock() - return uh.hds[chainID].GetHeight() + 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 +// 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) + + // retrieve counterparty client from dst chain + counterpartyClientRes, err := dstChain.QueryClientState(0) + 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) + if !ok { + panic("height is not an instance of height! wtf") + } + return height.EpochHeight } diff --git a/relayer/log-tx.go b/relayer/log-tx.go index c499c8ddb..d6b223a32 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) @@ -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)) } @@ -33,7 +36,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,34 +45,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.ChannelResponse) { +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, + MustGetHeight(srcChan.ProofHeight), src.PathEnd.ChannelID, - conn[src.ChainID].Channel.State, + srcChan.Channel.State, dst.ChainID, - conn[dst.ChainID].ProofHeight, + MustGetHeight(dstChan.ProofHeight), dst.PathEnd.ChannelID, - conn[dst.ChainID].Channel.State, + dstChan.Channel.State, )) } -func logConnectionStates(src, dst *Chain, conn map[string]connTypes.ConnectionResponse) { +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, + MustGetHeight(srcConn.ProofHeight), src.PathEnd.ConnectionID, - conn[src.ChainID].Connection.State, + srcConn.Connection.State, dst.ChainID, - conn[dst.ChainID].ProofHeight, + MustGetHeight(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/naive-strategy.go b/relayer/naive-strategy.go index c933e4d84..153b57aa6 100644 --- a/relayer/naive-strategy.go +++ b/relayer/naive-strategy.go @@ -3,10 +3,14 @@ package relayer import ( "fmt" "strconv" + "strings" "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" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + "golang.org/x/sync/errgroup" ) var _ Strategy = &NaiveStrategy{} @@ -32,12 +36,74 @@ 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) + var ( + eg = new(errgroup.Group) + srcPacketSeq = []uint64{} + dstPacketSeq = []uint64{} + err error + rs = &RelaySequences{Src: []uint64{}, Dst: []uint64{}} + ) + + eg.Go(func() error { + var res *chanTypes.QueryPacketCommitmentsResponse + 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) + } + return nil + }) + + eg.Go(func() error { + var res *chanTypes.QueryPacketCommitmentsResponse + 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) + } + return nil + }) + + if err := eg.Wait(); err != nil { + return nil, err + } + + eg.Go(func() error { + // Query all packets sent by src that have been received by dst + 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.QueryUnrecievedPackets(sh.GetHeight(src.ChainID), dstPacketSeq) + 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) { - return UnrelayedSequences(src, dst, sh) + return nrs.UnrelayedSequencesOrdered(src, dst, sh) } // HandleEvents defines how the relayer will handle block and transaction events as they are emitted @@ -160,10 +226,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, @@ -185,6 +255,12 @@ func (nrs *NaiveStrategy) sendTxFromEventPackets(src, dst *Chain, rlyPackets []r } } +// RelaySequences represents unrelayed packets on src and dst +type RelaySequences struct { + Src []uint64 `json:"src"` + Dst []uint64 `json:"dst"` +} + // RelayPacketsUnorderedChan creates transactions to relay un-relayed messages func (nrs *NaiveStrategy) RelayPacketsUnorderedChan(src, dst *Chain, sp *RelaySequences, sh *SyncHeaders) error { // TODO: Implement unordered channels @@ -203,6 +279,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 { @@ -236,10 +313,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 @@ -263,17 +350,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 @@ -322,64 +409,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 = p.Value } + if string(p.Key) == "packet_timeout_height" { + timeout, _ := strconv.ParseUint(strings.Split(string(p.Value), "-")[1], 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 0bd43fd8c..63255a2e7 100644 --- a/relayer/packet-tx.go +++ b/relayer/packet-tx.go @@ -2,165 +2,33 @@ package relayer 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" ) 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 { - 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 := dstHeader.GetHeight() + uint64(defaultPacketTimeout) - - // Properly render the address string - done := dst.UseSDKContext() - dstAddrString := dstAddr.String() - done() - - // MsgTransfer will call SendPacket on src chain - txs := RelayMsgs{ - Src: []sdk.Msg{c.PathEnd.MsgTransfer( - dst.PathEnd, dstHeader.GetHeight(), sdk.NewCoins(amount), dstAddrString, c.MustGetAddress(), - )}, - 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 ( - hs map[string]*tmclient.Header - seqRecv chanTypes.RecvResponse - seqSend uint64 - srcCommitRes CommitmentResponse - ) - - if err = retry.Do(func() error { - hs, err = UpdatesWithHeaders(c, dst) - if err != nil { - return err - } - - seqRecv, err = dst.QueryNextSeqRecv(hs[dst.ChainID].Height) - if err != nil { - return err - } - - seqSend, err = c.QueryNextSeqSend(hs[c.ChainID].Height) - if err != nil { - return err - } - - srcCommitRes, err = c.QueryPacketCommitment(hs[c.ChainID].Height-1, int64(seqSend-1)) - if err != nil { - return err - } - - if srcCommitRes.Proof.Proof == nil { - return fmt.Errorf("proof nil, retrying") - } - - return nil - }); err != nil { - return err - } - - // Properly render the source and destination address strings - done = c.UseSDKContext() - srcAddrString := c.MustGetAddress().String() - done() - - done = dst.UseSDKContext() - dstAddrString = dstAddr.String() - done() - - // reconstructing packet data here instead of retrieving from an indexed node - xferPacket := c.PathEnd.XferPacket( - sdk.NewCoins(amount), - srcAddrString, - dstAddrString, - ) - - // 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.MsgRecvPacket( - c.PathEnd, - seqRecv.NextSequenceRecv, - timeoutHeight, - defaultPacketTimeoutStamp(), - xferPacket, - srcCommitRes.Proof, - 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) - } - - dstHeader, err := dst.UpdateLiteWithHeader() +func (c *Chain) SendTransferMsg(dst *Chain, amount sdk.Coin, dstAddr fmt.Stringer) error { + h, err := dst.UpdateLightWithHeader() if err != nil { return err } // Properly render the address string - done := dst.UseSDKContext() + dst.UseSDKContext() dstAddrString := dstAddr.String() - done() // MsgTransfer will call SendPacket on src chain + // TODO: Add ability to specify timeout time or height via command line flags txs := RelayMsgs{ Src: []sdk.Msg{c.PathEnd.MsgTransfer( - dst.PathEnd, dstHeader.GetHeight(), sdk.NewCoins(amount), dstAddrString, c.MustGetAddress(), + dst.PathEnd, amount, dstAddrString, c.MustGetAddress(), uint64(h.Header.Height+1000), 0, )}, Dst: []sdk.Msg{}, } @@ -170,28 +38,3 @@ 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 -} diff --git a/relayer/packetMsgs.go b/relayer/packetMsgs.go deleted file mode 100644 index 3465a3dda..000000000 --- a/relayer/packetMsgs.go +++ /dev/null @@ -1,67 +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.Codec - -func RegisterCodec(cdc *codec.Codec) { - 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 -} - -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/path.go b/relayer/path.go index 4a16f13bc..6a8ef50d3 100644 --- a/relayer/path.go +++ b/relayer/path.go @@ -5,14 +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" -) - -var ( // Default identifiers for dummy usage - dcon = "defaultconnectionid" - dcha = "defaultchannelid" - dpor = "defaultportid" + chantypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ) // Paths represent connection paths between chains @@ -103,7 +96,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 +162,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 aee2e68de..780998125 100644 --- a/relayer/pathEnd.go +++ b/relayer/pathEnd.go @@ -5,13 +5,14 @@ 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" + "github.com/cosmos/cosmos-sdk/x/ibc/exported" + "github.com/tendermint/tendermint/light" ) // TODO: add Order chanTypes.Order as a property and wire it up in validation @@ -30,45 +31,74 @@ 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 + return chanTypes.UNORDERED case "ORDERED": - return ibctypes.ORDERED + return chanTypes.ORDERED default: - return ibctypes.NONE + return chanTypes.NONE } } -func (pe *PathEnd) getOrder() ibctypes.Order { +func (pe *PathEnd) getOrder() chanTypes.Order { return OrderFromString(strings.ToUpper(pe.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( +func (pe *PathEnd) UpdateClient(dstHeader exported.Header, signer sdk.AccAddress) sdk.Msg { + if err := dstHeader.ValidateBasic(); err != nil { + panic(err) + } + msg, err := clientTypes.NewMsgUpdateClient( pe.ClientID, - *dstHeader, + 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, +func (pe *PathEnd) CreateClient( + dstHeader *tmclient.Header, + trustingPeriod, unbondingPeriod time.Duration, signer sdk.AccAddress) sdk.Msg { - if err := dstHeader.ValidateBasic(dstHeader.ChainID); err != nil { + if err := dstHeader.ValidateBasic(); err != nil { panic(err) } + + // Blank Client State // TODO: figure out how to dynmaically set unbonding time - return tmclient.NewMsgCreateClient( - pe.ClientID, - *dstHeader, + clientState := tmclient.NewClientState( + dstHeader.GetHeader().GetChainID(), + tmclient.NewFractionFromTm(light.DefaultTrustLevel), trustingPeriod, - defaultUnbondingTime, - defaultMaxClockDrift, + unbondingPeriod, + time.Minute*1, + dstHeader.GetHeight().(clientTypes.Height), + commitmenttypes.GetSDKSpecs(), + false, + false, + ) + + msg, err := clientTypes.NewMsgCreateClient( + pe.ClientID, + clientState, + dstHeader.ConsensusState(), signer, ) + + if err != nil { + panic(err) + } + if err = msg.ValidateBasic(); err != nil { + panic(err) + } + return msg } // ConnInit creates a MsgConnectionOpenInit @@ -85,45 +115,71 @@ 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 { - return connTypes.NewMsgConnectionOpenTry( +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) + } + msg := connTypes.NewMsgConnectionOpenTry( pe.ConnectionID, pe.ClientID, dst.ConnectionID, dst.ClientID, + cs, defaultChainPrefix, - defaultIBCVersions, + connTypes.GetCompatibleEncodedVersions(), dstConnState.Proof, + dstClientState.Proof, dstConsState.Proof, - dstConnState.ProofHeight+1, - uint64(dstCsHeight), + dstConnState.ProofHeight, + cs.GetLatestHeight().(clientTypes.Height), signer, ) + if err = msg.ValidateBasic(); err != nil { + panic(err) + } + return msg } // ConnAck creates a MsgConnectionOpenAck // NOTE: ADD NOTE ABOUT PROOF HEIGHT CHANGE HERE -func (pe *PathEnd) ConnAck(dstConnState connTypes.ConnectionResponse, dstConsState clientTypes.ConsensusStateResponse, - dstCsHeight int64, signer sdk.AccAddress) sdk.Msg { +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) + } return connTypes.NewMsgConnectionOpenAck( pe.ConnectionID, + cs, dstConnState.Proof, + dstClientState.Proof, dstConsState.Proof, - dstConnState.ProofHeight+1, - uint64(dstCsHeight), - defaultIBCVersion, + dstConsState.ProofHeight, + cs.GetLatestHeight().(clientTypes.Height), + connTypes.GetCompatibleEncodedVersions()[0], signer, ) } // 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, - dstConnState.ProofHeight+1, + dstConnState.ProofHeight, signer, ) } @@ -143,7 +199,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, @@ -154,30 +210,30 @@ func (pe *PathEnd) ChanTry(dst *PathEnd, dstChanState chanTypes.ChannelResponse, dst.ChannelID, dstChanState.Channel.Version, dstChanState.Proof, - dstChanState.ProofHeight+1, + dstChanState.ProofHeight, signer, ) } // 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, dstChanState.Channel.Version, dstChanState.Proof, - dstChanState.ProofHeight+1, + dstChanState.ProofHeight, signer, ) } // 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, dstChanState.Proof, - dstChanState.ProofHeight+1, + dstChanState.ProofHeight, signer, ) } @@ -192,92 +248,31 @@ 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, dstChanState.Proof, - dstChanState.ProofHeight+1, - signer, - ) -} - -// MsgRecvPacket creates a MsgPacket -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, - ) -} - -// 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, - ) -} - -// 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, + dstChanState.ProofHeight, 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, + clientTypes.NewHeight(0, timeoutHeight), + timeoutTimestamp, ) } -// 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 { @@ -288,31 +283,17 @@ func (pe *PathEnd) NewPacket(dst *PathEnd, sequence uint64, packetData []byte, pe.ChannelID, dst.PortID, dst.ChannelID, - timeoutHeight, + clientTypes.NewHeight(0, timeoutHeight), timeoutStamp, ) } // 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() } - -// 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 { - return c.PathEnd.MsgRecvPacket( - dst.PathEnd, - uint64(seq), - timeout, - timeoutStamp, - xferPacket, - dstCommitRes.Proof, - dstCommitRes.ProofHeight, - c.MustGetAddress(), - ) -} diff --git a/relayer/query.go b/relayer/query.go index d4f8b6f99..249adc3ec 100644 --- a/relayer/query.go +++ b/relayer/query.go @@ -1,30 +1,33 @@ package relayer import ( - "encoding/binary" + "context" "encoding/hex" "errors" "fmt" "strings" - "sync" "time" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/rootmulti" sdk "github.com/cosmos/cosmos-sdk/types" - authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/types/query" bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" - clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" + 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" connTypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" + chanUtils "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/client/utils" 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" + 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" 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}" @@ -38,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() @@ -54,23 +54,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: true, + }) - if bz, _, err = c.QueryWithData(route, bz); err != nil { - return nil, qBalErr(addr, err) - } + queryClient := bankTypes.NewQueryClient(c.CLIContext(0)) - 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 -} - -func qBalErr(acc sdk.AccAddress, err error) error { - return fmt.Errorf("query balance for acct %s failed: %w", acc.String(), err) + return res.Balances, nil } // //////////////////////////// @@ -79,491 +77,296 @@ 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 - ) - - 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) - } - - state := &tmclient.ConsensusState{ - Timestamp: commit.Time, - Root: commitmenttypes.NewMerkleRoot(commit.AppHash), - ValidatorSet: tmtypes.NewValidatorSet(validators.Validators), - } - - return state, nil +func (c *Chain) QueryConsensusState(height int64) (*tmclient.ConsensusState, int64, error) { + return clientUtils.QueryNodeConsensusState(c.CLIContext(height)) } -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.ConsensusStateResponse, error) { - var conStateRes clientTypes.ConsensusStateResponse - 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 -} - -type csstates struct { - sync.Mutex - Map map[string]clientTypes.ConsensusStateResponse - 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(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.ConsensusStateResponse, error) { - hs := &csstates{ - Map: make(map[string]clientTypes.ConsensusStateResponse), - 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(chp.h, 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 } -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 - 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 -} - -type cstates struct { - sync.Mutex - Map map[string]*clientTypes.StateResponse - 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.StateResponse, error) { - hs := &cstates{ - Map: make(map[string]*clientTypes.StateResponse), - 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 } -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(clientTypes.NewQueryAllClientsParams(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.QueryClientStatesResponse, error) { + qc := clientTypes.NewQueryClient(c.CLIContext(0)) + res, err := qc.ClientStates(context.Background(), &clientTypes.QueryClientStatesRequest{ + Pagination: &query.PageRequest{ + Key: []byte(""), + Offset: offset, + Limit: limit, + CountTotal: true, + }, + }) + return res, 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( + 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, + Limit: limit, + CountTotal: true, + }, + }) + return res, 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.ClientConnectionsResponse, 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(height), c.PathEnd.ClientID, true) } // QueryConnection returns the remote end of a given connection -func (c *Chain) QueryConnection(height int64) (connTypes.ConnectionResponse, error) { - if !c.PathSet() { - return connTypes.ConnectionResponse{}, 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.ConnectionResponse{}, qConnErr(err) - } else if res.Value == nil { - // NOTE: This is returned so that the switch statement in ConnectionStep works properly +func (c *Chain) QueryConnection(height int64) (*connTypes.QueryConnectionResponse, error) { + 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 } - - var connection connTypes.ConnectionEnd - if err = c.Cdc.UnmarshalBinaryBare(res.Value, &connection); err != nil { - return connTypes.ConnectionResponse{}, qConnErr(err) - } - - return connTypes.NewConnectionResponse(c.PathEnd.ConnectionID, connection, res.Proof, res.Height), nil -} - -type conns struct { - sync.Mutex - Map map[string]connTypes.ConnectionResponse - Errs errs + return res, nil } -type chpair struct { - c *Chain - h int64 -} +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) (map[string]connTypes.ConnectionResponse, error) { - hs := &conns{ - Map: make(map[string]connTypes.ConnectionResponse), - 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 } -// // 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.ConnectionResponse{Connection: connTypes.ConnectionEnd{ID: ""}} - // //////////////////////////// // 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.QueryConnectionChannelsResponse, error) { + qc := chanTypes.NewQueryClient(c.CLIContext(0)) + return qc.ConnectionChannels(context.Background(), &chanTypes.QueryConnectionChannelsRequest{ + Connection: connectionID, + Pagination: &query.PageRequest{ + Key: []byte(""), + Offset: offset, + Limit: limit, + CountTotal: true, + }, + }) } // QueryChannel returns the channel associated with a channelID -func (c *Chain) QueryChannel(height int64) (chanRes chanTypes.ChannelResponse, 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 +func (c *Chain) QueryChannel(height int64) (chanRes *chanTypes.QueryChannelResponse, err error) { + 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 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) - // } - // } +var emptyChannelRes = chanTypes.NewQueryChannelResponse( + "port", + "channel", + chanTypes.NewChannel( + chanTypes.UNINITIALIZED, + chanTypes.UNORDERED, + chanTypes.NewCounterparty( + "port", + "channel", + ), + []string{}, + "version", + ), + []byte{}, + clientTypes.NewHeight(0, 0), +) - return chanTypes.NewChannelResponse(c.PathEnd.PortID, c.PathEnd.ChannelID, channel, res.Proof, res.Height), nil +// 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) + eg.Go(func() error { + srcChan, err = src.QueryChannel(srcH) + return err + }) + eg.Go(func() error { + dstChan, err = dst.QueryChannel(dstH) + return err + }) + err = eg.Wait() + return } -type chans struct { - sync.Mutex - Map map[string]chanTypes.ChannelResponse - Errs errs +// QueryChannels returns all the channels that are registered on a chain +func (c *Chain) QueryChannels(offset, limit uint64) (*chanTypes.QueryChannelsResponse, error) { + qc := chanTypes.NewQueryClient(c.CLIContext(0)) + res, err := qc.Channels(context.Background(), &chanTypes.QueryChannelsRequest{ + Pagination: &query.PageRequest{ + Key: []byte(""), + Offset: offset, + Limit: limit, + CountTotal: true, + }, + }) + return res, err +} + +// QueryChannelClient returns the client state of the client supporting a given channel +func (c *Chain) QueryChannelClient() (*chanTypes.QueryChannelClientStateResponse, error) { + qc := chanTypes.NewQueryClient(c.CLIContext(0)) + return qc.ChannelClientState(context.Background(), &chanTypes.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: true, + }, + }) } -// QueryChannelPair returns a pair of channel responses -func QueryChannelPair(src, dst *Chain, srcH, dstH int64) (map[string]chanTypes.ChannelResponse, error) { - hs := &chans{ - Map: make(map[string]chanTypes.ChannelResponse), - Errs: []error{}, - } +///////////////////////////////////// +// STAKING -> HistoricalInfo // +///////////////////////////////////// - var wg sync.WaitGroup +// 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 + qc := stakingTypes.NewQueryClient(c.CLIContext(int64(height.EpochHeight))) + return qc.HistoricalInfo(context.Background(), &stakingTypes.QueryHistoricalInfoRequest{ + Height: int64(height.EpochHeight), + }) +} - chps := []chpair{ - {src, srcH}, - {dst, dstH}, +// 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 { + return nil, err } - 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) + // create tendermint ValidatorSet from SDK Validators + tmVals := stakingTypes.Validators(res.Hist.Valset).ToTmValidators() + tmValSet := &tmtypes.ValidatorSet{ + Validators: tmVals, + Proposer: tmVals[0], } - wg.Wait() - return hs.Map, hs.Errs.err() -} -func qChanErr(err error) error { return fmt.Errorf("query channel failed: %w", err) } + return tmValSet.ToProto() +} -// 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 - ) +// QueryUnbondingPeriod returns the unbonding period of the chain +func (c *Chain) QueryUnbondingPeriod() (time.Duration, error) { + req := stakingTypes.QueryParamsRequest{} - if bz, err = c.Cdc.MarshalJSON(chanTypes.NewQueryAllChannelsParams(page, limit)); err != nil { - return nil, qChansErr(err) - } + queryClient := stakingTypes.NewQueryClient(c.CLIContext(0)) - 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) + res, err := queryClient.Params(context.Background(), &req) + if err != nil { + return 0, err } - return channels, nil + return res.Params.UnbondingTime, nil } -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 @@ -588,398 +391,66 @@ 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) { - 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(height), 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) -} - -// 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"` +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.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{ + Offset: offset, + Limit: limit, + CountTotal: true, + }, + }) + // return res.Commitments, err } -// 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"` +// 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.UnreceivedPackets(context.Background(), &chanTypes.QueryUnreceivedPacketsRequest{ + PortId: c.PathEnd.PortID, + ChannelId: c.PathEnd.ChannelID, + PacketCommitmentSequences: seqs, + }) + return res.Sequences, err } -// 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{}, - }, - }, - 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 +// 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 -func (c *Chain) QueryTx(hashHex string) (sdk.TxResponse, error) { +func (c *Chain) QueryTx(hashHex string) (*ctypes.ResultTx, 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 - - resBlocks, err := c.queryBlocksForTxResults([]*ctypes.ResultTx{resTx}) - if err != nil { - return sdk.TxResponse{}, err - } - - out, err := c.formatTxResult(resTx, resBlocks[resTx.Height]) - 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") } @@ -992,30 +463,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, "") + res, 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) - 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 @@ -1076,44 +528,19 @@ 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(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 @@ -1122,14 +549,15 @@ 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 func (c *Chain) QueryHeaderAtHeight(height int64) (*tmclient.Header, error) { + var ( + page int = 1 + perPage int = 100000 + ) if height <= 0 { return nil, fmt.Errorf("must pass in valid height, %d not valid", height) } @@ -1139,16 +567,21 @@ 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 } 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), + // We are missing a light.Commit type here + SignedHeader: res.SignedHeader.ToProto(), + ValidatorSet: protoVal, }, nil } @@ -1172,60 +605,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.Codec, 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.Codec, txBytes []byte) (sdk.Tx, error) { - var tx authTypes.StdTx - err := cdc.UnmarshalBinaryBare(txBytes, &tx) - if err != nil { - return nil, err - } - - 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, "'") @@ -1256,7 +635,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/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 a35541a66..b3fb9a0cb 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" ) @@ -21,7 +22,7 @@ type relayMsgTimeout struct { seq uint64 timeout uint64 timeoutStamp uint64 - dstRecvRes *chanTypes.RecvResponse + dstRecvRes *chanTypes.QueryPacketCommitmentResponse pass bool } @@ -39,25 +40,29 @@ 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(sh.GetHeader(dst.ChainID).Header.Height-1, rp.seq) if err != nil { return err - } else if dstRecvRes.Proof.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)-1), rp.seq) + dst.ChainID, int64(sh.GetHeight(dst.ChainID)), rp.seq) } return nil }); err != nil { dst.Error(err) return } - - rp.dstRecvRes = &dstRecvRes + rp.dstRecvRes = dstRecvRes return } @@ -65,12 +70,18 @@ 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, rp.dstRecvRes.ProofHeight, src.MustGetAddress(), @@ -82,7 +93,7 @@ type relayMsgRecvPacket struct { seq uint64 timeout uint64 timeoutStamp uint64 - dstComRes *CommitmentResponse + dstComRes *chanTypes.QueryPacketCommitmentResponse pass bool } @@ -111,16 +122,21 @@ 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(sh.GetHeader(dst.ChainID).Header.Height-1, rp.seq) if err != nil { return err - } else if dstCommitRes.Proof.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)-1), rp.seq) + dst.ChainID, int64(sh.GetHeight(dst.ChainID)), rp.seq) } return nil }); err != nil { @@ -128,7 +144,7 @@ func (rp *relayMsgRecvPacket) FetchCommitResponse(src, dst *Chain, sh *SyncHeade return } - rp.dstComRes = &dstCommitRes + rp.dstComRes = dstCommitRes return } @@ -136,8 +152,21 @@ 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, + 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, + ) + return chanTypes.NewMsgRecvPacket( + packet, + rp.dstComRes.Proof, + rp.dstComRes.ProofHeight, + src.MustGetAddress(), ) } @@ -147,7 +176,7 @@ type relayMsgPacketAck struct { seq uint64 timeout uint64 timeoutStamp uint64 - dstComRes *CommitmentResponse + dstComRes *chanTypes.QueryPacketCommitmentResponse } func (rp *relayMsgPacketAck) Data() []byte { @@ -161,13 +190,18 @@ 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, rp.dstComRes.ProofHeight, src.MustGetAddress(), @@ -175,20 +209,26 @@ 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(sh.GetHeader(dst.ChainID).Header.Height-1, rp.seq) if err != nil { return err - } else if dstCommitRes.Proof.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)-1), rp.seq) + dst.ChainID, int64(sh.GetHeight(dst.ChainID)), rp.seq) } return nil }); err != nil { dst.Error(err) return } - rp.dstComRes = &dstCommitRes + rp.dstComRes = dstCommitRes return nil } 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/relayer/verifier.go b/relayer/verifier.go index 94b4cff71..322b8fa91 100644 --- a/relayer/verifier.go +++ b/relayer/verifier.go @@ -6,7 +6,6 @@ import ( "io/ioutil" "os" "path/filepath" - "sync" "time" tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" @@ -15,168 +14,113 @@ 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" + 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" ) -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 { - out = fmt.Errorf("err: %w", err) +// 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 light client logging. (maybe as a hidden prop +// on the Chain struct that users could pass in the config??) +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) { + 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) +// 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 { + srch, err = src.QueryLatestHeader() + return err + }) + eg.Go(func() error { + dsth, err = dst.QueryLatestHeader() + return err + }) + if err := eg.Wait(); err != nil { + return nil, nil, err } - wg.Wait() - return hs.Map, hs.err() + 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.LiteClientWithoutTrust(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.TrustedHeader(0) + sh, err = client.TrustedLightBlock(0) if err != nil { - return nil, liteError(err) + return nil, lightError(err) } } - vs, _, err := client.TrustedValidatorSet(sh.Height) - if err != nil { - return nil, liteError(err) - } - - return &tmclient.Header{SignedHeader: *sh, ValidatorSet: vs}, nil -} - -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) + protoVal, err := tmtypes.NewValidatorSet(sh.ValidatorSet.Validators).ToProto() if err != nil { return nil, err } - return &tmclient.Header{SignedHeader: *sh, ValidatorSet: vs}, nil + return &tmclient.Header{ + SignedHeader: sh.SignedHeader.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) +// 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 { - 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.NewClientFromTrustedStore(c.ChainID, c.GetTrustingPeriod(), httpProvider, - []litep.Provider{httpProvider}, dbs.New(db, ""), - lite.Logger(logger)) -} - -// 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 + panic(err) } - return lc, err + return cl } -// 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 +// 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.LightHTTP() if err := retry.Do(func() error { height, err = c.QueryLatestHeight() @@ -188,32 +132,63 @@ 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.Hash().Bytes())) + lb, err := prov.LightBlock(height) if err != nil { return nil, err } + return light.NewClient( + c.ChainID, + light.TrustOptions{ + Period: c.GetTrustingPeriod(), + Height: height, + Hash: lb.SignedHeader.Hash(), + }, + prov, + // TODO: provide actual witnesses! + // NOTE: This requires adding them to the chain config + []lightp.Provider{prov}, + dbs.New(db, ""), + logger) +} - _, err = lc.Update(time.Now()) - if err != nil { - return nil, err - } +// LightClientWithTrust takes a header from the chain and attempts to add that header to the light +// database. +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 + []lightp.Provider{prov}, + dbs.New(db, ""), + logger) +} - return lc, nil +// 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 + []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 { @@ -230,23 +205,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. @@ -257,8 +232,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 } @@ -267,15 +242,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.LiteClientWithoutTrust(db) + client, err := c.LightClient(db) if err != nil { return -1, err } @@ -283,43 +258,43 @@ 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.LiteClientWithoutTrust(db) + client, err := c.LightClient(db) if err != nil { return nil, err } - sh, err := client.TrustedHeader(height) + sh, err := client.TrustedLightBlock(height) if err != nil { return nil, err } - vs, _, err := client.TrustedValidatorSet(sh.Height) + protoVal, err := tmtypes.NewValidatorSet(sh.ValidatorSet.Validators).ToProto() if err != nil { return nil, err } - return &tmclient.Header{SignedHeader: *sh, ValidatorSet: vs}, nil + 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.TrustNodeInitClient(db) + _, err = c.LightClientWithoutTrust(db) if err != nil { return err } diff --git a/scripts/config-relayer b/scripts/config-relayer index 68da43d6c..5217ee699 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" @@ -30,14 +30,11 @@ 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) -echo +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 -echo "Creating lite clients..." -echo +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 9616c2c13..99721b91e 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" @@ -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 203e228a1..a8e6b7ff7 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" @@ -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/scripts/one-chain b/scripts/one-chain new file mode 100755 index 000000000..3cd11129d --- /dev/null +++ b/scripts/one-chain @@ -0,0 +1,63 @@ +#!/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 $(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 + +# 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 +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 & \ No newline at end of file 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..8065eb233 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 @@ -41,7 +43,7 @@ if [[ -d $GAIA_REPO ]]; then 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 @@ -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/relayer_agoric_test.go b/test/relayer_agoric_test.go deleted file mode 100644 index f8202fd6b..000000000 --- a/test/relayer_agoric_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/iqlusioninc/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(), true)) - require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress(), true)) - - // 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)) - - // 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(), false)) - require.NoError(t, dst.SendTransferMsg(src, twoSrcTestCoin, src.MustGetAddress(), false)) - - // 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()) - - // 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) - 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 71d764d29..000000000 --- a/test/relayer_coco_test.go +++ /dev/null @@ -1,98 +0,0 @@ -package test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/iqlusioninc/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(), true)) - require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress(), true)) - - // 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)) - - // 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(), false)) - require.NoError(t, dst.SendTransferMsg(src, twoTestCoinSrc, src.MustGetAddress(), false)) - - // 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()) - - // 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) - 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_gaia_test.go b/test/relayer_gaia_test.go index 8906976b5..731e6a7d3 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" ) @@ -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)) @@ -75,24 +75,20 @@ 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()) - - // 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)) + require.Equal(t, dstExpected.AmountOf(testDenom).Int64()-4000, dstGot.AmountOf(testDenom).Int64()) // 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()) } diff --git a/test/relayer_mtd_test.go b/test/relayer_mtd_test.go deleted file mode 100644 index 0eac379ff..000000000 --- a/test/relayer_mtd_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/iqlusioninc/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(), true)) - require.NoError(t, src.SendTransferMsg(dst, srcTestCoin, dst.MustGetAddress(), true)) - - // 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)) - - // 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(), false)) - require.NoError(t, dst.SendTransferMsg(src, twoSrcTestCoin, src.MustGetAddress(), false)) - - // 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()) - - // 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) - 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 fa5c72e86..000000000 --- a/test/relayer_rocketzone_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/iqlusioninc/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(), true)) - require.NoError(t, src.SendTransferMsg(dst, testCoinSrc, dst.MustGetAddress(), true)) - - // 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)) - - // 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(), false)) - require.NoError(t, dst.SendTransferMsg(src, twoTestCoinSrc, src.MustGetAddress(), false)) - - // 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()) - - // 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) - 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/test_chains.go b/test/test_chains.go index e2a7521ac..0c1802b0d 100644 --- a/test/test_chains.go +++ b/test/test_chains.go @@ -5,104 +5,23 @@ import ( "testing" "time" - "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/iqlusioninc/relayer/relayer" + 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: "2d61264", + 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", } ) @@ -120,14 +39,9 @@ type ( testChainConfig struct { dockerImage string dockerTag string - cdc *std.Codec - amino *codec.Codec rpcPort string timeout time.Duration accountPrefix string - gas uint64 - gasPrices string - defaultDenom string trustingPeriod string } ) @@ -136,15 +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, - DefaultDenom: tc.t.defaultDenom, + GasAdjustment: 1.0, TrustingPeriod: tc.t.trustingPeriod, } } diff --git a/test/test_queries.go b/test/test_queries.go index 61c42e724..150fb4acd 100644 --- a/test/test_queries.go +++ b/test/test_queries.go @@ -3,9 +3,10 @@ package test import ( "testing" + clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" "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 @@ -16,11 +17,12 @@ 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) - 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.ClientType().String(), "tendermint") } // testConnectionPair tests that the only connection on src and dst is between the two chains @@ -31,23 +33,24 @@ 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) - 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") + 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) 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 @@ -58,21 +61,21 @@ 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].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) 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.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 6048dfbfb..6ff9e2b7e 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 @@ -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()) @@ -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) @@ -162,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 } @@ -205,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 } diff --git a/testnets/README.md b/testnets/README.md index f06793e3f..03905da72 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 @@ -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...