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

docs: IBC setup docs was added #554

Merged
merged 2 commits into from
Apr 6, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
250 changes: 250 additions & 0 deletions docs/IBC-TRANSFER-WALKTHROUGH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
# IBC-transfer Walkthrough
## Summary
We will:
1. Add relayer account in config.yaml file
2. Specify the ports in config.yaml file
3. Install the relayer
4. Setup the relayer
5. Start the chains
6. Create the connection
7. Create Channel
8. Start the Relayer
9. Make a Sample Transaction

## Add relayer account in config.yaml file
You need to add the relayer account in config.yaml file in both chains.To add the account you simply need to add the following code.
```
- name: relayer
address : "<relayer_address>"
coins: ["10000000000upylon", "100000000ubedrock"]
```
The `address` field will be added later in the walkthrough guide.

## Specify the ports in config.yaml file
We will specify the ports in `config.yaml` file so that both chains donot use the same port and to avoid errors.
The sample ports for `pylons/config.yaml`
```
host:
rpc: ":36659"
p2p: ":36658"
prof: ":6062"
grpc: ":9991"
api: ":1318"
frontend: ":8081"
dev-ui: ":12346"
grpc-web: ":9093"
```

The sample ports for `juno/config.yaml` are:
```
host:
rpc: ":26659"
p2p: ":26658"
prof: ":5062"
grpc: ":8991"
api: ":1316"
frontend: ":8081"
dev-ui: ":13346"
grpc-web: ":8093"
```
You can have different port but the respective ports on both chain should not match.
faisalnaveedRNS marked this conversation as resolved.
Show resolved Hide resolved

## Installing the relayer
We will be using the confio ts-relayer.
Command to install the relayer is:
faisalnaveedRNS marked this conversation as resolved.
Show resolved Hide resolved
`sudo npm i -g @confio/relayer@main`

It will allow you to use two commads `ibc-setup` & `ibc-relayer`.

Link to the relayer installation : https://github.com/confio/ts-relayer

## Setting-up the relayer
Firstly, you want to create a registry file. Command to create registry file is
faisalnaveedRNS marked this conversation as resolved.
Show resolved Hide resolved
`ibc-setup init`
This command will create a registery.yaml file.
faisalnaveedRNS marked this conversation as resolved.
Show resolved Hide resolved

#### Configure Registry.yaml
Open the file in VS code by this command.
`code ~/.ibc-setup/registry.yaml`
Now, you to add the chain's object and you need to define the details of chains as follows.
faisalnaveedRNS marked this conversation as resolved.
Show resolved Hide resolved
```
chain:
juno:
chain_id: juno-1
prefix: juno
gas_price: 0.000001token
ics20_port: 'transfer'
rpc:
- http://localhost:26659

pylons:
chain_id: pylons-1
prefix: pylo
gas_price: 0.000001ubedrock
ics20_port: 'transfer'
rpc:
- http://localhost:36659
```
ics20_port: if default = ‘transfer’ else you can find the port-id in `x/type/keys.go`.
rpc values can be find inside the `config.yaml` file in both chains.

Choose a reason for hiding this comment

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

"found" instead of "find"


### Configure app.yaml
If app..yaml file is not generated along with the registry.yaml file. Write this command to generate app.yaml file.
faisalnaveedRNS marked this conversation as resolved.
Show resolved Hide resolved
`ibc-setup init --src pylons --dest juno`
Open the app.yaml file in the editor by this command.
`code ~/.ibc-setup/app.yaml`
The file will look like this.
```
src: pylons
dest: juno
mnemonic: stick deputy ankle near motion banana shift normal social hill between major
srcConnection: connection-0
destConnection: connection-0
```
Add `srcConnection: connection-0` & `destConnection: connection-0`
The `mnemonic` will be used to generate the address of the relayer for both chains.

### Get the relayer address for chain
You need to open terminal inside the chain's directory and run the following commands.
`<pylonsd> keys add relayer --recover --dry-run`
Write the `mnemonic` and press enter.
The output will be like this.
```
abc@abc:~$ pylonsd keys add relayer --recover --dry-run
> Enter your bip39 mnemonic
stick deputy ankle near motion banana shift normal social hill between major

- name: relayer
type: local
address: pylo1qvcf7rug8k0uumxdvy0mrkyug75s9umdfa9px9
pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Ak1JEnioXVLln60raRz8kRjhoykTaQR9Cl6pF/77+T5A"}'
mnemonic: ""


```
Copy the address and write it in the `address` field in relayer account in the `<pylons>/config.yml`
The code below for reference is from the `pylons/config.yaml`
```
accounts:
- name: alice
coins: ["20000000000upylon", "200000000ubedrock"]
- name: bob
coins: ["10000000000upylon", "100000000ubedrock"]
- name: relayer
address : "pylo1qvcf7rug8k0uumxdvy0mrkyug75s9umdfa9px9"
coins: ["10000000000upylon", "100000000ubedrock"]
```
Repeat the same process for other chain .

## Start the chains
Start both chain by opening the terminal in the chain's directory and running the following command.
```
starport chain init
starport chain serve --force-reset
```

## Create the connection.
After serving both chains, you will need create a connection. This will take the details of the connection from the `registry.yaml` and `app.yaml` file.
faisalnaveedRNS marked this conversation as resolved.
Show resolved Hide resolved
Command to create connection is:
faisalnaveedRNS marked this conversation as resolved.
Show resolved Hide resolved
`starport tools ibc-setup connect -- -v`

The terminal output will be similiar to this.
faisalnaveedRNS marked this conversation as resolved.
Show resolved Hide resolved
```
hassan@hassan-rns:~/work/src/old ones/pylons$ starport tools ibc-setup connect -- -v
verbose: Queried unbonding period {"seconds":1814400}
verbose: Create Tendermint client
verbose: Queried unbonding period {"seconds":1814400}
verbose: Create Tendermint client
info: Connection open init: 07-tendermint-0 => 07-tendermint-0
verbose: Get latest commit
verbose: Get validator set for height 462
verbose: Get header for height 462
verbose: Get validator set for height 452
verbose: Get header for height 452
verbose: Update Tendermint client 07-tendermint-0
info: Connection open try: 07-tendermint-0 => 07-tendermint-0 (connection-0)
verbose: Get latest commit
verbose: Get validator set for height 494
verbose: Get header for height 494
verbose: Get validator set for height 480
verbose: Get header for height 480
verbose: Update Tendermint client 07-tendermint-0
info: Connection open ack: connection-0 => connection-0
verbose: Get latest commit
verbose: Get validator set for height 476
verbose: Get header for height 476
verbose: Get validator set for height 463
verbose: Get header for height 463
verbose: Update Tendermint client 07-tendermint-0
info: Connection open confirm: connection-0
Created connections connection-0 (07-tendermint-0) <=> connection-0 (07-tendermint-0)
```

## Create Channel
To create the channel between the two chain, run this command
faisalnaveedRNS marked this conversation as resolved.
Show resolved Hide resolved
`starport tools ibc-setup channel -- --src-connection <connection-0> --dest-connection <connection-0> --src-port <transfer> --dest-port <transfer> --version ics20-1
`

`--src-connection` & `--dest-connection` are the fields you specified in `app.yaml` file.
default `--src-port` is `transfer`
default `--dest-port` is `transfer`

Screenshot of the output:
```
hassan@hassan-rns:~/work/src/old ones/pylons$ starport tools ibc-setup channel -- --src-connection connection-0 --dest-connection connection-0 --src-port transfer --dest-port transfer --version ics20-1
·
· 🛸 Starport v0.19.5 is available!
·
· If you're looking to upgrade check out the instructions: https://docs.starport.network/guide/install.html#upgrading-your-starport-installation
·
··

info: Create channel with sender pylons: transfer => transfer
Created channel:
pylons-1: transfer/channel-0 (connection-0)
juno-1: transfer/channel-0 (connection-0)
```

## Start the Relayer
Command to start the relayer is:
faisalnaveedRNS marked this conversation as resolved.
Show resolved Hide resolved
`starport tools ibc-relayer start -- -v`

```
hassan@hassan-rns:~/work/src/old ones/pylons$ starport tools ibc-relayer start -- -v
·
· 🛸 Starport v0.19.5 is available!
·
· If you're looking to upgrade check out the instructions: https://docs.starport.network/guide/install.html#upgrading-your-starport-installation
·
··

info: Use last queried heights from /home/hassan/.ibc-setup/last-queried-heights.json file.
verbose: [juno-1] Get header for height 632
verbose: [pylons-1] Get header for height 614
verbose: Get pending packets on pylons
verbose: Get pending packets on juno
info: Relay 0 packets from pylons => juno
info: Relay 0 packets from juno => pylons
verbose: Get pending acks on pylons
verbose: Get pending acks on juno
info: Relay 0 acks from pylons => juno
info: Relay 0 acks from juno => pylons
info: Timeout 0 packets sent from pylons
info: Timeout 0 packets sent from juno
verbose: next heights to relay {"packetHeightA":700,"packetHeightB":725,"ackHeightA":702,"ackHeightB":727}
info: Ensuring clients are not stale
verbose: Checking if juno has recent header of pylons
verbose: Checking if pylons has recent header of juno
info: Sleeping 60 seconds...

```

Relayer setup is completed.

## Sample Transaction

To do a transaction between the two chains, use this command:

`<pylonsd> tx ibc-transfer transfer transfer channel-0 <reciever_address> 10000upylon --from <sender_address>`