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

DNM: IBC-Gaia Integration #130

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0f68573
update mod
mossid Sep 3, 2019
601ea4c
fix mod
mossid Sep 3, 2019
e6563ce
update mod
mossid Sep 17, 2019
d6b9f98
Merge branch 'master' of github.com:cosmos/gaia into joon/ibc-gaia-in…
mossid Sep 17, 2019
38e34ca
fix go mod problem completly
mossid Sep 17, 2019
609c4b8
reflect sdk commit
mossid Sep 19, 2019
bbc7aed
add shell scripts, add readme
mossid Sep 19, 2019
d3e21d2
add channel handshake
mossid Sep 20, 2019
e583706
Fix IBC docs
jackzampolin Sep 30, 2019
6102c55
Update docs
jackzampolin Oct 1, 2019
90abacc
fix handshake
mossid Oct 1, 2019
114be93
add mocksend/mockrecv apps
mossid Oct 1, 2019
18a6b52
remove -mod=readonly
jackzampolin Oct 1, 2019
edffb9c
use cosmos/cosmos-sdk#5124 as SDK-IBC interface
fedekunze Oct 3, 2019
b96de61
merge master
fedekunze Oct 3, 2019
dd2f1e9
remove -mod=readonly again
fedekunze Oct 3, 2019
3dcbc39
WIP 2chainz tutorial, verifier still blockin
jackzampolin Oct 4, 2019
0d7afc9
Verifier creation working properly, debugging panic on store query be…
jackzampolin Oct 4, 2019
4848be2
Just need to be able to flush packet from channel
jackzampolin Oct 7, 2019
3ecb299
Clarify which branch in instructions
jackzampolin Oct 7, 2019
171ae0f
fix readme
mossid Oct 9, 2019
513e0cd
Update cmd/gaiacli/README.md
fedekunze Oct 9, 2019
409d5ff
update go mod
mossid Oct 10, 2019
ced210a
Merge branch 'joon/ibc-gaia-interface' of github.com:cosmos/gaia into…
mossid Oct 10, 2019
176c722
Update IBC CLI UX
jackzampolin Oct 11, 2019
2c4c56b
add ibcante, update readme
mossid Oct 12, 2019
7eec0a3
Merge branch 'joon/ibc-gaia-interface' of github.com:cosmos/gaia into…
mossid Oct 12, 2019
c1c09be
fix go.sum
mossid Oct 12, 2019
121357d
Merge PR #157: Fix typos
alexfmpe Oct 14, 2019
6df9ff7
Demo in working state
jackzampolin Oct 15, 2019
9248903
Fix go.mod
jackzampolin Oct 15, 2019
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ else
endif

install: go.sum check-ledger
go install -mod=readonly $(BUILD_FLAGS) ./cmd/gaiad
go install -mod=readonly $(BUILD_FLAGS) ./cmd/gaiacli
go install $(BUILD_FLAGS) ./cmd/gaiad
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmmm how comes? Did you have any issues with -mod=readonly? Is there anything I can help out with?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I was having issues with -mod=readonly!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this the case @alessio?

go install $(BUILD_FLAGS) ./cmd/gaiacli

install-debug: go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/gaiadebug
Expand Down
35 changes: 24 additions & 11 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import (
distr "github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/ibc"
mockrecv "github.com/cosmos/cosmos-sdk/x/ibc/mock/recv"
mocksend "github.com/cosmos/cosmos-sdk/x/ibc/mock/send"
"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
Expand Down Expand Up @@ -53,6 +56,7 @@ var (
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
supply.AppModuleBasic{},
ibc.AppModuleBasic{},
)

// module account permissions
Expand Down Expand Up @@ -91,16 +95,19 @@ type GaiaApp struct {
tkeys map[string]*sdk.TransientStoreKey

// keepers
accountKeeper auth.AccountKeeper
bankKeeper bank.Keeper
supplyKeeper supply.Keeper
stakingKeeper staking.Keeper
slashingKeeper slashing.Keeper
mintKeeper mint.Keeper
distrKeeper distr.Keeper
govKeeper gov.Keeper
crisisKeeper crisis.Keeper
paramsKeeper params.Keeper
accountKeeper auth.AccountKeeper
bankKeeper bank.Keeper
supplyKeeper supply.Keeper
stakingKeeper staking.Keeper
slashingKeeper slashing.Keeper
mintKeeper mint.Keeper
distrKeeper distr.Keeper
govKeeper gov.Keeper
crisisKeeper crisis.Keeper
paramsKeeper params.Keeper
ibcKeeper ibc.Keeper
ibcMockSendKeeper mocksend.Keeper
ibcMockRecvKeeper mockrecv.Keeper

// the module manager
mm *module.Manager
Expand All @@ -122,7 +129,7 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
keys := sdk.NewKVStoreKeys(
bam.MainStoreKey, auth.StoreKey, staking.StoreKey,
supply.StoreKey, mint.StoreKey, distr.StoreKey, slashing.StoreKey,
gov.StoreKey, params.StoreKey,
gov.StoreKey, params.StoreKey, ibc.StoreKey, mocksend.ModuleName, mockrecv.ModuleName,
)
tkeys := sdk.NewTransientStoreKeys(staking.TStoreKey, params.TStoreKey)

Expand Down Expand Up @@ -160,6 +167,9 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
app.cdc, keys[slashing.StoreKey], &stakingKeeper, slashingSubspace, slashing.DefaultCodespace,
)
app.crisisKeeper = crisis.NewKeeper(crisisSubspace, invCheckPeriod, app.supplyKeeper, auth.FeeCollectorName)
app.ibcKeeper = ibc.NewKeeper(app.cdc, keys[ibc.StoreKey])
app.ibcMockSendKeeper = mocksend.NewKeeper(app.cdc, keys[mocksend.ModuleName], app.ibcKeeper.Port(mocksend.ModuleName))
app.ibcMockRecvKeeper = mockrecv.NewKeeper(app.cdc, keys[mockrecv.ModuleName], app.ibcKeeper.Port(mockrecv.ModuleName))

// register the proposal types
govRouter := gov.NewRouter()
Expand Down Expand Up @@ -190,6 +200,9 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
mint.NewAppModule(app.mintKeeper),
slashing.NewAppModule(app.slashingKeeper, app.stakingKeeper),
staking.NewAppModule(app.stakingKeeper, app.accountKeeper, app.supplyKeeper),
ibc.NewAppModule(app.ibcKeeper),
mocksend.NewAppModule(app.ibcMockSendKeeper),
mockrecv.NewAppModule(app.ibcMockRecvKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down
148 changes: 148 additions & 0 deletions cmd/gaiacli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# IBC instruction

// temporal document

## Dependencies

This branch uses non-canonical branch of cosmos-sdk. Before building, run `go mod vendor` on the root directory to retrive the dependencies. To build:

```shell
git clone git@github.com:cosmos/gaia
cd gaia
go mod vendor
make install
gaiad version
gaiacli version
```

Stub out testnet files for 2 nodes, this example does so in your $HOME directory:

```shell
cd ~ && mkdir ibc-testnets && cd ibc-testnet
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
gaiad testnet -o ibc0 --v 1 --chain-id ibc0 --node-dir-prefix n
gaiad testnet -o ibc1 --v 1 --chain-id ibc1 --node-dir-prefix n
```

Fix the configuration files to allow both chains/nodes to run on the same machine

```shell
# Configure the proper database backend for each node
sed -i '' 's/"leveldb"/"goleveldb"/g' ibc0/n0/gaiad/config/config.toml
sed -i '' 's/"leveldb"/"goleveldb"/g' ibc1/n0/gaiad/config/config.toml

# Configure chain ibc1 to have different listening ports
sed -i '' 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:26556"#g' ibc1/n0/gaiad/config/config.toml
sed -i '' 's#"tcp://0.0.0.0:26657"#"tcp://0.0.0.0:26557"#g' ibc1/n0/gaiad/config/config.toml
sed -i '' 's#"localhost:6060"#"localhost:6061"#g' ibc1/n0/gaiad/config/config.toml
sed -i '' 's#"tcp://127.0.0.1:26658"#"tcp://127.0.0.1:26558"#g' ibc1/n0/gaiad/config/config.toml
```

Then configure your `gaiacli` instances for each chain:

```bash
gaiacli config --home ibc0/n0/gaiacli/ chain-id ibc0
gaiacli config --home ibc1/n0/gaiacli/ chain-id ibc1
gaiacli config --home ibc0/n0/gaiacli/ node http://localhost:26657
gaiacli config --home ibc1/n0/gaiacli/ node http://localhost:26557

# Add the key from ibc1 to the ibc0 cli
jq -r '.secret' ibc1/n0/gaiacli/key_seed.json | pbcopy

# Paste the mnemonic from the above command after setting password (12345678)
gaiacli --home ibc0/n0/gaiacli keys add n1 --recover
```

After configuration is complete, start each node in a seperate terminal window:

```bash
gaiad --home ibc0/n0/gaiad start
gaiad --home ibc1/n0/gaiad start
```

## Client

Create a client on ibc1:

```bash
gaiacli --home ibc0/n0/gaiacli q ibc client path > path0.json
gaiacli --home ibc0/n0/gaiacli q ibc client consensus-state > state0.json
gaiacli --home ibc1/n0/gaiacli tx ibc client create c1 ./state0.json --from n0
gaiacli --home ibc1/n0/gaiacli q ibc client client c1
```

Create a client on ibc0:

```bash
gaiacli --home ibc1/n0/gaiacli q ibc client path > path1.json
gaiacli --home ibc1/n0/gaiacli q ibc client consensus-state > state1.json
gaiacli --home ibc0/n0/gaiacli tx ibc client create c0 ./state1.json --from n0
gaiacli --home ibc0/n0/gaiacli q ibc client client c0
```

## Connection

Connections can be established with `connection.sh $CLIENTID` command. It will print

```shell
gaiacli \
--home ibc0/n0/gaiacli \
tx ibc connection handshake \
conn0 c0 path1.json \
conn1 c1 path0.json \
--from1 n0 --from2 n1 \
--node1 tcp://localhost:26657 \
--node2 tcp://localhost:26557
```

Once the connection is established you should be able to query it:

```bash
gaiacli --home ibc0/n0/gaiacli q ibc connection connection conn0 --trust-node
```

## Channel

To establish a channel using the `ibc-mock` application protocol run the following command:

```
gaiacli \
--home ibc0/n0/gaiacli \
tx ibc channel handshake \
ibc-mock chan0 conn0 \
ibc-mock chan1 conn1 \
--from1 n0 --from2 n1
```

You can query the channel after establishment by

```bash
gaiacli --home ibc0/n0/gaiacli query ibc channel channel ibc-mock chan0 --trust-node
```

## Send Packet
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both send-packet commands are using ibc0, but all the other sections have matched pairs of ibc0/ibc1 commands. Is this intentional? I'm guessing it's just a typo.

Copy link
Member

@jackzampolin jackzampolin Oct 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should the commands look? This part of the instructions are left over from the loopback demo

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flush command is currently using ibc0 as its home but making transaction on ibc1, which is bit misleading

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mossid so how would you rewrite the example?


To send a packet using the `ibc-mock` application protocol run the following command:

```
gaiacli --home ibc0/n0/gaiacli q ibcmocksend sequence chan0
```

The command will return the latest sent sequence(0 if not exists). Run command with next sequence.

```
gaiacli --home ibc0/n0/gaiacli tx ibcmocksend sequence chan0 (sequence+1)
```

## Receive Packet

To receive packets using the `ibc-mock` application protocol run the following command:

```
gaiacli --home ibc0/n0/gaiacli tx ibc channel flush ibcmocksend chan0 --trust-node
```

To see the updated sequence run the following command:

```
gaiacli --home ibc1/n0/gaiacli q ibcmockrecv sequence chan1 --trust-node
```
Loading