Skip to content

Commit

Permalink
Merge pull request #782 from cosmos/release/v0.13.1
Browse files Browse the repository at this point in the history
Release/v0.13.1
  • Loading branch information
ebuchman authored Apr 3, 2018
2 parents 797aec2 + 414d3e0 commit 4f0acc4
Show file tree
Hide file tree
Showing 16 changed files with 1,486 additions and 644 deletions.
21 changes: 14 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# Changelog

## 0.13.1 (April 3, 2018)

BUG FIXES

* [x/ibc] Fix CLI and relay for IBC txs
* [x/stake] Various fixes/improvements

## 0.13.0 (April 2, 2018)

BREAKING CHANGES

* [basecoin] Remove cool/sketchy modules -> moved to new `democoin`
* [basecoin] NewBasecoinApp takes a `map[string]dbm.DB` as temporary measure
to allow mounting multiple stores with their own DB until they can share one
* [staking] Renamed to `simplestake`
* [x/staking] Renamed to `simplestake`
* [builder] Functions don't take `passphrase` as argument
* [server] GenAppState returns generated seed and address
* [basecoind] `init` command outputs JSON of everything necessary for testnet
Expand All @@ -18,7 +25,7 @@ FEATURES

* [types] `Coin` supports direct arithmetic operations
* [basecoind] Add `show_validator` and `show_node_id` commands
* [staking] Initial merge of full staking module!
* [x/stake] Initial merge of full staking module!
* [democoin] New example application to demo custom modules

IMPROVEMENTS
Expand All @@ -42,9 +49,9 @@ BREAKING CHANGES
* [types] Replace tx.GetFeePayer with FeePayer(tx) - returns the first signer
* [types] NewStdTx takes the Fee
* [types] ParseAccount -> AccountDecoder; ErrTxParse -> ErrTxDecoder
* [auth] AnteHandler deducts fees
* [bank] Move some errors to `types`
* [bank] Remove sequence and signature from Input
* [x/auth] AnteHandler deducts fees
* [x/bank] Move some errors to `types`
* [x/bank] Remove sequence and signature from Input

FEATURES

Expand All @@ -68,8 +75,8 @@ IMPROVEMENTS
* [specs] Staking

BUG FIXES
* [auth] Fix setting pubkey on new account
* [auth] Require signatures to include the sequences
* [x/auth] Fix setting pubkey on new account
* [x/auth] Require signatures to include the sequences
* [baseapp] Dont panic on nil handler
* [basecoin] Check for empty bytes in account and tx

Expand Down
4 changes: 2 additions & 2 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ package version

const Maj = "0"
const Min = "13"
const Fix = "0"
const Fix = "1"

const Version = "0.13.0"
const Version = "0.13.1"

// GitCommit set by build flags
var GitCommit = ""
160 changes: 146 additions & 14 deletions x/ibc/commands/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,157 @@
# IBC CLI Usage
# IBC Doubble Hubble

## initialize
## Remove remaining data

```bash
basecoind init # copy the recover key
basecli keys add keyname --recover
basecoind start
```console
> rm -r ~/.chain1
> rm -r ~/.chain2
> rm -r ~/.basecli
```

## transfer
## Initialize both chains

`transfer` sends coins from one chain to another(or itself).
```console
> basecoind init --home ~/.chain1
I[04-02|14:03:33.704] Generated private validator module=main path=/home/mossid/.chain1/config/priv_validator.json
I[04-02|14:03:33.705] Generated genesis file module=main path=/home/mossid/.chain1/config/genesis.json
{
"secret": "crunch ignore trigger neither differ dance cheap brick situate floor luxury citizen husband decline arrow abandon",
"account": "C69FEB398A29AAB1B3C4F07DE22208F35E711BCC",
"validator": {
"pub_key": {
"type": "ed25519",
"data": "8C9917D5E982E221F5A1450103102B44BBFC1E8768126C606246CB37B5794F4D"
},
"power": 10,
"name": ""
},
"node_id": "3ac8e6242315fd62143dc3e52c161edaaa6b1a64",
"chain_id": "test-chain-ZajMfr"
}
> ADDR1=C69FEB398A29AAB1B3C4F07DE22208F35E711BCC
> ID1=test-chain-ZajMfr
> NODE1=tcp://0.0.0.0:36657
> basecli keys add key1 --recover
Enter a passphrase for your key:
Repeat the passphrase:
Enter your recovery seed phrase:
crunch ignore trigger neither differ dance cheap brick situate floor luxury citizen husband decline arrow abandon
key1 C69FEB398A29AAB1B3C4F07DE22208F35E711BCC

```bash
basecli transfer --name keyname --to address_of_destination --amount 10mycoin --chain test-chain-AAAAAA --chain-id AAAAAA

> basecoind init --home ~/.chain2
I[04-02|14:09:14.453] Generated private validator module=main path=/home/mossid/.chain2/config/priv_validator.json
I[04-02|14:09:14.453] Generated genesis file module=main path=/home/mossid/.chain2/config/genesis.json
{
"secret": "age guide awesome month female left oxygen soccer define high grocery work desert dinner arena abandon",
"account": "DC26002735D3AA9573707CFA6D77C12349E49868",
"validator": {
"pub_key": {
"type": "ed25519",
"data": "A94FE4B9AD763D301F4DD5A2766009812495FB7A79F1275FB8A5AF09B44FD5F3"
},
"power": 10,
"name": ""
},
"node_id": "ad26831330e1c72b85276d53c20f0680e6fd4cf5"
"chain_id": "test-chain-4XHTPn"
}
> ADDR2=DC26002735D3AA9573707CFA6D77C12349E49868
> ID2=test-chain-4XHTPn
> NODE2=tcp://0.0.0.0:46657
> basecli keys add key2 --recover
Enter a passphrase for your key:
Repeat the passphrase:
Enter your recovery seed phrase:
age guide awesome month female left oxygen soccer define high grocery work desert dinner arena abandon
key2 DC26002735D3AA9573707CFA6D77C12349E49868


> basecoind start --home ~/.chain1 --address tcp://0.0.0.0:36658 --rpc.laddr tcp://0.0.0.0:36657 --p2p.laddr tcp://0.0.0.0:36656
...

> basecoind start --home ~/.chain2 # --address tcp://0.0.0.0:46658 --rpc.laddr tcp://0.0.0.0:46657 --p2p.laddr tcp://0.0.0.0:46656
...
```
## Check balance

```console
> basecli account $ADDR1 --node $NODE1
{
"address": "C69FEB398A29AAB1B3C4F07DE22208F35E711BCC",
"coins": [
{
"denom": "mycoin",
"amount": 9007199254740992
}
],
"public_key": null,
"sequence": 0,
"name": ""
}

> basecli account $ADDR2 --node $NODE2
{
"address": "DC26002735D3AA9573707CFA6D77C12349E49868",
"coins": [
{
"denom": "mycoin",
"amount": 9007199254740992
}
],
"public_key": null,
"sequence": 0,
"name": ""
}

```

## Transfer coins (addr1:chain1 -> addr2:chain2)

```console
> basecli transfer --name key1 --to $ADDR2 --amount 10mycoin --chain $ID2 --chain-id $ID1 --node $NODE1
Password to sign with 'key1':
Committed at block 1022. Hash: E16019DCC4AA08CA70AFCFBC96028ABCC51B6AD0
> basecli account $ADDR1 --node $NODE1
{
"address": "C69FEB398A29AAB1B3C4F07DE22208F35E711BCC",
"coins": [
{
"denom": "mycoin",
"amount": 9007199254740982
}
],
"public_key": {
"type": "ed25519",
"data": "9828FF1780A066A0D93D840737566B697035448D6C880807322BED8919348B2B"
},
"sequence": 1,
"name": ""
}
```

The id of the chain can be found in `$HOME/.basecoind/config/genesis.json`
## Relay IBC packets

## relay
```console
> basecli relay --name key2 --from-chain-id $ID1 --from-chain-node $NODE1 --to-chain-id $ID2 --to-chain-node $NODE2 --chain-id $ID2
Password to sign with 'key2':
I[04-03|16:18:59.984] Detected IBC packet number=0
I[04-03|16:19:00.869] Relayed IBC packet number=0
> basecli account $ADDR2 --node $NODE2
{
"address": "DC26002735D3AA9573707CFA6D77C12349E49868",
"coins": [
{
"denom": "mycoin",
"amount": 9007199254741002
}
],
"public_key": {
"type": "ed25519",
"data": "F52B4FA545F4E9BFE5D7AF1DD2236899FDEF905F9B3057C38D7C01BF1B8EB52E"
},
"sequence": 1,
"name": ""
}

```bash
basecli relay --name keyname --from-chain-id test-chain-AAAAAA --from-chain-node=tcp://0.0.0.0:46657 --to-chain-id test-chain-AAAAAA --to-chain-node=tcp://0.0.0.0:46657
```
2 changes: 1 addition & 1 deletion x/ibc/commands/ibctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func buildMsg(from sdk.Address) (sdk.Msg, error) {
}
to := sdk.Address(bz)

packet := ibc.NewIBCPacket(from, to, coins, client.FlagChainID,
packet := ibc.NewIBCPacket(from, to, coins, viper.GetString(client.FlagChainID),
viper.GetString(flagChain))

msg := ibc.IBCTransferMsg{
Expand Down
61 changes: 37 additions & 24 deletions x/ibc/commands/relay.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package commands

import (
"fmt"
"os"
"time"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/tendermint/tmlibs/log"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/builder"

Expand All @@ -30,6 +32,8 @@ type relayCommander struct {
decoder sdk.AccountDecoder
mainStore string
ibcStore string

logger log.Logger
}

func IBCRelayCmd(cdc *wire.Codec) *cobra.Command {
Expand All @@ -38,6 +42,8 @@ func IBCRelayCmd(cdc *wire.Codec) *cobra.Command {
decoder: authcmd.GetAccountDecoder(cdc),
ibcStore: "ibc",
mainStore: "main",

logger: log.NewTMLogger(log.NewSyncWriter(os.Stdout)),
}

cmd := &cobra.Command{
Expand Down Expand Up @@ -86,27 +92,26 @@ func (c relayCommander) loop(fromChainID, fromChainNode, toChainID, toChainNode
}

ingressKey := ibc.IngressSequenceKey(fromChainID)

processedbz, err := query(toChainNode, ingressKey, c.ibcStore)
if err != nil {
panic(err)
}

var processed int64
if processedbz == nil {
processed = 0
} else if err = c.cdc.UnmarshalBinary(processedbz, &processed); err != nil {
panic(err)
}

OUTER:
for {
time.Sleep(time.Second)
time.Sleep(5 * time.Second)

processedbz, err := query(toChainNode, ingressKey, c.ibcStore)
if err != nil {
panic(err)
}

var processed int64
if processedbz == nil {
processed = 0
} else if err = c.cdc.UnmarshalBinary(processedbz, &processed); err != nil {
panic(err)
}

lengthKey := ibc.EgressLengthKey(toChainID)
egressLengthbz, err := query(fromChainNode, lengthKey, c.ibcStore)
if err != nil {
fmt.Printf("Error querying outgoing packet list length: '%s'\n", err)
c.logger.Error("Error querying outgoing packet list length", "err", err)
continue OUTER
}
var egressLength int64
Expand All @@ -115,25 +120,30 @@ OUTER:
} else if err = c.cdc.UnmarshalBinary(egressLengthbz, &egressLength); err != nil {
panic(err)
}
fmt.Printf("egressLength queried: %d\n", egressLength)
if egressLength > processed {
c.logger.Info("Detected IBC packet", "number", egressLength-1)
}

seq := c.getSequence(toChainNode)

for i := processed; i < egressLength; i++ {
egressbz, err := query(fromChainNode, ibc.EgressKey(toChainID, i), c.ibcStore)
if err != nil {
fmt.Printf("Error querying egress packet: '%s'\n", err)
c.logger.Error("Error querying egress packet", "err", err)
continue OUTER
}

viper.Set(client.FlagSequence, seq)
seq++

err = c.broadcastTx(toChainNode, c.refine(egressbz, i, passphrase))
if err != nil {
fmt.Printf("Error broadcasting ingress packet: '%s'\n", err)
c.logger.Error("Error broadcasting ingress packet", "err", err)
continue OUTER
}

fmt.Printf("Relayed packet: %d\n", i)
c.logger.Info("Relayed IBC packet", "number", i)
}

processed = egressLength
}
}

Expand All @@ -148,8 +158,6 @@ func query(node string, key []byte, storeName string) (res []byte, err error) {
func (c relayCommander) broadcastTx(node string, tx []byte) error {
orig := viper.GetString(client.FlagNode)
viper.Set(client.FlagNode, node)
seq := c.getSequence(node) + 1
viper.Set(client.FlagSequence, seq)
_, err := builder.BroadcastTx(tx)
viper.Set(client.FlagNode, orig)
return err
Expand All @@ -160,6 +168,7 @@ func (c relayCommander) getSequence(node string) int64 {
if err != nil {
panic(err)
}

account, err := c.decoder(res)
if err != nil {
panic(err)
Expand All @@ -168,6 +177,10 @@ func (c relayCommander) getSequence(node string) int64 {
return account.GetSequence()
}

func setSequence(seq int64) {
viper.Set(client.FlagSequence, seq)
}

func (c relayCommander) refine(bz []byte, sequence int64, passphrase string) []byte {
var packet ibc.IBCPacket
if err := c.cdc.UnmarshalBinary(bz, &packet); err != nil {
Expand Down
Loading

0 comments on commit 4f0acc4

Please sign in to comment.