From 4c0a1432c847145edeef3df46866d67f9da199df Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 28 Nov 2022 15:45:01 -0500 Subject: [PATCH 01/15] Added initial commit that sets up an ibc network. --- Makefile | 31 ++++++ networks/ibc/README.md | 7 ++ networks/ibc/blockchain-ibc/Dockerfile | 97 +++++++++++++++++++ networks/ibc/blockchain-ibc/entrypoint.sh | 20 ++++ networks/ibc/blockchain-relayer/Dockerfile | 39 ++++++++ networks/ibc/blockchain-relayer/config.yaml | 44 +++++++++ networks/ibc/blockchain-relayer/entrypoint.sh | 14 +++ networks/ibc/docker-compose.yml | 53 ++++++++++ scripts/ibcnet-add-relayer-key.sh | 5 + 9 files changed, 310 insertions(+) create mode 100644 networks/ibc/README.md create mode 100644 networks/ibc/blockchain-ibc/Dockerfile create mode 100755 networks/ibc/blockchain-ibc/entrypoint.sh create mode 100644 networks/ibc/blockchain-relayer/Dockerfile create mode 100644 networks/ibc/blockchain-relayer/config.yaml create mode 100755 networks/ibc/blockchain-relayer/entrypoint.sh create mode 100644 networks/ibc/docker-compose.yml create mode 100755 scripts/ibcnet-add-relayer-key.sh diff --git a/Makefile b/Makefile index b3648edc2e..b6bb3e5806 100644 --- a/Makefile +++ b/Makefile @@ -472,6 +472,37 @@ localnet-start: localnet-generate localnet-up localnet-stop: docker-compose -f networks/local/docker-compose.yml --project-directory ./ down + + +# Quick build using ibc environment and go platform target options. +docker-build-ibc: vendor + docker build --target provenance-$(shell uname -m) --tag provenance-io/blockchain-ibc -f networks/ibc/blockchain-ibc/Dockerfile . + docker build --target relayer --tag provenance-io/blockchain-relayer -f networks/ibc/blockchain-relayer/Dockerfile . + +# jq . build/ibc0-0/config/genesis.json | jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq '.app_state.bank.balances += [{"address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"' > build/ibc0-0/config/genesis.json +# cat build/ibc1-0/config/genesis.json | jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq '.app_state.bank.balances += [{"address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"' > build/ibc1-0/config/genesis.json + +# Generate config files for a 2-node ibcnet with relayer +ibcnet-generate: ibcnet-stop docker-build-ibc + @if ! [ -f build/ibc0-0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/provenance:Z provenance-io/blockchain-ibc testnet --v 1 -o . --starting-ip-address 192.168.20.2 --node-dir-prefix=ibc0- --keyring-backend=test --chain-id=testing ; fi + mv build/gentxs/ibc0-0.json build/gentxs/tmp + @if ! [ -f build/ibc1-0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/provenance:Z provenance-io/blockchain-ibc testnet --v 1 -o . --starting-ip-address 192.168.20.3 --node-dir-prefix=ibc1- --keyring-backend=test --chain-id=testing2 ; fi + mv build/gentxs/tmp build/gentxs/ibc0-0.json + scripts/ibcnet-add-relayer-key.sh + +# Run a 2-node testnet locally with a relayer +ibcnet-up: + docker-compose -f networks/ibc/docker-compose.yml --project-directory ./ up -d + +# Run a 2-node testnet locally with a relayer +ibcnet-start: ibcnet-generate ibcnet-up + +# Stop ibcnet +ibcnet-stop: + docker-compose -f networks/ibc/docker-compose.yml --project-directory ./ down + + + # Quick build using devnet environment and go platform target options. docker-build-dev: vendor docker build --target provenance-$(shell uname -m) --tag provenance-io/blockchain-dev -f networks/dev/blockchain-dev/Dockerfile . diff --git a/networks/ibc/README.md b/networks/ibc/README.md new file mode 100644 index 0000000000..663d5d84dc --- /dev/null +++ b/networks/ibc/README.md @@ -0,0 +1,7 @@ +## Local IBC Test Cluster + +NOTE: This folder contains files to run an image using a locally built binary +that leverages Go's ability to target platforms during builds. These docker +files are _not_ the ones used to build the release image. For those images +see the `docker/blockchain` folder in the project root. + diff --git a/networks/ibc/blockchain-ibc/Dockerfile b/networks/ibc/blockchain-ibc/Dockerfile new file mode 100644 index 0000000000..640a1590f8 --- /dev/null +++ b/networks/ibc/blockchain-ibc/Dockerfile @@ -0,0 +1,97 @@ +# This docker file builds a test image using binaries built locally. +# Use `make docker-build-local` to build or `make localnet-start` to +# start the test network and `make localnet-stop` to stop it. + +## Build provenance for x86_64 +FROM golang:1.18-bullseye as build-x86_64 +WORKDIR /go/src/github.com/provenance-io/provenance +ENV GOPRIVATE=github.com/provenance-io +RUN apt-get update && apt-get upgrade -y && apt-get install -y libleveldb-dev + +COPY client/ ./client/ +COPY app/ ./app/ +COPY go.* ./ +COPY cmd/ ./cmd/ +COPY internal/ ./internal/ +COPY x/ ./x/ +COPY vendor/ ./vendor/ + +# Build the binaries +RUN go build -mod vendor -tags=cleveldb -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/version.Name=Provenance-Blockchain' -o /go/bin/ ./cmd/... + +## Run provenance for x86_64 +FROM debian:bullseye-slim as provenance-x86_64 +ENV LOCALNET=1 +ENV LD_LIBRARY_PATH="/usr/local/lib" + +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y curl jq libleveldb-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/ + +# Requires a mounted volume with the config in it. +VOLUME [ "/provenance" ] +WORKDIR /provenance +EXPOSE 26656 26657 1317 9090 + +# Source binaries from the build above +COPY --from=build-x86_64 /go/src/github.com/provenance-io/provenance/vendor/github.com/CosmWasm/wasmvm/internal/api/libwasmvm.x86_64.so /usr/local/lib/ +COPY --from=build-x86_64 /go/bin/provenanced /usr/bin/provenanced + +COPY networks/ibc/blockchain-ibc/entrypoint.sh /usr/bin/entrypoint.sh + +STOPSIGNAL SIGTERM + +ENTRYPOINT ["/usr/bin/entrypoint.sh"] +CMD ["start"] + + + + + + +## Build provenance for ARM +FROM golang:1.18-bullseye as build-arm64 +WORKDIR /go/src/github.com/provenance-io/provenance +ENV GOPRIVATE=github.com/provenance-io +RUN apt-get update && apt-get upgrade -y && apt-get install -y libleveldb-dev + +COPY client/ ./client/ +COPY app/ ./app/ +COPY go.* ./ +COPY cmd/ ./cmd/ +COPY internal/ ./internal/ +COPY x/ ./x/ +COPY vendor/ ./vendor/ + +# Build the binaries +RUN go build -mod vendor -tags=cleveldb -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/version.Name=Provenance-Blockchain' -o /go/bin/ ./cmd/... + +## Run provenance for ARM +FROM debian:bullseye-slim as provenance-arm64 +ENV LOCALNET=1 +ENV LD_LIBRARY_PATH="/usr/local/lib" + +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y curl jq libleveldb-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/ + +# Requires a mounted volume with the config in it. +VOLUME [ "/provenance" ] +WORKDIR /provenance +EXPOSE 26656 26657 1317 9090 + +# Source binaries from the build above +COPY --from=build-arm64 /go/src/github.com/provenance-io/provenance/vendor/github.com/CosmWasm/wasmvm/internal/api/libwasmvm.aarch64.so /usr/local/lib/ + +COPY --from=build-arm64 /go/bin/provenanced /usr/bin/provenanced + +COPY networks/ibc/blockchain-ibc/entrypoint.sh /usr/bin/entrypoint.sh + +STOPSIGNAL SIGTERM + +ENTRYPOINT ["/usr/bin/entrypoint.sh"] +CMD ["start"] diff --git a/networks/ibc/blockchain-ibc/entrypoint.sh b/networks/ibc/blockchain-ibc/entrypoint.sh new file mode 100755 index 0000000000..9c87d7159b --- /dev/null +++ b/networks/ibc/blockchain-ibc/entrypoint.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +## +## Input parameters +## +ID=${ID:-0} +export PIO_HOME="/provenance/ibc${ID}-0" + +BINARY=/usr/bin/${BINARY:-provenanced} +LOG=${LOG:-provenance.log} + +## +## Run binary with all parameters +## +if [ -d "$(dirname "${PIO_HOME}"/"${LOG}")" ]; then + "${BINARY}" -t --home "${PIO_HOME}" "$@" | tee "${PIO_HOME}/${LOG}" +else + "${BINARY}" -t --home "${PIO_HOME}" "$@" +fi + diff --git a/networks/ibc/blockchain-relayer/Dockerfile b/networks/ibc/blockchain-relayer/Dockerfile new file mode 100644 index 0000000000..20056db3c4 --- /dev/null +++ b/networks/ibc/blockchain-relayer/Dockerfile @@ -0,0 +1,39 @@ +## Build provenance for ARM +FROM golang:1.18-bullseye as build +WORKDIR / +RUN apt-get update && apt-get upgrade -y && apt-get install -y libleveldb-dev && apt-get install -y git +RUN git clone https://github.com/cosmos/relayer.git /relayer && cd /relayer && git checkout v2.1.1 && make install && cd / && rm -rf /relayer + +## Run provenance for ARM +FROM build as relayer +ENV LD_LIBRARY_PATH="/usr/local/lib" + +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/ + +# Requires a mounted volume with the config in it. +VOLUME [ "/relayer" ] +WORKDIR /relayer +EXPOSE 26656 26657 1317 9090 + +COPY --from=build /go/bin/rly /usr/bin/rly + +# We need to setup the relayer +RUN rly config init --home "/relayer" + +# Copy over the network config +COPY networks/ibc/blockchain-relayer/config.yaml /relayer/config/config.yaml + +# Generate the keys +# Key is tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y +RUN rly keys restore local default "list judge day spike walk easily outer state fashion library review include leisure casino wagon zoo chuckle alien stock bargain stone wait squeeze fade" --home "/relayer" +RUN rly keys restore local2 default "list judge day spike walk easily outer state fashion library review include leisure casino wagon zoo chuckle alien stock bargain stone wait squeeze fade" --home "/relayer" + +COPY networks/ibc/blockchain-relayer/entrypoint.sh /usr/bin/entrypoint.sh + +STOPSIGNAL SIGTERM + +ENTRYPOINT ["/usr/bin/entrypoint.sh"] +CMD ["start"] diff --git a/networks/ibc/blockchain-relayer/config.yaml b/networks/ibc/blockchain-relayer/config.yaml new file mode 100644 index 0000000000..7ef5a540a2 --- /dev/null +++ b/networks/ibc/blockchain-relayer/config.yaml @@ -0,0 +1,44 @@ +global: + api-listen-addr: :5183 + timeout: 10s + memo: "" + light-cache-size: 20 +chains: + local: + type: cosmos + value: + key: default + chain-id: testing + rpc-addr: http://192.168.20.2:26657 + account-prefix: tp + keyring-backend: test + gas-adjustment: 1.5 + gas-prices: 1905nhash + debug: false + timeout: 20s + output-format: json + sign-mode: direct + local2: + type: cosmos + value: + key: default + chain-id: testing2 + rpc-addr: http://192.168.20.3:26657 + account-prefix: tp + keyring-backend: test + gas-adjustment: 1.5 + gas-prices: 1905nhash + debug: false + timeout: 20s + output-format: json + sign-mode: direct + +paths: + local_local2: + src: + chain-id: testing + dst: + chain-id: testing2 + src-channel-filter: + rule: "" + channel-list: [] \ No newline at end of file diff --git a/networks/ibc/blockchain-relayer/entrypoint.sh b/networks/ibc/blockchain-relayer/entrypoint.sh new file mode 100755 index 0000000000..5b00773871 --- /dev/null +++ b/networks/ibc/blockchain-relayer/entrypoint.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +## +## Input parameters +## + +export RELAYER_HOME="/relayer" +export RELAY_PATH="local_local2" + +# Setup the connection, client, and channel +rly tx link "$RELAY_PATH" --home "$RELAYER_HOME" + +# Start the relayer +rly start "$RELAY_PATH" -p events --home "$RELAYER_HOME" \ No newline at end of file diff --git a/networks/ibc/docker-compose.yml b/networks/ibc/docker-compose.yml new file mode 100644 index 0000000000..d52b202f60 --- /dev/null +++ b/networks/ibc/docker-compose.yml @@ -0,0 +1,53 @@ +version: '3' + +services: + ibc0: + container_name: ibc0 + image: "provenance-io/blockchain-ibc" + ports: + - "26656-26657:26656-26657" + - "1317:1317" + - "9090:9090" + environment: + - ID=0 + - LOG=${LOG:-provenanced.log} + - PIO_HOME=/provenance + volumes: + - ./build:/provenance:Z + + networks: + localnet: + ipv4_address: 192.168.20.2 + + ibc1: + container_name: ibc1 + image: "provenance-io/blockchain-ibc" + ports: + - "26659-26660:26656-26657" + environment: + - ID=1 + - LOG=${LOG:-provenanced.log} + - PIO_HOME=/provenance + volumes: + - ./build:/provenance:Z + networks: + localnet: + ipv4_address: 192.168.20.3 + + relayer: + container_name: relayer + image: "provenance-io/blockchain-relayer" + ports: + - "26661-26662:26656-26657" + networks: + localnet: + ipv4_address: 192.168.20.4 + +networks: + localnet: + driver: bridge + ipam: + driver: default + config: + - + subnet: 192.168.20.0/24 diff --git a/scripts/ibcnet-add-relayer-key.sh b/scripts/ibcnet-add-relayer-key.sh new file mode 100755 index 0000000000..78f95a93d2 --- /dev/null +++ b/scripts/ibcnet-add-relayer-key.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# We probably want to verify that the address doesn't exist +echo $(jq . build/ibc0-0/config/genesis.json | jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq '.app_state.bank.balances += [{"address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"') > build/ibc0-0/config/genesis.json +echo $(jq . build/ibc1-0/config/genesis.json | jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq '.app_state.bank.balances += [{"address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"') > build/ibc1-0/config/genesis.json From d22a6de6fb68e8e26f8f7c1708a9bbff53fd6e71 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 28 Nov 2022 16:51:32 -0500 Subject: [PATCH 02/15] Updated scripts to check if genesis file was already updated. Also added check for jq. --- scripts/ibcnet-add-relayer-key.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/ibcnet-add-relayer-key.sh b/scripts/ibcnet-add-relayer-key.sh index 78f95a93d2..cf7b3432e4 100755 --- a/scripts/ibcnet-add-relayer-key.sh +++ b/scripts/ibcnet-add-relayer-key.sh @@ -1,5 +1,25 @@ #!/bin/bash +# Verify that jq exists +if ! command -v jq &> /dev/null +then + echo "jq could not be found." + exit 1 +fi + # We probably want to verify that the address doesn't exist -echo $(jq . build/ibc0-0/config/genesis.json | jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq '.app_state.bank.balances += [{"address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"') > build/ibc0-0/config/genesis.json -echo $(jq . build/ibc1-0/config/genesis.json | jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq '.app_state.bank.balances += [{"address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"') > build/ibc1-0/config/genesis.json +ACCOUNTS=$(jq . build/ibc0-0/config/genesis.json | jq '.app_state.auth.accounts' | jq length) +if [ "$ACCOUNTS" -eq "1" ]; then + echo "Updating genesis for ibc0." + echo $(jq . build/ibc0-0/config/genesis.json | jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq '.app_state.bank.balances += [{"address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"') > build/ibc0-0/config/genesis.json +else + echo "Genesis file is already updated for ibc0. Skipping..." +fi + +ACCOUNTS=$(jq . build/ibc1-0/config/genesis.json | jq '.app_state.auth.accounts' | jq length) +if [ "$ACCOUNTS" -eq "1" ]; then + echo "Updating genesis for ibc1." + echo $(jq . build/ibc1-0/config/genesis.json | jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq '.app_state.bank.balances += [{"address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"') > build/ibc1-0/config/genesis.json +else + echo "Genesis file is already updated for ibc1. Skipping..." +fi \ No newline at end of file From eb0d5bb7c5bcfb8952b4138efae02ee6e4c79a18 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 29 Nov 2022 09:55:13 -0500 Subject: [PATCH 03/15] Extracted private key and mnemonic out of scripts and files. They are configurable through the Makefile. --- Makefile | 13 ++++--------- networks/ibc/blockchain-relayer/Dockerfile | 6 +++--- scripts/ibcnet-add-relayer-key.sh | 11 +++++++++-- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index b6bb3e5806..89f92dd912 100644 --- a/Makefile +++ b/Makefile @@ -472,15 +472,12 @@ localnet-start: localnet-generate localnet-up localnet-stop: docker-compose -f networks/local/docker-compose.yml --project-directory ./ down - - # Quick build using ibc environment and go platform target options. +RELAYER_MNEMONIC="list judge day spike walk easily outer state fashion library review include leisure casino wagon zoo chuckle alien stock bargain stone wait squeeze fade" +RELAYER_KEY=tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y docker-build-ibc: vendor docker build --target provenance-$(shell uname -m) --tag provenance-io/blockchain-ibc -f networks/ibc/blockchain-ibc/Dockerfile . - docker build --target relayer --tag provenance-io/blockchain-relayer -f networks/ibc/blockchain-relayer/Dockerfile . - -# jq . build/ibc0-0/config/genesis.json | jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq '.app_state.bank.balances += [{"address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"' > build/ibc0-0/config/genesis.json -# cat build/ibc1-0/config/genesis.json | jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq '.app_state.bank.balances += [{"address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"' > build/ibc1-0/config/genesis.json + docker build --target relayer --tag provenance-io/blockchain-relayer -f networks/ibc/blockchain-relayer/Dockerfile --build-arg MNEMONIC=$(RELAYER_MNEMONIC) . # Generate config files for a 2-node ibcnet with relayer ibcnet-generate: ibcnet-stop docker-build-ibc @@ -488,7 +485,7 @@ ibcnet-generate: ibcnet-stop docker-build-ibc mv build/gentxs/ibc0-0.json build/gentxs/tmp @if ! [ -f build/ibc1-0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/provenance:Z provenance-io/blockchain-ibc testnet --v 1 -o . --starting-ip-address 192.168.20.3 --node-dir-prefix=ibc1- --keyring-backend=test --chain-id=testing2 ; fi mv build/gentxs/tmp build/gentxs/ibc0-0.json - scripts/ibcnet-add-relayer-key.sh + scripts/ibcnet-add-relayer-key.sh $(RELAYER_KEY) # Run a 2-node testnet locally with a relayer ibcnet-up: @@ -501,8 +498,6 @@ ibcnet-start: ibcnet-generate ibcnet-up ibcnet-stop: docker-compose -f networks/ibc/docker-compose.yml --project-directory ./ down - - # Quick build using devnet environment and go platform target options. docker-build-dev: vendor docker build --target provenance-$(shell uname -m) --tag provenance-io/blockchain-dev -f networks/dev/blockchain-dev/Dockerfile . diff --git a/networks/ibc/blockchain-relayer/Dockerfile b/networks/ibc/blockchain-relayer/Dockerfile index 20056db3c4..02fd5bee40 100644 --- a/networks/ibc/blockchain-relayer/Dockerfile +++ b/networks/ibc/blockchain-relayer/Dockerfile @@ -6,6 +6,7 @@ RUN git clone https://github.com/cosmos/relayer.git /relayer && cd /relayer && g ## Run provenance for ARM FROM build as relayer +ARG MNEMONIC ENV LD_LIBRARY_PATH="/usr/local/lib" RUN apt-get update && \ @@ -27,9 +28,8 @@ RUN rly config init --home "/relayer" COPY networks/ibc/blockchain-relayer/config.yaml /relayer/config/config.yaml # Generate the keys -# Key is tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y -RUN rly keys restore local default "list judge day spike walk easily outer state fashion library review include leisure casino wagon zoo chuckle alien stock bargain stone wait squeeze fade" --home "/relayer" -RUN rly keys restore local2 default "list judge day spike walk easily outer state fashion library review include leisure casino wagon zoo chuckle alien stock bargain stone wait squeeze fade" --home "/relayer" +RUN rly keys restore local default "$MNEMONIC" --home "/relayer" +RUN rly keys restore local2 default "$MNEMONIC" --home "/relayer" COPY networks/ibc/blockchain-relayer/entrypoint.sh /usr/bin/entrypoint.sh diff --git a/scripts/ibcnet-add-relayer-key.sh b/scripts/ibcnet-add-relayer-key.sh index cf7b3432e4..193928abfa 100755 --- a/scripts/ibcnet-add-relayer-key.sh +++ b/scripts/ibcnet-add-relayer-key.sh @@ -7,11 +7,18 @@ then exit 1 fi +if [ "$#" -ne 1 ]; then + echo "The relayer key must be the only argument passed in." + exit 1 +fi + +RELAYER_KEY=$1 + # We probably want to verify that the address doesn't exist ACCOUNTS=$(jq . build/ibc0-0/config/genesis.json | jq '.app_state.auth.accounts' | jq length) if [ "$ACCOUNTS" -eq "1" ]; then echo "Updating genesis for ibc0." - echo $(jq . build/ibc0-0/config/genesis.json | jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq '.app_state.bank.balances += [{"address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"') > build/ibc0-0/config/genesis.json + echo $(jq . build/ibc0-0/config/genesis.json | jq --arg KEY $RELAYER_KEY '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "\($KEY)", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq --arg KEY $RELAYER_KEY '.app_state.bank.balances += [{"address": "\($KEY)", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"') > build/ibc0-0/config/genesis.json else echo "Genesis file is already updated for ibc0. Skipping..." fi @@ -19,7 +26,7 @@ fi ACCOUNTS=$(jq . build/ibc1-0/config/genesis.json | jq '.app_state.auth.accounts' | jq length) if [ "$ACCOUNTS" -eq "1" ]; then echo "Updating genesis for ibc1." - echo $(jq . build/ibc1-0/config/genesis.json | jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq '.app_state.bank.balances += [{"address": "tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"') > build/ibc1-0/config/genesis.json + echo $(jq . build/ibc1-0/config/genesis.json | jq --arg KEY $RELAYER_KEY '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "\($KEY)", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq --arg KEY $RELAYER_KEY '.app_state.bank.balances += [{"address": "\($KEY)", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"') > build/ibc1-0/config/genesis.json else echo "Genesis file is already updated for ibc1. Skipping..." fi \ No newline at end of file From 9c029a3611f4e56619fe9f8bcc6e9fef17d0fe46 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 29 Nov 2022 09:59:00 -0500 Subject: [PATCH 04/15] Added default value for mnemonic and private key. They are configurable through make now. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 89f92dd912..0f1f1bb2d9 100644 --- a/Makefile +++ b/Makefile @@ -473,8 +473,8 @@ localnet-stop: docker-compose -f networks/local/docker-compose.yml --project-directory ./ down # Quick build using ibc environment and go platform target options. -RELAYER_MNEMONIC="list judge day spike walk easily outer state fashion library review include leisure casino wagon zoo chuckle alien stock bargain stone wait squeeze fade" -RELAYER_KEY=tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y +RELAYER_MNEMONIC ?= "list judge day spike walk easily outer state fashion library review include leisure casino wagon zoo chuckle alien stock bargain stone wait squeeze fade" +RELAYER_KEY ?= tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y docker-build-ibc: vendor docker build --target provenance-$(shell uname -m) --tag provenance-io/blockchain-ibc -f networks/ibc/blockchain-ibc/Dockerfile . docker build --target relayer --tag provenance-io/blockchain-relayer -f networks/ibc/blockchain-relayer/Dockerfile --build-arg MNEMONIC=$(RELAYER_MNEMONIC) . From 3b6e34529243034a214b6d1dcc2fe44ff91f2fe3 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 29 Nov 2022 10:10:43 -0500 Subject: [PATCH 05/15] Linted shell script and removed redundant commands. --- scripts/ibcnet-add-relayer-key.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/ibcnet-add-relayer-key.sh b/scripts/ibcnet-add-relayer-key.sh index 193928abfa..ebf15124ef 100755 --- a/scripts/ibcnet-add-relayer-key.sh +++ b/scripts/ibcnet-add-relayer-key.sh @@ -13,20 +13,23 @@ if [ "$#" -ne 1 ]; then fi RELAYER_KEY=$1 +TEMP=tmp # We probably want to verify that the address doesn't exist ACCOUNTS=$(jq . build/ibc0-0/config/genesis.json | jq '.app_state.auth.accounts' | jq length) if [ "$ACCOUNTS" -eq "1" ]; then - echo "Updating genesis for ibc0." - echo $(jq . build/ibc0-0/config/genesis.json | jq --arg KEY $RELAYER_KEY '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "\($KEY)", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq --arg KEY $RELAYER_KEY '.app_state.bank.balances += [{"address": "\($KEY)", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"') > build/ibc0-0/config/genesis.json + GENESIS=build/ibc0-0/config/genesis.json + echo "Updating $GENESIS" + jq . "$GENESIS" | jq --arg KEY "$RELAYER_KEY" '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "\($KEY)", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq --arg KEY "$RELAYER_KEY" '.app_state.bank.balances += [{"address": "\($KEY)", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"' > "$TEMP" && mv "$TEMP" "$GENESIS" else echo "Genesis file is already updated for ibc0. Skipping..." fi ACCOUNTS=$(jq . build/ibc1-0/config/genesis.json | jq '.app_state.auth.accounts' | jq length) if [ "$ACCOUNTS" -eq "1" ]; then - echo "Updating genesis for ibc1." - echo $(jq . build/ibc1-0/config/genesis.json | jq --arg KEY $RELAYER_KEY '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "\($KEY)", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq --arg KEY $RELAYER_KEY '.app_state.bank.balances += [{"address": "\($KEY)", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"') > build/ibc1-0/config/genesis.json + GENESIS=build/ibc1-0/config/genesis.json + echo "Updating $GENESIS" + jq . "$GENESIS" | jq --arg KEY "$RELAYER_KEY" '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "\($KEY)", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq --arg KEY "$RELAYER_KEY" '.app_state.bank.balances += [{"address": "\($KEY)", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"' > "$TEMP" && mv "$TEMP" "$GENESIS" else echo "Genesis file is already updated for ibc1. Skipping..." fi \ No newline at end of file From 23d298e716a874383aa689f49d2f06ffbb0ede86 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 29 Nov 2022 10:28:54 -0500 Subject: [PATCH 06/15] Updated comments. --- scripts/ibcnet-add-relayer-key.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/ibcnet-add-relayer-key.sh b/scripts/ibcnet-add-relayer-key.sh index ebf15124ef..6f89666daf 100755 --- a/scripts/ibcnet-add-relayer-key.sh +++ b/scripts/ibcnet-add-relayer-key.sh @@ -15,20 +15,25 @@ fi RELAYER_KEY=$1 TEMP=tmp -# We probably want to verify that the address doesn't exist +# Verify the relayer account hasn't been added ACCOUNTS=$(jq . build/ibc0-0/config/genesis.json | jq '.app_state.auth.accounts' | jq length) if [ "$ACCOUNTS" -eq "1" ]; then GENESIS=build/ibc0-0/config/genesis.json echo "Updating $GENESIS" + + # Update genesis to include the relayer jq . "$GENESIS" | jq --arg KEY "$RELAYER_KEY" '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "\($KEY)", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq --arg KEY "$RELAYER_KEY" '.app_state.bank.balances += [{"address": "\($KEY)", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"' > "$TEMP" && mv "$TEMP" "$GENESIS" else echo "Genesis file is already updated for ibc0. Skipping..." fi +# Verify the relayer account hasn't been added ACCOUNTS=$(jq . build/ibc1-0/config/genesis.json | jq '.app_state.auth.accounts' | jq length) if [ "$ACCOUNTS" -eq "1" ]; then GENESIS=build/ibc1-0/config/genesis.json echo "Updating $GENESIS" + + # Update genesis to include the relayer jq . "$GENESIS" | jq --arg KEY "$RELAYER_KEY" '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "\($KEY)", "pub_key": null, "account_number": "1", "sequence": "0"}]' | jq --arg KEY "$RELAYER_KEY" '.app_state.bank.balances += [{"address": "\($KEY)", "coins": [{"denom": "nhash","amount": "100000000000000000"}]}]' | jq '.app_state.bank.balances[0].coins[0].amount = "99900000000000000000"' > "$TEMP" && mv "$TEMP" "$GENESIS" else echo "Genesis file is already updated for ibc1. Skipping..." From 75de1c61c258c678cf529dfbd9c0b7154e3995f5 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 29 Nov 2022 11:24:34 -0500 Subject: [PATCH 07/15] Extracted version out of Dockerfile, and updated relayer version to 2.1.2 --- Makefile | 3 ++- networks/ibc/blockchain-relayer/Dockerfile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0f1f1bb2d9..1877329c8d 100644 --- a/Makefile +++ b/Makefile @@ -475,9 +475,10 @@ localnet-stop: # Quick build using ibc environment and go platform target options. RELAYER_MNEMONIC ?= "list judge day spike walk easily outer state fashion library review include leisure casino wagon zoo chuckle alien stock bargain stone wait squeeze fade" RELAYER_KEY ?= tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y +RELAYER_VERSION ?= v2.1.2 docker-build-ibc: vendor docker build --target provenance-$(shell uname -m) --tag provenance-io/blockchain-ibc -f networks/ibc/blockchain-ibc/Dockerfile . - docker build --target relayer --tag provenance-io/blockchain-relayer -f networks/ibc/blockchain-relayer/Dockerfile --build-arg MNEMONIC=$(RELAYER_MNEMONIC) . + docker build --target relayer --tag provenance-io/blockchain-relayer -f networks/ibc/blockchain-relayer/Dockerfile --build-arg MNEMONIC=$(RELAYER_MNEMONIC) --build-arg VERSION=$(RELAYER_VERSION) . # Generate config files for a 2-node ibcnet with relayer ibcnet-generate: ibcnet-stop docker-build-ibc diff --git a/networks/ibc/blockchain-relayer/Dockerfile b/networks/ibc/blockchain-relayer/Dockerfile index 02fd5bee40..8d241ca32a 100644 --- a/networks/ibc/blockchain-relayer/Dockerfile +++ b/networks/ibc/blockchain-relayer/Dockerfile @@ -1,8 +1,9 @@ ## Build provenance for ARM FROM golang:1.18-bullseye as build WORKDIR / +ARG VERSION RUN apt-get update && apt-get upgrade -y && apt-get install -y libleveldb-dev && apt-get install -y git -RUN git clone https://github.com/cosmos/relayer.git /relayer && cd /relayer && git checkout v2.1.1 && make install && cd / && rm -rf /relayer +RUN git clone https://github.com/cosmos/relayer.git /relayer && cd /relayer && git checkout "$VERSION" && make install && cd / && rm -rf /relayer ## Run provenance for ARM FROM build as relayer From f2e4b651d77e9034c5ebd442d9b70a0d02513791 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 29 Nov 2022 16:03:28 -0500 Subject: [PATCH 08/15] Updated README to contain more documentation and examples. --- networks/ibc/README.md | 99 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/networks/ibc/README.md b/networks/ibc/README.md index 663d5d84dc..3f45303bb0 100644 --- a/networks/ibc/README.md +++ b/networks/ibc/README.md @@ -1,4 +1,101 @@ -## Local IBC Test Cluster +## Inter-Blockchain Communication (IBC) Test Cluster +# Overview + +This folder contains the files to create 3 containers for testing IBC. The first container +is a single node running a blockchain with chain-id testing. The second container is also a +single node running a blockchain, but this chain has chain-id testing2. Lastly, the third container +is the relayer used to forward packets between chains. + +# Relayer Account + +Each chain has an account for the relayer that is funded. The relayer uses this account +to publish packets from the sending chain to the receiving chain. + +``` +- type: local + address: tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y + pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Aj/FqZi4LKRTT+q0tByQsqk27uIMO9nf1UnkTyUaQRV5"}' + mnemonic: "" +- balances: + amount: "99999998039505445" + denom: nhash +``` + +# Transferring Currency + +The simplest test that can be used to verify that IBC is working is using the Fungible Token +Transfer (ICS-20) subprotocol. This subprotocol is exposed through provenance with the `ibc-transfer` +transaction. It transfers coins from an account on one chain to an account on another chain. +In this example we will transfer from an account on ibc0-0 to an account on ibc1-0. + +1. On the container for ibc1-0, obtain your receiving address. In this example our receiving address is +`tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y`. + +``` +provenanced -t --home ibc1-0/ keys list + +- address: tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y + name: ibc1-0 + pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AjOKuV/CkfDBmZgSHZFrCN2PXz68ZyUssvBiWfe4A/ut"}' + type: local +``` + +2. Next, obtain your sending address on container ibc0-0. In this example our sending address is +`tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd`. + +``` +provenanced -t --home ibc0-0/ keys list + +- address: tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd + name: ibc0-0 + pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A5RlZL3Gn3uEyzrVIkk9nyDV5LxJeUqPF/kOQmGX6nnQ"}' + type: local +``` + +3. Now, we can transfer currency from ibc0-0 to ibc1-0. The following command sends 500nhash from our +sending account `tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y` to our receiving account +`tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd`, when ran on container ibc0-0. + +``` +provenanced -t --home ibc0-0/ tx ibc-transfer transfer transfer channel-0 tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y 500nhash --from tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd --gas auto --gas-prices 1905nhash --gas-adjustment 1.5 --chain-id testing -y +``` + +4. Lastly, let's check the balances for the receiving account on container ibc1-0. You should see the 500nhash sent +from ibc0-0. It will have its own denom specified with ibc/denom... + +``` +provenanced -t --home ibc1-0/ q bank balances tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y +balances: +- amount: "500" + denom: ibc/319937B2FDA7A07031DBE22EA76C34CAC9DCFBD9AA1A922FA2B87421107B545D +- amount: "99899999900000000000" + denom: nhash +``` + +# Networking + +It's always important to first verify that your relayer is working before doing anything +IBC related. You can verify that your relayer is working as inteded by running the following +command on the relayer container. + +``` +rly --home /relayer paths list +0: local_local2 -> chns(✔) clnts(✔) conn(✔) (testing<>testing2) +``` + +Notice that the output above has 3 checkmarks. This is saying that the channels, clients, +and connections are all properly working. + +# Smart Contracts + +Smart Contracts can be stored and instantiated on this chain like any other. The only benefit +that this chain offers for testing smart contracts is support for the IBC entry points. Users +do not have to worry about setting up multiple chains and a relayer just to test out the IBC +portions of their smart contracts. + +Please see the provwasm tutorial for more information on uploading and using contracts. +https://github.com/provenance-io/provwasm/blob/main/docs/tutorial/01-overview.md + NOTE: This folder contains files to run an image using a locally built binary that leverages Go's ability to target platforms during builds. These docker From 9a1760ff0b44283544a51e8603d906dcf040aa80 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 29 Nov 2022 16:05:22 -0500 Subject: [PATCH 09/15] Moved networking section up. --- networks/ibc/README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/networks/ibc/README.md b/networks/ibc/README.md index 3f45303bb0..8629f71e39 100644 --- a/networks/ibc/README.md +++ b/networks/ibc/README.md @@ -21,6 +21,20 @@ to publish packets from the sending chain to the receiving chain. denom: nhash ``` +# Networking + +It's always important to first verify that your relayer is working before doing anything +IBC related. You can verify that your relayer is working as inteded by running the following +command on the relayer container. + +``` +rly --home /relayer paths list +0: local_local2 -> chns(✔) clnts(✔) conn(✔) (testing<>testing2) +``` + +Notice that the output above has 3 checkmarks. This is saying that the channels, clients, +and connections are all properly working. + # Transferring Currency The simplest test that can be used to verify that IBC is working is using the Fungible Token @@ -72,20 +86,6 @@ balances: denom: nhash ``` -# Networking - -It's always important to first verify that your relayer is working before doing anything -IBC related. You can verify that your relayer is working as inteded by running the following -command on the relayer container. - -``` -rly --home /relayer paths list -0: local_local2 -> chns(✔) clnts(✔) conn(✔) (testing<>testing2) -``` - -Notice that the output above has 3 checkmarks. This is saying that the channels, clients, -and connections are all properly working. - # Smart Contracts Smart Contracts can be stored and instantiated on this chain like any other. The only benefit From 48619bcefcdc1906cdfdc4d2f3935475155481a9 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 29 Nov 2022 16:07:13 -0500 Subject: [PATCH 10/15] Fixed typo. --- networks/ibc/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/networks/ibc/README.md b/networks/ibc/README.md index 8629f71e39..42a392392e 100644 --- a/networks/ibc/README.md +++ b/networks/ibc/README.md @@ -67,8 +67,8 @@ provenanced -t --home ibc0-0/ keys list ``` 3. Now, we can transfer currency from ibc0-0 to ibc1-0. The following command sends 500nhash from our -sending account `tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y` to our receiving account -`tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd`, when ran on container ibc0-0. +sending account `tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd` to our receiving account +`tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y`, when ran on container ibc0-0. ``` provenanced -t --home ibc0-0/ tx ibc-transfer transfer transfer channel-0 tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y 500nhash --from tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd --gas auto --gas-prices 1905nhash --gas-adjustment 1.5 --chain-id testing -y From 9c1ab97e2dff3e2ddd6d38d1a85bd2aa71c457cd Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 30 Nov 2022 10:14:37 -0500 Subject: [PATCH 11/15] Updated commands to use the --node flag instead of having to exec into the containers. --- networks/ibc/README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/networks/ibc/README.md b/networks/ibc/README.md index 42a392392e..952d85f0af 100644 --- a/networks/ibc/README.md +++ b/networks/ibc/README.md @@ -4,7 +4,7 @@ This folder contains the files to create 3 containers for testing IBC. The first container is a single node running a blockchain with chain-id testing. The second container is also a single node running a blockchain, but this chain has chain-id testing2. Lastly, the third container -is the relayer used to forward packets between chains. +holds the relayer used to forward packets between chains. # Relayer Account @@ -42,11 +42,11 @@ Transfer (ICS-20) subprotocol. This subprotocol is exposed through provenance wi transaction. It transfers coins from an account on one chain to an account on another chain. In this example we will transfer from an account on ibc0-0 to an account on ibc1-0. -1. On the container for ibc1-0, obtain your receiving address. In this example our receiving address is +1. First, obtain the receiving address from ibc1-0. In this example our receiving address is `tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y`. ``` -provenanced -t --home ibc1-0/ keys list +./build/provenanced -t --home ./build/ibc1-0/ keys list - address: tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y name: ibc1-0 @@ -54,11 +54,11 @@ provenanced -t --home ibc1-0/ keys list type: local ``` -2. Next, obtain your sending address on container ibc0-0. In this example our sending address is +2. Next, obtain your sending address from ibc0-0. In this example our sending address is `tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd`. ``` -provenanced -t --home ibc0-0/ keys list +./build/provenanced -t --home ./build/ibc0-0/ keys list - address: tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd name: ibc0-0 @@ -68,17 +68,18 @@ provenanced -t --home ibc0-0/ keys list 3. Now, we can transfer currency from ibc0-0 to ibc1-0. The following command sends 500nhash from our sending account `tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd` to our receiving account -`tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y`, when ran on container ibc0-0. +`tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y`. ``` -provenanced -t --home ibc0-0/ tx ibc-transfer transfer transfer channel-0 tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y 500nhash --from tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd --gas auto --gas-prices 1905nhash --gas-adjustment 1.5 --chain-id testing -y +./build/provenanced -t --home ./build/ibc0-0/ tx ibc-transfer transfer transfer channel-0 tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y 500nhash --from tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd --gas auto --gas-prices 1905nhash --gas-adjustment 1.5 --chain-id testing --node http://localhost:26656 -y ``` 4. Lastly, let's check the balances for the receiving account on container ibc1-0. You should see the 500nhash sent from ibc0-0. It will have its own denom specified with ibc/denom... ``` -provenanced -t --home ibc1-0/ q bank balances tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y +./build/provenanced -t --home ./build/ibc1-0/ q bank balances tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y --node http://localhost:26660 + balances: - amount: "500" denom: ibc/319937B2FDA7A07031DBE22EA76C34CAC9DCFBD9AA1A922FA2B87421107B545D From f4ba3d0ce87121bf0b6d0936204183b3e1e91e3c Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 30 Nov 2022 10:16:52 -0500 Subject: [PATCH 12/15] Added Note to the tutorial section to clarify where commands are being ran from. --- networks/ibc/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/networks/ibc/README.md b/networks/ibc/README.md index 952d85f0af..750b59fd7c 100644 --- a/networks/ibc/README.md +++ b/networks/ibc/README.md @@ -42,6 +42,10 @@ Transfer (ICS-20) subprotocol. This subprotocol is exposed through provenance wi transaction. It transfers coins from an account on one chain to an account on another chain. In this example we will transfer from an account on ibc0-0 to an account on ibc1-0. +## Note +The following tutorial assumes the user has built provenanced, and their current working directory +is within the root of their provenance source directory. + 1. First, obtain the receiving address from ibc1-0. In this example our receiving address is `tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y`. @@ -71,7 +75,7 @@ sending account `tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd` to our receiving acc `tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y`. ``` -./build/provenanced -t --home ./build/ibc0-0/ tx ibc-transfer transfer transfer channel-0 tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y 500nhash --from tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd --gas auto --gas-prices 1905nhash --gas-adjustment 1.5 --chain-id testing --node http://localhost:26656 -y +./build/provenanced -t --home ./build/ibc0-0/ tx ibc-transfer transfer transfer channel-0 tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y 500nhash --from tp1u3ry0ry80hvj9vcfa8h5e30wkx9ec4l5jsqujd --gas auto --gas-prices 1905nhash --gas-adjustment 1.5 --chain-id testing --node http://localhost:26657 -y ``` 4. Lastly, let's check the balances for the receiving account on container ibc1-0. You should see the 500nhash sent From 4fce50107086ee5d28bca9e2b39e11b9f62e1025 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 30 Nov 2022 10:26:55 -0500 Subject: [PATCH 13/15] Included make targets in Overview section. --- networks/ibc/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/networks/ibc/README.md b/networks/ibc/README.md index 750b59fd7c..45b8d7437b 100644 --- a/networks/ibc/README.md +++ b/networks/ibc/README.md @@ -6,6 +6,9 @@ is a single node running a blockchain with chain-id testing. The second containe single node running a blockchain, but this chain has chain-id testing2. Lastly, the third container holds the relayer used to forward packets between chains. +Two make targets `make ibcnet-start` and `make ibcnet-stop` were added to the project's Makefile to +easily bring the containers up and down. This will also handle all network configuration. + # Relayer Account Each chain has an account for the relayer that is funded. The relayer uses this account From 53824bdc0b0ef35e11cbb53e24ee1d01a2eb4c61 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 30 Nov 2022 11:49:36 -0500 Subject: [PATCH 14/15] Updated changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d377ab1b8d..c52ad460a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,7 @@ The `v1.13.0` release includes minor bug fixes and enhancements along with a res * Publish Java/Kotlin JARs to Maven for release candidates [#1223](https://github.com/provenance-io/provenance/issues/1223). * Added two new Makefile targets to install and start the relayer [#1051] (https://github.com/provenance-io/provenance/pull/1051) * Updated relayer scripts to make them headless for external services [#1068] (https://github.com/provenance-io/provenance/pull/1068) +* Added docker environment for testing IBC and added Makefile targets to bring this environment up/down [#1248] (https://github.com/provenance-io/provenance/pull/1248). ### Bug Fixes From afc59c041ce963e22d3686e846d95a5488507bda Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 30 Nov 2022 13:26:47 -0500 Subject: [PATCH 15/15] Added note for examples. --- networks/ibc/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/networks/ibc/README.md b/networks/ibc/README.md index 45b8d7437b..4e021033ae 100644 --- a/networks/ibc/README.md +++ b/networks/ibc/README.md @@ -49,6 +49,9 @@ In this example we will transfer from an account on ibc0-0 to an account on ibc1 The following tutorial assumes the user has built provenanced, and their current working directory is within the root of their provenance source directory. +All or some of the addresses in the examples may be different than what you have locally. They are +there just for example purposes. + 1. First, obtain the receiving address from ibc1-0. In this example our receiving address is `tp1vtvgsl9je747twlxkh4ycl2g3td6g5gcpc6t0y`.