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

Added the handling of begin and end block events #189

Merged
merged 47 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d671209
Added the handling of begin and end block events
RiccardoM May 25, 2021
17b5fb5
Run yarn fix
RiccardoM May 25, 2021
ec21380
Updated chain requirements to have Cosmos v0.42.4 and PR 9081 merged
RiccardoM May 25, 2021
1aefddf
Added changeset entry
RiccardoM May 25, 2021
a50da75
Add home option to ics20 command
Jun 9, 2021
2a955ea
Add changeset
Jun 10, 2021
c3f0e81
Merge pull request #191 from iov-one/add-home-to-ics20
ethanfrey Jun 10, 2021
dcabf3d
musselnet -> oysternet, remove relayer testnets
ethanfrey Jun 21, 2021
a4035b8
Add nyancat testnet
ethanfrey Jun 21, 2021
27de19c
Update README using nyancat
ethanfrey Jun 21, 2021
6f572b5
Test README demo with nyancat
ethanfrey Jun 21, 2021
a4c9a31
Add changelog entry
ethanfrey Jun 21, 2021
621c4ed
Prettify README
ethanfrey Jun 21, 2021
20906ca
[skip ci] Point to non-pruning node on nyancat
ethanfrey Jun 21, 2021
72cc9fd
Merge pull request #193 from confio/update-registry-testnets
ethanfrey Jun 21, 2021
f82ab96
Update blockchain versions
ethanfrey Jun 21, 2021
9033648
Bump cosmjs to 0.25.4
ethanfrey Jun 21, 2021
b8ab8f4
Use standard signing client setup in balances
ethanfrey Jun 21, 2021
ae2ebca
Use much faster polling for binary tests
ethanfrey Jun 21, 2021
9e4a5c3
Add changeset
ethanfrey Jun 21, 2021
eb30805
Merge pull request #194 from confio/update-deps
ethanfrey Jun 21, 2021
ef52b7e
Rough draft cw20 upload
ethanfrey Jun 21, 2021
2a48bf2
Upload script for cw20-base and cw20-ics20
ethanfrey Jun 21, 2021
4401e68
Add contract upload to CI
ethanfrey Jun 21, 2021
1b15924
Prettier js scripts
ethanfrey Jun 21, 2021
0045dab
Instantiate contracts in unit test
ethanfrey Jun 21, 2021
efc8ba3
Test channel handshake with ics20 contract
ethanfrey Jun 21, 2021
ef2895e
Send packet with contract
ethanfrey Jun 21, 2021
e74a38f
Return token over channel
ethanfrey Jun 21, 2021
95b61ca
Expect error on relaying native token over channel
ethanfrey Jun 21, 2021
71d5a36
Refactor and remove need for init script
ethanfrey Jun 21, 2021
752a80a
Merge pull request #195 from confio/use-cw20-ics20-contract
ethanfrey Jun 21, 2021
492f554
Bump to v0.1.6
ethanfrey Jun 21, 2021
25ece0b
add iris installation
chengwenxi Jun 22, 2021
a9fba16
Minor cleanup for CI
ethanfrey Jun 22, 2021
cfbf4cf
Merge pull request #196 from chengwenxi/vincent-iris
ethanfrey Jun 22, 2021
d5f0ccd
Updated CosmJS to 0.25.5
RiccardoM Jun 24, 2021
e88fb01
Added the handling of begin and end block events
RiccardoM May 25, 2021
004ee47
Run yarn fix
RiccardoM May 25, 2021
36afad0
Updated chain requirements to have Cosmos v0.42.4 and PR 9081 merged
RiccardoM May 25, 2021
b124983
Added changeset entry
RiccardoM May 25, 2021
b382422
Updated CosmJS to 0.25.5
RiccardoM Jun 24, 2021
5c5252e
Updated CosmJS to 0.25.5
RiccardoM Jun 24, 2021
f14a333
Merge remote-tracking branch 'origin/riccardo/block-results-events' i…
RiccardoM Jun 24, 2021
ade449b
Reverted custom @cosmjs/tendermint-rpc dependency
RiccardoM Jun 24, 2021
5343358
Run yarn fix:prettier
RiccardoM Jun 24, 2021
a502458
Updated simapp environment
RiccardoM Jun 24, 2021
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: 2 additions & 0 deletions .changeset/blue-pillows-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
5 changes: 5 additions & 0 deletions .changeset/long-hats-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@confio/relayer': patch
---

Added the handling of begin and end block events
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.1.6

### Patch Changes

- a4c9a31: Update relayer demo to use oysternet and nyancat
- 2a955ea: Add home option to ics20 command
- 9e4a5c3: Update deps, faster polling for tests

## 0.1.5

### Patch Changes
Expand Down
8 changes: 6 additions & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ See [docs for starter pack](https://www.npmjs.com/package/typescript-starter).

### Set up local chains

To start two local blockchains, so we can test, run the following commands in two different consoles.
To start two local blockchains, so we can test, run the following commands in three different consoles.
These are long-living commands and will keep running indefinitely

```sh
# in one console
./scripts/simapp/start.sh
# in another console
./scripts/wasmd/start.sh
# in yet another console
./scripts/gaia/start.sh
```

When you are done, you can run the following in any console:
When you are done running tests, you can run the following in any console to shut down the chains:

```sh
./scripts/simapp/stop.sh
./scripts/wasmd/stop.sh
./scripts/gaia/stop.sh
```

### Setup binaries
Expand Down
65 changes: 45 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,41 @@ Reads the configuration and starts relaying packets.
1. Init the configuration

```sh
ibc-setup init --src relayer_test_1 --dest relayer_test_2
ibc-setup init --src oysternet --dest nyancat
```

- creates relayer's home directory at `~/.ibc-setup`
- creates `app.yaml` inside relayer's home with `src`, `dest` and newly generated `mnemonic`
- pulls default `registry.yaml` to relayer's home
- funds addresses on both sides so relayer can pay the fee while relaying packets
- funds addresses on `oysternet` so relayer can pay the fee while relaying packets

> **NOTE:** Test blockchains `relayer_test_1` and `relayer_test_2` are running in the public. You do not need to start any blockchain locally to complete the quick start guide.
> **NOTE:** Both testnets are running in the public. You do not need to start any blockchain locally to complete the quick start guide.

> **NOTE:** Run `ibc-setup balances` to see the amount of tokens on each address.

2. Create `ics20` channel
2. Get testnet tokens for `nyancat`

- Find your relayer address on nyancat via: `ibc-setup keys list | grep nyancat`
- Join IRISnet discord with [this invite link](https://discord.gg/X6dZZxs3#nyncat-faucet)
- Go to the `nyancat-faucet` channel
- Request tokens at this address in the above channel: `$faucet iaa1fxmqew9dgg44jdf3l34zwa8rx7tcf42wz8ehjk`
- Check you have tokens on oysternet and nyancat via `ibc-setup balances`

[Original Instructions from IRISnet](https://github.com/irisnet/testnets/tree/master/nyancat#faucet)

3. Create `ics20` channel

```sh
ibc-setup ics20
ibc-setup ics20 -v
```

- creates a new connection on source and desination chains
- saves connection ids to `app.yaml` file
- creates a new channel

3. Start the relayer in the verbose mode and 10s frequency polling
4. Start the relayer in the verbose mode and 10s frequency polling
```sh
ibc-relayer start -v --poll 10
ibc-relayer start -v --poll 15
```

### Send tokens between chains
Expand All @@ -102,29 +112,44 @@ Reads the configuration and starts relaying packets.
make install
```

2. Create a new account and fund it
2. Make sure `iris` binary is installed on your system

- you must be running Linux or OSX on amd64
- [install Go 1.15+](https://golang.org/doc/install) and ensure that `$PATH` includes Go binaries (you may need to restart your terminal session)
- clone and install `iris`:
```sh
git clone https://github.com/irisnet/irishub
cd irishub
git checkout v1.1.1
make install
```

3. Create a new account and fund it

```sh
wasmd keys add sender
JSON=$(jq -n --arg addr $(wasmd keys show -a sender) '{"denom":"umuon","address":$addr}')
curl -X POST --header "Content-Type: application/json" --data "$JSON" http://49.12.73.189:8001/credit
JSON=$(jq -n --arg addr $(wasmd keys show -a sender) '{"denom":"usponge","address":$addr}')
curl -X POST --header "Content-Type: application/json" --data "$JSON" https://faucet.oysternet.cosmwasm.com/credit
```

3. Create another account to send tokens to
4. Create a valid IRISnet address to send tokens to

```sh
wasmd keys add receiver
iris keys add receiver
```
4. Send tokens

[Get testnet tokens](https://github.com/irisnet/testnets/tree/master/nyancat#faucet) if you want to send tokens to `oysternet`.

5. Send tokens
```sh
wasmd tx ibc-transfer transfer transfer <channel-id> $(wasmd keys show -a receiver) 200umuon --from $(wasmd keys show -a sender) --node http://168.119.254.205:26657 --chain-id network-1 --fees 2000umuon
wasmd tx ibc-transfer transfer transfer <channel-id> $(iris keys show -a receiver) 200usponge --from $(wasmd keys show -a sender) --node http://rpc.oysternet.cosmwasm.com:80 --chain-id oysternet-1 --fees 2000usponge --packet-timeout-height 0-0
```
- replace `<channel-id>` with the channel id obtained while configuring the relayer (2nd point)
- if you cleared out the terminal, query the channel
```sh
# replace `connection-id` with value of `srcConnection` property from `~/.ibc-setup/app.yaml` file
ibc-setup channels --chain relayer_test_1 --connection <connection-id>
ibc-setup channels --chain oysternet
```
5. Observe the relayer output
6. Observe the relayer output

## Configuration overview

Expand Down Expand Up @@ -200,9 +225,9 @@ The `GET /metrics` endpoint will be exposed by default on port `8080`, which you

## Chain Requirements

The blockchain must be based on Cosmos SDK `v0.41.1+`. In particular it must have
[PR 8458](https://github.com/cosmos/cosmos-sdk/pull/8458) merged (if you are using a fork)
in order for the relayer to work properly. `ibc-setup` should work on `v0.40.0+`
The blockchain must be based on Cosmos SDK `v0.42.4+`. In particular it must have
[PR 8458](https://github.com/cosmos/cosmos-sdk/pull/8458) and [PR 9081](https://github.com/cosmos/cosmos-sdk/pull/9081)
merged (if you are using a fork) in order for the relayer to work properly. `ibc-setup` should work on `v0.40.0+`

The chain must have a large value for `staking.params.historical_entries` (often set in genesis).
The default is "10000" and this should work with "1000", but no relayer will work if it is set to 0.
Expand Down
37 changes: 14 additions & 23 deletions demo/registry.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
version: 1

chains:
musselnet:
chain_id: musselnet-4
oysternet:
chain_id: oysternet-1
# Bech32 prefix for addresses
prefix: wasm
# This determines the gas payments we make (and defines the fee token)
gas_price: 0.025umayo
gas_price: 0.025usponge
# The path we use to derive the private key from the mnemonic
# Note: The hd paths shown have no meaningful relationship to the existing chains.
# It is recommended practice to use a different hd_path than those commonly used for user accounts.
hd_path: m/44'/1234'/0'/1'
# If you include an optional faucet, it will load the relayer with tokens in `ibc-setup init`
faucet: https://faucet.musselnet.cosmwasm.com
faucet: https://faucet.oysternet.cosmwasm.com
# You can optionally define a default ics20_port that will be used instead of transfer if no flags set
ics20_port: 'transfer'
# You can include multiple RPC endpoints and it will rotate through them if
# one is down (TODO)
rpc:
- https://rpc.musselnet.cosmwasm.com
- http://rpc.oysternet.cosmwasm.com:80
local_wasm:
chain_id: testing
prefix: wasm
Expand All @@ -34,24 +34,6 @@ chains:
ics20_port: 'custom'
rpc:
- http://localhost:26658
relayer_test_1:
chain_id: network-1
prefix: wasm
gas_price: 0.01umuon
hd_path: m/44'/1234'/0'/4'
ics20_port: 'transfer'
faucet: http://49.12.73.189:8001
rpc:
- http://168.119.254.205:26657
relayer_test_2:
chain_id: network-2
prefix: wasm
gas_price: 0.01umuon
hd_path: m/44'/1234'/0'/5'
ics20_port: 'transfer'
faucet: http://49.12.73.189:8002
rpc:
- http://188.34.162.78:26657
cosmoshub-4:
chain_id: cosmoshub-4
prefix: cosmos
Expand All @@ -63,3 +45,12 @@ chains:
ics20_port: 'transfer'
rpc:
- https://rpc.cosmos.network:443
nyancat:
# This is a long-living testnet by IrisNet
chain_id: nyancat-8
prefix: iaa
gas_price: 0.2unyan
hd_path: m/44'/118'/0'/0/0
ics20_port: 'transfer'
rpc:
- http://34.80.202.172:26657/
27 changes: 14 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "@confio/relayer",
"version": "0.1.5",
"version": "0.1.6",
"description": "IBC Relayer in TypeScript",
"repository": "https://github.com/confio/ts-relayer",
"license": "MIT",
"keywords": [],
"scripts": {
"build": "tsc -p tsconfig.json",
"fix": "run-s fix:*",
"fix:prettier": "prettier \"**/*.{ts,md}\" --write",
"fix:prettier": "prettier \"**/*.{ts,md}\" \"scripts/wasmd/*.js\" --write",
"fix:lint": "eslint src --ext .ts --fix",
"test": "run-s build test:*",
"test:lint": "eslint src --ext .ts",
"test:prettier": "prettier \"**/*.{ts,md}\" --list-different",
"test:prettier": "prettier \"**/*.{ts,md}\" \"scripts/wasmd/*.js\" --list-different",
"test:unit": "nyc --silent ava --serial",
"focused-test": "yarn test:unit ./src/lib/link.spec.ts",
"focused-test": "yarn test:unit ./src/lib/cosmwasm.spec.ts",
"watch:build": "tsc -p tsconfig.json -w",
"watch:test": "nyc --silent ava --watch --serial",
"cov": "run-s build test:unit cov:html cov:lcov && open-cli coverage/index.html",
Expand All @@ -28,15 +28,16 @@
"node": ">=12"
},
"dependencies": {
"@cosmjs/crypto": "0.25.3",
"@cosmjs/encoding": "0.25.3",
"@cosmjs/faucet-client": "0.25.3",
"@cosmjs/math": "0.25.3",
"@cosmjs/proto-signing": "0.25.3",
"@cosmjs/stargate": "0.25.3",
"@cosmjs/stream": "0.25.3",
"@cosmjs/tendermint-rpc": "0.25.3",
"@cosmjs/utils": "0.25.3",
"@cosmjs/cosmwasm-stargate": "0.25.5",
"@cosmjs/crypto": "0.25.5",
"@cosmjs/encoding": "0.25.5",
"@cosmjs/faucet-client": "0.25.5",
"@cosmjs/math": "0.25.5",
"@cosmjs/proto-signing": "0.25.5",
"@cosmjs/stargate": "0.25.5",
"@cosmjs/stream": "0.25.5",
"@cosmjs/tendermint-rpc": "0.25.5",
"@cosmjs/utils": "0.25.5",
"ajv": "7.1.1",
"axios": "0.21.1",
"commander": "7.1.0",
Expand Down
3 changes: 2 additions & 1 deletion scripts/simapp/env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Choose from https://hub.docker.com/r/interchainio/simapp/tags
REPOSITORY="interchainio/simapp"
VERSION="v0.41.3"
# We pin this to the oldest version we want to maintain compatibility with
VERSION="v0.42.4"
CONTAINER_NAME="simapp"
99 changes: 99 additions & 0 deletions scripts/wasmd/deploy_contracts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env node
/*jshint esversion: 8 */

/* eslint-disable @typescript-eslint/naming-convention */
const axios = require('axios');
const { SigningCosmWasmClient } = require('@cosmjs/cosmwasm-stargate');
const { GasPrice } = require('@cosmjs/stargate');
const { DirectSecp256k1HdWallet } = require('@cosmjs/proto-signing');
const {
QueryPacketReceiptRequest,
} = require('@cosmjs/stargate/build/codec/ibc/core/channel/v1/query');

// from src/lib/testutils.ts:wasmd
const config = {
endpoint: 'http://localhost:26659',
bech32prefix: 'wasm',
feeDenom: 'ucosm',
gasPrice: GasPrice.fromString('0.025ucosm'),
mnemonic:
'enlist hip relief stomach skate base shallow young switch frequent cry park',
};

const contracts = [
{
name: 'cw20-base',
wasmUrl:
'https://github.com/CosmWasm/cosmwasm-plus/releases/download/v0.6.1/cw20_base.wasm',
codeMeta: {
source:
'https://github.com/CosmWasm/cosmwasm-plus/tree/v0.6.0/contracts/cw20-base',
builder: 'cosmwasm/workspace-optimizer:0.11.0',
},
},
{
name: 'cw20-ics20',
wasmUrl:
'https://github.com/CosmWasm/cosmwasm-plus/releases/download/v0.6.1/cw20_ics20.wasm',
codeMeta: {
source:
'https://github.com/CosmWasm/cosmwasm-plus/tree/v0.6.0/contracts/cw20-ics20',
builder: 'cosmwasm/workspace-optimizer:0.11.0',
},
},
];

async function downloadWasm(url) {
const r = await axios.get(url, { responseType: 'arraybuffer' });
if (r.status !== 200) {
throw new Error(`Download error: ${r.status}`);
}
return r.data;
}

async function main() {
// use the faucet account to upload (it has fee tokens)
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(config.mnemonic, {
prefix: config.bech32prefix,
});
const { address } = (await wallet.getAccounts())[0];
const options = {
prefix: config.bech32prefix,
gasPrice: config.gasPrice,
gasLimits: {
upload: 1750000,
},
};
const client = await SigningCosmWasmClient.connectWithSigner(
config.endpoint,
wallet,
options
);

const uploaded = [];
for (const contract of contracts) {
console.info(`Downloading ${contract.name} at ${contract.wasmUrl}...`);
const wasm = await downloadWasm(contract.wasmUrl);
const receipt = await client.upload(
address,
wasm,
contract.codeMeta,
`Upload ${contract.name}`
);
console.debug(`Upload succeeded. Receipt: ${JSON.stringify(receipt)}`);
uploaded.push({ codeId: receipt.codeId, name: contract.name });
}

uploaded.forEach((x) => console.log(x));
}

main().then(
() => {
console.info('All done, let the coins flow.');
process.exit(0);
},
(error) => {
console.error(error);
process.exit(1);
}
);
Loading