Move contrib/ in scripts/ (#1848)

This commit is contained in:
pinosu
2024-04-02 13:28:28 +02:00
committed by GitHub
parent 8c9a744b76
commit f71e3bd89d
24 changed files with 9 additions and 10 deletions

View File

@@ -0,0 +1,85 @@
###
# Find OS and Go environment
# GO contains the Go binary
# FS contains the OS file separator
###
ifeq ($(OS),Windows_NT)
GO := $(shell where go.exe 2> NUL)
FS := "\\"
else
GO := $(shell command -v go 2> /dev/null)
FS := "/"
endif
ifeq ($(GO),)
$(error could not find go. Is it in PATH? $(GO))
endif
###############################################################################
### Functions ###
###############################################################################
go_get = $(if $(findstring Windows_NT,$(OS)),\
IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS) ( mkdir $(GITHUBDIR)$(FS)$(1) ) else (cd .) &\
IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS)$(2)$(FS) ( cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2) ) else (cd .) &\
,\
mkdir -p $(GITHUBDIR)$(FS)$(1) &&\
(test ! -d $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2)) || true &&\
)\
cd $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && git fetch origin && git checkout -q $(3)
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(shell cd $(shell dirname $(mkfile_path)); pwd)
###############################################################################
### Tools ###
###############################################################################
PREFIX ?= /usr/local
BIN ?= $(PREFIX)/bin
UNAME_S ?= $(shell uname -s)
UNAME_M ?= $(shell uname -m)
GOPATH ?= $(shell $(GO) env GOPATH)
GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com
BUF_VERSION ?= 0.11.0
TOOLS_DESTDIR ?= $(GOPATH)/bin
STATIK = $(TOOLS_DESTDIR)/statik
RUNSIM = $(TOOLS_DESTDIR)/runsim
GOLANGCI_LINT = $(TOOLS_DESTDIR)/golangci-lint
tools: tools-stamp
tools-stamp: statik runsim golangci-lint
# Create dummy file to satisfy dependency and avoid
# rebuilding when this Makefile target is hit twice
# in a row.
touch $@
statik: $(STATIK)
$(STATIK):
@echo "Installing statik..."
@(cd /tmp && go install github.com/rakyll/statik@v0.1.6)
# Install the runsim binary with a temporary workaround of entering an outside
# directory as the "go get" command ignores the -mod option and will polute the
# go.{mod, sum} files.
#
# ref: https://github.com/golang/go/issues/30515
runsim: $(RUNSIM)
$(RUNSIM):
@echo "Installing runsim..."
@(cd /tmp && go install github.com/cosmos/tools/cmd/runsim@v1.0.0)
golangci-lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT):
@echo "Installing golangci-lint..."
@(cd /tmp && go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.47.0)
tools-clean:
rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM)
rm -f tools-stamp
.PHONY: tools-clean statik runsim

View File

@@ -0,0 +1,6 @@
## Contributors
Thanks to the entire Cosmos SDK team and the contributors who put their efforts into making simulation testing
easier to implement. 🤗
https://github.com/cosmos/cosmos-sdk/blob/master/contrib/devtools/Makefile

View File

@@ -0,0 +1,18 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
BASE_ACCOUNT=$(wasmd keys show validator -a --keyring-backend=test)
wasmd q auth account "$BASE_ACCOUNT" -o json | jq
echo "## Add new account"
wasmd keys add fred --keyring-backend=test
echo "## Check balance"
NEW_ACCOUNT=$(wasmd keys show fred -a --keyring-backend=test)
wasmd q bank balances "$NEW_ACCOUNT" -o json || true
echo "## Transfer tokens"
wasmd tx bank send validator "$NEW_ACCOUNT" 1ustake --gas 1000000 -y --chain-id=testing --node=http://localhost:26657 -b sync -o json --keyring-backend=test | jq
echo "## Check balance again"
wasmd q bank balances "$NEW_ACCOUNT" -o json | jq

View File

@@ -0,0 +1,113 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail -x
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
echo "-----------------------"
echo "## Add new CosmWasm contract"
RESP=$(wasmd tx wasm store "$DIR/../../x/wasm/keeper/testdata/hackatom.wasm" \
--from validator --gas 1500000 -y --chain-id=testing --node=http://localhost:26657 -b sync -o json --keyring-backend=test)
sleep 6
RESP=$(wasmd q tx $(echo "$RESP"| jq -r '.txhash') -o json)
CODE_ID=$(echo "$RESP" | jq -r '.events[]| select(.type=="store_code").attributes[]| select(.key=="code_id").value')
CODE_HASH=$(echo "$RESP" | jq -r '.events[]| select(.type=="store_code").attributes[]| select(.key=="code_checksum").value')
echo "* Code id: $CODE_ID"
echo "* Code checksum: $CODE_HASH"
echo "* Download code"
TMPDIR=$(mktemp -d -t wasmdXXXXXX)
wasmd q wasm code "$CODE_ID" "$TMPDIR/delme.wasm"
rm -f "$TMPDIR/delme.wasm"
echo "-----------------------"
echo "## List code"
wasmd query wasm list-code --node=http://localhost:26657 -o json | jq
echo "-----------------------"
echo "## Create new contract instance"
INIT="{\"verifier\":\"$(wasmd keys show validator -a --keyring-backend=test)\", \"beneficiary\":\"$(wasmd keys show fred -a --keyring-backend=test)\"}"
RESP=$(wasmd tx wasm instantiate "$CODE_ID" "$INIT" --admin="$(wasmd keys show validator -a --keyring-backend=test)" \
--from validator --amount="100ustake" --label "local0.1.0" \
--gas 1000000 -y --chain-id=testing -b sync -o json --keyring-backend=test)
sleep 6
wasmd q tx $(echo "$RESP"| jq -r '.txhash') -o json | jq
CONTRACT=$(wasmd query wasm list-contract-by-code "$CODE_ID" -o json | jq -r '.contracts[-1]')
echo "* Contract address: $CONTRACT"
echo "## Create new contract instance with predictable address"
RESP=$(wasmd tx wasm instantiate2 "$CODE_ID" "$INIT" $(echo -n "testing" | xxd -ps) \
--admin="$(wasmd keys show validator -a --keyring-backend=test)" \
--from validator --amount="100ustake" --label "local0.1.0" \
--fix-msg \
--gas 1000000 -y --chain-id=testing -b sync -o json --keyring-backend=test)
sleep 6
wasmd q tx $(echo "$RESP"| jq -r '.txhash') -o json | jq
predictedAdress=$(wasmd q wasm build-address "$CODE_HASH" $(wasmd keys show validator -a --keyring-backend=test) $(echo -n "testing" | xxd -ps) "$INIT")
wasmd q wasm contract "$predictedAdress" -o json | jq
echo "### Query all"
RESP=$(wasmd query wasm contract-state all "$CONTRACT" -o json)
echo "$RESP" | jq
echo "### Query smart"
wasmd query wasm contract-state smart "$CONTRACT" '{"verifier":{}}' -o json | jq
echo "### Query raw"
KEY=$(echo "$RESP" | jq -r ".models[0].key")
wasmd query wasm contract-state raw "$CONTRACT" "$KEY" -o json | jq
echo "-----------------------"
echo "## Execute contract $CONTRACT"
MSG='{"release":{}}'
RESP=$(wasmd tx wasm execute "$CONTRACT" "$MSG" \
--from validator \
--gas 1000000 -y --chain-id=testing -b sync -o json --keyring-backend=test)
sleep 6
wasmd q tx $(echo "$RESP"| jq -r '.txhash') -o json | jq
echo "-----------------------"
echo "## Set new admin"
echo "### Query old admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.contract_info.admin')"
echo "### Update contract"
RESP=$(wasmd tx wasm set-contract-admin "$CONTRACT" "$(wasmd keys show fred -a --keyring-backend=test)" \
--from validator -y --chain-id=testing -b sync -o json --keyring-backend=test)
sleep 6
wasmd q tx $(echo "$RESP"| jq -r '.txhash') -o json | jq
echo "### Query new admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.contract_info.admin')"
echo "-----------------------"
echo "## Migrate contract"
echo "### Upload new code"
RESP=$(wasmd tx wasm store "$DIR/../../x/wasm/keeper/testdata/burner.wasm" \
--from validator --gas 1100000 -y --chain-id=testing --node=http://localhost:26657 -b sync -o json --keyring-backend=test)
sleep 6
RESP=$(wasmd q tx $(echo "$RESP"| jq -r '.txhash') -o json)
BURNER_CODE_ID=$(echo "$RESP" | jq -r '.events[]| select(.type=="store_code").attributes[]| select(.key=="code_id").value')
echo "### Migrate to code id: $BURNER_CODE_ID"
DEST_ACCOUNT=$(wasmd keys show fred -a --keyring-backend=test)
RESP=$(wasmd tx wasm migrate "$CONTRACT" "$BURNER_CODE_ID" "{\"payout\": \"$DEST_ACCOUNT\"}" --from fred \
--chain-id=testing -b sync -y -o json --keyring-backend=test)
sleep 6
wasmd q tx $(echo "$RESP"| jq -r '.txhash') -o json | jq
echo "### Query destination account: $BURNER_CODE_ID"
wasmd q bank balances "$DEST_ACCOUNT" -o json | jq
echo "### Query contract meta data: $CONTRACT"
wasmd q wasm contract "$CONTRACT" -o json | jq
echo "### Query contract meta history: $CONTRACT"
wasmd q wasm contract-history "$CONTRACT" -o json | jq
echo "-----------------------"
echo "## Clear contract admin"
echo "### Query old admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.contract_info.admin')"
echo "### Update contract"
RESP=$(wasmd tx wasm clear-contract-admin "$CONTRACT" \
--from fred -y --chain-id=testing -b sync -o json --keyring-backend=test)
sleep 6
wasmd q tx $(echo "$RESP"| jq -r '.txhash') -o json | jq
echo "### Query new admin: $(wasmd q wasm contract "$CONTRACT" -o json | jq -r '.contract_info.admin')"

View File

@@ -0,0 +1,24 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
echo "-----------------------"
echo "### List all codes"
RESP=$(grpcurl -plaintext localhost:9090 cosmwasm.wasm.v1.Query/Codes)
echo "$RESP" | jq
CODE_ID=$(echo "$RESP" | jq -r '.codeInfos[-1].codeId')
echo "### List contracts by code"
RESP=$(grpcurl -plaintext -d "{\"codeId\": $CODE_ID}" localhost:9090 cosmwasm.wasm.v1.Query/ContractsByCode)
echo "$RESP" | jq
echo "### Show history for contract"
CONTRACT=$(echo "$RESP" | jq -r ".contracts[-1]")
grpcurl -plaintext -d "{\"address\": \"$CONTRACT\"}" localhost:9090 cosmwasm.wasm.v1.Query/ContractHistory | jq
echo "### Show contract state"
grpcurl -plaintext -d "{\"address\": \"$CONTRACT\"}" localhost:9090 cosmwasm.wasm.v1.Query/AllContractState | jq
echo "Empty state due to 'burner' contract cleanup"

18
scripts/contrib/local/04-gov.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
sleep 1
echo "## Submit a CosmWasm gov proposal"
RESP=$(wasmd tx wasm submit-proposal store-instantiate "$DIR/../../x/wasm/keeper/testdata/reflect.wasm" \
'{}' --label="testing" \
--title "testing" --summary "Testing" --deposit "1000000000ustake" \
--admin $(wasmd keys show -a validator --keyring-backend=test) \
--amount 123ustake \
--keyring-backend=test \
--from validator --gas auto --gas-adjustment=1.5 -y --chain-id=testing --node=http://localhost:26657 -b sync -o json)
echo $RESP
sleep 6
wasmd q tx $(echo "$RESP"| jq -r '.txhash') -o json | jq

View File

@@ -0,0 +1,26 @@
# Dev scripts
For manual testing. Works on my box(*) ...
*) OSX
```
make install
cd scripts/contrib/local
rm -rf /tmp/trash
HOME=/tmp/trash bash setup_wasmd.sh
HOME=/tmp/trash bash start_node.sh
```
Next shell:
```
cd scripts/contrib/local
HOME=/tmp/trash bash 01-accounts.sh
HOME=/tmp/trash bash 02-contracts.sh
```
## Shell script development
[Use `shellcheck`](https://www.shellcheck.net/) to avoid common mistakes in shell scripts.
[Use `shfmt`](https://github.com/mvdan/sh) to ensure a consistent code formatting.

View File

@@ -0,0 +1,36 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
PASSWORD=${PASSWORD:-1234567890}
STAKE=${STAKE_TOKEN:-ustake}
FEE=${FEE_TOKEN:-ucosm}
CHAIN_ID=${CHAIN_ID:-testing}
MONIKER=${MONIKER:-node001}
wasmd init --chain-id "$CHAIN_ID" "$MONIKER"
# staking/governance token is hardcoded in config, change this
## OSX requires: -i.
sed -i. "s/\"stake\"/\"$STAKE\"/" "$HOME"/.wasmd/config/genesis.json
if ! wasmd keys show validator --keyring-backend=test; then
(
echo "$PASSWORD"
echo "$PASSWORD"
) | wasmd keys add validator --keyring-backend=test
fi
# hardcode the validator account for this instance
echo "$PASSWORD" | wasmd genesis add-genesis-account validator "1000000000000$STAKE,1000000000000$FEE" --keyring-backend=test
# (optionally) add a few more genesis accounts
for addr in "$@"; do
echo "$addr"
wasmd genesis add-genesis-account "$addr" "1000000000$STAKE,1000000000$FEE" --keyring-backend=test
done
# submit a genesis validator tx
## Workraround for https://github.com/cosmos/cosmos-sdk/issues/8251
(
echo "$PASSWORD"
echo "$PASSWORD"
echo "$PASSWORD"
) | wasmd genesis gentx validator "250000000$STAKE" --chain-id="$CHAIN_ID" --amount="250000000$STAKE" --keyring-backend=test
## should be:
# (echo "$PASSWORD"; echo "$PASSWORD"; echo "$PASSWORD") | wasmd gentx validator "250000000$STAKE" --chain-id="$CHAIN_ID"
wasmd genesis collect-gentxs

View File

@@ -0,0 +1,4 @@
#!/bin/bash
set -eu
wasmd start --rpc.laddr tcp://0.0.0.0:26657 --log_level=info --trace #remove trace flag if you don't wantg the stack trace to be printed

View File

@@ -0,0 +1,53 @@
# Setup
Enable prometheus metrics in wasmd:
* Edit `$HOME/config/app.toml`
```toml
[telemetry]
# Enabled enables the application telemetry functionality. When enabled,
# an in-memory sink is also enabled by default. Operators may also enabled
# other sinks such as Prometheus.
enabled =true
# ...
# PrometheusRetentionTime, when positive, enables a Prometheus metrics sink.
prometheus-retention-time = 15
```
`retention-time` must be >0 (see prometheus scrape config)
* Edit `$HOME/config/config.toml`
```toml
[instrumentation]
# When true, Prometheus metrics are served under /metrics on
# PrometheusListenAddr.
# Check out the documentation for the list of available metrics.
prometheus = true
```
Test manually at:
`http://localhost:1317/metrics?format=prometheus`
Note the `format` parameter in the request for the endpoint:
# Local testing
## Run Prometheus
```sh
# port 9090 is used by wasmd already
docker run -it -v $(pwd)/scripts/contrib/prometheus:/prometheus -p9091:9090 prom/prometheus --config.file=/prometheus/prometheus.yaml
```
* Open [console](http://localhost:9091) and find `wasm_`service metrics
## Run Grafana
```shell
docker run -it -p 3000:3000 grafana/grafana
```
* Add Prometheus data source
`http://host.docker.internal:9091`
### Labels
* `wasm_contract_create` = nanosec

View File

@@ -0,0 +1,11 @@
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: 15s # By default, scrape targets every 15 seconds.
rule_files:
scrape_configs:
- job_name: wasmd
scrape_interval: 5s
static_configs:
- targets: ['host.docker.internal:26660']

View File

@@ -0,0 +1,51 @@
FROM golang:1.16.8-alpine3.13 AS build
#ARG PROTOTOOL_VERSION=1.10.0
ARG PROTODOC_VERSION=1.3.2
ARG GRPC_GATEWAY_VERSION=1.16.0
ARG REGEN_GOGOPROTO_VERSION=0.3.0
ARG REGEN_PROTOBUF_VERSION=1.3.2-alpha.regen.4
ARG BUF_VERSION=0.30.0
RUN apk --no-cache add --update curl git libc6-compat make upx
RUN go get -d \
github.com/gogo/protobuf/gogoproto && \
mkdir -p /usr/include/google/protobuf/ && \
mv /go/src/github.com/gogo/protobuf/protobuf/google/protobuf/empty.proto /usr/include/google/protobuf/ && \
mv /go/src/github.com/gogo/protobuf/protobuf/google/protobuf/descriptor.proto /usr/include/google/protobuf/
RUN GO111MODULE=on go get \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v${GRPC_GATEWAY_VERSION} \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v${GRPC_GATEWAY_VERSION} && \
mv /go/bin/protoc-gen-grpc-gateway /usr/local/bin/ && \
mv /go/bin/protoc-gen-swagger /usr/local/bin/
# Install regen fork of gogo proto
# To install a fix version this can only be done via this go.mod workaround
WORKDIR /work
RUN GO111MODULE=on go mod init foobar && \
go mod edit -replace github.com/gogo/protobuf=github.com/regen-network/protobuf@v${REGEN_PROTOBUF_VERSION} && \
go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@v${REGEN_GOGOPROTO_VERSION} && \
mv /go/bin/protoc-gen-gocosmos* /usr/local/bin/
RUN GO111MODULE=on go get \
github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@v${PROTODOC_VERSION} && \
mv /go/bin/protoc-gen-doc /usr/local/bin/
RUN GO111MODULE=on go get \
github.com/bufbuild/buf/cmd/buf@v${BUF_VERSION} && \
mv /go/bin/buf /usr/local/bin/
RUN upx --lzma /usr/local/bin/*
FROM golang:1.19-alpine
ENV LD_LIBRARY_PATH=/lib64:/lib
WORKDIR /work
RUN apk --no-cache add --update curl git libc6-compat make
RUN apk --no-cache add --update ca-certificates libc6-compat protoc
COPY --from=build /usr/local/bin /usr/local/bin
COPY --from=build /usr/include /usr/include
RUN chmod -R 755 /usr/include

View File

@@ -0,0 +1,21 @@
Prototool Docker Helper
=======================
Docker container for all the protobuf generation...
Based on the work by @pseudomuto [prototool-docker](https://github.com/charithe/prototool-docker) project:
Installs generators and tools from:
* https://github.com/bufbuild/buf
* https://github.com/grpc-ecosystem
* https://github.com/regen-network/cosmos-proto
* https://github.com/pseudomuto/protoc-gen-doc
### Build
```shell script
docker build -t cosmwasm/prototools-docker -f ./scripts/contrib/prototools-docker/Dockerfile .
```
```shell script
docker run -it -v $(go list -f "{{ .Dir }}" -m github.com/cosmos/cosmos-sdk):/workspace/cosmos_sdk_dir -v $(pwd):/workspace --workdir /workspace --env COSMOS_SDK_DIR=/cosmos_sdk_dir cosmwasm/prototool-docker sh
```

View File

@@ -0,0 +1,3 @@
# Testing
.relayer
data

View File

@@ -0,0 +1,14 @@
# Relayer tests
These scripts helps to test go-relayer with two local wasmd chains. \
Make sure you run below scripts under `wasmd/scripts/contrib/relayer-tests` directory.
- `./init_two_chainz_relayer.sh` will spin two chains and runs
- `./one_chain.sh` will spin a single chain. This script used by the one above
- `./test_ibc_transfer.sh` will setup a path between chains and send tokens between chains.
## Thank you
The setup scripts here are taken from [cosmos/relayer](https://github.com/cosmos/relayer)
Thank your relayer team for these scripts.

View File

@@ -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"}

View File

@@ -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"}

View File

@@ -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"}}

View File

@@ -0,0 +1,64 @@
#!/bin/bash
# init_two_chainz_relayer creates two wasmd chains and configures the relayer
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
WASMD_DATA="$(pwd)/data"
RELAYER_CONF="$(pwd)/.relayer"
# Ensure relayer is installed
if ! [ -x "$(which rly)" ]; then
echo "Error: wasmd is not installed. Try running 'make build-wasmd'" >&2
exit 1
fi
# 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
# 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 ../
./one_chain.sh wasmd $chainid0 ./data 26657 26656 6060 9090
./one_chain.sh 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."
echo "Generating rly configurations..."
rly config init
rly config add-chains configs/wasmd/chains
rly config add-paths configs/wasmd/paths
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

View File

@@ -0,0 +1,115 @@
#!/bin/sh
set -e
display_usage() {
echo "\nMissing $1 parameter. Please check if all parameters were specified."
echo "\nUsage: ./one-chain [BINARY] [CHAIN_ID] [CHAIN_DIR] [RPC_PORT] [P2P_PORT] [PROFILING_PORT] [GRPC_PORT]"
echo "\nExample: ./one-chain $BINARY test-chain-id ./data 26657 26656 6060 9090 \n"
exit 1
}
KEYRING=--keyring-backend="test"
SILENT=1
redirect() {
if [ "$SILENT" -eq 1 ]; then
"$@" > /dev/null 2>&1
else
"$@"
fi
}
BINARY=$1
CHAINID=$2
CHAINDIR=$3
RPCPORT=$4
P2PPORT=$5
PROFPORT=$6
GRPCPORT=$7
if [ -z "$1" ]; then
display_usage "[BINARY] ($BINARY|akash)"
fi
if [ -z "$2" ]; then
display_usage "[CHAIN_ID]"
fi
if [ -z "$3" ]; then
display_usage "[CHAIN_DIR]"
fi
if [ -z "$4" ]; then
display_usage "[RPC_PORT]"
fi
if [ -z "$5" ]; then
display_usage "[P2P_PORT]"
fi
if [ -z "$6" ]; then
display_usage "[PROFILING_PORT]"
fi
if [ -z "$7" ]; then
display_usage "[GRPC_PORT]"
fi
echo "Creating $BINARY instance: home=$CHAINDIR | chain-id=$CHAINID | p2p=:$P2PPORT | rpc=:$RPCPORT | profiling=:$PROFPORT | grpc=:$GRPCPORT"
# Add dir for chain, exit if error
if ! mkdir -p $CHAINDIR/$CHAINID 2>/dev/null; then
echo "Failed to create chain folder. Aborting..."
exit 1
fi
# Build genesis file incl account for passed address
chain_one_coins="100000000000stake,100000000000umuon,100000000000test"
chain_two_coins="100000000000stake,100000000000umuon"
delegate="100000000000stake"
redirect $BINARY --home $CHAINDIR/$CHAINID --chain-id $CHAINID init $CHAINID
sleep 1
$BINARY --home $CHAINDIR/$CHAINID keys add validator $KEYRING --output json > $CHAINDIR/$CHAINID/validator_seed.json 2> /dev/null
sleep 1
$BINARY --home $CHAINDIR/$CHAINID keys add user $KEYRING --output json > $CHAINDIR/$CHAINID/key_seed.json 2> /dev/null
sleep 1
redirect $BINARY --home $CHAINDIR/$CHAINID add-genesis-account $($BINARY --home $CHAINDIR/$CHAINID keys $KEYRING show user -a) $chain_one_coins
sleep 1
redirect $BINARY --home $CHAINDIR/$CHAINID add-genesis-account $($BINARY --home $CHAINDIR/$CHAINID keys $KEYRING show validator -a) $chain_two_coins
sleep 1
redirect $BINARY --home $CHAINDIR/$CHAINID gentx validator $delegate $KEYRING --chain-id $CHAINID
sleep 1
redirect $BINARY --home $CHAINDIR/$CHAINID collect-gentxs
sleep 1
# Check platform
platform='unknown'
unamestr=`uname`
if [ "$unamestr" = 'Linux' ]; then
platform='linux'
fi
# Set proper defaults and change ports (use a different sed for Mac or Linux)
echo "Change settings in config.toml file..."
if [ $platform = 'linux' ]; then
sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPCPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
sed -i 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
sed -i 's#"localhost:6060"#"localhost:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml
sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml
sed -i 's/index_all_keys = false/index_all_keys = true/g' $CHAINDIR/$CHAINID/config/config.toml
# sed -i '' 's#index-events = \[\]#index-events = \["message.action","send_packet.packet_src_channel","send_packet.packet_sequence"\]#g' $CHAINDIR/$CHAINID/config/app.toml
else
sed -i '' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPCPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
sed -i '' 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
sed -i '' 's#"localhost:6060"#"localhost:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml
sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml
sed -i '' 's/index_all_keys = false/index_all_keys = true/g' $CHAINDIR/$CHAINID/config/config.toml
# sed -i '' 's#index-events = \[\]#index-events = \["message.action","send_packet.packet_src_channel","send_packet.packet_sequence"\]#g' $CHAINDIR/$CHAINID/config/app.toml
fi
# Start the gaia
redirect $BINARY --home $CHAINDIR/$CHAINID start --pruning=nothing --grpc.address="0.0.0.0:$GRPCPORT" > $CHAINDIR/$CHAINID.log &

View File

@@ -0,0 +1,26 @@
#!/bin/bash
set -e
# Ensure relayer is installed
if ! [ -x "$(which rly)" ]; then
echo "Error: rly is not installed." >&2
exit 1
fi
rly tx link demo -d
rly tx transfer ibc-0 ibc-1 1000000test $(rly chains address ibc-1)
sleep 2
EXPECTED_BALANCE="100000000000test"
CHAIN_1_BALANCE=$(rly q bal ibc-1)
if [[ "$CHAIN_1_BALANCE" == *"$EXPECTED_BALANCE" ]]; then
echo "Token not sent correctly"
echo "$EXPECTED_BALANCE not found in $CHAIN_1_BALANCE"
exit 1
fi
echo "IBC transfer executed successfully"