Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Gaia v3.0 #278

Merged
merged 57 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
7c7b34a
WIP: not compiling, some errors fixed
jackzampolin Aug 27, 2020
90ebd23
s/iqlusioninc/ovrclk/g
jackzampolin Aug 27, 2020
51526bc
s/iqlusioninc/ovrclk/g
jackzampolin Aug 27, 2020
f526201
WIP: continued debugging, not close to compiling
jackzampolin Aug 27, 2020
4205283
WIP query migration to new cliContext
jackzampolin Aug 28, 2020
ab62a71
Compiler errors in /relayer
jackzampolin Aug 29, 2020
dd19d03
COMPILING
jackzampolin Aug 30, 2020
7e5029f
Reimplement connection messages
jackzampolin Aug 30, 2020
9c04ca5
Refactor two-chainz to call one-chain and get dev-env working again
jackzampolin Aug 30, 2020
0dad18e
Fix lite client wip client transactions
jackzampolin Aug 31, 2020
1dcd598
Update to latest SDK and refactor create client msgs
jackzampolin Sep 1, 2020
acf795d
Working client creation
jackzampolin Sep 2, 2020
97553d5
Pull in latest sdk
jackzampolin Sep 4, 2020
a7caf16
Update relayer to latest version of sdk
jackzampolin Sep 7, 2020
d1b253e
Prepare to fix update-client
jackzampolin Sep 7, 2020
5a6b12f
add inject fields method
AdityaSripal Sep 7, 2020
e3018a3
fix godoc
AdityaSripal Sep 7, 2020
85e4593
fix UpdateClient
AdityaSripal Sep 7, 2020
4d441eb
fix clientstate bug
AdityaSripal Sep 7, 2020
0147938
Update to latest sdk
jackzampolin Sep 8, 2020
98785d0
Update to latest sdk
jackzampolin Sep 8, 2020
25b9e0c
Concurrency refactor and query refactor
jackzampolin Sep 8, 2020
233bd55
Latest debugging
jackzampolin Sep 8, 2020
9e0a9f2
remove unused code
jackzampolin Sep 8, 2020
3144e72
fix TRY query
AdityaSripal Sep 8, 2020
22f405d
WORKING CHANNEL CREATION
jackzampolin Sep 8, 2020
3952033
fix tests
jackzampolin Sep 8, 2020
f5e20ce
MOAR tests
jackzampolin Sep 9, 2020
8490c91
WIP relay unrelayed packets
jackzampolin Sep 9, 2020
20d0ed7
WIP
jackzampolin Sep 9, 2020
43aac85
Bump sdk version
jackzampolin Sep 10, 2020
eea8044
fix timeout issue
AdityaSripal Sep 10, 2020
5e45a77
Merge branch 'jack/gaiav3.0' of github.com:ovrclk/relayer into jack/g…
AdityaSripal Sep 10, 2020
17eb4fe
WORKING STATE :tada:
jackzampolin Sep 11, 2020
53d9e2d
Fix gaia test, prepare for cleanup
jackzampolin Sep 11, 2020
84c9407
Push current state
jackzampolin Sep 14, 2020
29f781f
Fix chain starting issue
jackzampolin Sep 14, 2020
947a964
lite -> light
jackzampolin Sep 14, 2020
135b46a
Working state
jackzampolin Sep 15, 2020
2ad2922
WIP denom support
jackzampolin Sep 15, 2020
853f595
fix querying unrelayed sequences
AdityaSripal Sep 15, 2020
34db59c
Merge branch 'jack/gaiav3.0' of github.com:ovrclk/relayer into jack/g…
AdityaSripal Sep 15, 2020
dc7815a
cleanup
AdityaSripal Sep 15, 2020
f414186
simplify further
AdityaSripal Sep 15, 2020
ea145db
remove commented-out code
AdityaSripal Sep 15, 2020
692443a
Added query for IBC denoms
jackzampolin Sep 16, 2020
f12e019
Merge branch 'jack/gaiav3.0' of github.com:ovrclk/relayer into jack/g…
jackzampolin Sep 16, 2020
7b17082
Update sdk version to incorporate IBC fixes
jackzampolin Sep 16, 2020
00fdbb3
lint cleanup
jackzampolin Sep 16, 2020
b915e5e
Remove old compatable chains, they will need to be re-added
jackzampolin Sep 16, 2020
acdb1d1
Fix linter version in CI
jackzampolin Sep 16, 2020
144de6c
Clean up chain fields
jackzampolin Sep 16, 2020
fa1feca
fix lint
jackzampolin Sep 16, 2020
6e09550
add human readable IBC denoms to bal output
jackzampolin Sep 17, 2020
9ee0dee
Update sdk version
jackzampolin Sep 20, 2020
36cdf04
Ensure that balance prints when there are no ibc transactions
jackzampolin Sep 21, 2020
74a2774
jack/gaiav3.0
jackzampolin Sep 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
[LICENSE]: https://github.com/ovrclk/relayer/blob/master/LICENSE
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)'

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -29,9 +29,9 @@ If you would like to join the relayer testnet, please [check out the instruction

| chain | tests | supported ports |
|-------|--------|----------------|
| [`gaia`](https://github.com/cosmos/gaia) | ![gaia](https://github.com/iqlusioninc/relayer/workflows/TESTING%20-%20gaia%20to%20gaia%20integration/badge.svg) | `transfer` |
| `microtick` | ![microtick](https://github.com/iqlusioninc/relayer/workflows/TESTING%20-%20mtd%20to%20ibc%20integration/badge.svg) | `transfer` |
| [`rocketzone`](https://github.com/rocket-protocol/rocketzone) | ![rocketzone](https://github.com/iqlusioninc/relayer/workflows/TESTING%20-%20rocketzone%20to%20ibc%20integration/badge.svg) | `transfer` |
| [`gaia`](https://github.com/cosmos/gaia) | ![gaia](https://github.com/ovrclk/relayer/workflows/TESTING%20-%20gaia%20to%20gaia%20integration/badge.svg) | `transfer` |
| `microtick` | ![microtick](https://github.com/ovrclk/relayer/workflows/TESTING%20-%20mtd%20to%20ibc%20integration/badge.svg) | `transfer` |
| [`rocketzone`](https://github.com/rocket-protocol/rocketzone) | ![rocketzone](https://github.com/ovrclk/relayer/workflows/TESTING%20-%20rocketzone%20to%20ibc%20integration/badge.svg) | `transfer` |
| [`coco`](https://github.com/CosmicCompass/post-chain) | ![coco](https://github.com/CosmicCompass/relayer/workflows/TESTING%20-%20coco%20to%20ibc%20integration/badge.svg) | `transfer` |

## Demoing the Relayer
Expand Down
5 changes: 2 additions & 3 deletions cmd/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"

"github.com/iqlusioninc/relayer/relayer"
"github.com/ovrclk/relayer/relayer"
)

const (
Expand Down Expand Up @@ -52,8 +52,7 @@ func chainsAddrCmd() *cobra.Command {
return err
}

done := chain.UseSDKContext()
defer done()
chain.UseSDKContext()

addr, err := chain.GetAddress()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
}
Expand Down
218 changes: 1 addition & 217 deletions cmd/dev.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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]",
Expand Down Expand Up @@ -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)
}
10 changes: 3 additions & 7 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ var (
func liteFlags(cmd *cobra.Command) *cobra.Command {
cmd.Flags().Int64(flags.FlagHeight, -1, "Trusted header's height")
cmd.Flags().BytesHexP(flagHash, "x", []byte{}, "Trusted header's hash")
cmd.Flags().StringP(flagURL, "u", "", "Optional URL to fetch trusted-hash and trusted-height")
if err := viper.BindPFlag(flags.FlagHeight, cmd.Flags().Lookup(flags.FlagHeight)); err != nil {
panic(err)
}
if err := viper.BindPFlag(flagHash, cmd.Flags().Lookup(flagHash)); err != nil {
panic(err)
}
if err := viper.BindPFlag(flagURL, cmd.Flags().Lookup(flagURL)); err != nil {
panic(err)
}
return cmd
}

Expand All @@ -53,9 +49,9 @@ func heightFlag(cmd *cobra.Command) *cobra.Command {
}

func paginationFlags(cmd *cobra.Command) *cobra.Command {
cmd.Flags().IntP(flags.FlagPage, "p", 1, "pagination page of light clients to to query for")
cmd.Flags().IntP(flags.FlagLimit, "l", 100, "pagination limit of light clients to query for")
if err := viper.BindPFlag(flags.FlagPage, cmd.Flags().Lookup(flags.FlagPage)); err != nil {
cmd.Flags().Uint64P(flags.FlagOffset, "o", 0, "pagination offset for query")
cmd.Flags().Uint64P(flags.FlagLimit, "l", 100, "pagination limit for query")
if err := viper.BindPFlag(flags.FlagOffset, cmd.Flags().Lookup(flags.FlagOffset)); err != nil {
panic(err)
}
if err := viper.BindPFlag(flags.FlagLimit, cmd.Flags().Lookup(flags.FlagLimit)); err != nil {
Expand Down
Loading