diff --git a/Makefile b/Makefile index 13c3a9df19..6dbae25dd5 100644 --- a/Makefile +++ b/Makefile @@ -285,43 +285,49 @@ release: ### Local Mainnet Development ### ############################################################################### -mainnet-zetarpc-node: - cd contrib/mainnet/zetacored && DOCKER_TAG=$(DOCKER_TAG) docker-compose up - -mainnet-bitcoind-node: +start-bitcoin-node-mainnet: cd contrib/mainnet/bitcoind && DOCKER_TAG=$(DOCKER_TAG) docker-compose up -testnet-zetarpc-node: +start-zetacored-rpc-mainnet: + cd contrib/mainnet/zetacored && DOCKER_TAG=$(DOCKER_TAG) docker-compose up + +start-zetacored-rpc-testnet: cd contrib/athens3/zetacored && DOCKER_TAG=$(DOCKER_TAG) docker-compose up -mainnet-bitcoind-node-down: +stop-bitcoin-node-mainnet: cd contrib/mainnet/bitcoind && DOCKER_TAG=$(DOCKER_TAG) docker-compose down -testnet-zetarpc-node-down: +stop-zetacored-rpc-testnet: cd contrib/athens3/zetacored && DOCKER_TAG=$(DOCKER_TAG) docker-compose down -mainnet-bitcoind-node-down-clean: +stop-zetacored-rpc-mainnet: + cd contrib/mainnet/zetacored && DOCKER_TAG=$(DOCKER_TAG) docker-compose down + +stop-and-clean-bitcoin-node-mainnet: cd contrib/mainnet/bitcoind && DOCKER_TAG=$(DOCKER_TAG) docker-compose down -v -testnet-zetarpc-node-down-clean: +stop-and-clean-zetacored-rpc-testnet: cd contrib/athens3/zetacored && DOCKER_TAG=$(DOCKER_TAG) docker-compose down -v -mainnet-zetarpc-node-local-dev: +stop-and-clean-zetacored-rpc-mainnet: + cd contrib/mainnet/zetacored && DOCKER_TAG=$(DOCKER_TAG) docker-compose down -v + +start-zetacored-rpc-mainnet-localbuild: cd contrib/mainnet/zetacored-localbuild && docker-compose up --build -testnet-zetarpc-node-local-dev: +start-zetacored-rpc-testnet-localbuild: cd contrib/athens3/zetacored-localbuild && docker-compose up --build -mainnet-zetarpc-node-local-dev-down: +stop-zetacored-rpc-mainnet-localbuild: cd contrib/mainnet/zetacored-localbuild && docker-compose down -testnet-zetarpc-node-local-dev-down: +stop-zetacored-rpc-testnet-localbuild: cd contrib/athens3/zetacored-localbuild && docker-compose down -mainnet-zetarpc-node-local-dev-down-clean: +stop-and-clean-zetacored-rpc-mainnet-localbuild: cd contrib/mainnet/zetacored-localbuild && docker-compose down -v -testnet-zetarpc-node-local-dev-down-cliean: +stop-and-clean-zetacored-rpc-testnet-localbuild: cd contrib/athens3/zetacored-localbuild && docker-compose down -v ############################################################################### diff --git a/contrib/athens3/zetacored-localbuild/docker-compose.yml b/contrib/athens3/zetacored-localbuild/docker-compose.yml index cfe01da31b..a6f4b13394 100644 --- a/contrib/athens3/zetacored-localbuild/docker-compose.yml +++ b/contrib/athens3/zetacored-localbuild/docker-compose.yml @@ -1,6 +1,6 @@ version: '3.8' services: - zetachain_mainnet_rpc: + zetachain_athens3_rpc: platform: linux/amd64 build: context: ../../.. @@ -15,7 +15,7 @@ services: VISOR_NAME: "cosmovisor" DAEMON_NAME: "zetacored" DAEMON_ALLOW_DOWNLOAD_BINARIES: "false" - DAEMON_RESTART_AFTER_UPGRADE: "true" + DAEMON_RESTART_AFTER_UPGRADE: "false" UNSAFE_SKIP_BACKUP: "true" CLIENT_DAEMON_NAME: "zetaclientd" CLIENT_DAEMON_ARGS: "" diff --git a/contrib/athens3/zetacored/docker-compose.yml b/contrib/athens3/zetacored/docker-compose.yml index 3116f690d8..8f2be919df 100644 --- a/contrib/athens3/zetacored/docker-compose.yml +++ b/contrib/athens3/zetacored/docker-compose.yml @@ -1,8 +1,8 @@ version: '3.8' services: - zetachain_mainnet_rpc: + zetachain_athens3_rpc: platform: linux/amd64 - image: zetachain/zetacored:${DOCKER_TAG:-ubuntu-v14.0.1} + image: zetachain/zetacored:${DOCKER_TAG:-ubuntu-v14.0.1.0} environment: DAEMON_HOME: "/root/.zetacored" NETWORK: athens3 diff --git a/contrib/docker-scripts/start.sh b/contrib/docker-scripts/start.sh index 42ab8766b8..8deb63389e 100644 --- a/contrib/docker-scripts/start.sh +++ b/contrib/docker-scripts/start.sh @@ -238,50 +238,39 @@ function move_zetacored_binaries { function start_network { if [ "${IS_LOCAL_DEVELOPMENT}" == "true" ]; then cp /usr/local/bin/zetacored ${DAEMON_HOME}/cosmovisor/genesis/bin/zetacored - rm -rf ${DAEMON_HOME}/cosmovisor/current/bin/zetacored + mkdir -p ${DAEMON_HOME}/cosmovisor/current/bin + rm -rf ${DAEMON_HOME}/cosmovisor/current/bin/zetacored || echo "Doesn't Exist" ln -s ${DAEMON_HOME}/cosmovisor/genesis/bin/zetacored ${DAEMON_HOME}/cosmovisor/current/bin/zetacored + fi + EXPECTED_MAJOR_VERSION=$(cat /scripts/EXPECTED_MAJOR_VERSION) + VISOR_VERSION=v$(${VISOR_NAME} version | tail -n 1 | tr -d '(devel)' | tr -d '\n') + DAEMON_VERSION=$(${DAEMON_NAME} version) + VISOR_MAJOR_VERSION=$(echo $VISOR_VERSION | grep -o '^v[0-9]*') + DAEMON_MAJOR_VERSION=$(echo $DAEMON_VERSION | grep -o '^v[0-9]*') + + logt "EXPECTED_MAJOR_VERSION: ${EXPECTED_MAJOR_VERSION}" + logt "VISOR_VERSION: ${VISOR_VERSION}" + logt "DAEMON_VERSION: ${DAEMON_VERSION}" + logt "VISOR_MAJOR_VERSION: ${VISOR_MAJOR_VERSION}" + logt "DAEMON_MAJOR_VERSION: ${DAEMON_MAJOR_VERSION}" + + if [ "$VISOR_MAJOR_VERSION" != "$EXPECTED_MAJOR_VERSION" ] || [ "$DAEMON_MAJOR_VERSION" != "$EXPECTED_MAJOR_VERSION" ]; then + logt "One or both versions don't match the expected major release version: $EXPECTED_MAJOR_VERSION" + else + logt "Both versions match the expected major release version: $EXPECTED_MAJOR_VERSION" + fi - EXPECTED_MAJOR_VERSION=$(cat /scripts/EXPECTED_MAJOR_VERSION) - VISOR_VERSION=v$(${VISOR_NAME} version | tail -n 1 | tr -d '(devel)' | tr -d '\n') - DAEMON_VERSION=$(${DAEMON_NAME} version) - VISOR_MAJOR_VERSION=$(echo $VISOR_VERSION | grep -o '^v[0-9]*') - DAEMON_MAJOR_VERSION=$(echo $DAEMON_VERSION | grep -o '^v[0-9]*') - - logt "EXPECTED_MAJOR_VERSION: ${EXPECTED_MAJOR_VERSION}" - logt "VISOR_VERSION: ${VISOR_VERSION}" - logt "DAEMON_VERSION: ${DAEMON_VERSION}" - logt "VISOR_MAJOR_VERSION: ${VISOR_MAJOR_VERSION}" - logt "DAEMON_MAJOR_VERSION: ${DAEMON_MAJOR_VERSION}" - - if [ "$VISOR_MAJOR_VERSION" != "$EXPECTED_MAJOR_VERSION" ] || [ "$DAEMON_MAJOR_VERSION" != "$EXPECTED_MAJOR_VERSION" ]; then - logt "One or both versions don't match the expected major release version: $EXPECTED_MAJOR_VERSION" - else - logt "Both versions match the expected major release version: $EXPECTED_MAJOR_VERSION" - fi - - if [ "$VISOR_VERSION" != "$DAEMON_VERSION" ]; then - logt "cosmovisor version doesn't appear to match your daemon version. Start ${DAEMON_NAME}" - ${DAEMON_NAME} start --home ${DAEMON_HOME} \ - --log_level info \ - --moniker ${MONIKER} \ - --rpc.laddr tcp://0.0.0.0:26657 \ - --minimum-gas-prices 1.0azeta "--grpc.enable=true" - else - logt "cosmovisor version match your daemon version. Start ${VISOR_NAME}" - ${VISOR_NAME} run start --home ${DAEMON_HOME} \ - --log_level info \ - --moniker ${MONIKER} \ - --rpc.laddr tcp://0.0.0.0:26657 \ - --minimum-gas-prices 1.0azeta "--grpc.enable=true" - fi + if [ "$VISOR_VERSION" != "$DAEMON_VERSION" ]; then + logt "cosmovisor version doesn't appear to match your daemon version. Start ${DAEMON_NAME}" else - logt "cosmovisor version match your daemon version. Start ${VISOR_NAME}" - ${VISOR_NAME} run start --home ${DAEMON_HOME} \ - --log_level info \ - --moniker ${MONIKER} \ - --rpc.laddr tcp://0.0.0.0:26657 \ - --minimum-gas-prices 1.0azeta "--grpc.enable=true" + logt "cosmovisor version match your daemon version. Start ${VISOR_NAME}" fi + + ${VISOR_NAME} run start --home ${DAEMON_HOME} \ + --log_level info \ + --moniker ${MONIKER} \ + --rpc.laddr tcp://0.0.0.0:26657 \ + --minimum-gas-prices 1.0azeta "--grpc.enable=true" } logt "Load Default Values for ENV Vars if not set." diff --git a/contrib/mainnet/zetacored-localbuild/docker-compose.yml b/contrib/mainnet/zetacored-localbuild/docker-compose.yml index bce18a6b80..4e3aa61e25 100644 --- a/contrib/mainnet/zetacored-localbuild/docker-compose.yml +++ b/contrib/mainnet/zetacored-localbuild/docker-compose.yml @@ -16,7 +16,7 @@ services: VISOR_NAME: "cosmovisor" DAEMON_NAME: "zetacored" DAEMON_ALLOW_DOWNLOAD_BINARIES: "false" - DAEMON_RESTART_AFTER_UPGRADE: "true" + DAEMON_RESTART_AFTER_UPGRADE: "false" UNSAFE_SKIP_BACKUP: "true" CLIENT_DAEMON_NAME: "zetaclientd" CLIENT_DAEMON_ARGS: "" diff --git a/contrib/mainnet/zetacored/docker-compose.yml b/contrib/mainnet/zetacored/docker-compose.yml index 753dfc6776..f08c2b4a3b 100644 --- a/contrib/mainnet/zetacored/docker-compose.yml +++ b/contrib/mainnet/zetacored/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.8' services: zetachain_mainnet_rpc: platform: linux/amd64 - image: zetachain/zetacored:${DOCKER_TAG:-ubuntu-v14.0.1.1} + image: zetachain/zetacored:${DOCKER_TAG:-ubuntu-v14.0.1.0} container_name: zetachain_mainnet_rpc environment: DAEMON_HOME: "/root/.zetacored" diff --git a/readme.md b/readme.md index ef502ffe9c..49ef8a0d13 100644 --- a/readme.md +++ b/readme.md @@ -110,194 +110,56 @@ Once the release is approved the pipeline will continue and will publish the rel This guide details deploying Zetacored nodes on both ZetaChain mainnet and Athens3 (testnet), alongside setting up a Bitcoin node for mainnet. The setup utilizes Docker Compose with environment variables for a streamlined deployment process. -### Deploying Zetacored Nodes - -#### Launching a Node - -**For Mainnet:** -- Use the `make` command with a specified Docker tag to initiate a mainnet Zetacored node. - ```shell - make mainnet-zetarpc-node DOCKER_TAG=ubuntu-v14.0.1 - ``` - -**For MAinnet:** -- Use this command for Mainnet to build form the current branch your on and launch with that binary with current athens3 state. This is for testing non-governance upgrade changes locally against a full node. - ```shell - make mainnet-zetarpc-node-local-dev - ``` - -**For Athens3 (Testnet):** -- Similar command structure for Athens3, ensuring the correct Docker tag is used. - ```shell - make testnet-zetarpc-node DOCKER_TAG=ubuntu-v14.0.1 - ``` - -**For Athens3 (Testnet) Local Development:** -- Use this command for Athens3 to build form the current branch your on and launch with that binary with current athens3 state. This is for testing non-governance upgrade changes locally against a full node. - ```shell - make testnet-zetarpc-node-local-dev - ``` - -#### Modifying the Sync Type - -**To change the sync type for your node:** -- Edit docker-compose.yml in contrib/{NETWORK}/zetacored/. -- Set RESTORE_TYPE to your desired method (snapshot, snapshot-archive, statesync). - -#### Zetacored Environment Variables - -| Variable | Description | -|----------|-------------| -| `DAEMON_HOME` | Daemon's home directory (`/root/.zetacored`). | -| `NETWORK` | Network identifier: `mainnet` or `athens3` (for testnet). | -| `RESTORE_TYPE` | Node restoration method: `snapshot`, `snapshot-archive`, `statesync`. | -| `SNAPSHOT_API` | API URL for fetching snapshots. | -| `TRUST_HEIGHT_DIFFERENCE_STATE_SYNC` | Trust height difference for state synchronization. | -| `CHAIN_ID` | Chain ID for the network. | -| `VISOR_NAME` | Visor software name, typically `cosmovisor`. | -| `DAEMON_NAME` | Daemon software name, `zetacored`. | -| `DAEMON_ALLOW_DOWNLOAD_BINARIES` | Enable daemon to download binaries. | -| `DAEMON_RESTART_AFTER_UPGRADE` | Restart daemon after software upgrade. | -| `UNSAFE_SKIP_BACKUP` | Skip backup during potentially unsafe operations. | -| `CLIENT_DAEMON_NAME` | Client daemon name, such as `zetaclientd`. | -| `CLIENT_DAEMON_ARGS` | Extra arguments for the client daemon. | -| `CLIENT_SKIP_UPGRADE` | Skip client software upgrade. | -| `CLIENT_START_PROCESS` | Begin client process start-up. | -| `MONIKER` | Node's moniker or nickname. | -| `RE_DO_START_SEQUENCE` | Restart node setup from scratch if necessary. | +Here's a comprehensive documentation using markdown tables to cover all the `make` commands for managing Zetacored and Bitcoin nodes, including where to modify the environment variables in Docker Compose configurations. + +### Zetacored / BTC Node Deployment and Management + +#### Commands Overview for Zetacored + +| Environment | Action | Command | Docker Compose Location | +|-------------|--------|---------|-------------------------| +| **Mainnet** | Start Node | `make start-mainnet-zetarpc-node DOCKER_TAG=ubuntu-v14.0.1` | `contrib/mainnet/zetacored` | +| **Mainnet** | Start Node (Local Build) | `make start-mainnet-zetarpc-node-local-build` | `contrib/mainnet/zetacored-localbuild` | +| **Mainnet** | Stop Node | `make stop-mainnet-zetarpc-node` | `contrib/mainnet/zetacored` | +| **Mainnet** | Clean Node Data | `make clean-mainnet-zetarpc-node` | `contrib/mainnet/zetacored` | +| **Testnet (Athens3)** | Start Node | `make start-testnet-zetarpc-node DOCKER_TAG=ubuntu-v14.0.1` | `contrib/athens3/zetacored` | +| **Testnet (Athens3)** | Start Node (Local Build) | `make start-testnet-zetarpc-node-local-build` | `contrib/athens3/zetacored-localbuild` | +| **Testnet (Athens3)** | Stop Node | `make stop-testnet-zetarpc-node` | `contrib/athens3/zetacored` | +| **Testnet (Athens3)** | Clean Node Data | `make clean-testnet-zetarpc-node` | `contrib/athens3/zetacored` | ### Bitcoin Node Setup for Mainnet -**Restoring a BTC Watcher Node:** -- To deploy a Bitcoin mainnet node, specify the `DOCKER_TAG` for your Docker image. - ```shell - make mainnet-bitcoind-node DOCKER_TAG=36-mainnet - ``` - -#### Bitcoin Node Environment Variables - -| Variable | Description | -|----------|-------------| -| `bitcoin_username` | Username for Bitcoin RPC. | -| `bitcoin_password` | Password for Bitcoin RPC. | -| `NETWORK_HEIGHT_URL` | URL to fetch the latest block height. | -| `WALLET_NAME` | Name of the Bitcoin wallet. | -| `WALLET_ADDRESS` | Bitcoin wallet address for transactions. | -| `SNAPSHOT_URL` | URL for downloading the blockchain snapshot. | -| `SNAPSHOT_RESTORE` | Enable restoration from snapshot. | -| `CLEAN_SNAPSHOT` | Clean existing data before restoring snapshot. | -| `DOWNLOAD_SNAPSHOT` | Download the snapshot if not present. | - -### Docker Compose Configurations - -#### Zetacored Mainnet - -```yaml -version: '3.8' -services: - zetachain_mainnet_rpc: - platform: linux/amd64 - image: zetachain/zetacored:${DOCKER_TAG:-ubuntu-v14.0.1} - environment: - DAEMON_HOME: "/root/.zetacored" - NETWORK: mainnet - RESTORE_TYPE: "snapshot" - SNAPSHOT_API: https://snapshots.zetachain.com - TRUST_HEIGHT_DIFFERENCE_STATE_SYNC: 40000 - CHAIN_ID: "zetachain_7000-1" - VISOR_NAME: "cosmovisor" - DAEMON_NAME: "zetacored" - DAEMON_ALLOW_DOWNLOAD_BINARIES: "false" - DAEMON_RESTART_AFTER_UPGRADE: "true" - UNSAFE_SKIP_BACKUP: "true" - CLIENT_DAEMON_NAME: "zetaclientd" - CLIENT_DAEMON_ARGS: "" - CLIENT_SKIP_UPGRADE: "true" - CLIENT_START_PROCESS: "false" - MONIKER: local-test - RE_DO_START_SEQUENCE: "false" - ports: - - "26656:26656" - - "1317:1317" - - "8545:8545" - - "8546:8546" - - "26657:26657" - - "9090:9090" - - "9091:9091" - volumes: - - - - zetacored_data_mainnet:/root/.zetacored/ - entrypoint: bash /scripts/start.sh -volumes: - zetacored_data_mainnet: -``` +#### Commands Overview for Bitcoin -#### Zetacored Athens3/Testnet - -```yaml -version: '3.8' -services: - zetachain_testnet_rpc: - platform: linux/amd64 - image: zetachain/zetacored:${DOCKER_TAG:-ubuntu-v14-testnet} - environment: - DAEMON_HOME: "/root/.zetacored" - NETWORK: athens3 - RESTORE_TYPE: "snapshot" - SNAPSHOT_API: https://snapshots.zetachain.com - TRUST_HEIGHT_DIFFERENCE_STATE_SYNC: 40000 - CHAIN_ID: "athens_7001-1" - VISOR_NAME: "cosmovisor" - DAEMON_NAME: "zetacored" - DAEMON_ALLOW_DOWNLOAD_BINARIES: "false" - DAEMON_RESTART_AFTER_UPGRADE: "true" - UNSAFE_SKIP_BACKUP: "true" - CLIENT_DAEMON_NAME: "zetaclientd" - CLIENT_DAEMON_ARGS: "" - CLIENT_SKIP_UPGRADE: "true" - CLIENT_START_PROCESS: "false" - MONIKER: local-test - RE_DO_START_SEQUENCE: "false" - ports: - - "26656:26656" - - "1317:1317" - - "8545:8545" - - "8546:8546" - - "26657:26657" - - "9090:9090" - - "9091:9091" - volumes: - - zetacored_data_athens3:/root/.zetacored/ - entrypoint: bash /scripts/start.sh -volumes: - zetacored_data_athens3: -``` +| Action | Command | Docker Compose Location | +|--------|---------|-------------------------| +| Start Node | `make start-mainnet-bitcoind-node DOCKER_TAG=36-mainnet` | `contrib/mainnet/bitcoind` | +| Stop Node | `make stop-mainnet-bitcoind-node` | `contrib/mainnet/bitcoind` | +| Clean Node Data | `make clean-mainnet-bitcoind-node` | `contrib/mainnet/bitcoind` | -#### Bitcoin Mainnet Node - -```yaml -version: '3' -services: - bitcoin: - image: zetachain/bitcoin:${DOCKER_TAG:-36-mainnet} - platform: linux/amd64 - environment: - - bitcoin_username=test - - bitcoin_password=test - - NETWORK_HEIGHT_URL=https://blockstream.info/api/blocks/tip/height - - WALLET_NAME=tssMainnet - - WALLET_ADDRESS=bc1qm24wp577nk8aacckv8np465z3dvmu7ry45el6y - - SNAPSHOT_URL=https://storage.googleapis.com/bitcoin-rpc-snapshots-prod/bitcoind-mainnet-2024-02-20-00-22-06.tar.gz - - SNAPSHOT_RESTORE=true - - CLEAN_SNAPSHOT=true - - DOWNLOAD_SNAPSHOT=true - volumes: - - bitcoin_data:/root/ - ports: - - 8332:8332 -volumes: - bitcoin_data: -``` +### Configuration Options + +#### Where to Modify Environment Variables + +The environment variables for both Zetacored and Bitcoin nodes are defined in the `docker-compose.yml` files located in the respective directories mentioned above. These variables control various operational aspects like the sync type, networking details, and client behavior. + +#### Example Environment Variables for Zetacored + +| Variable | Description | Example | +|----------|-------------|---------| +| `DAEMON_HOME` | Daemon's home directory | `/root/.zetacored` | +| `NETWORK` | Network identifier | `mainnet`, `athens3` | +| `CHAIN_ID` | Chain ID for the network | `zetachain_7000-1`, `athens_7001-1` | +| `RESTORE_TYPE` | Node restoration method | `snapshot`, `statesync` | +| `SNAPSHOT_API` | API URL for fetching snapshots | `https://snapshots.zetachain.com` | + +#### Example Environment Variables for Bitcoin + +| Variable | Description | Example | +|----------|-------------|---------| +| `bitcoin_username` | Username for Bitcoin RPC | `user` | +| `bitcoin_password` | Password for Bitcoin RPC | `pass` | +| `WALLET_NAME` | Name of the Bitcoin wallet | `tssMainnet` | +| `WALLET_ADDRESS` | Bitcoin wallet address for transactions | `bc1qm24wp577nk8aacckv8np465z3dvmu7ry45el6y` | -Replace placeholders in Docker Compose files and `make` commands with actual values appropriate for your deployment scenario. This complete setup guide is designed to facilitate the deployment and management of Zetacored and Bitcoin nodes in various environments. \ No newline at end of file +This detailed tabulation ensures all necessary commands and configurations are neatly organized, providing clarity on where to manage the settings and how to execute different operations for Zetacored and Bitcoin nodes across different environments.