Skip to content

Commit

Permalink
Merge PR #284: Update to v0.40.0-rc0
Browse files Browse the repository at this point in the history
* Working state

* Fix tests

* WIP packet relay

* Merge PR #285: Fixed issues in scripts to start two or three chains

* Compling

* Finish denom work, move on to streaming relayer proof query issue

* working streaming relayer

* Add debug logging to faucet for remote debug

* add additional logging

* moar faucet debugging

* Update to v0.40.0-rc0 and ensure working README, other docs, tests, etc...

Co-authored-by: Andy Nogueira <[email protected]>
  • Loading branch information
jackzampolin and andynog authored Oct 13, 2020
1 parent 2ed4afd commit 438815d
Show file tree
Hide file tree
Showing 35 changed files with 568 additions and 464 deletions.
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ meant for users wishing to relay packets/data between sets of IBC enabled chains
In additon, it is well documented and intended as an example where anyone who is
interested in building their own relayer can come for complete, working, examples.

If you are here for Game of Zones, please be sure to check out the [offical website](https://goz.cosmosnetwork.dev). The best place for questions is [[email protected]](mailto:[email protected]) regarding Game of Zones and prepratory testnets.

### Security Notice

If you would like to report a security critical bug related to the relayer repo, please send an email to [`[email protected]`](mailto:[email protected])
Expand All @@ -21,7 +19,7 @@ The iqlusion team is dedicated to providing an inclusive and harrassment free ex

## Testnet

If you would like to join the relayer testnet, please [check out the instructions](./testnets/README.md).
If you would like to join a relayer testnet, please [check out the instructions](./testnets/README.md).

### Compatability Table:

Expand Down Expand Up @@ -63,43 +61,43 @@ $ rly cfg add-dir configs/demo/
$ cat ~/.relayer/config/config.yaml

# Now, add the key seeds from each chain to the relayer to give it funds to work with
$ 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)"
$ rly keys restore ibc0 testkey "$(jq -r '.mnemonic' data/ibc0/key_seed.json)"
$ rly k r ibc1 testkey "$(jq -r '.mnemonic' data/ibc1/key_seed.json)"

# 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
$ rly l i 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
$ tree ~/.relayer

# See if the chains are ready to relay over
$ rly chains list

# Now you can connect the two chains with one command:
$ rly tx link demo -d -o 3s

# Check the token balances on both chains
$ rly q balance ibc0
$ rly q bal ibc1
$ rly q balance ibc0 | jq
$ rly q bal ibc1 | jq

# Then send some tokens between the chains
$ rly tx transfer ibc0 ibc1 1000000samoleans $(rly chains address ibc1)
$ rly tx relay demo
$ rly tx relay demo -d

# See that the transfer has completed
$ rly q bal ibc0
$ rly q bal ibc1

# Query the ibc denom to send the tokens back to the sender
$ rly q bal ibc1 -i
$ rly q bal ibc0 | jq
$ rly q bal ibc1 | jq

# Send the tokens back to the account on ibc0
$ rly tx xfer ibc1 ibc0 1000000ibc/2EF4DA9D3880846723AE8514CA9D77738B4F11FBA2A437EDEE43FF62E6792037 $(rly ch addr ibc0)
$ rly tx relay demo
$ rly tx xfer ibc1 ibc0 1000000transfer/ibczeroxfer/samoleans $(rly ch addr ibc0)
$ rly tx rly demo -d

# See that the return trip has completed
$ rly q bal ibc0
$ rly q bal ibc1
$ rly q bal ibc0 | jq
$ rly q bal ibc1 | jq

# NOTE: you will see the stake balances decreasing on each chain. This is to pay for fees
# You can change the amount of fees you are paying on each chain in the configuration.
Expand Down
11 changes: 10 additions & 1 deletion cmd/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func userInputAdd(cmd *cobra.Command) (cfg *Config, err error) {
return nil, err
}

fmt.Println("Gas Adjustment (i.e. 1.0):")
fmt.Println("Gas Adjustment (i.e. 1.3):")
if value, err = readStdin(); err != nil {
return nil, err
}
Expand All @@ -396,6 +396,15 @@ func userInputAdd(cmd *cobra.Command) (cfg *Config, err error) {
return nil, err
}

fmt.Println("Gas Prices (i.e. 0.025stake):")
if value, err = readStdin(); err != nil {
return nil, err
}

if c, err = c.Update("gas-prices", value); err != nil {
return nil, err
}

fmt.Println("Trusting Period (i.e. 336h)")
if value, err = readStdin(); err != nil {
return nil, err
Expand Down
5 changes: 2 additions & 3 deletions cmd/dev.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package cmd

import (
"context"
"fmt"
"os"

// tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -38,7 +37,7 @@ func genesisCmd() *cobra.Command {
return err
}

gen, err := c.Client.Genesis()
gen, err := c.Client.Genesis(context.Background())
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"strconv"

"github.com/cosmos/cosmos-sdk/client/flags"
tmclient "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
tmclient "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
"github.com/ovrclk/relayer/relayer"
"github.com/spf13/cobra"
)
Expand Down
26 changes: 13 additions & 13 deletions cmd/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"io/ioutil"
"os"

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"
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
conntypes "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"
chantypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"
"github.com/ovrclk/relayer/relayer"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -103,7 +103,7 @@ func pathsGenCmd() *cobra.Command {

for _, c := range srcClients.ClientStates {
// TODO: support other client types through a switch here as they become available
clnt, _ := clientTypes.UnpackClientState(c.ClientState)
clnt, _ := clienttypes.UnpackClientState(c.ClientState)
if relayer.MustGetHeight(clnt.GetLatestHeight()) != 0 && !clnt.IsFrozen() {
path.Src.ClientID = c.ClientId
}
Expand All @@ -116,7 +116,7 @@ func pathsGenCmd() *cobra.Command {

for _, c := range dstClients.ClientStates {
// TODO: support other client types through a switch here as they become available
clnt, _ := clientTypes.UnpackClientState(c.ClientState)
clnt, _ := clienttypes.UnpackClientState(c.ClientState)
if relayer.MustGetHeight(clnt.GetLatestHeight()) != 0 && !clnt.IsFrozen() {
path.Dst.ClientID = c.ClientId
}
Expand Down Expand Up @@ -161,7 +161,7 @@ func pathsGenCmd() *cobra.Command {
return err
}

var srcCon *connTypes.IdentifiedConnection
var srcCon *conntypes.IdentifiedConnection
for _, c := range srcConns.Connections {
if c.ClientId == path.Src.ClientID {
srcCon = c
Expand All @@ -174,7 +174,7 @@ func pathsGenCmd() *cobra.Command {
return err
}

var dstCon *connTypes.IdentifiedConnection
var dstCon *conntypes.IdentifiedConnection
for _, c := range dstConns.Connections {
if c.ClientId == path.Dst.ClientID {
dstCon = c
Expand Down Expand Up @@ -217,7 +217,7 @@ func pathsGenCmd() *cobra.Command {
return err
}

var srcChan *chanTypes.IdentifiedChannel
var srcChan *chantypes.IdentifiedChannel
for _, c := range srcChans.Channels {
if c.ConnectionHops[0] == path.Src.ConnectionID {
srcChan = c
Expand All @@ -230,7 +230,7 @@ func pathsGenCmd() *cobra.Command {
return err
}

var dstChan *chanTypes.IdentifiedChannel
var dstChan *chantypes.IdentifiedChannel
for _, c := range dstChans.Channels {
if c.ConnectionHops[0] == path.Dst.ConnectionID {
dstChan = c
Expand Down Expand Up @@ -370,7 +370,7 @@ func pathsListCmd() *cobra.Command {

srcConn, err := ch[src].QueryConnection(srch)
dstConn, _ := ch[dst].QueryConnection(dsth)
if err == nil && srcConn.Connection.State == connTypes.OPEN && dstConn.Connection.State == connTypes.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)
Expand All @@ -380,7 +380,7 @@ func pathsListCmd() *cobra.Command {

srcChan, err := ch[src].QueryChannel(srch)
dstChan, _ := ch[dst].QueryChannel(dsth)
if err == nil && srcChan.Channel.State == chanTypes.OPEN && dstChan.Channel.State == chanTypes.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)
Expand Down Expand Up @@ -473,13 +473,13 @@ func pathsShowCmd() *cobra.Command {

srcConn, err := ch[src].QueryConnection(srch)
dstConn, _ := ch[dst].QueryConnection(dsth)
if err == nil && srcConn.Connection.State == connTypes.OPEN && dstConn.Connection.State == connTypes.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 == chanTypes.OPEN && dstChan.Channel.State == chanTypes.OPEN {
if err == nil && srcChan.Channel.State == chantypes.OPEN && dstChan.Channel.State == chantypes.OPEN {
channel = true
}

Expand Down
48 changes: 41 additions & 7 deletions cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
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"
tmclient "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
"github.com/ovrclk/relayer/relayer"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -57,7 +57,11 @@ func queryIBCDenoms() *cobra.Command {
if err != nil {
return err
}
res, err := chain.QueryDenomTraces(0, 1000)
h, err := chain.QueryLatestHeight()
if err != nil {
return err
}
res, err := chain.QueryDenomTraces(0, 1000, h)
if err != nil {
return err
}
Expand Down Expand Up @@ -153,10 +157,12 @@ func queryAccountCmd() *cobra.Command {
return err
}

chain.UseSDKContext()

res, err := types.NewQueryClient(chain.CLIContext(0)).Account(
context.Background(),
&types.QueryAccountRequest{
Address: addr,
Address: addr.String(),
})
if err != nil {
return err
Expand Down Expand Up @@ -199,7 +205,12 @@ func queryBalanceCmd() *cobra.Command {
return chain.Print(coins, false, false)
}

dts, err := chain.QueryDenomTraces(0, 1000)
h, err := chain.QueryLatestHeight()
if err != nil {
return err
}

dts, err := chain.QueryDenomTraces(0, 1000, h)
if err != nil {
return err
}
Expand All @@ -208,11 +219,13 @@ func queryBalanceCmd() *cobra.Command {
out := sdk.Coins{}
for _, c := range coins {
for _, d := range dts.DenomTraces {
if c.Denom == d.IBCDenom() {
switch {
case c.Amount.Equal(sdk.NewInt(0)):
case c.Denom == d.IBCDenom():
out = append(out, sdk.NewCoin(d.GetFullDenomPath(), c.Amount))
continue
default:
out = append(out, c)
}
out = append(out, c)
}
}
return chain.Print(out, false, false)
Expand Down Expand Up @@ -318,6 +331,13 @@ func queryClientCmd() *cobra.Command {
return err
}

if height == 0 {
height, err = chain.QueryLatestHeight()
if err != nil {
return err
}
}

if err = chain.AddPath(args[1], dcon, dcha, dpor, dord); err != nil {
return err
}
Expand Down Expand Up @@ -423,6 +443,13 @@ func queryConnectionsUsingClient() *cobra.Command {
return err
}

if height == 0 {
height, err = chain.QueryLatestHeight()
if err != nil {
return err
}
}

res, err := chain.QueryConnectionsUsingClient(height)
if err != nil {
return err
Expand Down Expand Up @@ -525,6 +552,13 @@ func queryChannel() *cobra.Command {
return err
}

if height == 0 {
height, err = chain.QueryLatestHeight()
if err != nil {
return err
}
}

res, err := chain.QueryChannel(height)
if err != nil {
return err
Expand Down
15 changes: 10 additions & 5 deletions cmd/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
clientTypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
"github.com/ovrclk/relayer/relayer"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -101,8 +101,13 @@ func createClientCmd() *cobra.Command {
return err
}

consensusParams, err := chains[dst].QueryConsensusParams()
if err != nil {
return err
}

return sendAndPrint([]sdk.Msg{chains[src].PathEnd.CreateClient(dstHeader,
chains[dst].GetTrustingPeriod(), ubdPeriod, chains[src].MustGetAddress())},
chains[dst].GetTrustingPeriod(), ubdPeriod, consensusParams, chains[src].MustGetAddress())},
chains[src], cmd)
},
}
Expand Down Expand Up @@ -173,7 +178,7 @@ func connTry() *cobra.Command {
if err != nil {
return err
}
dstClientState, err := clientTypes.UnpackClientState(dstClientStateRes.ClientState)
dstClientState, err := clienttypes.UnpackClientState(dstClientStateRes.ClientState)
if err != nil {
return err
}
Expand Down Expand Up @@ -238,7 +243,7 @@ func connAck() *cobra.Command {
if err != nil {
return err
}
dstClientState, _ := clientTypes.UnpackClientState(dstClientStateResponse.ClientState)
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
Expand Down Expand Up @@ -469,7 +474,7 @@ func chanAck() *cobra.Command {
}
txs := []sdk.Msg{
chains[src].PathEnd.UpdateClient(updateHeader, chains[src].MustGetAddress()),
chains[src].PathEnd.ChanAck(dstChanState, chains[src].MustGetAddress()),
chains[src].PathEnd.ChanAck(chains[dst].PathEnd, dstChanState, chains[src].MustGetAddress()),
}

return sendAndPrint(txs, chains[src], cmd)
Expand Down
Loading

0 comments on commit 438815d

Please sign in to comment.