diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 893ba7eeb..44f8f4fa1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -155,41 +155,14 @@ jobs: name: cheqd-node-image.tar path: cheqd-node-image.tar - build-testnet-image: - name: Build cheqd-testnet image - runs-on: ubuntu-20.04 - needs: build-node-images - steps: - - name: Check out - uses: actions/checkout@v2 - - - name: Download node image - uses: actions/download-artifact@v2 - with: - name: cheqd-cli-image.tar - - - name: Load node image - run: docker load -i cheqd-cli-image.tar - - - name: Build - run: docker build -f tests/networks/docker-localnet/Dockerfile --no-cache -t cheqd-testnet . - - - name: Save - run: docker save -o cheqd-testnet-image.tar cheqd-testnet - - - name: Store artifact - uses: actions/upload-artifact@v2 - with: - name: cheqd-testnet-image.tar - path: cheqd-testnet-image.tar - publish: name: "Publish images and release" # Reference to workflow-setup job is required to access its various outputs. - needs: [ build-binary, build-node-images, build-testnet-image, build-deb-package, build-tar-package ] + needs: [ build-binary, build-node-images, build-deb-package, build-tar-package ] runs-on: ubuntu-latest env: VERSION: ${{ needs.build-binary.outputs.VERSION }} + REGISTRY: ghcr.io steps: - name: Git checkout uses: actions/checkout@v2 @@ -210,17 +183,12 @@ jobs: - name: Load cheqd-node image run: docker load -i cheqd-node-image.tar - - name: Download testnet image - uses: actions/download-artifact@v2 + - name: Log in to the Container registry + uses: docker/login-action@v1 with: - name: cheqd-testnet-image.tar - - - name: Load testnet image - run: docker load -i cheqd-testnet-image.tar - - - name: Login to docker - run: | - echo ${{ secrets.GH_PAT }} | docker login ghcr.io --username ${{ secrets.GH_USER }} --password-stdin + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Push cheqd-node image run: | @@ -229,20 +197,12 @@ jobs: docker push ghcr.io/${{ github.repository }}:${{ env.VERSION }} docker push ghcr.io/${{ github.repository }}:latest - - name: Push cheqd-cli image run: | - docker tag cheqd-cli ghcr.io/${{ env.GITHUB_ORG_NAME }}/cheqd-cli:${{ env.VERSION }} - docker tag cheqd-cli ghcr.io/${{ env.GITHUB_ORG_NAME }}/cheqd-cli:latest - docker push ghcr.io/${{ env.GITHUB_ORG_NAME }}:${{ env.VERSION }} - docker push ghcr.io/${{ env.GITHUB_ORG_NAME }}:latest - - - name: Push testnet image - run: | - docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/cheqd-testnet:${{ env.VERSION }} - docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/cheqd-testnet:latest - docker push ghcr.io/${{ github.repository_owner }}/cheqd-testnet:${{ env.VERSION }} - docker push ghcr.io/${{ github.repository_owner }}/cheqd-testnet:latest + docker tag cheqd-cli ghcr.io/${{ github.repository_owner }}/cheqd-cli:${{ env.VERSION }} + docker tag cheqd-cli ghcr.io/${{ github.repository_owner }}/cheqd-cli:latest + docker push ghcr.io/${{ github.repository_owner }}/cheqd-cli:${{ env.VERSION }} + docker push ghcr.io/${{ github.repository_owner }}/cheqd-cli:latest - name: Download deb uses: actions/download-artifact@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7e46b27c1..328a402c7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,10 +9,9 @@ on: - '.gitbook/**' env: - NODE_CONFIGS_BASE: "/home/runner/work/cheqd-node/cheqd-node/tests/networks/docker-compose-localnet/network-config" + NODE_CONFIGS_BASE: "/home/runner/work/cheqd-node/cheqd-node/docker/localnet/network-config" jobs: - run-unit-test: name: Run unit tests runs-on: ubuntu-20.04 @@ -175,34 +174,6 @@ jobs: name: cheqd-node-image.tar path: cheqd-node-image.tar - build-testnet-image: - name: Build cheqd-testnet image - runs-on: ubuntu-20.04 - needs: build-node-images - steps: - - name: Check out - uses: actions/checkout@v2 - - - name: Download node image - uses: actions/download-artifact@v2 - with: - name: cheqd-cli-image.tar - - - name: Load node image - run: docker load -i cheqd-cli-image.tar - - - name: Build - run: docker build -f tests/networks/docker-localnet/Dockerfile --no-cache -t cheqd-testnet . - - - name: Save - run: docker save -o cheqd-testnet-image.tar cheqd-testnet - - - name: Store artifact - uses: actions/upload-artifact@v2 - with: - name: cheqd-testnet-image.tar - path: cheqd-testnet-image.tar - test-new-node-setup-from-deb: name: Test new node setup from deb runs-on: ubuntu-20.04 @@ -221,34 +192,34 @@ jobs: - name: Download node image uses: actions/download-artifact@v2 with: - name: cheqd-cli-image.tar + name: cheqd-node-image.tar - name: Load node image - run: docker load -i cheqd-cli-image.tar + run: docker load -i cheqd-node-image.tar - name: Check out uses: actions/checkout@v2 - - name: Set up 4 validators + 2 observers node docker pool # TODO: Replace with testnet image - working-directory: ./tests/networks/docker-compose-localnet + - name: Set up 4 validators + 2 observers node docker pool + working-directory: ./docker/localnet run: | bash gen-network-config.sh - docker-compose up -d + CHEQD_NODE_IMAGE=cheqd-node CHEQD_NODE_VERSION=latest docker compose up -d - name: Wait for chain - run: bash tests/networks/tools/wait-for-chain.sh + run: bash tests/tools/wait-for-chain.sh - name: Add observer node - working-directory: ./tests/networks/docker-compose-localnet + working-directory: ./tests/e2e-complex/deb-install run: | ./add-observer.sh cheqd-noded status -n tcp://localhost:26677 2>&1 ./wait.sh '[[ $(cheqd-noded status -n '"'"'tcp://localhost:26677'"'"' 2>&1 | wc -l) == 1 ]] && echo "New node returns status!"' - name: Promote observer to validator - working-directory: ./tests/networks/docker-compose-localnet + working-directory: ./tests/e2e-complex/deb-install run: | - bash -x promote-validator.sh + bash promote-validator.sh cheqd-noded query staking validators --node "http://localhost:26657" | sed -nr 's/.*status: (.*?).*/\1/p' $1 | while read x; do [[ "BOND_STATUS_BONDED" == $x ]] && echo "Validator's status is bonded!" || exit 1 ; done ./wait.sh '[[ $(curl -s localhost:26657/block | sed -nr '"'"'s/.*signature": (.*?).*/\1/p'"'"' | wc -l) == 5 ]] && echo "There are 5 validators signatures in block!"' ./wait.sh '[[ $(curl -s localhost:26657/block | sed -nr '"'"'s/.*(signature": null).*/\1/p'"'"' | wc -l) == 0 ]] && echo "There are no null signatures in block!"' @@ -258,11 +229,6 @@ jobs: run: | journalctl -ex | grep cheqd - - name: Gather logs on failure 2 - if: ${{ failure() }} - run: | - journalctl -u service-name.service --no-pager - run-python-based-integration-tests: name: Run python based cosmos and identity tests runs-on: ubuntu-20.04 @@ -280,24 +246,25 @@ jobs: - name: Download node image uses: actions/download-artifact@v2 with: - name: cheqd-cli-image.tar + name: cheqd-node-image.tar - name: Load node image - run: docker load -i cheqd-cli-image.tar + run: docker load -i cheqd-node-image.tar - - uses: actions/checkout@v2 + - name: Check out + uses: actions/checkout@v2 - - name: Set up 4 validators + 2 observers node docker pool for local test run # Replace with testnet image - working-directory: ./tests/networks/docker-compose-localnet + - name: Set up 4 validators + 2 observers node docker pool + working-directory: ./docker/localnet run: | bash gen-network-config.sh - docker-compose up -d + CHEQD_NODE_IMAGE=cheqd-node CHEQD_NODE_VERSION=latest docker compose up -d - name: Wait for chain - run: bash tests/networks/tools/wait-for-chain.sh + run: bash tests/tools/wait-for-chain.sh - name: Set up test environment - working-directory: ./tests/e2e + working-directory: ./tests/e2e-pytest run: | pip3 install -r requirements.txt >> /dev/null cp -Rf ${NODE_CONFIGS_BASE}/validator-0/. /home/runner/.cheqdnode @@ -305,25 +272,25 @@ jobs: sudo chmod -R 777 /home/runner - name: Run cosmos-related tests + working-directory: ./tests/e2e-pytest run: | set -euxo pipefail export OP0_ADDRESS=$(cheqd-noded keys list --keyring-backend "test" --home "${NODE_CONFIGS_BASE}/validator-0" | sed -nr 's/.*address: (.*?).*/\1/p' | sed 's/\r//g') export OP1_ADDRESS=$(cheqd-noded keys list --keyring-backend "test" --home "${NODE_CONFIGS_BASE}/validator-1" | sed -nr 's/.*address: (.*?).*/\1/p' | sed 's/\r//g') - pytest -v -rP tests/e2e/test_cosmos.py + pytest -v -rP test_cosmos.py - name: Run identity-related tests # TODO: Move into separate stage? + working-directory: ./tests/e2e-pytest run: | export OP0_ADDRESS=$(cheqd-noded keys list --keyring-backend "test" | sed -nr 's/.*address: (.*?).*/\1/p' | sed -n 1p | sed 's/\r//g') export OP1_ADDRESS=$(cheqd-noded keys list --keyring-backend "test" | sed -nr 's/.*address: (.*?).*/\1/p' | sed -n 2p | sed 's/\r//g') - pytest -v -rP tests/e2e/test_identity.py + pytest -v -rP test_identity.py run-bash-based-integration-tests: name: Run bash based identity tests runs-on: ubuntu-20.04 - needs: [build-binary, build-testnet-image] + needs: [build-binary, build-node-images] steps: - - uses: actions/checkout@v2 - - name: Load binary artifact uses: actions/download-artifact@v2 with: @@ -333,23 +300,34 @@ jobs: - name: Restore binary permissions run: sudo chmod +x /home/runner/.local/bin/cheqd-noded - - name: Download testnet image + - name: Download node image uses: actions/download-artifact@v2 with: - name: cheqd-testnet-image.tar + name: cheqd-node-image.tar - - name: Load testnet image - run: docker load -i cheqd-testnet-image.tar + - name: Load node image + run: docker load -i cheqd-node-image.tar - - name: Run test net container + - name: Check out + uses: actions/checkout@v2 + + - name: Set up 4 validators + 2 observers node docker pool + working-directory: ./docker/localnet run: | - docker run -d --rm -p "26657:26657" -p "1317:1317" cheqd-testnet - bash tests/networks/tools/wait-for-chain.sh + bash gen-network-config.sh + CHEQD_NODE_IMAGE=cheqd-node CHEQD_NODE_VERSION=latest docker compose up -d - - name: Set up and run tests - working-directory: tests/cli + - name: Wait for chain + run: bash tests/tools/wait-for-chain.sh + + - name: Import keys + working-directory: docker/localnet run: | bash import_keys.sh + + - name: Set up and run tests + working-directory: tests/e2e-bash + run: | bash run_all.sh run-upgrade-test-positive-case: @@ -361,25 +339,25 @@ jobs: with: fetch-depth: 0 # It's needed for getting the full version of package by `git describe` - - name: Download node image + - name: Download cli image uses: actions/download-artifact@v2 with: name: cheqd-cli-image.tar - - name: Load node image + - name: Load cli image run: docker load -i cheqd-cli-image.tar - name: Chown for current user run: sudo chown $USER:$USER . - name: Prepare nodes for checking upgrade - working-directory: ./tests/upgrade + working-directory: ./tests/e2e-complex/upgrade run: bash prepare.sh - name: Initiate the upgrade process - working-directory: ./tests/upgrade + working-directory: ./tests/e2e-complex/upgrade run: bash initiate_upgrade.sh - name: Make the upgrade and check results - working-directory: ./tests/upgrade + working-directory: ./tests/e2e-complex/upgrade run: bash upgrade_and_check.sh diff --git a/cmd/cheqd-noded/cmd/debug_extensions.go b/cmd/cheqd-noded/cmd/debug_extensions.go index 7e1a85abd..3e93ce23a 100644 --- a/cmd/cheqd-noded/cmd/debug_extensions.go +++ b/cmd/cheqd-noded/cmd/debug_extensions.go @@ -42,7 +42,6 @@ func ed25519RandomCmd() *cobra.Command { keyInfo := struct { PubKeyBase64 string `json:"pub_key_base_64"` - PubKeyMultibase58 string `json:"pub_key_multibase_58"` PrivKeyBase64 string `json:"priv_key_base_64"` }{ PubKeyBase64: base64.StdEncoding.EncodeToString(pubKey), diff --git a/docker/Dockerfile b/docker/Dockerfile index 900de76c2..54ad0680f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -85,7 +85,7 @@ ENTRYPOINT [ "cheqd-noded" ] FROM base AS node # Set runner script -COPY --chown=cheqd:cheqd docker/persistent-chains/entrypoint.sh /bin/node-start +COPY --chown=cheqd:cheqd docker/entrypoint.sh /bin/node-start RUN chmod +x /bin/node-start # Default entrypoint for cheqd-noded CLI usage diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 000000000..ce5915173 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# Inits node configuration and runs the node. +# e -> exit immediately, u -> treat unset variables as errors and immediately, o -> sets the exit code to the rightmost command +set -euo pipefail + +# within the container, $HOME=/home/cheqd +CHEQD_ROOT_DIR="$HOME/.cheqdnode" + +# Init node config directory +if [ ! -d "${CHEQD_ROOT_DIR}/config" ] +then + echo "Node config not found. Initializing." + cheqd-noded init "moniker-placeholder" +else + echo "Node config exists. Skipping initialization." +fi + +# Check if a genesis file has been passed in config +if [ -f "/genesis" ] +then + echo "Genesis file passed. Adding/replacing current genesis file." + cp /genesis "${CHEQD_ROOT_DIR}/config/genesis.json" +else + echo "No genesis file passed. Skipping and retaining existing genesis." +fi + +# Check if a seeds file has been passed in config +if [ -f "/seeds" ] +then + echo "Seeds file passed. Overriding current seeds." + cp /seeds "${CHEQD_ROOT_DIR}/config/seeds.txt" + CHEQD_NODED_P2P_SEEDS="$(cat "${CHEQD_ROOT_DIR}/config/seeds.txt")" + export CHEQD_NODED_P2P_SEEDS +else + echo "No seeds file passed. Skipping and retaining existing seeds." +fi + +# Check if a node_key file has been passed in config +if [ -f "/node_key" ] +then + echo "Node key file passed. Overriding current key." + cp /node_key "${CHEQD_ROOT_DIR}/config/node_key.json" +else + echo "No node key file passed. Skipping and retaining existing node key." +fi + +# Check if a priv_validator_key file has been passed in config +if [ -f "/priv_validator_key" ] +then + echo "Private validator key file passed. Replacing current key." + cp /priv_validator_key "${CHEQD_ROOT_DIR}/config/priv_validator_key.json" +else + echo "No private validator key file passed. Skipping and retaining existing key." +fi + +# Run node +cheqd-noded start diff --git a/docker/localnet/container-env/observer-0.env b/docker/localnet/container-env/observer-0.env new file mode 100644 index 000000000..2851f7d7b --- /dev/null +++ b/docker/localnet/container-env/observer-0.env @@ -0,0 +1,13 @@ +# Environment variables used by the container + +# General +CHEQD_NODED_MONIKER="observer-0" +CHEQD_NODED_RPC_LADDR="tcp://0.0.0.0:26657" +CHEQD_NODED_API_ENABLE="true" +CHEQD_NODED_MINIMUM_GAS_PRICES="25ncheq" +# Consensus +CHEQD_NODED_CONSENSUS_TIMEOUT_PROPOSE="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_PREVOTE="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_PRECOMMIT="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_COMMIT="500ms" +CHEQD_NODED_CREATE_EMPTY_BLOCKS="false" diff --git a/docker/localnet/container-env/seed-0.env b/docker/localnet/container-env/seed-0.env new file mode 100644 index 000000000..856a997a9 --- /dev/null +++ b/docker/localnet/container-env/seed-0.env @@ -0,0 +1,17 @@ +# Environment variables used by the container + +# General +CHEQD_NODED_MONIKER="seed-0" +CHEQD_NODED_RPC_LADDR="tcp://0.0.0.0:26657" +CHEQD_NODED_API_ENABLE="true" +CHEQD_NODED_MINIMUM_GAS_PRICES="25ncheq" + +# Seed specific +CHEQD_NODED_P2P_SEED_MODE + +# Consensus +CHEQD_NODED_CONSENSUS_TIMEOUT_PROPOSE="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_PREVOTE="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_PRECOMMIT="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_COMMIT="500ms" +CHEQD_NODED_CREATE_EMPTY_BLOCKS="false" diff --git a/docker/localnet/container-env/validator-0.env b/docker/localnet/container-env/validator-0.env new file mode 100644 index 000000000..841c2f8c6 --- /dev/null +++ b/docker/localnet/container-env/validator-0.env @@ -0,0 +1,13 @@ +# Environment variables used by the container + +# General +CHEQD_NODED_MONIKER="validator-0" +CHEQD_NODED_RPC_LADDR="tcp://0.0.0.0:26657" +CHEQD_NODED_API_ENABLE="true" +CHEQD_NODED_MINIMUM_GAS_PRICES="25ncheq" +# Consensus +CHEQD_NODED_CONSENSUS_TIMEOUT_PROPOSE="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_PREVOTE="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_PRECOMMIT="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_COMMIT="500ms" +CHEQD_NODED_CREATE_EMPTY_BLOCKS="false" diff --git a/docker/localnet/container-env/validator-1.env b/docker/localnet/container-env/validator-1.env new file mode 100644 index 000000000..6ddd7b148 --- /dev/null +++ b/docker/localnet/container-env/validator-1.env @@ -0,0 +1,13 @@ +# Environment variables used by the container + +# General +CHEQD_NODED_MONIKER="validator-1" +CHEQD_NODED_RPC_LADDR="tcp://0.0.0.0:26657" +CHEQD_NODED_API_ENABLE="true" +CHEQD_NODED_MINIMUM_GAS_PRICES="25ncheq" +# Consensus +CHEQD_NODED_CONSENSUS_TIMEOUT_PROPOSE="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_PREVOTE="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_PRECOMMIT="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_COMMIT="500ms" +CHEQD_NODED_CREATE_EMPTY_BLOCKS="false" diff --git a/docker/localnet/container-env/validator-2.env b/docker/localnet/container-env/validator-2.env new file mode 100644 index 000000000..392af9f58 --- /dev/null +++ b/docker/localnet/container-env/validator-2.env @@ -0,0 +1,13 @@ +# Environment variables used by the container + +# General +CHEQD_NODED_MONIKER="validator-2" +CHEQD_NODED_RPC_LADDR="tcp://0.0.0.0:26657" +CHEQD_NODED_API_ENABLE="true" +CHEQD_NODED_MINIMUM_GAS_PRICES="25ncheq" +# Consensus +CHEQD_NODED_CONSENSUS_TIMEOUT_PROPOSE="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_PREVOTE="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_PRECOMMIT="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_COMMIT="500ms" +CHEQD_NODED_CREATE_EMPTY_BLOCKS="false" diff --git a/docker/localnet/container-env/validator-3.env b/docker/localnet/container-env/validator-3.env new file mode 100644 index 000000000..5a9d44be5 --- /dev/null +++ b/docker/localnet/container-env/validator-3.env @@ -0,0 +1,13 @@ +# Environment variables used by the container + +# General +CHEQD_NODED_MONIKER="validator-3" +CHEQD_NODED_RPC_LADDR="tcp://0.0.0.0:26657" +CHEQD_NODED_API_ENABLE="true" +CHEQD_NODED_MINIMUM_GAS_PRICES="25ncheq" +# Consensus +CHEQD_NODED_CONSENSUS_TIMEOUT_PROPOSE="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_PREVOTE="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_PRECOMMIT="500ms" +CHEQD_NODED_CONSENSUS_TIMEOUT_COMMIT="500ms" +CHEQD_NODED_CREATE_EMPTY_BLOCKS="false" diff --git a/docker/localnet/docker-compose.env b/docker/localnet/docker-compose.env new file mode 100644 index 000000000..921c9c241 --- /dev/null +++ b/docker/localnet/docker-compose.env @@ -0,0 +1,12 @@ +# Environment variables used by Docker Compose + +############################################################### +### REQUIRED: Node/network selection ### +############################################################### +# Define cheqd-noded image source. Change if using your own build. +CHEQD_NODE_IMAGE="ghcr.io/cheqd/cheqd-node" + +# Define cheqd-noded software release version +# Current MAINNET recommended version: v0.3.1 +# Current TESTNET recommended version: v0.3.1 +CHEQD_NODE_VERSION="0.3.1" diff --git a/docker/localnet/docker-compose.yml b/docker/localnet/docker-compose.yml new file mode 100644 index 000000000..bdedbfa4b --- /dev/null +++ b/docker/localnet/docker-compose.yml @@ -0,0 +1,239 @@ +version: '3.7' + +services: + validator-0: + image: ${CHEQD_NODE_IMAGE}:${CHEQD_NODE_VERSION} + ports: + - target: 26656 + published: 26656 # Tendermint peer-to-peer (P2P) port + - target: 26657 + published: 26657 # Tendermint RPC port + - target: 1317 + published: 1317 # Cosmos REST API port + - target: 9090 + published: 9090 # gRPC port + - target: 9091 + published: 9091 # gRPC-Gateway port + - target: 26660 + published: 26660 # Prometheus metrics port + volumes: + - type: volume + source: validator-0-data + target: /home/cheqd + env_file: + - container-env/validator-0.env + configs: + - source: genesis + target: /genesis + - source: seeds + target: /seeds + - source: validator-0-node-key + target: /node_key + - source: validator-0-priv-val-key + target: /priv_validator_key + + validator-1: + image: ${CHEQD_NODE_IMAGE}:${CHEQD_NODE_VERSION} + ports: + - target: 26656 + published: 26756 # Tendermint peer-to-peer (P2P) port + - target: 26657 + published: 26757 # Tendermint RPC port + - target: 1317 + published: 1417 # Cosmos REST API port + - target: 9090 + published: 9190 # gRPC port + - target: 9091 + published: 9191 # gRPC-Gateway port + - target: 26660 + published: 26760 # Prometheus metrics port + volumes: + - type: volume + source: validator-1-data + target: /home/cheqd + env_file: + - container-env/validator-1.env + configs: + - source: genesis + target: /genesis + - source: seeds + target: /seeds + - source: validator-1-node-key + target: /node_key + - source: validator-1-priv-val-key + target: /priv_validator_key + + validator-2: + image: ${CHEQD_NODE_IMAGE}:${CHEQD_NODE_VERSION} + ports: + - target: 26656 + published: 26856 # Tendermint peer-to-peer (P2P) port + - target: 26657 + published: 26857 # Tendermint RPC port + - target: 1317 + published: 1517 # Cosmos REST API port + - target: 9090 + published: 9290 # gRPC port + - target: 9091 + published: 9291 # gRPC-Gateway port + - target: 26660 + published: 26860 # Prometheus metrics port + volumes: + - type: volume + source: validator-2-data + target: /home/cheqd + env_file: + - container-env/validator-2.env + configs: + - source: genesis + target: /genesis + - source: seeds + target: /seeds + - source: validator-2-node-key + target: /node_key + - source: validator-2-priv-val-key + target: /priv_validator_key + + validator-3: + image: ${CHEQD_NODE_IMAGE}:${CHEQD_NODE_VERSION} + ports: + - target: 26656 + published: 26956 # Tendermint peer-to-peer (P2P) port + - target: 26657 + published: 26957 # Tendermint RPC port + - target: 1317 + published: 1617 # Cosmos REST API port + - target: 9090 + published: 9390 # gRPC port + - target: 9091 + published: 9391 # gRPC-Gateway port + - target: 26660 + published: 26960 # Prometheus metrics port + volumes: + - type: volume + source: validator-3-data + target: /home/cheqd + env_file: + - container-env/validator-3.env + configs: + - source: genesis + target: /genesis + - source: seeds + target: /seeds + - source: validator-3-node-key + target: /node_key + - source: validator-3-priv-val-key + target: /priv_validator_key + + seed-0: + image: ${CHEQD_NODE_IMAGE}:${CHEQD_NODE_VERSION} + ports: + - target: 26656 + published: 27056 # Tendermint peer-to-peer (P2P) port + - target: 26657 + published: 27057 # Tendermint RPC port + - target: 1317 + published: 1717 # Cosmos REST API port + - target: 9090 + published: 9490 # gRPC port + - target: 9091 + published: 9491 # gRPC-Gateway port + - target: 26660 + published: 27060 # Prometheus metrics port + volumes: + - type: volume + source: seed-0-data + target: /home/cheqd + env_file: + - container-env/seed-0.env + configs: + - source: genesis + target: /genesis + - source: seeds + target: /seeds + - source: seed-0-node-key + target: /node_key + - source: seed-0-priv-val-key + target: /priv_validator_key + + observer-0: + image: ${CHEQD_NODE_IMAGE}:${CHEQD_NODE_VERSION} + ports: + - target: 26656 + published: 27156 # Tendermint peer-to-peer (P2P) port + - target: 26657 + published: 27157 # Tendermint RPC port + - target: 1317 + published: 1817 # Cosmos REST API port + - target: 9090 + published: 9590 # gRPC port + - target: 9091 + published: 9591 # gRPC-Gateway port + - target: 26660 + published: 27160 # Prometheus metrics port + volumes: + - type: volume + source: observer-0-data + target: /home/cheqd + env_file: + - container-env/observer-0.env + configs: + - source: genesis + target: /genesis + - source: seeds + target: /seeds + - source: observer-0-node-key + target: /node_key + - source: observer-0-priv-val-key + target: /priv_validator_key + +configs: + # Genesis and seeds + genesis: + file: network-config/genesis.json + seeds: + file: network-config/seeds.txt + + # Validator 0 + validator-0-node-key: + file: network-config/validator-0/config/node_key.json + validator-0-priv-val-key: + file: network-config/validator-0/config/priv_validator_key.json + + # Validator 1 + validator-1-node-key: + file: network-config/validator-1/config/node_key.json + validator-1-priv-val-key: + file: network-config/validator-1/config/priv_validator_key.json + + # Validator 2 + validator-2-node-key: + file: network-config/validator-2/config/node_key.json + validator-2-priv-val-key: + file: network-config/validator-2/config/priv_validator_key.json + + # Validator 3 + validator-3-node-key: + file: network-config/validator-3/config/node_key.json + validator-3-priv-val-key: + file: network-config/validator-3/config/priv_validator_key.json + + # Seed 0 + seed-0-node-key: + file: network-config/seed-0/config/node_key.json + seed-0-priv-val-key: + file: network-config/seed-0/config/priv_validator_key.json + + # Observer 0 + observer-0-node-key: + file: network-config/observer-0/config/node_key.json + observer-0-priv-val-key: + file: network-config/observer-0/config/priv_validator_key.json + +volumes: + validator-0-data: + validator-1-data: + validator-2-data: + validator-3-data: + seed-0-data: + observer-0-data: diff --git a/tests/networks/tools/gen-network-config-base.sh b/docker/localnet/gen-network-config.sh similarity index 94% rename from tests/networks/tools/gen-network-config-base.sh rename to docker/localnet/gen-network-config.sh index af1876a55..700ebfb81 100644 --- a/tests/networks/tools/gen-network-config-base.sh +++ b/docker/localnet/gen-network-config.sh @@ -202,5 +202,27 @@ do cp "${TMP_NODE_HOME}/config/genesis.json" "${NODE_HOME}/config/genesis.json" done -# We don't need tmp node anymore +# Leave one copy of genesis in the root of network-config +cp "${TMP_NODE_HOME}/config/genesis.json" "${NETWORK_CONFIG_DIR}/genesis.json" + +# Generate seeds.txt +SEEDS_STR="" + +for ((i=0 ; i "${NETWORK_CONFIG_DIR}/seeds.txt" + +# We don't need the tmp node anymore rm -rf "${TMP_NODE_HOME}" diff --git a/tests/cli/import_keys.sh b/docker/localnet/import_keys.sh similarity index 100% rename from tests/cli/import_keys.sh rename to docker/localnet/import_keys.sh diff --git a/docker/persistent-chains/container.env b/docker/persistent-chains/container.env index db5fd3921..f95bf08c7 100644 --- a/docker/persistent-chains/container.env +++ b/docker/persistent-chains/container.env @@ -7,10 +7,10 @@ # Externally-reachable address for the node # Syntax is :26656 or :26656 -P2P_EXTERNAL_ADDRESS=":26656" +CHEQD_NODED_P2P_EXTERNAL_ADDRESS=":26656" # A custom human-readable name for this node -NODE_MONIKER="" +CHEQD_NODED_MONIKER="" ############################################################### ### OPTIONAL: Per-node safe defaults ### @@ -19,19 +19,19 @@ NODE_MONIKER="" # These can be changed WITHOUT major network-wide consequences. # Default gas price. Higher gas prices can impact inclusion in mempool. -MIN_GAS_PRICES="25ncheq" +CHEQD_NODED_MINIMUM_GAS_PRICES="25ncheq" # Comma-separated list of persistent peers to maintain connections to. # Syntax is @: -P2P_PERSISTENT_PEERS="" +CHEQD_NODED_P2P_PERSISTENT_PEERS="" # Max. send/receive rate throttle. Values below compute to ~20 MB/s. # Can be increased if your node can handle higher network throughput. -P2P_SEND_RATE=20000000 -P2P_RECV_RATE=20000000 +CHEQD_NODED_P2P_SEND_RATE=20000000 +CHEQD_NODED_P2P_RECV_RATE=20000000 # Flip whether the node is a seed. For most users, the answer is false. -P2P_SEED_MODE=false +CHEQD_NODED_P2P_SEED_MODE=false ############################################################### @@ -41,15 +41,13 @@ P2P_SEED_MODE=false # Changing these CAN cause connectivity issues for your node. # Only change if you understand the consequences. - # Fetches correct genesis.json and seeds.txt from GitHub -NETWORK=testnet # TODO: Replace with block-sync on TM upgrade -FASTSYNC_VERSION="v0" +CHEQD_NODED_FASTSYNC_VERSION="v0" # TODO: Check if empty block creation is actually turned off -CREATE_EMPTY_BLOCKS=false +CHEQD_NODED_CONSENSUS_CREATE_EMPTY_BLOCKS=false # Max. message payload size. Default is ~10 KB -P2P_MAX_PACKET_MSG_PAYLOAD_SIZE=10240 +CHEQD_NODED_P2P_MAX_PACKET_MSG_PAYLOAD_SIZE=10240 # Tendermint P2P port. Port exposed on host is more relevant to control access. -P2P_LADDR="tcp://0.0.0.0:26656" +CHEQD_NODED_P2P_LADDR="tcp://0.0.0.0:26656" # Tendermint RPC port. Port exposed on host is more relevant to control access. -RPC_LADDR="tcp://0.0.0.0:26657" +CHEQD_NODED_RPC_LADDR="tcp://0.0.0.0:26657" diff --git a/docker/persistent-chains/docker-compose.yml b/docker/persistent-chains/docker-compose.yml index a60bda95c..03db267a1 100644 --- a/docker/persistent-chains/docker-compose.yml +++ b/docker/persistent-chains/docker-compose.yml @@ -2,19 +2,20 @@ version: '3.7' services: cheqd_node: - # CAUTION: Change CHEQD_NODE_VERSION to local in docker-compose.env if building your own image in section below - image: ghcr.io/cheqd/cheqd-node:${CHEQD_NODE_VERSION} # OPTIONAL: Rebuild cheq-node Docker image, if you want build your own # Default is to pull in the pre-published image on GitHub Container Registry # SYNTAX: docker compose --env-file docker/persistent-chains/docker-compose.env -f docker/persistent-chains/docker-compose.yml build --no-cache - build: - context: ../.. - dockerfile: docker/Dockerfile - target: node - args: - CHEQD_HOME_DIR: ${CHEQD_HOME_DIR} - UID: ${UID} - GID: ${GID} + # build: + # context: ../.. + # dockerfile: docker/Dockerfile + # target: node + # args: + # CHEQD_HOME_DIR: ${CHEQD_HOME_DIR} + # UID: ${UID} + # GID: ${GID} + # CAUTION: Change CHEQD_NODE_VERSION to local in docker-compose.env if building your own image in section below + # image: cheqd-node-custom-build:${CHEQD_NODE_VERSION} + image: ghcr.io/cheqd/cheqd-node:${CHEQD_NODE_VERSION} user: cheqd configs: - source: genesis @@ -79,3 +80,9 @@ volumes: name: cheqd_volume_${CHEQD_NETWORK} driver: ${CHEQD_DOCKER_VOLUME_DRIVER} external: ${CHEQD_DOCKER_VOLUME_IS_EXTERNAL} + +# secrets: +# node-key: +# file: +# validator-key: +# file: diff --git a/docker/persistent-chains/entrypoint.sh b/docker/persistent-chains/entrypoint.sh deleted file mode 100644 index ba91d3e21..000000000 --- a/docker/persistent-chains/entrypoint.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -# Inits node configuration and runs the node. -# e -> exit immediately, u -> treat unset variables as errors and immediately, o -> sets the exit code to the rightmost command -set -euo pipefail - -# within the container, $HOME=/home/cheqd -CHEQD_ROOT_DIR="$HOME/.cheqdnode" - -# Init node config directory -if [ ! -d "${CHEQD_ROOT_DIR}/config" ] -then - echo "Node config not found. Initializing." - cheqd-noded init "$NODE_MONIKER" --home "${CHEQD_ROOT_DIR}" -else - echo "Node config exists. Skipping initialization." -fi - -# Check if a genesis file has been passed in config -if [ -f "/genesis" ] -then - echo "Genesis file passed. Adding/replacing current genesis file." - cp /genesis "${CHEQD_ROOT_DIR}/config/genesis.json" -else - echo "No genesis file passed. Skipping and retaining existing genesis." -fi - -# Check if a genesis file has been passed in config -if [ -f "/seeds" ] -then - echo "Seeds file passed. Replacing current seeds." - cp /seeds "${CHEQD_ROOT_DIR}/config/seeds.txt" - cheqd-noded configure p2p seeds "$(cat "${CHEQD_ROOT_DIR}/config/seeds.txt")" -else - echo "No seeds file passed. Skipping and retaining existing seeds." -fi - -# Run configure -# `! -z` is used instead of `-n` to distinguish null and empty values -if [[ -n ${CREATE_EMPTY_BLOCKS+x} ]]; then cheqd-noded configure create-empty-blocks "${CREATE_EMPTY_BLOCKS}"; fi -if [[ -n ${FASTSYNC_VERSION+x} ]]; then cheqd-noded configure fastsync-version "${FASTSYNC_VERSION}"; fi -if [[ -n ${MIN_GAS_PRICES+x} ]]; then cheqd-noded configure min-gas-prices "${MIN_GAS_PRICES}"; fi -if [[ -n ${RPC_LADDR+x} ]]; then cheqd-noded configure rpc-laddr "${RPC_LADDR}"; fi -if [[ -n ${P2P_EXTERNAL_ADDRESS+x} ]]; then cheqd-noded configure p2p external-address "${P2P_EXTERNAL_ADDRESS}"; fi -if [[ -n ${P2P_LADDR+x} ]]; then cheqd-noded configure p2p laddr "${P2P_LADDR}"; fi -if [[ -n ${P2P_MAX_PACKET_MSG_PAYLOAD_SIZE+x} ]]; then cheqd-noded configure p2p max-packet-msg-payload-size "${P2P_MAX_PACKET_MSG_PAYLOAD_SIZE}"; fi -if [[ -n ${P2P_SEEDS+x} ]]; then cheqd-noded configure p2p seeds "${P2P_SEEDS}"; fi -if [[ -n ${P2P_PERSISTENT_PEERS+x} ]]; then cheqd-noded configure p2p persistent-peers "${P2P_PERSISTENT_PEERS}"; fi -if [[ -n ${P2P_SEED_MODE+x} ]]; then cheqd-noded configure p2p seed-mode "${P2P_SEED_MODE}"; fi -if [[ -n ${P2P_RECV_RATE+x} ]]; then cheqd-noded configure p2p recv-rate "${P2P_RECV_RATE}"; fi -if [[ -n ${P2P_SEND_RATE+x} ]]; then cheqd-noded configure p2p send-rate "${P2P_SEND_RATE}"; fi - -# Run node -cheqd-noded start diff --git a/docs/setup-and-configure/docker-install.md b/docs/setup-and-configure/docker-install.md index bb92af832..0ecdfaf67 100644 --- a/docs/setup-and-configure/docker-install.md +++ b/docs/setup-and-configure/docker-install.md @@ -21,7 +21,7 @@ docker pull ghcr.io/cheqd/cheqd-node:latest To build the image: * Go to the repository root; -* Run `docker build -f docker/Dockerfile -t cheqd-node .`. +* Run `docker build --target node -t cheqd-node -f docker/Dockerfile .`. Default home directory for `cheqd` user is `/cheqd`. It can be overridden via `CHEQD_HOME_DIR` build argument. Example: `--build-arg CHEQD_HOME_DIR=/home/cheqd`. diff --git a/tests/cli/run_all.sh b/tests/e2e-bash/run_all.sh similarity index 100% rename from tests/cli/run_all.sh rename to tests/e2e-bash/run_all.sh diff --git a/tests/cli/tests/common.sh b/tests/e2e-bash/tests/common.sh similarity index 92% rename from tests/cli/tests/common.sh rename to tests/e2e-bash/tests/common.sh index 0b6286daf..b40674da4 100644 --- a/tests/cli/tests/common.sh +++ b/tests/e2e-bash/tests/common.sh @@ -50,3 +50,9 @@ function assert_tx_successful() { OUTPUT=$1 assert_eq "$(echo "${OUTPUT}" | jq -r ".code")" "0" } + +function assert_tx_code() { + OUTPUT=$1 + CODE=$2 + assert_eq "$(echo "${OUTPUT}" | jq -r ".code")" "$CODE" +} diff --git a/tests/cli/tests/test_create_did.sh b/tests/e2e-bash/tests/test_create_did.sh similarity index 100% rename from tests/cli/tests/test_create_did.sh rename to tests/e2e-bash/tests/test_create_did.sh diff --git a/tests/e2e-bash/tests/test_create_did_with_invalid_pubkey.sh b/tests/e2e-bash/tests/test_create_did_with_invalid_pubkey.sh new file mode 100644 index 000000000..75596ca70 --- /dev/null +++ b/tests/e2e-bash/tests/test_create_did_with_invalid_pubkey.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -euox pipefail + +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +# shellcheck source=/dev/null +source "$SCRIPT_DIR/common.sh" + + +# Generate Alice identity key +ALICE_VER_KEY="$(cheqd-noded debug ed25519 random)" +ALICE_VER_PRIV_BASE_64=$(echo "${ALICE_VER_KEY}" | jq -r ".priv_key_base_64") + +# Build CreateDid message +DID="did:cheqd:testnet:$(random_string)" +KEY_ID="${DID}#key1" + +MSG_CREATE_DID='{ + "id": "'${DID}'", + "verification_method": [{ + "id": "'${KEY_ID}'", + "type": "Ed25519VerificationKey2020", + "controller": "'${DID}'", + "public_key_multibase": "z6qdb7tjBeqaaWHU9W8nLHoxtZzro4ka" + }], + "authentication": [ + "'${KEY_ID}'" + ] +}'; + +# Post the message +# shellcheck disable=SC2086 +RESULT=$(cheqd-noded tx cheqd create-did "${MSG_CREATE_DID}" "${KEY_ID}" --ver-key "${ALICE_VER_PRIV_BASE_64}" \ + --from "${BASE_ACCOUNT_1}" ${TX_PARAMS}) + +assert_tx_code "$RESULT" "1100" diff --git a/tests/cli/tests/test_query_did.sh b/tests/e2e-bash/tests/test_query_did.sh similarity index 100% rename from tests/cli/tests/test_query_did.sh rename to tests/e2e-bash/tests/test_query_did.sh diff --git a/tests/cli/tests/test_query_did_via_rest.sh b/tests/e2e-bash/tests/test_query_did_via_rest.sh similarity index 100% rename from tests/cli/tests/test_query_did_via_rest.sh rename to tests/e2e-bash/tests/test_query_did_via_rest.sh diff --git a/tests/cli/tests/test_rotate_key.sh b/tests/e2e-bash/tests/test_rotate_key.sh similarity index 100% rename from tests/cli/tests/test_rotate_key.sh rename to tests/e2e-bash/tests/test_rotate_key.sh diff --git a/tests/cli/tests/test_update_did.sh b/tests/e2e-bash/tests/test_update_did.sh similarity index 100% rename from tests/cli/tests/test_update_did.sh rename to tests/e2e-bash/tests/test_update_did.sh diff --git a/tests/e2e-complex/deb-install/add-observer.sh b/tests/e2e-complex/deb-install/add-observer.sh new file mode 100755 index 000000000..345009d69 --- /dev/null +++ b/tests/e2e-complex/deb-install/add-observer.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -euox pipefail +sudo chown -R cheqd:cheqd "/home/runner/cheqd/" + +sudo -u cheqd cheqd-noded init node5 + +VALIDATOR_0_ID=$(cat "${NODE_CONFIGS_BASE}/validator-0/node_id.txt") +PERSISTENT_PEERS="${VALIDATOR_0_ID}@127.0.0.1:26656" +sudo -u cheqd cheqd-noded configure p2p persistent-peers "${PERSISTENT_PEERS}" + +sudo cp "${NODE_CONFIGS_BASE}/validator-0/config/genesis.json" "/home/runner/cheqd/.cheqdnode/config" + +sudo chmod -R 777 "/home/runner/cheqd/.cheqdnode" + +# Configure ports because they conflict with localnet +sudo -u cheqd cheqd-noded configure p2p laddr "tcp://0.0.0.0:26676" +sudo -u cheqd cheqd-noded configure rpc-laddr "tcp://0.0.0.0:26677" + +# TODO: Use environment variables +sudo -u cheqd sed -i.bak 's|pprof_laddr = "localhost:6060"|pprof_laddr = "localhost:6070"|g' /home/runner/cheqd/.cheqdnode/config/config.toml +sudo -u cheqd sed -i.bak 's|address = "0.0.0.0:9090"|address = "0.0.0.0:9100"|g' /home/runner/cheqd/.cheqdnode/config/app.toml +sudo -u cheqd sed -i.bak 's|address = "0.0.0.0:9091"|address = "0.0.0.0:9101"|g' /home/runner/cheqd/.cheqdnode/config/app.toml +sudo -u cheqd sed -i.bak 's|address = "tcp://0.0.0.0:1317"|address = "tcp://0.0.0.0:1327"|g' /home/runner/cheqd/.cheqdnode/config/app.toml +sudo -u cheqd sed -i.bak 's|address = ":8080"|address = ":8090"|g' /home/runner/cheqd/.cheqdnode/config/app.toml + +sudo systemctl start cheqd-noded +sleep 10 +systemctl status cheqd-noded diff --git a/tests/networks/docker-compose-localnet/promote-validator.sh b/tests/e2e-complex/deb-install/promote-validator.sh similarity index 100% rename from tests/networks/docker-compose-localnet/promote-validator.sh rename to tests/e2e-complex/deb-install/promote-validator.sh diff --git a/tests/networks/docker-compose-localnet/wait.sh b/tests/e2e-complex/deb-install/wait.sh similarity index 84% rename from tests/networks/docker-compose-localnet/wait.sh rename to tests/e2e-complex/deb-install/wait.sh index 5db8422cd..6d8fe54c8 100755 --- a/tests/networks/docker-compose-localnet/wait.sh +++ b/tests/e2e-complex/deb-install/wait.sh @@ -6,8 +6,8 @@ set -euox pipefail cmd="$1" -for _ in 1 2 3; do - sleep 60 +for _ in 1 2 3 4 5 6 7 8 9; do + sleep 20 if eval "$cmd"; then echo "Waiter returned success!" exit 0 diff --git a/tests/ibc-defi/README.md b/tests/e2e-complex/ibc-defi/README.md similarity index 100% rename from tests/ibc-defi/README.md rename to tests/e2e-complex/ibc-defi/README.md diff --git a/tests/ibc-defi/cheqd/cheqd.Dockerfile b/tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile similarity index 100% rename from tests/ibc-defi/cheqd/cheqd.Dockerfile rename to tests/e2e-complex/ibc-defi/cheqd/cheqd.Dockerfile diff --git a/tests/ibc-defi/cheqd/cheqd_init.sh b/tests/e2e-complex/ibc-defi/cheqd/cheqd_init.sh similarity index 100% rename from tests/ibc-defi/cheqd/cheqd_init.sh rename to tests/e2e-complex/ibc-defi/cheqd/cheqd_init.sh diff --git a/tests/ibc-defi/docker-compose.yaml b/tests/e2e-complex/ibc-defi/docker-compose.yaml similarity index 100% rename from tests/ibc-defi/docker-compose.yaml rename to tests/e2e-complex/ibc-defi/docker-compose.yaml diff --git a/tests/ibc-defi/gravity/gravity.Dockerfile b/tests/e2e-complex/ibc-defi/gravity/gravity.Dockerfile similarity index 100% rename from tests/ibc-defi/gravity/gravity.Dockerfile rename to tests/e2e-complex/ibc-defi/gravity/gravity.Dockerfile diff --git a/tests/ibc-defi/gravity/gravity_init.sh b/tests/e2e-complex/ibc-defi/gravity/gravity_init.sh similarity index 100% rename from tests/ibc-defi/gravity/gravity_init.sh rename to tests/e2e-complex/ibc-defi/gravity/gravity_init.sh diff --git a/tests/ibc-defi/hermes/config.toml b/tests/e2e-complex/ibc-defi/hermes/config.toml similarity index 100% rename from tests/ibc-defi/hermes/config.toml rename to tests/e2e-complex/ibc-defi/hermes/config.toml diff --git a/tests/ibc-defi/hermes/hermes.Dockerfile b/tests/e2e-complex/ibc-defi/hermes/hermes.Dockerfile similarity index 100% rename from tests/ibc-defi/hermes/hermes.Dockerfile rename to tests/e2e-complex/ibc-defi/hermes/hermes.Dockerfile diff --git a/tests/ibc-defi/hermes/hermes_init.sh b/tests/e2e-complex/ibc-defi/hermes/hermes_init.sh similarity index 100% rename from tests/ibc-defi/hermes/hermes_init.sh rename to tests/e2e-complex/ibc-defi/hermes/hermes_init.sh diff --git a/tests/ibc-defi/ibc-transfer-test.sh b/tests/e2e-complex/ibc-defi/ibc-transfer-test.sh similarity index 100% rename from tests/ibc-defi/ibc-transfer-test.sh rename to tests/e2e-complex/ibc-defi/ibc-transfer-test.sh diff --git a/tests/ibc-defi/osmosis/osmosis.Dockerfile b/tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile similarity index 100% rename from tests/ibc-defi/osmosis/osmosis.Dockerfile rename to tests/e2e-complex/ibc-defi/osmosis/osmosis.Dockerfile diff --git a/tests/ibc-defi/osmosis/osmosis_init.sh b/tests/e2e-complex/ibc-defi/osmosis/osmosis_init.sh similarity index 100% rename from tests/ibc-defi/osmosis/osmosis_init.sh rename to tests/e2e-complex/ibc-defi/osmosis/osmosis_init.sh diff --git a/tests/networks/docker-compose-localnet/.env b/tests/e2e-complex/upgrade/.env similarity index 100% rename from tests/networks/docker-compose-localnet/.env rename to tests/e2e-complex/upgrade/.env diff --git a/tests/upgrade/common.sh b/tests/e2e-complex/upgrade/common.sh similarity index 100% rename from tests/upgrade/common.sh rename to tests/e2e-complex/upgrade/common.sh diff --git a/tests/upgrade/docker-compose.yml b/tests/e2e-complex/upgrade/docker-compose.yml similarity index 100% rename from tests/upgrade/docker-compose.yml rename to tests/e2e-complex/upgrade/docker-compose.yml diff --git a/tests/upgrade/gen_node_configs.sh b/tests/e2e-complex/upgrade/gen_node_configs.sh similarity index 100% rename from tests/upgrade/gen_node_configs.sh rename to tests/e2e-complex/upgrade/gen_node_configs.sh diff --git a/tests/upgrade/initiate_upgrade.sh b/tests/e2e-complex/upgrade/initiate_upgrade.sh similarity index 100% rename from tests/upgrade/initiate_upgrade.sh rename to tests/e2e-complex/upgrade/initiate_upgrade.sh diff --git a/tests/upgrade/prepare.sh b/tests/e2e-complex/upgrade/prepare.sh similarity index 94% rename from tests/upgrade/prepare.sh rename to tests/e2e-complex/upgrade/prepare.sh index 025372e70..dae6f82af 100755 --- a/tests/upgrade/prepare.sh +++ b/tests/e2e-complex/upgrade/prepare.sh @@ -18,7 +18,7 @@ bash gen_node_configs.sh docker_compose_up "${CHEQD_IMAGE_FROM}" "$(pwd)" # Wait for start ordering, till height 1 -bash ../networks/tools/wait-for-chain.sh 1 +bash ../../tools/wait-for-chain.sh 1 # Get address of operator which will be used for sending tokens before upgrade get_addresses diff --git a/tests/upgrade/upgrade_and_check.sh b/tests/e2e-complex/upgrade/upgrade_and_check.sh similarity index 90% rename from tests/upgrade/upgrade_and_check.sh rename to tests/e2e-complex/upgrade/upgrade_and_check.sh index 107f9467f..bd543978e 100755 --- a/tests/upgrade/upgrade_and_check.sh +++ b/tests/e2e-complex/upgrade/upgrade_and_check.sh @@ -6,7 +6,7 @@ set -euox pipefail . common.sh # Wait for upgrade height -bash ../networks/tools/wait-for-chain.sh "$UPGRADE_HEIGHT" $((2 * VOTING_PERIOD)) +bash ../../tools/wait-for-chain.sh "$UPGRADE_HEIGHT" $((2 * VOTING_PERIOD)) # Stop docker-compose service docker_compose_down @@ -20,7 +20,7 @@ docker_compose_up "$CHEQD_IMAGE_TO" "$(pwd)" # Check that upgrade was successful # Wait for upgrade height -bash ../networks/tools/wait-for-chain.sh $((UPGRADE_HEIGHT + 2)) +bash ../../tools/wait-for-chain.sh $((UPGRADE_HEIGHT + 2)) CURRENT_VERSION=$(docker run --entrypoint cheqd-noded "$CHEQD_IMAGE_TO" version 2>&1) diff --git a/tests/e2e/conftest.py b/tests/e2e-pytest/conftest.py similarity index 100% rename from tests/e2e/conftest.py rename to tests/e2e-pytest/conftest.py diff --git a/tests/e2e/helpers.py b/tests/e2e-pytest/helpers.py similarity index 100% rename from tests/e2e/helpers.py rename to tests/e2e-pytest/helpers.py diff --git a/tests/e2e/requirements.txt b/tests/e2e-pytest/requirements.txt similarity index 100% rename from tests/e2e/requirements.txt rename to tests/e2e-pytest/requirements.txt diff --git a/tests/e2e/test_cosmos.py b/tests/e2e-pytest/test_cosmos.py similarity index 100% rename from tests/e2e/test_cosmos.py rename to tests/e2e-pytest/test_cosmos.py diff --git a/tests/e2e/test_identity.py b/tests/e2e-pytest/test_identity.py similarity index 100% rename from tests/e2e/test_identity.py rename to tests/e2e-pytest/test_identity.py diff --git a/tests/e2e/libindy.so b/tests/e2e/libindy.so deleted file mode 100644 index 178936024..000000000 Binary files a/tests/e2e/libindy.so and /dev/null differ diff --git a/tests/networks/docker-compose-localnet/add-observer.sh b/tests/networks/docker-compose-localnet/add-observer.sh deleted file mode 100755 index 68193b69e..000000000 --- a/tests/networks/docker-compose-localnet/add-observer.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -set -euox pipefail -sudo chown -R cheqd:cheqd "/home/runner/cheqd/" - -NODE_CONFIGS_BASE="/home/runner/work/cheqd-node/cheqd-node/tests/networks/docker-compose-localnet/network-config" -sudo -u cheqd cheqd-noded init node5 - -VALIDATOR_0_ID=$(cat "${NODE_CONFIGS_BASE}/validator-0/node_id.txt") -PERSISTENT_PEERS="${VALIDATOR_0_ID}@127.0.0.1:26656" -sudo -u cheqd cheqd-noded configure p2p persistent-peers "${PERSISTENT_PEERS}" - -sudo cp "${NODE_CONFIGS_BASE}/validator-0/config/genesis.json" "/home/runner/cheqd/.cheqdnode/config" - -sudo chmod -R 777 "/home/runner/cheqd/.cheqdnode" - -sudo -u cheqd cheqd-noded configure p2p laddr "tcp://0.0.0.0:26676" -sudo -u cheqd cheqd-noded configure rpc-laddr "tcp://0.0.0.0:26677" - - -sudo systemctl start cheqd-noded -sleep 10 -systemctl status cheqd-noded - diff --git a/tests/networks/docker-compose-localnet/docker-compose.yml b/tests/networks/docker-compose-localnet/docker-compose.yml deleted file mode 100644 index 6a1b9c94f..000000000 --- a/tests/networks/docker-compose-localnet/docker-compose.yml +++ /dev/null @@ -1,56 +0,0 @@ -version: '3.2' - -services: - validator-0: - image: "${CHEQD_IMAGE_NAME}" - ports: - - "26656:26656" # p2p - - "26657:26657" # rpc - volumes: - - "${MOUNT_POINT}/network-config/validator-0:/home/cheqd/.cheqdnode" - command: start - - validator-1: - image: "${CHEQD_IMAGE_NAME}" - ports: - - "26659:26656" # p2p - - "26660:26657" # rpc - volumes: - - "${MOUNT_POINT}/network-config/validator-1:/home/cheqd/.cheqdnode" - command: start - - validator-2: - image: "${CHEQD_IMAGE_NAME}" - ports: - - "26662:26656" # p2p - - "26663:26657" # rpc - volumes: - - "${MOUNT_POINT}/network-config/validator-2:/home/cheqd/.cheqdnode" - command: start - - validator-3: - image: "${CHEQD_IMAGE_NAME}" - ports: - - "26665:26656" # p2p - - "26666:26657" # rpc - volumes: - - "${MOUNT_POINT}/network-config/validator-3:/home/cheqd/.cheqdnode" - command: start - - seed-0: - image: "${CHEQD_IMAGE_NAME}" - ports: - - "26668:26656" # p2p - - "26669:26657" # rpc - volumes: - - "${MOUNT_POINT}/network-config/seed-0:/home/cheqd/.cheqdnode" - command: start - - observer-0: - image: "${CHEQD_IMAGE_NAME}" - ports: - - "26671:26656" # p2p - - "26672:26657" # rpc - volumes: - - "${MOUNT_POINT}/network-config/observer-0:/home/cheqd/.cheqdnode" - command: start diff --git a/tests/networks/docker-compose-localnet/gen-network-config.sh b/tests/networks/docker-compose-localnet/gen-network-config.sh deleted file mode 100644 index 5b05b2ad8..000000000 --- a/tests/networks/docker-compose-localnet/gen-network-config.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# Tweaks network configuration generated by `../tools/gen-network-config.sh` for use with docker-localnet container. - -set -euo pipefail - -# Generate base network configuration -bash ../tools/gen-network-config-base.sh cheqd 4 1 1 # 4 validators, 1 observer and 1 seed - -# Set peers -SEED_0_ID=$(cheqd-noded tendermint show-node-id --home "network-config/seed-0") -PERSISTENT_PEERS="$SEED_0_ID@seed-0:26656" -sed -i.bak "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" network-config/validator-0/config/config.toml -sed -i.bak "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" network-config/validator-1/config/config.toml -sed -i.bak "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" network-config/validator-2/config/config.toml -sed -i.bak "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" network-config/validator-3/config/config.toml -sed -i.bak "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" network-config/observer-0/config/config.toml diff --git a/tests/networks/docker-localnet/Dockerfile b/tests/networks/docker-localnet/Dockerfile deleted file mode 100644 index 25db8d2f7..000000000 --- a/tests/networks/docker-localnet/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM cheqd-cli - -USER root - -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends \ - supervisor \ - jq \ - nano - -USER cheqd - -COPY --chown=cheqd:cheqd tests/networks/tools/gen-network-config-base.sh ./ -COPY --chown=cheqd:cheqd tests/networks/docker-localnet/gen-network-config.sh ./ -COPY tests/networks/docker-localnet/supervisord.conf /etc - -RUN chmod +x ./gen-network-config.sh; \ - ./gen-network-config.sh - -EXPOSE 1317 26656 26657 9090 - -ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] -STOPSIGNAL SIGTERM diff --git a/tests/networks/docker-localnet/gen-network-config.sh b/tests/networks/docker-localnet/gen-network-config.sh deleted file mode 100644 index 46846d57d..000000000 --- a/tests/networks/docker-localnet/gen-network-config.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# Tweaks network configuration generated by `../tools/gen-network-config.sh` for use with docker-localnet container. - -set -euo pipefail - -# Generate base network configuration -bash gen-network-config-base.sh cheqd 2 0 0 # 2 validators, 0 observers and 0 seeds - -# Change ports for validator-1 -sed -i.bak 's|laddr = "tcp://0.0.0.0:26656"|laddr = "tcp://0.0.0.0:26666"|g' network-config/validator-1/config/config.toml -sed -i.bak 's|laddr = "tcp://0.0.0.0:26657"|laddr = "tcp://0.0.0.0:26667"|g' network-config/validator-1/config/config.toml -sed -i.bak 's|pprof_laddr = "localhost:6060"|pprof_laddr = "localhost:6070"|g' network-config/validator-1/config/config.toml - -sed -i.bak 's|address = "0.0.0.0:9090"|address = "0.0.0.0:9100"|g' network-config/validator-1/config/app.toml -sed -i.bak 's|address = "0.0.0.0:9091"|address = "0.0.0.0:9101"|g' network-config/validator-1/config/app.toml -sed -i.bak 's|address = "tcp://0.0.0.0:1317"|address = "tcp://0.0.0.0:1327"|g' network-config/validator-1/config/app.toml -sed -i.bak 's|address = ":8080"|address = ":8090"|g' network-config/validator-1/config/app.toml - -# Set peers -VAL_0_ID=$(cheqd-noded tendermint show-node-id --home "network-config/validator-0") -PERSISTENT_PEERS="$VAL_0_ID@127.0.0.1:26656" -sed -i.bak "s/persistent_peers = \"\"/persistent_peers = \"$PERSISTENT_PEERS\"/g" network-config/validator-1/config/config.toml diff --git a/tests/networks/docker-localnet/supervisord.conf b/tests/networks/docker-localnet/supervisord.conf deleted file mode 100644 index 2de38b184..000000000 --- a/tests/networks/docker-localnet/supervisord.conf +++ /dev/null @@ -1,41 +0,0 @@ -[supervisord] -logfile = /tmp/supervisord.log -logfile_maxbytes = 50MB -logfile_backups=10 -logLevel = error -pidfile = /tmp/supervisord.pid -nodaemon = true -minfds = 1024 -minprocs = 200 -umask = 022 -user = cheqd -identifier = supervisor -directory = /tmp -nocleanup = true -childlogdir = /tmp -strip_ansi = false - - -[program:validator-0] -command=cheqd-noded start --home "/home/cheqd/network-config/validator-0" -directory=/home/cheqd -stdout_logfile=/tmp/validator-0.log -stderr_logfile=/tmp/validator-0.log - -[program:validator-1] -command=cheqd-noded start --home "/home/cheqd/network-config/validator-1" -directory=/home/cheqd -stdout_logfile=/tmp/validator-1.log -stderr_logfile=/tmp/validator-1.log - -[program:validator-0-log] -command=tail -f /tmp/validator-0.log -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -redirect_stderr=true - -[program:validator-1-log] -command=tail -f /tmp/validator-1.log -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -redirect_stderr=true diff --git a/tests/networks/tools/wait-for-chain.sh b/tests/tools/wait-for-chain.sh similarity index 100% rename from tests/networks/tools/wait-for-chain.sh rename to tests/tools/wait-for-chain.sh diff --git a/tests/upgrade/.env b/tests/upgrade/.env deleted file mode 100644 index b7a6ab404..000000000 --- a/tests/upgrade/.env +++ /dev/null @@ -1,2 +0,0 @@ -CHEQD_IMAGE_NAME="cheqd-cli" -MOUNT_POINT="." diff --git a/x/cheqd/keeper/verify.go b/x/cheqd/keeper/verify.go index f90c3861f..0cf3535a2 100644 --- a/x/cheqd/keeper/verify.go +++ b/x/cheqd/keeper/verify.go @@ -86,7 +86,12 @@ func VerifyIdentitySignature(signer types.Signer, signatures []*types.SignInfo, return false, err } - result = result && ed25519.Verify(pubKey, signingInput, signature) + verRes, err := verifyNoPanic(pubKey, signingInput, signature) + if err != nil { + return false, fmt.Errorf("signature verification error. verification method: %s. error: %s", info.VerificationMethodId, err) + } + + result = result && verRes foundOne = true } } @@ -97,3 +102,14 @@ func VerifyIdentitySignature(signer types.Signer, signatures []*types.SignInfo, return result, nil } + +func verifyNoPanic(publicKey ed25519.PublicKey, message, sig []byte) (res bool, err error) { + defer func() { + if rec := recover(); rec != nil { + err = fmt.Errorf("%s", rec) + } + }() + + internalRes := ed25519.Verify(publicKey, message, sig) + return internalRes, nil +}