From 40c2c92361586a0e43d6a2bf0425d70e2d1ef0ba Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sun, 28 Mar 2021 14:57:07 -0400 Subject: [PATCH 01/23] init commit --- .gitignore | 3 ++- Dockerfile | 7 +++---- README.md | 22 ---------------------- dev-env | 29 ----------------------------- scripts/one-chain | 2 +- 5 files changed, 6 insertions(+), 57 deletions(-) delete mode 100755 dev-env diff --git a/.gitignore b/.gitignore index 105b3d29d..149782221 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ release.tar.gz nchainz/ .idea/ .csv -chain-code/ \ No newline at end of file +chain-code/ +.docker/ diff --git a/Dockerfile b/Dockerfile index cb35bb960..6fc682eb1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,15 +7,14 @@ COPY . . # Update and install needed deps prioir to installing the binary. RUN apk update && \ - apk --no-cache add make git && \ - make install + apk --no-cache add make git && \ + make install FROM alpine:latest ENV RELAYER /relayer -RUN addgroup rlyuser && \ - adduser -S -G rlyuser rlyuser -h "$RELAYER" +RUN addgroup rlyuser && adduser -S -G rlyuser rlyuser -h "$RELAYER" USER rlyuser diff --git a/README.md b/README.md index f6cdfbd2f..a76750269 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,6 @@ wanting to build their [IBC](https://ibcprotocol.org/)-compliant relayer. - [Compatibility Table](#compatibility-table) - [Testnet](#testnet) - [Demo](#demo) - - [Setting up Developer Environment](#setting-up-developer-environment) - [Security Notice](#security-notice) - [Code of Conduct](#code-of-conduct) @@ -263,27 +262,6 @@ $ rly q bal ibc-1 # You can change the amount of fees you are paying on each chain in the configuration. ``` -## Setting up Developer Environment - -Working with the relayer can frequently involve working with local development -branches of your desired applications/networks, e.g. `gaia`, `akash`, in addition -to `cosmos-sdk` and the `relayer`. - -To setup your environment to point at the local versions of the code and reduce -the amount of time in your read-eval-print loops try the following: - -1. Set `replace github.com/cosmos/cosmos-sdk => /path/to/local/github.com/comsos/cosmos-sdk` - at the end of the `go.mod` files for the `relayer` and your network/application, - e.g. `gaia`. This will force building from the local version of the `cosmos-sdk` - when running the `./dev-env` script. -2. After `./dev-env` has run, you can use `go run main.go` for any relayer - commands you are working on. This allows you make changes and immediately test - them as long as there are no server side changes. -3. If you make changes in `cosmos-sdk` that need to be reflected server-side, - be sure to re-run `./two-chainz`. -4. If you need to work off of a `gaia` branch other than `master`, change the - branch name at the top of the `./two-chainz` script. - ## Security Notice If you would like to report a security critical bug related to the relayer repo, diff --git a/dev-env b/dev-env deleted file mode 100755 index 019b55fd1..000000000 --- a/dev-env +++ /dev/null @@ -1,29 +0,0 @@ -#/bin/bash -e - -RELAYER_DIR="$GOPATH/src/github.com/cosmos/relayer" -RELAYER_CONF="$HOME/.relayer" -GAIA_CONF="$(pwd)/data" - -# Ensure user understands what will be deleted -if ([[ -d $RELAYER_CONF ]] || [[ -d $GAIA_CONF ]]) && [[ ! "$1" == "skip" ]]; then - read -p "$0 will delete \$HOME/.relayer and \$(pwd)/data folder. Do you wish to continue? (y/n): " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - exit 1 - fi -fi - -cd $RELAYER_DIR -rm -rf $RELAYER_CONF &> /dev/null -bash scripts/two-chainz "skip" - -echo "waiting for blocks..." -sleep 3 - -rly tx link demo -d -o 3s -rly tx txf ibc-0 ibc-1 100000samoleans $(rly ch addr ibc-1) -rly tx txf ibc-1 ibc-0 100000samoleans $(rly ch addr ibc-0) -sleep 1 -rly tx relay demo -d -sleep 1 -rly tx acks demo -d diff --git a/scripts/one-chain b/scripts/one-chain index d0995fec4..b2325b58e 100755 --- a/scripts/one-chain +++ b/scripts/one-chain @@ -109,4 +109,4 @@ else fi # Start the gaia -redirect $BINARY --home $CHAINDIR/$CHAINID start --pruning=nothing --grpc.address="0.0.0.0:$GRPCPORT" > $CHAINDIR/$CHAINID.log & +redirect $BINARY --home $CHAINDIR/$CHAINID start --pruning=nothing --grpc.address="0.0.0.0:$GRPCPORT" > $CHAINDIR/$CHAINID.log 2>&1 & From d0c404db5a4cc95a46e520f8f1a94cfd37b020d0 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sun, 28 Mar 2021 16:58:21 -0400 Subject: [PATCH 02/23] make: add two-chains target --- .gitignore | 3 ++- Makefile | 13 ++++++++++-- configs/demo/paths/demo.json | 6 ------ docker-compose.yaml | 30 --------------------------- two-chains/chains/ibc-0.json | 9 ++++++++ two-chains/chains/ibc-1.json | 9 ++++++++ two-chains/docker-compose.yaml | 38 ++++++++++++++++++++++++++++++++++ two-chains/paths/transfer.json | 21 +++++++++++++++++++ two-chains/relayer-setup | 31 +++++++++++++++++++++++++++ 9 files changed, 121 insertions(+), 39 deletions(-) delete mode 100644 docker-compose.yaml create mode 100644 two-chains/chains/ibc-0.json create mode 100644 two-chains/chains/ibc-1.json create mode 100644 two-chains/docker-compose.yaml create mode 100644 two-chains/paths/transfer.json create mode 100755 two-chains/relayer-setup diff --git a/.gitignore b/.gitignore index 149782221..d0eb614f5 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ nchainz/ .idea/ .csv chain-code/ -.docker/ +two-chains/ibc-* +two-chains/.relayer diff --git a/Makefile b/Makefile index 985a86fe6..21d153b2c 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,15 @@ install: go.sum ############################################################################### # Tests / CI ############################################################################### + +two-chains: + @docker-compose -f ./two-chains/docker-compose.yaml down + @rm -fr ./two-chains/ibc-* ./two-chains/.relayer + @docker-compose -f ./two-chains/docker-compose.yaml up -d + @while ! curl localhost:26657 &> /dev/null; do sleep 1; done + @while ! curl localhost:26667 &> /dev/null; do sleep 1; done + @cd ./two-chains && sh relayer-setup* && cd .. + test: @TEST_DEBUG=true go test -mod=readonly -v ./test/... @@ -66,8 +75,6 @@ lint: @find . -name '*.go' -type f -not -path "*.git*" | xargs gofmt -d -s @go mod verify -.PHONY: install build lint coverage clean - ############################################################################### # Chain Code Downloads ############################################################################### @@ -104,3 +111,5 @@ check-swagger: update-swagger-docs: check-swagger swagger generate spec -o ./docs/swagger-ui/swagger.yaml + +.PHONY: two-chains install build lint coverage clean diff --git a/configs/demo/paths/demo.json b/configs/demo/paths/demo.json index 3be245258..369fae2f0 100644 --- a/configs/demo/paths/demo.json +++ b/configs/demo/paths/demo.json @@ -1,18 +1,12 @@ { "src": { "chain-id": "ibc-0", - "client-id": "", - "connection-id": "", - "channel-id": "", "port-id": "transfer", "order": "unordered", "version": "ics20-1" }, "dst": { "chain-id": "ibc-1", - "client-id": "", - "connection-id": "", - "channel-id": "", "port-id": "transfer", "order": "unordered", "version": "ics20-1" diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 064e7d197..000000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,30 +0,0 @@ -version: "3.7" -services: - ibc-0: - image: "jackzampolin/gaiatest:gaiav3.0" - ports: - - "46657:26657" - command: - - "ibc-0" - - "${IBC0ADDR}" - ibc-1: - image: "jackzampolin/gaiatest:gaiav3.0" - ports: - - "46658:26657" - command: - - "ibc-1" - - "${IBC1ADDR}" - ibc-2: - image: "jackzampolin/gaiatest:gaiav3.0" - ports: - - "46659:26657" - command: - - "ibc-2" - - "${IBC2ADDR}" - ibc-3: - image: "jackzampolin/gaiatest:gaiav3.0" - ports: - - "46660:26657" - command: - - "ibc-3" - - "${IBC3ADDR}" diff --git a/two-chains/chains/ibc-0.json b/two-chains/chains/ibc-0.json new file mode 100644 index 000000000..fe1ac6471 --- /dev/null +++ b/two-chains/chains/ibc-0.json @@ -0,0 +1,9 @@ +{ + "key": "ibc-0-relayer-key", + "chain-id": "ibc-0", + "rpc-addr": "http://localhost:26657", + "account-prefix": "cosmos", + "gas-adjustment": 1.5, + "gas-prices": "0.025uatom", + "trusting-period": "336h" +} diff --git a/two-chains/chains/ibc-1.json b/two-chains/chains/ibc-1.json new file mode 100644 index 000000000..a8b83d2df --- /dev/null +++ b/two-chains/chains/ibc-1.json @@ -0,0 +1,9 @@ +{ + "key": "ibc-1-relayer-key", + "chain-id": "ibc-1", + "rpc-addr": "http://localhost:26667", + "account-prefix": "cosmos", + "gas-adjustment": 1.5, + "gas-prices": "0.025uatom", + "trusting-period": "336h" +} diff --git a/two-chains/docker-compose.yaml b/two-chains/docker-compose.yaml new file mode 100644 index 000000000..96fd260b7 --- /dev/null +++ b/two-chains/docker-compose.yaml @@ -0,0 +1,38 @@ +version: "3.9" +services: + ibc-0: + image: "tendermint/gaia:v4.2.0" + ports: + - "26656-26657:26656-26657" + - "1317:1317" + - "9090:9090" + volumes: + - ./ibc-0:/gaia/.gaia + command: > + sh -c "gaiad --chain-id=ibc-0 init ibc-0 + && gaiad keys add validator --keyring-backend='test' --output json > $$HOME/.gaia/validator_seed.json 2> /dev/null + && gaiad keys add user --keyring-backend='test' --output json > $$HOME/.gaia/key_seed.json 2> /dev/null + && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show user -a) 100000000000stake,100000000000uatom + && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show validator -a) 100000000000stake,100000000000uatom + && gaiad gentx validator 100000000000stake --keyring-backend='test' --chain-id ibc-0 + && gaiad collect-gentxs + && sed -i'.bank' -e 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:26657#g' $$HOME/.gaia/config/config.toml + && gaiad start --pruning=nothing" + ibc-1: + image: "tendermint/gaia:v4.2.0" + ports: + - "26666-26667:26656-26657" + - "1318:1317" + - "9091:9090" + volumes: + - ./ibc-1:/gaia/.gaia + command: > + sh -c "gaiad --chain-id=ibc-1 init ibc-1 + && gaiad keys add validator --keyring-backend='test' --output json > $$HOME/.gaia/validator_seed.json 2> /dev/null + && gaiad keys add user --keyring-backend='test' --output json > $$HOME/.gaia/key_seed.json 2> /dev/null + && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show user -a) 100000000000stake,100000000000uatom + && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show validator -a) 100000000000stake,100000000000uatom + && gaiad gentx validator 100000000000stake --keyring-backend='test' --chain-id ibc-1 + && gaiad collect-gentxs + && sed -i'.bank' -e 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:26657#g' $$HOME/.gaia/config/config.toml + && gaiad start --pruning=nothing" diff --git a/two-chains/paths/transfer.json b/two-chains/paths/transfer.json new file mode 100644 index 000000000..3be245258 --- /dev/null +++ b/two-chains/paths/transfer.json @@ -0,0 +1,21 @@ +{ + "src": { + "chain-id": "ibc-0", + "client-id": "", + "connection-id": "", + "channel-id": "", + "port-id": "transfer", + "order": "unordered", + "version": "ics20-1" + }, + "dst": { + "chain-id": "ibc-1", + "client-id": "", + "connection-id": "", + "channel-id": "", + "port-id": "transfer", + "order": "unordered", + "version": "ics20-1" + }, + "strategy": { "type": "naive" } +} diff --git a/two-chains/relayer-setup b/two-chains/relayer-setup new file mode 100755 index 000000000..4c9eac252 --- /dev/null +++ b/two-chains/relayer-setup @@ -0,0 +1,31 @@ +#!/bin/bash + +relayer_dir=./.relayer + +echo "removing old relayer test directory" +rm -fr $relayer_dir + +echo "creating new relayer test directory" +mkdir $relayer_dir + +echo "generating relayer configuration..." +rly config init --home $relayer_dir +rly config add-chains ./chains --home $relayer_dir + +echo "importing relayer keys..." +seed_ibc0=$(jq -r '.mnemonic' ./ibc-0/key_seed.json) +seed_ibc1=$(jq -r '.mnemonic' ./ibc-1/key_seed.json) +echo "key $(rly keys restore --home $relayer_dir ibc-0 ibc-0-relayer-key "$seed_ibc0") imported from ibc-0 to relayer" +echo "key $(rly keys restore --home $relayer_dir ibc-1 ibc-1-relayer-key "$seed_ibc1") imported from ibc-1 to relayer" + +echo "adding transfer path to relayer..." +rly config add-paths ./paths --home $relayer_dir + +echo "creating light clients..." +rly light init ibc-0 -f --home $relayer_dir +rly light init ibc-1 -f --home $relayer_dir + +echo "linking transfer path..." +rly tx link transfer --home $relayer_dir -r 10 -o 20s + +echo "relayer ready to use 🎉" From cf4b1c1c199f8d5b40b63df574bc10e72f0c8090 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sun, 28 Mar 2021 16:58:58 -0400 Subject: [PATCH 03/23] chain: patch MustGetLatestLightHeight --- relayer/tm-light-client.go | 41 +++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/relayer/tm-light-client.go b/relayer/tm-light-client.go index dc6b43d08..52626fef3 100644 --- a/relayer/tm-light-client.go +++ b/relayer/tm-light-client.go @@ -34,6 +34,9 @@ var ( // a lock to prevent two processes from trying to access the light client // database at the same time resulting in errors and panics. lightDBMutex sync.Mutex + + // ErrDatabase defines a sentinel database general error type. + ErrDatabase = errors.New("database failure") ) func lightError(err error) error { return fmt.Errorf("light client: %w", err) } @@ -175,28 +178,29 @@ func (c *Chain) LightClient(db dbm.DB) (*light.Client, error) { ) } -// NewLightDB returns a new instance of the lightclient database connection -// CONTRACT: must close the database connection when done with it (defer df()) -func (c *Chain) NewLightDB() (db *dbm.GoLevelDB, df func(), err error) { - // a lock is used to prevent error messages or panics from two processes - // trying to simultanenously use the light client +// NewLightDB returns a new instance of the lightclient database connection. The +// caller MUST close the database connection through a deferred execution of the +// returned cleanup function. +func (c *Chain) NewLightDB() (db *dbm.GoLevelDB, cleanup func(), err error) { + // XXX: A lock is used to prevent error messages or panics from two processes + // trying to simultaneously use the light client. lightDBMutex.Lock() db, err = dbm.NewGoLevelDB(c.ChainID, lightDir(c.HomePath)) if err != nil { lightDBMutex.Unlock() - return nil, nil, fmt.Errorf("can't open light client database: %w", err) + return nil, nil, fmt.Errorf("%s: %w", err, ErrDatabase) } - df = func() { + cleanup = func() { err := db.Close() lightDBMutex.Unlock() if err != nil { - panic(err) + panic(fmt.Sprintf("failed to close light client database: %s", err)) } } - return + return db, cleanup, nil } // DeleteLightDB removes the light client database on disk, forcing re-initialization @@ -269,12 +273,25 @@ func (c *Chain) GetLatestLightHeight() (int64, error) { return client.LastTrustedHeight() } -// MustGetLatestLightHeight returns the latest height of the light client -// and panics if an error occurs. +// MustGetLatestLightHeight returns the latest height of the light client. If +// an error occurs due to a database failure, we keep trying with a delayed +// re-attempt. Otherwise, we panic. func (c *Chain) MustGetLatestLightHeight() uint64 { height, err := c.GetLatestLightHeight() if err != nil { - panic(err) + if errors.Is(err, ErrDatabase) { + // XXX: Sleep and try again if the database is unavailable. This can easily + // happen if two distinct resources try to access the database at the same + // time. To avoid causing a corrupted or lost packet, we keep trying as to + // not halt the relayer. + // + // ref: https://github.com/cosmos/relayer/issues/444 + c.logger.Error("failed to get latest height due to a database failure; trying again...", "err", err) + time.Sleep(time.Second) + c.MustGetLatestLightHeight() + } else { + panic(err) + } } return uint64(height) From ce1b4772326c243e916be7c28a01c310e6a0e326 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sun, 28 Mar 2021 17:02:33 -0400 Subject: [PATCH 04/23] lint++ --- two-chains/docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/two-chains/docker-compose.yaml b/two-chains/docker-compose.yaml index 96fd260b7..b59783410 100644 --- a/two-chains/docker-compose.yaml +++ b/two-chains/docker-compose.yaml @@ -16,7 +16,7 @@ services: && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show validator -a) 100000000000stake,100000000000uatom && gaiad gentx validator 100000000000stake --keyring-backend='test' --chain-id ibc-0 && gaiad collect-gentxs - && sed -i'.bank' -e 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:26657#g' $$HOME/.gaia/config/config.toml + && sed -i'.bak' -e 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:26657#g' $$HOME/.gaia/config/config.toml && gaiad start --pruning=nothing" ibc-1: image: "tendermint/gaia:v4.2.0" @@ -34,5 +34,5 @@ services: && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show validator -a) 100000000000stake,100000000000uatom && gaiad gentx validator 100000000000stake --keyring-backend='test' --chain-id ibc-1 && gaiad collect-gentxs - && sed -i'.bank' -e 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:26657#g' $$HOME/.gaia/config/config.toml + && sed -i'.bak' -e 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:26657#g' $$HOME/.gaia/config/config.toml && gaiad start --pruning=nothing" From 966f7aed5e61dcb2d2851de0e33d69fb8ea515c9 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sun, 28 Mar 2021 17:03:46 -0400 Subject: [PATCH 05/23] lint++ --- two-chains/paths/transfer.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/two-chains/paths/transfer.json b/two-chains/paths/transfer.json index 3be245258..369fae2f0 100644 --- a/two-chains/paths/transfer.json +++ b/two-chains/paths/transfer.json @@ -1,18 +1,12 @@ { "src": { "chain-id": "ibc-0", - "client-id": "", - "connection-id": "", - "channel-id": "", "port-id": "transfer", "order": "unordered", "version": "ics20-1" }, "dst": { "chain-id": "ibc-1", - "client-id": "", - "connection-id": "", - "channel-id": "", "port-id": "transfer", "order": "unordered", "version": "ics20-1" From b4f3ec86047bd07b99367fd03983c816a649972d Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sun, 28 Mar 2021 22:50:25 -0400 Subject: [PATCH 06/23] update scripts --- .gitignore | 1 + Makefile | 2 +- two-chains/relayer-setup | 20 +++++------ two-chains/relayer-test | 78 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 11 deletions(-) create mode 100755 two-chains/relayer-test diff --git a/.gitignore b/.gitignore index d0eb614f5..30346ae64 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ nchainz/ chain-code/ two-chains/ibc-* two-chains/.relayer +two-chains/*.log diff --git a/Makefile b/Makefile index 21d153b2c..dc7cafb2d 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ install: go.sum two-chains: @docker-compose -f ./two-chains/docker-compose.yaml down - @rm -fr ./two-chains/ibc-* ./two-chains/.relayer + @rm -fr ./two-chains/ibc-* ./two-chains/.relayer ./two-chains/rly.log @docker-compose -f ./two-chains/docker-compose.yaml up -d @while ! curl localhost:26657 &> /dev/null; do sleep 1; done @while ! curl localhost:26667 &> /dev/null; do sleep 1; done diff --git a/two-chains/relayer-setup b/two-chains/relayer-setup index 4c9eac252..99b8ce037 100755 --- a/two-chains/relayer-setup +++ b/two-chains/relayer-setup @@ -2,30 +2,30 @@ relayer_dir=./.relayer -echo "removing old relayer test directory" +echo "--> removing old relayer test directory" rm -fr $relayer_dir -echo "creating new relayer test directory" +echo "--> creating new relayer test directory" mkdir $relayer_dir -echo "generating relayer configuration..." +echo "--> generating relayer configuration..." rly config init --home $relayer_dir rly config add-chains ./chains --home $relayer_dir -echo "importing relayer keys..." +echo "--> importing relayer keys..." seed_ibc0=$(jq -r '.mnemonic' ./ibc-0/key_seed.json) seed_ibc1=$(jq -r '.mnemonic' ./ibc-1/key_seed.json) -echo "key $(rly keys restore --home $relayer_dir ibc-0 ibc-0-relayer-key "$seed_ibc0") imported from ibc-0 to relayer" -echo "key $(rly keys restore --home $relayer_dir ibc-1 ibc-1-relayer-key "$seed_ibc1") imported from ibc-1 to relayer" +echo "--> key $(rly keys restore --home $relayer_dir ibc-0 ibc-0-relayer-key "$seed_ibc0") imported from ibc-0 to relayer" +echo "--> key $(rly keys restore --home $relayer_dir ibc-1 ibc-1-relayer-key "$seed_ibc1") imported from ibc-1 to relayer" -echo "adding transfer path to relayer..." +echo "--> adding transfer path to relayer..." rly config add-paths ./paths --home $relayer_dir -echo "creating light clients..." +echo "--> creating light clients..." rly light init ibc-0 -f --home $relayer_dir rly light init ibc-1 -f --home $relayer_dir -echo "linking transfer path..." +echo "--> linking transfer path..." rly tx link transfer --home $relayer_dir -r 10 -o 20s -echo "relayer ready to use 🎉" +echo "--> relayer ready to use 🎉" diff --git a/two-chains/relayer-test b/two-chains/relayer-test new file mode 100755 index 000000000..b9ff296b1 --- /dev/null +++ b/two-chains/relayer-test @@ -0,0 +1,78 @@ +#!/bin/bash + +relayer_dir=./.relayer + +# start relayer on the transfer path +echo "--> starting the relayer..." +rm -fr rly.log +rly start transfer --home $relayer_dir --time-threshold=1m > rly.log 2>&1 & +rly_pid=$! + +sleep 5 + +declare -a client_updates_pids +declare -a transfer_pids + +for i in {0..19} +do + # update clients and store PID + echo "--> ($((i+1))/20)updating clients..." + rly tx update-clients transfer --home $relayer_dir & + client_updates_pids+=($!) + + sleep 1 + + # send transfer and store PID + echo "--> ($((i+1))/20)sending transfer..." + rly tx transfer ibc-0 ibc-1 1000uatom cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk --path=transfer --home $relayer_dir & + transfer_pids+=($!) + + sleep 1 +done + +# wait for all client updates processes to exit +successful_clients_updated=0 +for pid in "${client_updates_pids[@]}" +do + wait $pid + result=$? + if [ $result -eq 0 ]; then + ((successful_clients_updated++)) + fi +done + +# wait for all transfer processes to exit +successful_transfers=0 +for pid in "${transfer_pids[@]}" +do + wait $pid + result=$? + if [ $result -eq 0 ]; then + ((successful_transfers++)) + fi +done + +echo "--> successful clients updates: $successful_clients_updated" +echo "--> successful transfers: $successful_transfers" + +if [ $successful_clients_updated -eq 0 ]; then + echo "--> all clients updates failed" + exit 1 +fi + +if [ $successful_transfers -eq 0 ]; then + echo "--> all transfers failed" + exit 1 +fi + +# ensure the relayer is still running and kill it afterwards +if ps -p $rly_pid > /dev/null +then + echo "--> stopping relayer..." + kill $rly_pid +else + echo "--> relayer is not running!" + exit 1 +fi + +echo "--> finished 🎉" From 8cab14f213ce1e7eebf5a2a6b5d151b78c0dde7c Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sun, 28 Mar 2021 22:58:16 -0400 Subject: [PATCH 07/23] lint++ --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dc7cafb2d..a8bb871c3 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ two-chains: @docker-compose -f ./two-chains/docker-compose.yaml up -d @while ! curl localhost:26657 &> /dev/null; do sleep 1; done @while ! curl localhost:26667 &> /dev/null; do sleep 1; done - @cd ./two-chains && sh relayer-setup* && cd .. + @cd ./two-chains && sh relayer-setup && cd .. test: @TEST_DEBUG=true go test -mod=readonly -v ./test/... From 381e45f31e945814742937a4aad20c157df5904d Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sun, 28 Mar 2021 23:02:02 -0400 Subject: [PATCH 08/23] lint++ --- cmd/tx.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/tx.go b/cmd/tx.go index a862bf64b..dca858042 100644 --- a/cmd/tx.go +++ b/cmd/tx.go @@ -54,10 +54,13 @@ Most of these commands take a [path] argument. Make sure: func sendCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "send [chain-id] [from-key] [to-address] [amount]", - Short: "send funds to a different address on the same chain", - Args: cobra.ExactArgs(4), - Example: strings.TrimSpace(fmt.Sprintf(`$ %s tx send testkey cosmos10yft4nc8tacpngwlpyq3u4t88y7qzc9xv0q4y8 10000uatom`, appName)), + Use: "send [chain-id] [from-key] [to-address] [amount]", + Short: "send funds to a different address on the same chain", + Args: cobra.ExactArgs(4), + Example: strings.TrimSpace(fmt.Sprintf(` +$ %s tx send testkey cosmos10yft4nc8tacpngwlpyq3u4t88y7qzc9xv0q4y8 10000uatom`, + appName, + )), RunE: func(cmd *cobra.Command, args []string) error { c, err := config.Chains.Get(args[0]) if err != nil { From 70b1d37e819ad54572b4a377b930a25ed7eade43 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 09:35:53 -0400 Subject: [PATCH 09/23] update script --- two-chains/relayer-test | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/two-chains/relayer-test b/two-chains/relayer-test index b9ff296b1..f45630e22 100755 --- a/two-chains/relayer-test +++ b/two-chains/relayer-test @@ -10,37 +10,18 @@ rly_pid=$! sleep 5 -declare -a client_updates_pids declare -a transfer_pids for i in {0..19} do - # update clients and store PID - echo "--> ($((i+1))/20)updating clients..." - rly tx update-clients transfer --home $relayer_dir & - client_updates_pids+=($!) - - sleep 1 - # send transfer and store PID - echo "--> ($((i+1))/20)sending transfer..." + echo "--> ($((i+1))/20) sending transfer..." rly tx transfer ibc-0 ibc-1 1000uatom cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk --path=transfer --home $relayer_dir & transfer_pids+=($!) sleep 1 done -# wait for all client updates processes to exit -successful_clients_updated=0 -for pid in "${client_updates_pids[@]}" -do - wait $pid - result=$? - if [ $result -eq 0 ]; then - ((successful_clients_updated++)) - fi -done - # wait for all transfer processes to exit successful_transfers=0 for pid in "${transfer_pids[@]}" @@ -52,14 +33,8 @@ do fi done -echo "--> successful clients updates: $successful_clients_updated" echo "--> successful transfers: $successful_transfers" -if [ $successful_clients_updated -eq 0 ]; then - echo "--> all clients updates failed" - exit 1 -fi - if [ $successful_transfers -eq 0 ]; then echo "--> all transfers failed" exit 1 From b5e8a881355f8850abc68b8b2521d5e1d0495bf6 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 09:47:03 -0400 Subject: [PATCH 10/23] github actions++ --- .github/workflows/build.yml | 124 +++++++++++++++++++++++------------- Makefile | 2 +- 2 files changed, 82 insertions(+), 44 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0e72fbec..238638f80 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,59 +1,97 @@ -name: BUILD - build and binary upload +name: Build, Test, and Cover on: pull_request: push: branches: - master + schedule: + - cron: "0 0 * * 0" # weekly jobs: - build: - name: build + lint: + name: lint runs-on: ubuntu-latest steps: - # Install and setup go - - name: Set up Go 1.15 - uses: actions/setup-go@v2 + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 with: - go-version: 1.15 + version: v1.29 + github-token: ${{ secrets.github_token }} - # setup gopath - - name: Set PATH + test-and-cover: + runs-on: ubuntu-latest + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + go: ["1.15", "1.16"] + steps: + - name: Setup + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + - name: Checkout + uses: actions/checkout@v2 + - name: Test liveness run: | - echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - shell: bash + make two-chains + - name: Coverage + uses: codecov/codecov-action@v1 + with: + file: ./profile.cov + name: codecov-umbrella # optional + fail_ci_if_error: true # optional (default = false) - # checkout relayer - - name: checkout relayer - uses: actions/checkout@v2 +# jobs: +# build: +# name: build +# runs-on: ubuntu-latest +# steps: +# # Install and setup go +# - name: Set up Go 1.15 +# uses: actions/setup-go@v2 +# with: +# go-version: 1.15 - # setup cache - - uses: actions/cache@v1 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - # build binary - - name: build binary and move to upload location - run: make build - - # upload resulting binaries - - name: upload binaries - uses: actions/upload-artifact@v1 - with: - name: rly - path: ./build/rly +# # setup gopath +# - name: Set PATH +# run: | +# echo "$(go env GOPATH)/bin" >> $GITHUB_PATH +# shell: bash - golangci: - name: golangci-lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: golangci/golangci-lint-action@master - with: - # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.28 - args: --timeout 10m - github-token: ${{ secrets.github_token }} +# # checkout relayer +# - name: checkout relayer +# uses: actions/checkout@v2 + +# # setup cache +# - uses: actions/cache@v1 +# with: +# path: ~/go/pkg/mod +# key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} +# restore-keys: | +# ${{ runner.os }}-go- + +# # build binary +# - name: build binary and move to upload location +# run: make build + +# # upload resulting binaries +# - name: upload binaries +# uses: actions/upload-artifact@v1 +# with: +# name: rly +# path: ./build/rly + +# golangci: +# name: golangci-lint +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - uses: golangci/golangci-lint-action@master +# with: +# # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. +# version: v1.28 +# args: --timeout 10m +# github-token: ${{ secrets.github_token }} diff --git a/Makefile b/Makefile index a8bb871c3..27efd6cc2 100644 --- a/Makefile +++ b/Makefile @@ -112,4 +112,4 @@ check-swagger: update-swagger-docs: check-swagger swagger generate spec -o ./docs/swagger-ui/swagger.yaml -.PHONY: two-chains install build lint coverage clean +.PHONY: two-chains test install build lint coverage clean From 792b4c97e6ef0a4c14779bf9429c92fb33606373 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 09:54:45 -0400 Subject: [PATCH 11/23] github actions++ --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 238638f80..e91913266 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,10 @@ jobs: uses: actions/checkout@v2 - name: Test liveness run: | - make two-chains + docker-compose -f ./two-chains/docker-compose.yaml down + rm -fr ./two-chains/ibc-* ./two-chains/.relayer ./two-chains/rly.log + docker-compose -f ./two-chains/docker-compose.yaml up -d + docker ps -a - name: Coverage uses: codecov/codecov-action@v1 with: From 3cb72ba9b6b4a2e7d87f0804672a4c48c571b389 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 09:58:35 -0400 Subject: [PATCH 12/23] github actions++ --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e91913266..5cd169055 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,7 @@ jobs: docker-compose -f ./two-chains/docker-compose.yaml down rm -fr ./two-chains/ibc-* ./two-chains/.relayer ./two-chains/rly.log docker-compose -f ./two-chains/docker-compose.yaml up -d + docker logs two-chains_ibc-0_1 docker ps -a - name: Coverage uses: codecov/codecov-action@v1 From f4d675d56e527ae4acf771ecb64ca47e0743cb4b Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 10:02:29 -0400 Subject: [PATCH 13/23] github actions++ --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5cd169055..a74a54144 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,9 +36,9 @@ jobs: uses: actions/checkout@v2 - name: Test liveness run: | - docker-compose -f ./two-chains/docker-compose.yaml down + sudo docker-compose -f ./two-chains/docker-compose.yaml down rm -fr ./two-chains/ibc-* ./two-chains/.relayer ./two-chains/rly.log - docker-compose -f ./two-chains/docker-compose.yaml up -d + sudo docker-compose -f ./two-chains/docker-compose.yaml up -d docker logs two-chains_ibc-0_1 docker ps -a - name: Coverage From 641a1a0e31cc975259ca858507c39f53c304c5c8 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 10:05:10 -0400 Subject: [PATCH 14/23] github actions++ --- .github/workflows/build.yml | 4 ++-- two-chains/docker-compose.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a74a54144..5cd169055 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,9 +36,9 @@ jobs: uses: actions/checkout@v2 - name: Test liveness run: | - sudo docker-compose -f ./two-chains/docker-compose.yaml down + docker-compose -f ./two-chains/docker-compose.yaml down rm -fr ./two-chains/ibc-* ./two-chains/.relayer ./two-chains/rly.log - sudo docker-compose -f ./two-chains/docker-compose.yaml up -d + docker-compose -f ./two-chains/docker-compose.yaml up -d docker logs two-chains_ibc-0_1 docker ps -a - name: Coverage diff --git a/two-chains/docker-compose.yaml b/two-chains/docker-compose.yaml index b59783410..dbd916f96 100644 --- a/two-chains/docker-compose.yaml +++ b/two-chains/docker-compose.yaml @@ -9,7 +9,7 @@ services: volumes: - ./ibc-0:/gaia/.gaia command: > - sh -c "gaiad --chain-id=ibc-0 init ibc-0 + sh -c "sudo gaiad --chain-id=ibc-0 init ibc-0 && gaiad keys add validator --keyring-backend='test' --output json > $$HOME/.gaia/validator_seed.json 2> /dev/null && gaiad keys add user --keyring-backend='test' --output json > $$HOME/.gaia/key_seed.json 2> /dev/null && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show user -a) 100000000000stake,100000000000uatom From 619f7d11572d8f5e5d770a73958460b9caa37149 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 10:11:47 -0400 Subject: [PATCH 15/23] github actions++ --- .github/workflows/build.yml | 4 ++-- two-chains/docker-compose.ci.yaml | 34 +++++++++++++++++++++++++++++++ two-chains/docker-compose.yaml | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 two-chains/docker-compose.ci.yaml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5cd169055..bde976f1f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,9 +36,9 @@ jobs: uses: actions/checkout@v2 - name: Test liveness run: | - docker-compose -f ./two-chains/docker-compose.yaml down + docker-compose -f ./two-chains/docker-compose.ci.yaml down rm -fr ./two-chains/ibc-* ./two-chains/.relayer ./two-chains/rly.log - docker-compose -f ./two-chains/docker-compose.yaml up -d + docker-compose -f ./two-chains/docker-compose.ci.yaml up -d docker logs two-chains_ibc-0_1 docker ps -a - name: Coverage diff --git a/two-chains/docker-compose.ci.yaml b/two-chains/docker-compose.ci.yaml new file mode 100644 index 000000000..ef94490b4 --- /dev/null +++ b/two-chains/docker-compose.ci.yaml @@ -0,0 +1,34 @@ +version: "3.9" +services: + ibc-0: + image: "tendermint/gaia:v4.2.0" + ports: + - "26656-26657:26656-26657" + - "1317:1317" + - "9090:9090" + command: > + sh -c "gaiad --chain-id=ibc-0 init ibc-0 + && gaiad keys add validator --keyring-backend='test' --output json > $$HOME/.gaia/validator_seed.json 2> /dev/null + && gaiad keys add user --keyring-backend='test' --output json > $$HOME/.gaia/key_seed.json 2> /dev/null + && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show user -a) 100000000000stake,100000000000uatom + && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show validator -a) 100000000000stake,100000000000uatom + && gaiad gentx validator 100000000000stake --keyring-backend='test' --chain-id ibc-0 + && gaiad collect-gentxs + && sed -i'.bak' -e 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:26657#g' $$HOME/.gaia/config/config.toml + && gaiad start --pruning=nothing" + ibc-1: + image: "tendermint/gaia:v4.2.0" + ports: + - "26666-26667:26656-26657" + - "1318:1317" + - "9091:9090" + command: > + sh -c "gaiad --chain-id=ibc-1 init ibc-1 + && gaiad keys add validator --keyring-backend='test' --output json > $$HOME/.gaia/validator_seed.json 2> /dev/null + && gaiad keys add user --keyring-backend='test' --output json > $$HOME/.gaia/key_seed.json 2> /dev/null + && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show user -a) 100000000000stake,100000000000uatom + && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show validator -a) 100000000000stake,100000000000uatom + && gaiad gentx validator 100000000000stake --keyring-backend='test' --chain-id ibc-1 + && gaiad collect-gentxs + && sed -i'.bak' -e 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:26657#g' $$HOME/.gaia/config/config.toml + && gaiad start --pruning=nothing" diff --git a/two-chains/docker-compose.yaml b/two-chains/docker-compose.yaml index dbd916f96..b59783410 100644 --- a/two-chains/docker-compose.yaml +++ b/two-chains/docker-compose.yaml @@ -9,7 +9,7 @@ services: volumes: - ./ibc-0:/gaia/.gaia command: > - sh -c "sudo gaiad --chain-id=ibc-0 init ibc-0 + sh -c "gaiad --chain-id=ibc-0 init ibc-0 && gaiad keys add validator --keyring-backend='test' --output json > $$HOME/.gaia/validator_seed.json 2> /dev/null && gaiad keys add user --keyring-backend='test' --output json > $$HOME/.gaia/key_seed.json 2> /dev/null && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show user -a) 100000000000stake,100000000000uatom From 718a882c44719295e48cbcacee9998ce1b7ed84b Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 10:20:10 -0400 Subject: [PATCH 16/23] github actions++ --- .github/workflows/build.yml | 6 +----- Makefile | 10 +++++++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bde976f1f..8d67994a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,11 +36,7 @@ jobs: uses: actions/checkout@v2 - name: Test liveness run: | - docker-compose -f ./two-chains/docker-compose.ci.yaml down - rm -fr ./two-chains/ibc-* ./two-chains/.relayer ./two-chains/rly.log - docker-compose -f ./two-chains/docker-compose.ci.yaml up -d - docker logs two-chains_ibc-0_1 - docker ps -a + make two-chains-ci - name: Coverage uses: codecov/codecov-action@v1 with: diff --git a/Makefile b/Makefile index 27efd6cc2..b442523fc 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,14 @@ two-chains: @while ! curl localhost:26667 &> /dev/null; do sleep 1; done @cd ./two-chains && sh relayer-setup && cd .. +two-chains-ci: + @docker-compose -f ./two-chains/docker-compose.ci.yaml down + @rm -fr ./two-chains/ibc-* ./two-chains/.relayer ./two-chains/rly.log + @docker-compose -f ./two-chains/docker-compose.ci.yaml up -d + @while ! curl localhost:26657 &> /dev/null; do sleep 1; done + @while ! curl localhost:26667 &> /dev/null; do sleep 1; done + @cd ./two-chains && sh relayer-setup && cd .. + test: @TEST_DEBUG=true go test -mod=readonly -v ./test/... @@ -112,4 +120,4 @@ check-swagger: update-swagger-docs: check-swagger swagger generate spec -o ./docs/swagger-ui/swagger.yaml -.PHONY: two-chains test install build lint coverage clean +.PHONY: two-chains two-chains-ci test install build lint coverage clean From d90925729c5b4be755e5f039ef3401ace0e2d423 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 10:22:25 -0400 Subject: [PATCH 17/23] github actions++ --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b442523fc..87ac23c66 100644 --- a/Makefile +++ b/Makefile @@ -61,8 +61,7 @@ two-chains-ci: @docker-compose -f ./two-chains/docker-compose.ci.yaml down @rm -fr ./two-chains/ibc-* ./two-chains/.relayer ./two-chains/rly.log @docker-compose -f ./two-chains/docker-compose.ci.yaml up -d - @while ! curl localhost:26657 &> /dev/null; do sleep 1; done - @while ! curl localhost:26667 &> /dev/null; do sleep 1; done + @sleep 5 @cd ./two-chains && sh relayer-setup && cd .. test: From 814caff310db59c5d6aa7d875b7ff0e85cccd3a3 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 10:33:28 -0400 Subject: [PATCH 18/23] github actions++ --- .github/workflows/build.yml | 2 +- main.go | 15 --------------- two-chains/docker-compose.yaml | 4 ++-- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8d67994a8..238638f80 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: uses: actions/checkout@v2 - name: Test liveness run: | - make two-chains-ci + make two-chains - name: Coverage uses: codecov/codecov-action@v1 with: diff --git a/main.go b/main.go index 120b750f1..50ab0e973 100644 --- a/main.go +++ b/main.go @@ -1,18 +1,3 @@ -/* -Copyright © 2020 Jack Zampolin jack.zampolin@gmail.com - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ package main import "github.com/cosmos/relayer/cmd" diff --git a/two-chains/docker-compose.yaml b/two-chains/docker-compose.yaml index b59783410..5972da5ba 100644 --- a/two-chains/docker-compose.yaml +++ b/two-chains/docker-compose.yaml @@ -7,7 +7,7 @@ services: - "1317:1317" - "9090:9090" volumes: - - ./ibc-0:/gaia/.gaia + - ./ibc-0:/gaia/.gaia:Z command: > sh -c "gaiad --chain-id=ibc-0 init ibc-0 && gaiad keys add validator --keyring-backend='test' --output json > $$HOME/.gaia/validator_seed.json 2> /dev/null @@ -25,7 +25,7 @@ services: - "1318:1317" - "9091:9090" volumes: - - ./ibc-1:/gaia/.gaia + - ./ibc-1:/gaia/.gaia:Z command: > sh -c "gaiad --chain-id=ibc-1 init ibc-1 && gaiad keys add validator --keyring-backend='test' --output json > $$HOME/.gaia/validator_seed.json 2> /dev/null From 23082d814f89cedcbdb853995955e892de6fcdd1 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 10:37:50 -0400 Subject: [PATCH 19/23] github actions++ --- .github/workflows/build.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 238638f80..597ed8b95 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,13 +36,17 @@ jobs: uses: actions/checkout@v2 - name: Test liveness run: | - make two-chains - - name: Coverage - uses: codecov/codecov-action@v1 - with: - file: ./profile.cov - name: codecov-umbrella # optional - fail_ci_if_error: true # optional (default = false) + docker-compose -f ./two-chains/docker-compose.yaml down + rm -fr ./two-chains/ibc-* ./two-chains/.relayer ./two-chains/rly.log + docker-compose -f ./two-chains/docker-compose.yaml up -d + docker logs two-chains_ibc-0_1 + docker ps -a + # - name: Coverage + # uses: codecov/codecov-action@v1 + # with: + # file: ./profile.cov + # name: codecov-umbrella # optional + # fail_ci_if_error: true # optional (default = false) # jobs: # build: From 705eec2dbcf46aa6c92beb54b15fe533d7870b39 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 10:38:57 -0400 Subject: [PATCH 20/23] github actions++ --- .codecov.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .codecov.yml diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 000000000..c4bc4f223 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,23 @@ +codecov: + require_ci_to_pass: yes + +coverage: + precision: 2 + round: down + range: "40...100" + + status: + # Learn more at https://docs.codecov.io/docs/commit-status + project: + default: + threshold: 1% # allow this much decrease on project + changes: false + +comment: + layout: "reach,diff,flags,tree" + behavior: default # update if exists else create new + require_changes: true + +ignore: + - "docs" + - "*.md" From 3958277584f254e73b565b1558918aaf624998ee Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 10:39:12 -0400 Subject: [PATCH 21/23] github actions++ --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 597ed8b95..5cd169055 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,12 +41,12 @@ jobs: docker-compose -f ./two-chains/docker-compose.yaml up -d docker logs two-chains_ibc-0_1 docker ps -a - # - name: Coverage - # uses: codecov/codecov-action@v1 - # with: - # file: ./profile.cov - # name: codecov-umbrella # optional - # fail_ci_if_error: true # optional (default = false) + - name: Coverage + uses: codecov/codecov-action@v1 + with: + file: ./profile.cov + name: codecov-umbrella # optional + fail_ci_if_error: true # optional (default = false) # jobs: # build: From 9e33567e5e3368a5a3ef06fb22a26a0aa0d5dcf9 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 10:56:36 -0400 Subject: [PATCH 22/23] github actions++ --- .github/workflows/build.yml | 4 ++-- two-chains/docker-compose.ci.yaml | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5cd169055..bde976f1f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,9 +36,9 @@ jobs: uses: actions/checkout@v2 - name: Test liveness run: | - docker-compose -f ./two-chains/docker-compose.yaml down + docker-compose -f ./two-chains/docker-compose.ci.yaml down rm -fr ./two-chains/ibc-* ./two-chains/.relayer ./two-chains/rly.log - docker-compose -f ./two-chains/docker-compose.yaml up -d + docker-compose -f ./two-chains/docker-compose.ci.yaml up -d docker logs two-chains_ibc-0_1 docker ps -a - name: Coverage diff --git a/two-chains/docker-compose.ci.yaml b/two-chains/docker-compose.ci.yaml index ef94490b4..3fb97b28e 100644 --- a/two-chains/docker-compose.ci.yaml +++ b/two-chains/docker-compose.ci.yaml @@ -2,10 +2,13 @@ version: "3.9" services: ibc-0: image: "tendermint/gaia:v4.2.0" + user: gaia ports: - "26656-26657:26656-26657" - "1317:1317" - "9090:9090" + volumes: + - ./ibc-0:/gaia/.gaia:Z command: > sh -c "gaiad --chain-id=ibc-0 init ibc-0 && gaiad keys add validator --keyring-backend='test' --output json > $$HOME/.gaia/validator_seed.json 2> /dev/null @@ -18,10 +21,13 @@ services: && gaiad start --pruning=nothing" ibc-1: image: "tendermint/gaia:v4.2.0" + user: gaia ports: - "26666-26667:26656-26657" - "1318:1317" - "9091:9090" + volumes: + - ./ibc-1:/gaia/.gaia:Z command: > sh -c "gaiad --chain-id=ibc-1 init ibc-1 && gaiad keys add validator --keyring-backend='test' --output json > $$HOME/.gaia/validator_seed.json 2> /dev/null From 06432a0c09932bce5ab735e3bb4a095a0f574735 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Mar 2021 11:01:30 -0400 Subject: [PATCH 23/23] github actions++ --- .codecov.yml | 23 ------ .github/workflows/build.yml | 128 ++++++++++-------------------- Makefile | 9 +-- two-chains/docker-compose.ci.yaml | 40 ---------- 4 files changed, 44 insertions(+), 156 deletions(-) delete mode 100644 .codecov.yml delete mode 100644 two-chains/docker-compose.ci.yaml diff --git a/.codecov.yml b/.codecov.yml deleted file mode 100644 index c4bc4f223..000000000 --- a/.codecov.yml +++ /dev/null @@ -1,23 +0,0 @@ -codecov: - require_ci_to_pass: yes - -coverage: - precision: 2 - round: down - range: "40...100" - - status: - # Learn more at https://docs.codecov.io/docs/commit-status - project: - default: - threshold: 1% # allow this much decrease on project - changes: false - -comment: - layout: "reach,diff,flags,tree" - behavior: default # update if exists else create new - require_changes: true - -ignore: - - "docs" - - "*.md" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bde976f1f..b0e72fbec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,101 +1,59 @@ -name: Build, Test, and Cover +name: BUILD - build and binary upload on: pull_request: push: branches: - master - schedule: - - cron: "0 0 * * 0" # weekly jobs: - lint: - name: lint + build: + name: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: golangci-lint - uses: golangci/golangci-lint-action@v2 - with: - version: v1.29 - github-token: ${{ secrets.github_token }} - - test-and-cover: - runs-on: ubuntu-latest - timeout-minutes: 20 - strategy: - fail-fast: false - matrix: - go: ["1.15", "1.16"] - steps: - - name: Setup + # Install and setup go + - name: Set up Go 1.15 uses: actions/setup-go@v2 with: - go-version: ${{ matrix.go }} - - name: Checkout - uses: actions/checkout@v2 - - name: Test liveness - run: | - docker-compose -f ./two-chains/docker-compose.ci.yaml down - rm -fr ./two-chains/ibc-* ./two-chains/.relayer ./two-chains/rly.log - docker-compose -f ./two-chains/docker-compose.ci.yaml up -d - docker logs two-chains_ibc-0_1 - docker ps -a - - name: Coverage - uses: codecov/codecov-action@v1 - with: - file: ./profile.cov - name: codecov-umbrella # optional - fail_ci_if_error: true # optional (default = false) - -# jobs: -# build: -# name: build -# runs-on: ubuntu-latest -# steps: -# # Install and setup go -# - name: Set up Go 1.15 -# uses: actions/setup-go@v2 -# with: -# go-version: 1.15 - -# # setup gopath -# - name: Set PATH -# run: | -# echo "$(go env GOPATH)/bin" >> $GITHUB_PATH -# shell: bash + go-version: 1.15 -# # checkout relayer -# - name: checkout relayer -# uses: actions/checkout@v2 - -# # setup cache -# - uses: actions/cache@v1 -# with: -# path: ~/go/pkg/mod -# key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} -# restore-keys: | -# ${{ runner.os }}-go- + # setup gopath + - name: Set PATH + run: | + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH + shell: bash -# # build binary -# - name: build binary and move to upload location -# run: make build + # checkout relayer + - name: checkout relayer + uses: actions/checkout@v2 -# # upload resulting binaries -# - name: upload binaries -# uses: actions/upload-artifact@v1 -# with: -# name: rly -# path: ./build/rly + # setup cache + - uses: actions/cache@v1 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + # build binary + - name: build binary and move to upload location + run: make build + + # upload resulting binaries + - name: upload binaries + uses: actions/upload-artifact@v1 + with: + name: rly + path: ./build/rly -# golangci: -# name: golangci-lint -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v2 -# - uses: golangci/golangci-lint-action@master -# with: -# # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. -# version: v1.28 -# args: --timeout 10m -# github-token: ${{ secrets.github_token }} + golangci: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: golangci/golangci-lint-action@master + with: + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: v1.28 + args: --timeout 10m + github-token: ${{ secrets.github_token }} diff --git a/Makefile b/Makefile index 87ac23c66..27efd6cc2 100644 --- a/Makefile +++ b/Makefile @@ -57,13 +57,6 @@ two-chains: @while ! curl localhost:26667 &> /dev/null; do sleep 1; done @cd ./two-chains && sh relayer-setup && cd .. -two-chains-ci: - @docker-compose -f ./two-chains/docker-compose.ci.yaml down - @rm -fr ./two-chains/ibc-* ./two-chains/.relayer ./two-chains/rly.log - @docker-compose -f ./two-chains/docker-compose.ci.yaml up -d - @sleep 5 - @cd ./two-chains && sh relayer-setup && cd .. - test: @TEST_DEBUG=true go test -mod=readonly -v ./test/... @@ -119,4 +112,4 @@ check-swagger: update-swagger-docs: check-swagger swagger generate spec -o ./docs/swagger-ui/swagger.yaml -.PHONY: two-chains two-chains-ci test install build lint coverage clean +.PHONY: two-chains test install build lint coverage clean diff --git a/two-chains/docker-compose.ci.yaml b/two-chains/docker-compose.ci.yaml deleted file mode 100644 index 3fb97b28e..000000000 --- a/two-chains/docker-compose.ci.yaml +++ /dev/null @@ -1,40 +0,0 @@ -version: "3.9" -services: - ibc-0: - image: "tendermint/gaia:v4.2.0" - user: gaia - ports: - - "26656-26657:26656-26657" - - "1317:1317" - - "9090:9090" - volumes: - - ./ibc-0:/gaia/.gaia:Z - command: > - sh -c "gaiad --chain-id=ibc-0 init ibc-0 - && gaiad keys add validator --keyring-backend='test' --output json > $$HOME/.gaia/validator_seed.json 2> /dev/null - && gaiad keys add user --keyring-backend='test' --output json > $$HOME/.gaia/key_seed.json 2> /dev/null - && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show user -a) 100000000000stake,100000000000uatom - && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show validator -a) 100000000000stake,100000000000uatom - && gaiad gentx validator 100000000000stake --keyring-backend='test' --chain-id ibc-0 - && gaiad collect-gentxs - && sed -i'.bak' -e 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:26657#g' $$HOME/.gaia/config/config.toml - && gaiad start --pruning=nothing" - ibc-1: - image: "tendermint/gaia:v4.2.0" - user: gaia - ports: - - "26666-26667:26656-26657" - - "1318:1317" - - "9091:9090" - volumes: - - ./ibc-1:/gaia/.gaia:Z - command: > - sh -c "gaiad --chain-id=ibc-1 init ibc-1 - && gaiad keys add validator --keyring-backend='test' --output json > $$HOME/.gaia/validator_seed.json 2> /dev/null - && gaiad keys add user --keyring-backend='test' --output json > $$HOME/.gaia/key_seed.json 2> /dev/null - && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show user -a) 100000000000stake,100000000000uatom - && gaiad add-genesis-account $$(gaiad keys --keyring-backend='test' show validator -a) 100000000000stake,100000000000uatom - && gaiad gentx validator 100000000000stake --keyring-backend='test' --chain-id ibc-1 - && gaiad collect-gentxs - && sed -i'.bak' -e 's#tcp://127.0.0.1:26657#tcp://0.0.0.0:26657#g' $$HOME/.gaia/config/config.toml - && gaiad start --pruning=nothing"