Skip to content

Commit

Permalink
Add wasmd to chains (cosmos#389)
Browse files Browse the repository at this point in the history
* Add wasmd scripts

* Apply suggestions from code review

Co-authored-by: colin axnér <[email protected]>

Co-authored-by: colin axnér <[email protected]>
  • Loading branch information
orkunkl and colin-axner authored Jan 22, 2021
1 parent d9decfa commit b61cf50
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ COMMIT := $(shell git log -1 --format='%H')
SDKCOMMIT := $(shell go list -m -u -f '{{.Version}}' github.com/cosmos/cosmos-sdk)
GAIA_VERSION := v3.0.1
AKASH_VERSION := jack/update-sdk
WASMD_VERSION := v0.14.1

GOPATH := $(shell go env GOPATH)
GOBIN := $(GOPATH)/bin
Expand Down Expand Up @@ -85,7 +86,14 @@ get-akash:
@mkdir -p ./chain-code/
@git clone --branch $(AKASH_VERSION) [email protected]:ovrclk/akash.git ./chain-code/akash

get-chains: get-gaia get-akash
get-chains: get-gaia get-akash get-wasmd

get-wasmd:
@mkdir -p ./chain-code/
@git clone --branch $(WASMD_VERSION) [email protected]:CosmWasm/wasmd.git ./chain-code/wasmd

build-wasmd:
@./scripts/build-wasmd

delete-chains:
@echo "Removing the ./chain-code/ directory..."
Expand Down
1 change: 1 addition & 0 deletions configs/wasmd/demo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"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"}}
1 change: 1 addition & 0 deletions configs/wasmd/ibc-0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"key":"testkey","chain-id":"ibc-0","rpc-addr":"http://localhost:26657","account-prefix":"wasm","gas-adjustment":1.5,"gas-prices":"0.025stake","trusting-period":"336h"}
1 change: 1 addition & 0 deletions configs/wasmd/ibc-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"key":"testkey","chain-id":"ibc-1","rpc-addr":"http://localhost:26557","account-prefix":"wasm","gas-adjustment":1.5,"gas-prices":"0.025stake", "trusting-period":"336h"}
11 changes: 11 additions & 0 deletions scripts/build-wasmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
WASMDDIR="$(dirname $SCRIPTDIR)/chain-code/wasmd"

[ ! -d "$WASMDDIR" ] && echo "Repository for wasmd does not exist at $WASMDDIR. Try running 'make get-wasmd'..." && exit 1

cd $WASMDDIR
echo "Building wasmd binary at branch($(git branch --show-current)) tag($(git describe --tags)) commit($(git rev-parse HEAD))"
make install &> /dev/null
wasmd version --long
71 changes: 71 additions & 0 deletions scripts/two-chainz-wasmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash
# two-chainz creates two wasmd chains and configures the relayer to

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
WASMD_DATA="$(pwd)/data"
RELAYER_DIR="$(dirname $SCRIPTDIR)"
RELAYER_CONF="$HOME/.relayer"

# Ensure wasmd is installed
if ! [ -x "$(which wasmd)" ]; then
echo "Error: wasmd is not installed. Try running 'make build-wasmd'" >&2
exit 1
fi

# Display software version for testers
echo "WASMD VERSION INFO:"
wasmd version --long

# Ensure jq is installed
if [[ ! -x "$(which jq)" ]]; then
echo "jq (a tool for parsing json in the command line) is required..."
echo "https://stedolan.github.io/jq/download/"
exit 1
fi

# Ensure user understands what will be deleted
if [[ -d $WASMD_DATA ]] && [[ ! "$1" == "skip" ]]; then
read -p "$(basename $0) will delete \$(pwd)/data and \$HOME/.relayer folders. Do you wish to continue? (y/n): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi

# Delete data from old runs
rm -rf $WASMD_DATA &> /dev/null
rm -rf $RELAYER_CONF &> /dev/null

# Stop existing wasmd processes
killall wasmd &> /dev/null

set -e

chainid0=ibc-0
chainid1=ibc-1

echo "Generating wasmd configurations..."
mkdir -p $WASMD_DATA && cd $WASMD_DATA && cd ../
./scripts/one-chain wasmd $chainid0 ./data 26657 26656 6060 9090
./scripts/one-chain wasmd $chainid1 ./data 26557 26556 6061 9091

[ -f $WASMD_DATA/$chainid0.log ] && echo "$chainid0 initialized. Watch file $WASMD_DATA/$chainid0.log to see its execution."
[ -f $WASMD_DATA/$chainid1.log ] && echo "$chainid1 initialized. Watch file $WASMD_DATA/$chainid1.log to see its execution."

cd $RELAYER_DIR

echo "Building Relayer..."
make install

echo "Generating rly configurations..."
rly config init
rly config add-dir configs/wasmd/

SEED0=$(jq -r '.mnemonic' $WASMD_DATA/ibc-0/key_seed.json)
SEED1=$(jq -r '.mnemonic' $WASMD_DATA/ibc-1/key_seed.json)
echo "Key $(rly keys restore ibc-0 testkey "$SEED0") imported from ibc-0 to relayer..."
echo "Key $(rly keys restore ibc-1 testkey "$SEED1") imported from ibc-1 to relayer..."
echo "Creating light clients..."
sleep 3
rly light init ibc-0 -f
rly light init ibc-1 -f

0 comments on commit b61cf50

Please sign in to comment.