Skip to content

Commit

Permalink
Merge branch 'master' into adi/469_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorenesduarte committed Jan 22, 2021
2 parents da8c37a + a1c393f commit 03c2469
Show file tree
Hide file tree
Showing 52 changed files with 2,048 additions and 706 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
14 changes: 14 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: End to End testing
on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build relayer image
run: docker-compose -f docker-compose.yml build relayer
- name: Start chains and relayer
run: docker-compose -f docker-compose.yml up -d ibc-0 ibc-1 relayer
- name: Run relayer workflow
run: docker exec relayer /bin/sh -c /relayer/setup_relayer.sh
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

### FEATURES

- Continous Integration (CI) end-to-end (e2e) testing ([#32])
- Add support for streamlining releases ([#507])
- [relayer-cli]
- Implement command to query the channels associated with a connection ([#505])
Expand All @@ -14,7 +15,7 @@

- Update to `tendermint-rs` v0.17.1 ([#517])
- Update to `tokio` 1.0, `prost` 0.7 and `tonic` 0.4 ([#527])

- [relayer-cli]
- Replace `ChannelConfig` in `Channel::new` ([#511])
- Add `packet-send` CLI ([#470])
Expand Down Expand Up @@ -45,6 +46,7 @@
[#517]: https://github.com/informalsystems/ibc-rs/issues/517
[#525]: https://github.com/informalsystems/ibc-rs/issues/525
[#527]: https://github.com/informalsystems/ibc-rs/issues/527
[#32]: https://github.com/informalsystems/ibc-rs/issues/32
[#536]: https://github.com/informalsystems/ibc-rs/issues/536
[#537]: https://github.com/informalsystems/ibc-rs/issues/537
[#540]: https://github.com/informalsystems/ibc-rs/issues/540
Expand All @@ -62,7 +64,6 @@ the latest cosmos proto versions from `v0.40.0-rc5` (sometimes called 'stargate-
- Update to cosmos-sdk IBC proto version `v0.40.0-rc5` ([#451])

- [relayer]
- Implement packet relaying ([#379])

- [relayer-cli]
- Packet CLIs for recv_packet ([#443])
Expand Down
4 changes: 2 additions & 2 deletions ci/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
gaia/
cosmos-sdk/
/gaia/**/*
data/**/*
190 changes: 190 additions & 0 deletions ci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
# Continous Integration for ibc-rs

This folder contains the files required to run the End to end testing in [Github Actions](https://github.com/informalsystems/ibc-rs/actions)

## End to end (e2e) testing

The [End to end (e2e) testing workflow](https://github.com/informalsystems/ibc-rs/actions?query=workflow%3A%22End+to+End+testing%22) spins up two `gaia` chains (`ibc-0` and `ibc-1`) in Docker containers and one container that runs the relayer. There's a script that configures the relayer (e.g. configure light clients and add keys) and run transactions and queries. A successful run of this script ensures that the relayer is working properly with two chains that support `IBC`.

### Running an End to end (e2e) test locally

If you want to run the end to end test locally, you will need [Docker](https://www.docker.com/) installed on your machine.

Follow these steps to run the e2e test locally:

__Note__: This assumes you are running this the first time, if not, please ensure you follow the steps to [clean up the containers](#cleaning-up) before running it again.

1. Clone the `ibc-rs` repo


2. Go into the repository folder

`cd ibc-rs`


3. Build the relayer container image (this might take a few minutes since it will do a fresh compile and build of all modules)

`docker-compose -f docker-compose.yml build relayer`


4. Run all the containers (two containers, one for each chain and one for the relayer)

`docker-compose -f docker-compose.yml up -d ibc-0 ibc-1 relayer`

If everything is successful you should see a message saying:
```shell
Creating ibc-1 ... done
Creating ibc-0 ... done
Creating relayer ... done
```

If you want to ensure they are all running properly you can use the command:

`docker-compose ps`

You should see the message below. Please ensure all containers are in a `Up` state
```shell
Name Command State Ports
--------------------------------------------------------
ibc-0 gaiad start --home=/chain ... Up
ibc-1 gaiad start --home=/chain ... Up
relayer /bin/sh Up
```

__Note__: If this is the first time you're running this command, the `informaldev/ibc-0:[RELEASE TAG]` and `informaldev/ibc-1:[RELEASE TAG]` container images will be pulled from the Docker Hub. For instructions on how to update these images in Docker Hub please see the [upgrading the release](#upgrading-chains) section.
5. Run the command below to execute the relayer end to end (e2e) test. This command will execute the `setup_relayer.sh` on the relayer container. The script will configure the light clients for both chains, add the private keys for both chains and run transactions on both chains (e.g. create-client transaction).
`docker exec relayer /bin/sh -c /relayer/setup_relayer.sh`
If the script runs sucessfully you should see an output similar to this one:
```shell
=================================================================================================================
INITIALIZE
=================================================================================================================
-----------------------------------------------------------------------------------------------------------------
Show relayer version
-----------------------------------------------------------------------------------------------------------------
relayer-cli 0.0.6
-----------------------------------------------------------------------------------------------------------------
Setting up chains
-----------------------------------------------------------------------------------------------------------------
Config: /relayer/simple_config.toml
Chain: ibc-0
creating chain store folder: [/data/ibc-0]
Chain: ibc-1 [/data/ibc-1]
creating chain store folder: [/data/ibc-1]
Waiting 20 seconds for chains to generate blocks...
=================================================================================================================
CONFIGURATION
=================================================================================================================
-----------------------------------------------------------------------------------------------------------------
Add keys for chains
-----------------------------------------------------------------------------------------------------------------
key add result: "Added key testkey (cosmos1tc3vcuxyyac0dmayf887v95tdg7qpyql48w7gj) on ibc-0 chain"
key add result: "Added key testkey (cosmos1zv3etpuk4n7p54r8fhsct0qys8eqf5zqw4pqp5) on ibc-1 chain"
-----------------------------------------------------------------------------------------------------------------
Set the primary peers for clients on each chain
-----------------------------------------------------------------------------------------------------------------
Executing: rrly -c /relayer/simple_config.toml light add tcp://ibc-0:26657 -c ibc-0 -s /data/ibc-0 -p -y -f
Success Added light client:
chain id: ibc-0
address: tcp://ibc-0:26657
peer id: DF766B47325BE49E27F9DF325327853AAFB5BBCA
height: 731
hash: 22639F0B84C0E95D51AB70D900E7BC0CBFBDF642F3F945093FF7AEB8120CC8DC
primary: true
-----------------------------------------------------------------------------------------------------------------
Executing: rrly -c /relayer/simple_config.toml light add tcp://ibc-1:26657 -c ibc-1 -s /data/ibc-1 -p -y -f
Success Added light client:
chain id: ibc-1
address: tcp://ibc-1:26657
peer id: B7A2809AA8AA825225D618DDD5200AB9BA236797
height: 733
hash: D5C190747A1A0805C4840FBF66EC3339E0C30520359EF36553508DBD775A6EEF
primary: true
-----------------------------------------------------------------------------------------------------------------
Set the secondary peers for clients on each chain
-----------------------------------------------------------------------------------------------------------------
Executing: rrly -c /relayer/simple_config.toml light add tcp://ibc-0:26657 -c ibc-0 -s /data/ibc-0 --peer-id 17D46D8C1576A79203A6733F63B2C9B7235DD559 -y
Success Added light client:
chain id: ibc-0
address: tcp://ibc-0:26657
peer id: 17D46D8C1576A79203A6733F63B2C9B7235DD559
height: 735
hash: 463691EED61772C333D38C5DC5F267946341F98ADE8EF9FBBE501A96022E5F1A
primary: false
-----------------------------------------------------------------------------------------------------------------
Executing: rrly -c /relayer/simple_config.toml light add tcp://ibc-1:26657 -c ibc-1 -s /data/ibc-1 --peer-id A885BB3D3DFF6101188B462466AE926E7A6CD51E -y
Success Added light client:
chain id: ibc-1
address: tcp://ibc-1:26657
peer id: A885BB3D3DFF6101188B462466AE926E7A6CD51E
height: 737
hash: 5377D2FDCD1886129AF32AABFDFC4C80112B2465F49814E91C25FD325DE54DCC
primary: false
=================================================================================================================
CLIENTS
=================================================================================================================
-----------------------------------------------------------------------------------------------------------------
Create client transactions
-----------------------------------------------------------------------------------------------------------------
Creating ibc-1 client on chain ibc-0
Message CreateClient for source chain: ChainId { id: "ibc-1", version: 1 }, on destination chain: ChainId { id: "ibc-0", version: 0 }
Jan 21 18:46:57.259 INFO relayer::event::monitor: running listener chain.id=ibc-1
Jan 21 18:46:57.278 INFO relayer::event::monitor: running listener chain.id=ibc-0
{"status":"success","result":[{"CreateClient":{"client_id":"07-tendermint-0","client_type":"Tendermint","consensus_height":{"revision_height":739,"revision_number":1},"height":"1"}}]}
-----------------------------------------------------------------------------------------------------------------
Creating ibc-0 client on chain ibc-1
Message CreateClient for source chain: ChainId { id: "ibc-0", version: 0 }, on destination chain: ChainId { id: "ibc-1", version: 1 }
Jan 21 18:46:58.299 INFO relayer::event::monitor: running listener chain.id=ibc-0
Jan 21 18:46:58.324 INFO relayer::event::monitor: running listener chain.id=ibc-1
{"status":"success","result":[{"CreateClient":{"client_id":"07-tendermint-0","client_type":"Tendermint","consensus_height":{"revision_height":740,"revision_number":0},"height":"1"}}]}
```
### [Cleaning up](#cleaning-up)
In order to clear up the testing environment and stop the containers you can run the command below
`docker-compose down`
If the command executes successfully you should see the message below:
```shell
Stopping relayer ... done
Stopping ibc-0 ... done
Stopping ibc-1 ... done
Removing relayer ... done
Removing ibc-0 ... done
Removing ibc-1 ... done
Removing network ibc-rs_relaynet
```
### [Upgrading the gaia chains release and generating new container images](#upgrading-chains)
The repository stores the files used to configure and build the chains for the containers. For example, the files for a `gaia` chain release `v3.0.0` can be seen [here](./chains/gaia)
If you need to generate configuration files for a new gaia release and new containers, please follow the steps below:
1. Move into the `ci` folder
`cd ci`
2. Open the `build-ibc-chains.sh` file and change the release. Just replace the value for the `GAIA_BRANCH` parameter. For example to set it to release `v3.0.0` use:
`GAIA_BRANCH="v3.0.0"`
3. Run the `build-ibc-chains.sh` script:
`./build-ibc-chains.sh`
__Note__: This will generate the files for the chains in the `/ci/chains/gaia` folder and build the Docker containers. At the end of the script it will ask if you want to push these new images to Docker Hub. In order to do so you need to have Docker login configured on your machine with permissions to push the container. If you don't want to push them (just have them built locally) just cancel the script execution (by hitting `CTRL+C`)


4. Committing the release files. If you want to add the new chain files generated to the ibc-rs repository, just `git commit` the files


5. Update the release for Docker Compose. If this new release should be the default release for running the end to end (e2e) test you need to update the release version in the `docker-compose.yml` file in the root of the repository. Open the file and change the release version in all the places required. For example, if current release is `v3.0.0` and the new one is `v4.0.0` just do a find and replace with these two values.
82 changes: 82 additions & 0 deletions ci/bootstrap_gaia.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/sh

# This file can be used to initialize a chain

# coins to add to each account
coins="100000000000stake,100000000000samoleans"
STAKE="100000000000stake"
# - the user also needs stake to perform actions
USER_COINS="${STAKE},${SAMOLEANS}samoleans"
#home="/chain"

echo Node: "$MONIKER"
echo Chain: "$CHAIN_ID"
echo Chain IP: "$CHAIN_IP"
echo RPC Port: "$RPC_PORT"
echo GRPC Port: "$GRPC_PORT"
echo Home_Dir: "$CHAIN_HOME"

# Clean home dir if exists
rm -Rf "$CHAIN_HOME"

# Create home dir
mkdir -p "$CHAIN_HOME"

ls -allh "$CHAIN_HOME"

# Check gaia version
echo "-------------------------------------------------------------------------------------------------------------------"
echo "Gaiad version"
echo "-------------------------------------------------------------------------------------------------------------------"
gaiad version --long

echo "-------------------------------------------------------------------------------------------------------------------"
echo "Initialize chain $CHAIN_ID"
echo "-------------------------------------------------------------------------------------------------------------------"
gaiad init "$MONIKER" --chain-id "$CHAIN_ID" --home "$CHAIN_HOME"

echo "-------------------------------------------------------------------------------------------------------------------"
echo "Replace addresses and ports in the config file and some performance tweaks"
echo "-------------------------------------------------------------------------------------------------------------------"
sed -i 's#"tcp://127.0.0.1:26657"#"tcp://'"$CHAIN_IP"':'"$RPC_PORT"'"#g' "$CHAIN_HOME"/config/config.toml
#sed -i 's#"tcp://0.0.0.0:26656"#"tcp://'"$CHAIN_ID"':'"$P2P_PORT"'"#g' "$CHAIN_HOME"/config/config.toml
#sed -i 's#grpc_laddr = ""#grpc_laddr = "tcp://'"$CHAIN_IP"':'"$GRPC_PORT"'"#g' "$CHAIN_HOME"/config/config.toml
sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' "$CHAIN_HOME"/config/config.toml
sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' "$CHAIN_HOME"/config/config.toml
sed -i 's/index_all_keys = false/index_all_keys = true/g' "$CHAIN_HOME"/config/config.toml

echo "-------------------------------------------------------------------------------------------------------------------"
echo "Adding validator key"
echo "-------------------------------------------------------------------------------------------------------------------"
gaiad keys add validator --keyring-backend="test" --home "$CHAIN_HOME" --output json > "$CHAIN_HOME"/validator_seed.json
cat "$CHAIN_HOME"/validator_seed.json

echo "-------------------------------------------------------------------------------------------------------------------"
echo "Adding use key"
echo "-------------------------------------------------------------------------------------------------------------------"
gaiad keys add user --keyring-backend="test" --home $CHAIN_HOME --output json > "$CHAIN_HOME"/key_seed.json
cat "$CHAIN_HOME"/key_seed.json

echo "-------------------------------------------------------------------------------------------------------------------"
echo "Adding user account to genesis"
echo "-------------------------------------------------------------------------------------------------------------------"
gaiad --home "$CHAIN_HOME" add-genesis-account $(gaiad --home "$CHAIN_HOME" keys --keyring-backend="test" show user -a) 1000000000stake
echo "Done!"

echo "-------------------------------------------------------------------------------------------------------------------"
echo "Adding validator account to genesis"
echo "-------------------------------------------------------------------------------------------------------------------"
gaiad --home "$CHAIN_HOME" add-genesis-account $(gaiad --home "$CHAIN_HOME" keys --keyring-backend="test" show validator -a) 1000000000stake,1000000000validatortoken
echo "Done!"

echo "-------------------------------------------------------------------------------------------------------------------"
echo "Generate a genesis transaction that creates a validator with a self-delegation"
echo "-------------------------------------------------------------------------------------------------------------------"
gaiad --home "$CHAIN_HOME" gentx validator 1000000000stake --keyring-backend="test" --chain-id "$CHAIN_ID"
echo "Done!"

echo "-------------------------------------------------------------------------------------------------------------------"
echo "Collect genesis txs and output a genesis.json file"
echo "-------------------------------------------------------------------------------------------------------------------"
gaiad collect-gentxs --home "$CHAIN_HOME"
echo "Done!"
Loading

0 comments on commit 03c2469

Please sign in to comment.