diff --git a/.github/workflows/docker-build-and-push.yml b/.github/workflows/docker-build-and-push.yml index b0c5080da8..a1fcf712a3 100644 --- a/.github/workflows/docker-build-and-push.yml +++ b/.github/workflows/docker-build-and-push.yml @@ -1,11 +1,9 @@ name: Zetacored-Docker-Build on: - pull_request: + release: types: - - closed - branches: - - 'main' + - created workflow_dispatch: inputs: version: @@ -32,9 +30,14 @@ jobs: fetch-depth: 0 - name: Set Version from the PR title. - if: github.event_name == 'pull_request' + if: github.event_name != 'workflow_dispatch' run: | - echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.pull_request.title }}" >> ${GITHUB_ENV} + LATEST_RELEASE=$(curl -s -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/repos/${{ github.repository }}/releases/latest) + RELEASE_TITLE=$(echo $LATEST_RELEASE | jq -r .name) + echo "Latest release title: $RELEASE_TITLE" + echo "GITHUB_TAG_MAJOR_VERSION=$RELEASE_TITLE" >> $GITHUB_ENV - name: Set Version for Hotfix Release from Input. if: github.event_name != 'pull_request' @@ -64,9 +67,14 @@ jobs: fetch-depth: 0 - name: Set Version from the PR title. - if: github.event_name == 'pull_request' + if: github.event_name != 'workflow_dispatch' run: | - echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.pull_request.title }}" >> ${GITHUB_ENV} + LATEST_RELEASE=$(curl -s -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/repos/${{ github.repository }}/releases/latest) + RELEASE_TITLE=$(echo $LATEST_RELEASE | jq -r .name) + echo "Latest release title: $RELEASE_TITLE" + echo "GITHUB_TAG_MAJOR_VERSION=$RELEASE_TITLE" >> $GITHUB_ENV - name: Set Version for Hotfix Release from Input. if: github.event_name != 'pull_request' @@ -107,9 +115,14 @@ jobs: fetch-depth: 0 - name: Set Version from the PR title. - if: github.event_name == 'pull_request' + if: github.event_name != 'workflow_dispatch' run: | - echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.pull_request.title }}" >> ${GITHUB_ENV} + LATEST_RELEASE=$(curl -s -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/repos/${{ github.repository }}/releases/latest) + RELEASE_TITLE=$(echo $LATEST_RELEASE | jq -r .name) + echo "Latest release title: $RELEASE_TITLE" + echo "GITHUB_TAG_MAJOR_VERSION=$RELEASE_TITLE" >> $GITHUB_ENV - name: Set Version for Hotfix Release from Input. if: github.event_name != 'pull_request' diff --git a/Dockerfile b/Dockerfile index e6da909959..dc68ba89c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,51 +1,53 @@ -# Purpose: This Dockerfile creates an environment for running ZetaChain -# It contains: -# - zetacored: the ZetaChain node binary -# - zetaclientd: the ZetaChain client binary for observers -# - zetae2e: the ZetaChain end-to-end tests CLI - -FROM golang:1.20-alpine3.18 +# Build Stage +FROM golang:1.20-alpine3.18 AS builder ENV GOPATH /go ENV GOOS=linux ENV CGO_ENABLED=1 -RUN apk --no-cache add git make build-base jq openssh libusb-dev linux-headers bash curl tmux -RUN ssh-keygen -b 2048 -t rsa -f /root/.ssh/localtest.pem -q -N "" +# Install build dependencies +RUN apk --no-cache add git make build-base jq openssh libusb-dev linux-headers bash curl python3 py3-pip +# Set the working directory WORKDIR /go/delivery/zeta-node + +# Copy module files and download dependencies COPY go.mod . COPY go.sum . - RUN go mod download + +# Copy the rest of the source code and build the application COPY . . -RUN make install -RUN make install-zetae2e -# -#FROM golang:1.20-alpine -#RUN apk --no-cache add openssh jq tmux vim curl bash -RUN ssh-keygen -A -WORKDIR /root +RUN make install -RUN cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys +# Run Stage +FROM alpine:3.18 -RUN cp /go/bin/zetaclientd /usr/local/bin -RUN cp /go/bin/zetacored /usr/local/bin -RUN cp /go/bin/zetae2e /usr/local/bin +# Copy Start Script Helpers +COPY contrib/docker-scripts/* /scripts/ -COPY contrib/localnet/scripts /root -COPY contrib/localnet/preparams /root/preparams -COPY contrib/localnet/ssh_config /root/.ssh/config -COPY contrib/localnet/zetacored /root/zetacored -COPY contrib/localnet/tss /root/tss +# Install runtime dependencies +RUN apk --no-cache add git jq bash curl python3 libusb-dev linux-headers make build-base wget py3-pip qemu-img qemu-system-x86_64 && \ + pip install requests && \ + chmod a+x -R /scripts && \ + wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.31-r0/glibc-2.31-r0.apk && \ + apk add --force-overwrite --allow-untrusted glibc-2.31-r0.apk -RUN chmod 755 /root/*.sh -RUN chmod 700 /root/.ssh -RUN chmod 600 /root/.ssh/* +# Copy the binaries from the build stage +COPY --from=builder /go/bin/zetaclientd /usr/local/bin/zetaclientd +COPY --from=builder /go/bin/zetacored /usr/local/bin/zetacored +# Set the working directory WORKDIR /usr/local/bin -ENV SHELL /bin/sh -EXPOSE 22 -ENTRYPOINT ["/usr/sbin/sshd", "-D"] +# Set the default shell +ENV SHELL /bin/bash + +EXPOSE 26656 +EXPOSE 1317 +EXPOSE 8545 +EXPOSE 8546 +EXPOSE 9090 +EXPOSE 26657 +EXPOSE 9091 diff --git a/Dockerfile-localnet b/Dockerfile-localnet new file mode 100644 index 0000000000..793b555c22 --- /dev/null +++ b/Dockerfile-localnet @@ -0,0 +1,52 @@ +FROM golang:1.20-alpine3.18 + +ENV GOPATH /go +ENV GOOS=linux +ENV CGO_ENABLED=1 + +RUN apk --no-cache add git make build-base jq openssh libusb-dev linux-headers bash curl tmux python3 py3-pip +RUN pip install requests +RUN ssh-keygen -b 2048 -t rsa -f /root/.ssh/localtest.pem -q -N "" + +WORKDIR /go/delivery/zeta-node +COPY go.mod . +COPY go.sum . +#RUN --mount=type=cache,target=/root/.cache/go-build \ +# go mod download +RUN go mod download +COPY . . + +#RUN --mount=type=cache,target=/root/.cache/go-build \ +# make install +#RUN --mount=type=cache,target=/root/.cache/go-build \ +# make install-zetae2e +RUN make install +RUN make install-zetae2e +# +#FROM golang:1.20-alpine + +#RUN apk --no-cache add openssh jq tmux vim curl bash +RUN ssh-keygen -A +WORKDIR /root + +RUN cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys + +RUN cp /go/bin/zetaclientd /usr/local/bin +RUN cp /go/bin/zetacored /usr/local/bin +RUN cp /go/bin/zetae2e /usr/local/bin + +COPY contrib/localnet/scripts /root +COPY contrib/localnet/preparams /root/preparams +COPY contrib/localnet/ssh_config /root/.ssh/config +COPY contrib/localnet/zetacored /root/zetacored +COPY contrib/localnet/tss /root/tss + +RUN chmod 755 /root/*.sh +RUN chmod 700 /root/.ssh +RUN chmod 600 /root/.ssh/* + +WORKDIR /usr/local/bin +ENV SHELL /bin/sh +EXPOSE 22 + +ENTRYPOINT ["/usr/sbin/sshd", "-D"] diff --git a/Makefile b/Makefile index 7caeeb66e7..90928fe5d6 100644 --- a/Makefile +++ b/Makefile @@ -184,7 +184,7 @@ generate: proto openapi specs typescript docs-zetacored zetanode: @echo "Building zetanode" - $(DOCKER) build -t zetanode -f ./Dockerfile . + $(DOCKER) build -t zetanode -f ./Dockerfile-localnet . $(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile.fastbuild . .PHONY: zetanode @@ -266,7 +266,10 @@ release: ############################################################################### mainnet-zetarpc-node: - cd contrib/local-mainnet/zetacored && docker-compose up + cd contrib/mainnet/zetacored && DOCKER_TAG=$(DOCKER_TAG) docker-compose up mainnet-bitcoind-node: - cd contrib/local-mainnet/bitcoind && docker-compose up \ No newline at end of file + cd contrib/mainnet/bitcoind && DOCKER_TAG=$(DOCKER_TAG) docker-compose up + +athens3-zetarpc-node: + cd contrib/athens3/zetacored && DOCKER_TAG=$(DOCKER_TAG) docker-compose up \ No newline at end of file diff --git a/changelog.md b/changelog.md index 7c42a29c16..ad26cc8c10 100644 --- a/changelog.md +++ b/changelog.md @@ -15,6 +15,7 @@ ### Tests * [1767](https://github.com/zeta-chain/node/pull/1767) - add unit tests for emissions module begin blocker +* [1791](https://github.com/zeta-chain/node/pull/1791) - add e2e tests for feature of restricted address ### Chores @@ -76,12 +77,17 @@ * Added docker-compose and make commands for launching full nodes. `make mainnet-zetarpc-node` `make mainnet-bitcoind-node` * Made adjustments to the docker-compose for launching mainnet full nodes to include examples of using the docker images build from the docker image build pipeline. * [1736](https://github.com/zeta-chain/node/pull/1736) - chore: add Ethermint endpoints to OpenAPI +* Re-wrote Dockerfile for building Zetacored docker images. +* Adjusted the docker-compose files for Zetacored nodes to utilize the new docker image. +* Added scripts for the new docker image that facilitate the start up automation. +* Adjusted the docker pipeline slightly to pull the version on PR from the app.go file. * [1781](https://github.com/zeta-chain/node/pull/1781) - add codecov coverage report in CI ### Features * [1425](https://github.com/zeta-chain/node/pull/1425) add `whitelist-erc20` command + ### Chores * [1729](https://github.com/zeta-chain/node/pull/1729) - add issue templates diff --git a/cmd/zetae2e/local/bitcoin.go b/cmd/zetae2e/local/bitcoin.go index 2cd39f9c53..3dd4fe3c13 100644 --- a/cmd/zetae2e/local/bitcoin.go +++ b/cmd/zetae2e/local/bitcoin.go @@ -69,6 +69,7 @@ func bitcoinTestRoutine( e2etests.TestBitcoinWithdrawName, e2etests.TestZetaWithdrawBTCRevertName, e2etests.TestCrosschainSwapName, + e2etests.TestBitcoinWithdrawRestrictedName, ); err != nil { return fmt.Errorf("bitcoin tests failed: %v", err) } diff --git a/cmd/zetae2e/local/erc20.go b/cmd/zetae2e/local/erc20.go index c3dbc3f354..2b1b266f83 100644 --- a/cmd/zetae2e/local/erc20.go +++ b/cmd/zetae2e/local/erc20.go @@ -66,6 +66,7 @@ func erc20TestRoutine( e2etests.TestMultipleWithdrawsName, e2etests.TestERC20DepositAndCallRefundName, e2etests.TestZRC20SwapName, + e2etests.TestERC20DepositRestrictedName, ); err != nil { return fmt.Errorf("erc20 tests failed: %v", err) } diff --git a/cmd/zetae2e/local/ethereum.go b/cmd/zetae2e/local/ethereum.go index 31e0e33b37..8925a8fc51 100644 --- a/cmd/zetae2e/local/ethereum.go +++ b/cmd/zetae2e/local/ethereum.go @@ -59,6 +59,7 @@ func ethereumTestRoutine( e2etests.TestContextUpgradeName, e2etests.TestEtherDepositAndCallName, e2etests.TestDepositAndCallRefundName, + e2etests.TestEtherWithdrawRestrictedName, ); err != nil { return fmt.Errorf("ethereum tests failed: %v", err) } diff --git a/cmd/zetae2e/local/zeta.go b/cmd/zetae2e/local/zeta.go index ac7243f7fb..ff62f41c2e 100644 --- a/cmd/zetae2e/local/zeta.go +++ b/cmd/zetae2e/local/zeta.go @@ -63,6 +63,7 @@ func zetaTestRoutine( e2etests.TestMessagePassingName, e2etests.TestMessagePassingRevertFailName, e2etests.TestMessagePassingRevertSuccessName, + e2etests.TestZetaDepositRestrictedName, ); err != nil { return fmt.Errorf("zeta tests failed: %v", err) } diff --git a/contrib/athens3/zetacored/docker-compose.yml b/contrib/athens3/zetacored/docker-compose.yml new file mode 100644 index 0000000000..6db48703d2 --- /dev/null +++ b/contrib/athens3/zetacored/docker-compose.yml @@ -0,0 +1,44 @@ +version: '3.8' +services: + zetachain_mainnet_rpc: + platform: linux/amd64 + #This will build the binary from the GIT_REF you are locally on. +# build: +# context: ../../.. +# dockerfile: Dockerfile + image: zetachain/zetacored:${DOCKER_TAG:-ubuntu-v14} + environment: + DAEMON_HOME: "/root/.zetacored" + NETWORK: athens3 + #RESTORE_TYPE=snapshot/snapshot-archive/statesync + RESTORE_TYPE: "statesync" + SNAPSHOT_API: https://snapshots.zetachain.com + TRUST_HEIGHT_DIFFERENCE_STATE_SYNC: 40000 + COSMOVISOR_VERSION: "v1.5.0" + CHAIN_ID: "athens_7001-1" + COSMOVISOR_CHECKSUM: "626dfc58c266b85f84a7ed8e2fe0e2346c15be98cfb9f9b88576ba899ed78cdc" + 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:/root/.zetacored/ + entrypoint: bash /scripts/start.sh + +volumes: + zetacored_data: diff --git a/contrib/docker-scripts/download_binaries.py b/contrib/docker-scripts/download_binaries.py new file mode 100644 index 0000000000..c33648952d --- /dev/null +++ b/contrib/docker-scripts/download_binaries.py @@ -0,0 +1,98 @@ +import re +import requests +import os +import json +import logging +import sys +import shutil + + +# Logger class for easier logging setup +class Logger: + def __init__(self): + self.log = logging.getLogger() + self.log.setLevel(logging.INFO) + self.handler = logging.StreamHandler(sys.stdout) + self.handler.setLevel(logging.DEBUG) + self.formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') + self.handler.setFormatter(self.formatter) + self.log.addHandler(self.handler) + + +# Initialize logger instance +logger = Logger() + +# Define the path where upgrades will be stored, using an environment variable for the base path +upgrade_path = f'{os.environ["DAEMON_HOME"]}/cosmovisor/upgrades/' + + +# Function to find the latest patch version of a binary based on major and optional minor version +def find_latest_patch_version(major_version, minor_version=None): + # Define a regex pattern to match version directories + pattern = re.compile( + f"v{major_version}\.{minor_version}\.(\d+)" if minor_version else f"v{major_version}\.0\.(\d+)") + # List directories that match the version pattern + versions = [folder for folder in os.listdir(upgrade_path) if pattern.match(folder)] + if versions: + try: + # Find the maximum version, assuming it's the latest patch + latest_patch_version = max(versions) + # Return the path to the binary of the latest patch version + return os.path.join(upgrade_path, latest_patch_version, "bin", "zetacored") + except ValueError as e: + logger.log.error(f"Error finding latest patch version: {e}") + return None + return None + + +# Function to replace an old binary with a new one +def replace_binary(source, target): + try: + # Log deletion of old binary + if os.path.exists(target): + logger.log.info(f"Deleted old binary: {target}") + os.remove(target) + # Copy the new binary to the target location + shutil.copy(source, target) + logger.log.info(f"Binary replaced: {target} -> {source}") + except Exception as e: + logger.log.error(f"Error replacing binary: {e}") + + +# Parse JSON from an environment variable to get binary download information +info = json.loads(os.environ["DOWNLOAD_BINARIES"]) + +try: + # Iterate over binaries to download + for binary in info["binaries"]: + download_link = binary["download_url"] + binary_location = binary["binary_location"] + binary_directory = os.path.dirname(binary_location) + # Log download link + logger.log.info(f"DOWNLOAD LINK: {download_link}") + split_download_link = download_link.split("/") + # Log split download link parts + logger.log.info(f"SPLIT DOWNLOAD LINK: {split_download_link}") + # Extract binary name and version from the download link + binary_name = download_link.split("/")[8] + # Check if binary already exists + logger.log.info(f"CHECKING / DOWNLOADING {binary_location}") + + if os.path.exists(binary_location): + # If binary exists, log and do nothing + logger.log.info(f"BINARY EXISTS ALREADY: {binary_location}") + else: + # If binary doesn't exist, download and save it + logger.log.info("BINARY DOES NOT EXIST.") + os.makedirs(binary_directory, exist_ok=True) + response = requests.get(download_link) + if response.status_code == 200: + with open(binary_location, "wb") as f: + f.write(response.content) + os.chmod(binary_location, 0o755) + logger.log.info("BINARY DOWNLOADED SUCCESSFULLY.") + else: + logger.log.info("FAILED TO DOWNLOAD BINARY. Status code:", response.status_code) + logger.log.info("BINARIES DOWNLOAD FINISHED...") +except Exception as e: + logger.log.error(str(e)) diff --git a/contrib/docker-scripts/install_cosmovisor.py b/contrib/docker-scripts/install_cosmovisor.py new file mode 100644 index 0000000000..568c9bbe8e --- /dev/null +++ b/contrib/docker-scripts/install_cosmovisor.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +import hashlib +import logging +import os +import requests +import sys + +# Constants defining the binary name, version, expected checksum, download URL, and installation path +BINARY_NAME = "cosmovisor" +BINARY_VERSION = os.getenv("COSMOVISOR_VERSION") # Get the cosmovisor version from environment variable +EXPECTED_CHECKSUM = os.getenv("COSMOVISOR_CHECKSUM") # Get the expected checksum from environment variable +BINARY_URL = f"https://binary-pickup.zetachain.com/cosmovisor-{BINARY_VERSION}-linux-amd64" # Construct the binary download URL +INSTALL_PATH = f"/usr/local/bin/{BINARY_NAME}" # Define the installation path for the binary + +# Check if necessary environment variables are set; exit if not +if not BINARY_VERSION or not EXPECTED_CHECKSUM: + logging.error("Environment variables COSMOVISOR_VERSION and COSMOVISOR_CHECKSUM must be set.") + sys.exit(1) + +# Configure logging to both stdout and a file +logging.basicConfig( + level=logging.INFO, # Set logging level to INFO + format="%(levelname)s: %(message)s", # Define log message format + handlers=[ + logging.StreamHandler(sys.stdout), # Log to stdout + logging.FileHandler("/var/log/update_cosmovisor.log") # Log to a file + ] +) + + +# Function to calculate the SHA-256 checksum of the downloaded binary +def calculate_checksum(file_path): + sha256 = hashlib.sha256() # Create a new SHA-256 hash object + with open(file_path, "rb") as f: # Open the binary file in binary read mode + for byte_block in iter(lambda: f.read(4096), + b""): # Read the file in chunks to avoid loading it all into memory + sha256.update(byte_block) # Update the hash object with the chunk + return sha256.hexdigest() # Return the hexadecimal digest of the hash object + + +# Function to download the binary and update it if the checksum matches +def download_and_update_binary(): + try: + response = requests.get(BINARY_URL) # Attempt to download the binary + response.raise_for_status() # Check if the download was successful, raises exception on failure + logging.info("Binary downloaded successfully.") + except requests.exceptions.RequestException as e: + logging.error(f"Failed to download the binary: {e}") # Log any error during download + sys.exit(1) # Exit the script on download failure + + with open(INSTALL_PATH, "wb") as f: # Open the installation path file in binary write mode + f.write(response.content) # Write the downloaded binary content to the file + + actual_checksum = calculate_checksum(INSTALL_PATH) # Calculate the checksum of the downloaded binary + if actual_checksum == EXPECTED_CHECKSUM: # Compare the actual checksum with the expected checksum + logging.info("Cosmovisor binary checksum verified.") # Log success if checksums match + os.chmod(INSTALL_PATH, 0o755) # Make the binary executable + logging.info("Cosmovisor binary updated successfully.") + else: + logging.error( + "Checksums do not match. Possible corrupted download. Deleting the downloaded binary.") # Log failure if checksums do not match + os.remove(INSTALL_PATH) # Remove the potentially corrupted binary + sys.exit(1) # Exit the script due to checksum mismatch + + +# Main script execution starts here +logging.info( + f"Downloading the {BINARY_NAME} binary (version {BINARY_VERSION})...") # Log the start of the download process +download_and_update_binary() # Call the function to download and update the binary diff --git a/contrib/docker-scripts/start.sh b/contrib/docker-scripts/start.sh new file mode 100644 index 0000000000..e235bc30ce --- /dev/null +++ b/contrib/docker-scripts/start.sh @@ -0,0 +1,317 @@ +#!/bin/bash + +logt() { + echo "$(date '+%Y-%m-%d %H:%M:%S') $1" +} + +function init_chain { + if [ -d "${DAEMON_HOME}/config" ]; then + logt "${DAEMON_NAME} home directory already initialized." + else + logt "${DAEMON_NAME} home directory not initialized." + logt "MONIKER: ${MONIKER}" + logt "DAEMON_HOME: ${DAEMON_HOME}" + ${DAEMON_NAME} init ${MONIKER} --home ${DAEMON_HOME} --chain-id ${CHAIN_ID} + fi +} + +function download_configs { + if [ "${NETWORK}" == "mainnet" ]; then + wget -q ${APP_TOML_FILE_MAINNET} -O ${DAEMON_HOME}/config/app.toml + wget -q ${CONFIG_TOML_FILE_MAINNET} -O ${DAEMON_HOME}/config/config.toml + wget -q ${CLIENT_TOML_FILE_MAINNET} -O ${DAEMON_HOME}/config/client.toml + wget -q ${GENESIS_FILE_MAINNET} -O ${DAEMON_HOME}/config/genesis.json + wget -q ${BINARY_LIST_MAINNET} + export DOWNLOAD_BINARIES=$(cat binary_list.json | tr -d '\n') + rm -rf binary_list.json + logt "BINARY_LIST: ${DOWNLOAD_BINARIES}" + elif [ "${NETWORK}" == "athens3" ]; then + wget -q ${APP_TOML_FILE_ATHENS3} -O ${DAEMON_HOME}/config/app.toml + wget -q ${CONFIG_TOML_FILE_ATHENS3} -O ${DAEMON_HOME}/config/config.toml + wget -q ${CLIENT_TOML_FILE_ATHENS3} -O ${DAEMON_HOME}/config/client.toml + wget -q ${GENESIS_FILE_ATHENS3} -O ${DAEMON_HOME}/config/genesis.json + wget -q ${BINARY_LIST_ATHENS3} + export DOWNLOAD_BINARIES=$(cat binary_list.json | tr -d '\n') + rm -rf binary_list.json + logt "BINARY_LIST: ${DOWNLOAD_BINARIES}" + else + logt "Initialize for Localnet." + fi +} + +function setup_restore_type { + if [ "${RESTORE_TYPE}" == "statesync" ]; then + logt "Statesync restore. Download state sync rpc address from network-config." + if [ "${NETWORK}" == "mainnet" ]; then + logt "MAINNET STATE SYNC" + logt "STATE_SYNC_RPC_NODE_FILE_MAINNET: ${STATE_SYNC_RPC_NODE_FILE_MAINNET}" + logt "RPC_STATE_SYNC_RPC_LIST_FILE_MAINNET: ${RPC_STATE_SYNC_RPC_LIST_FILE_MAINNET}" + wget -q ${STATE_SYNC_RPC_NODE_FILE_MAINNET} + wget -q ${RPC_STATE_SYNC_RPC_LIST_FILE_MAINNET} + export STATE_SYNC_SERVER=$(cat state_sync_node) + export RPC_STATE_SYNC_SERVERS=$(cat rpc_state_sync_nodes) + rm -rf state_sync_node + rm -rf rpc_state_sync_nodes + elif [ "${NETWORK}" == "athens3" ]; then + logt "ATHENS STATE SYNC" + logt "STATE_SYNC_RPC_NODE_FILE_MAINNET: ${STATE_SYNC_RPC_NODE_FILE_ATHENS3}" + logt "RPC_STATE_SYNC_RPC_LIST_FILE_MAINNET: ${RPC_STATE_SYNC_RPC_LIST_FILE_ATHENS3}" + wget -q ${STATE_SYNC_RPC_NODE_FILE_ATHENS3} + wget -q ${RPC_STATE_SYNC_RPC_LIST_FILE_ATHENS3} + export STATE_SYNC_SERVER=$(cat state_sync_node) + export RPC_STATE_SYNC_SERVERS=$(cat rpc_state_sync_nodes) + rm -rf state_sync_node + rm -rf rpc_state_sync_nodes + fi + elif [ "${RESTORE_TYPE}" == "snapshot" ]; then + if [ "${NETWORK}" == "mainnet" ]; then + logt "Get Latest Snapshot URL" + SNAPSHOT_URL=$(curl -s ${SNAPSHOT_API}/latest-snapshot?network=mainnet | jq -r .latest_snapshot) + SNAPSHOT_FILENAME=$(basename "${SNAPSHOT_URL}") + SNAPSHOT_DIR=$(pwd) + logt "Download Snapshot from url: ${SNAPSHOT_URL}" + curl -o "${SNAPSHOT_FILENAME}" "${SNAPSHOT_URL}" + logt "Change to: ${DAEMON_HOME} and extract snapshot." + cd ${DAEMON_HOME} + tar xvf ${SNAPSHOT_DIR}/${SNAPSHOT_FILENAME} + logt " Cleanup Snapshot" + rm -rf ${SNAPSHOT_DIR}/${SNAPSHOT_FILENAME} + elif [ "${NETWORK}" == "athens3" ]; then + SNAPSHOT_URL=$(curl -s ${SNAPSHOT_API}/latest-snapshot?network=athens3 | jq .latest_snapshot) + SNAPSHOT_FILENAME=$(basename "${SNAPSHOT_URL}") + SNAPSHOT_DIR=$(pwd) + logt "Download Snapshot from url: ${SNAPSHOT_URL}" + curl -o "${SNAPSHOT_FILENAME}" "${SNAPSHOT_URL}" + logt "Change to: ${DAEMON_HOME} and extract snapshot." + cd ${DAEMON_HOME} + tar xvf ${SNAPSHOT_DIR}/${SNAPSHOT_FILENAME} + logt " Cleanup Snapshot" + rm -rf ${SNAPSHOT_DIR}/${SNAPSHOT_FILENAME} + fi + elif [ "${RESTORE_TYPE}" == "snapshot-archive" ]; then + if [ "${NETWORK}" == "mainnet" ]; then + logt "Get Latest Snapshot URL" + SNAPSHOT_URL=$(curl -s ${SNAPSHOT_API}/latest-archive-snapshot?network=mainnet | jq .latest_snapshot) + SNAPSHOT_FILENAME=$(basename "${SNAPSHOT_URL}") + SNAPSHOT_DIR=$(pwd) + logt "Download Snapshot from url: ${SNAPSHOT_URL}" + curl -o "${SNAPSHOT_FILENAME}" "${SNAPSHOT_URL}" + logt "Change to: ${DAEMON_HOME} and extract snapshot." + cd ${DAEMON_HOME} + tar xvf ${SNAPSHOT_DIR}/${SNAPSHOT_FILENAME} + logt " Cleanup Snapshot" + rm -rf ${SNAPSHOT_DIR}/${SNAPSHOT_FILENAME} + elif [ "${NETWORK}" == "athens3" ]; then + SNAPSHOT_URL=$(curl -s ${SNAPSHOT_API}/latest-archive-snapshot?network=athens3 | jq .latest_snapshot) + SNAPSHOT_FILENAME=$(basename "${SNAPSHOT_URL}") + SNAPSHOT_DIR=$(pwd) + logt "Download Snapshot from url: ${SNAPSHOT_URL}" + curl -o "${SNAPSHOT_FILENAME}" "${SNAPSHOT_URL}" + logt "Change to: ${DAEMON_HOME} and extract snapshot." + cd ${DAEMON_HOME} + tar xvf ${SNAPSHOT_DIR}/${SNAPSHOT_FILENAME} + logt " Cleanup Snapshot" + rm -rf ${SNAPSHOT_DIR}/${SNAPSHOT_FILENAME} + fi + else + logt "Initialize for Localnet." + fi +} + +function change_config_values { + if [ "${RESTORE_TYPE}" == "statesync" ]; then + export STATE_SYNC_SERVER="${STATE_SYNC_SERVER}" + export TRUST_HEIGHT=$(curl -s ${STATE_SYNC_SERVER}/block | jq -r '.result.block.header.height') + export HEIGHT=$((TRUST_HEIGHT-${TRUST_HEIGHT_DIFFERENCE_STATE_SYNC})) + export TRUST_HASH=$(curl -s "${STATE_SYNC_SERVER}/block?height=${HEIGHT}" | jq -r '.result.block_id.hash') + export RPC_STATE_SYNC_SERVERS="${RPC_STATE_SYNC_SERVERS}" + export EXTERNAL_IP=$(curl -4 icanhazip.com) + + logt "******* DEBUG STATE SYNC VALUES *******" + logt "STATE_SYNC_SERVER: ${STATE_SYNC_SERVER}" + logt "RPC_STATE_SYNC_SERVERS: ${RPC_STATE_SYNC_SERVERS}" + logt "TRUST_HEIGHT: ${TRUST_HEIGHT}" + logt "TRUST_HASH: ${TRUST_HASH}" + logt "HEIGHT: ${HEIGHT}" + logt "EXTERNAL_IP: ${EXTERNAL_IP}" + + logt "SED Change Config Files." + sed -i -e "s/^enable = .*/enable = \"true\"/" ${DAEMON_HOME}/config/config.toml + sed -i -e "s/^rpc_servers = .*/rpc_servers = \"${RPC_STATE_SYNC_SERVERS}\"/" ${DAEMON_HOME}/config/config.toml + sed -i -e "s/^trust_height = .*/trust_height = \"${HEIGHT}\"/" ${DAEMON_HOME}/config/config.toml + sed -i -e "s/^trust_hash = .*/trust_hash = \"${TRUST_HASH}\"/" ${DAEMON_HOME}/config/config.toml + sed -i -e "s/^moniker = .*/moniker = \"${MONIKER}\"/" ${DAEMON_HOME}/config/config.toml + sed -i -e "s/^external_address = .*/external_address = \"${EXTERNAL_IP}:26656\"/" ${DAEMON_HOME}/config/config.toml + else + export EXTERNAL_IP=$(curl -4 icanhazip.com) + logt "******* DEBUG STATE SYNC VALUES *******" + logt "EXTERNAL_IP: ${EXTERNAL_IP}" + logt "SED Change Config Files." + sed -i -e "s/^enable = .*/enable = \"true\"/" ${DAEMON_HOME}/config/config.toml + sed -i -e "s/^moniker = .*/moniker = \"${MONIKER}\"/" ${DAEMON_HOME}/config/config.toml + sed -i -e "s/^external_address = .*/external_address = \"${EXTERNAL_IP}:26656\"/" ${DAEMON_HOME}/config/config.toml + fi +} + +function setup_basic_keyring { + if ${DAEMON_NAME} keys show "$MONIKER" --keyring-backend test > /dev/null 2>&1; then + echo "Key $MONIKER already exists." + else + ${DAEMON_NAME} keys add "$MONIKER" --keyring-backend test + echo "Key $MONIKER created." + fi +} + +function install_dependencies { + apt-get update + apt-get install nano jq python3 -y + pip3 install requests +} + +function download_cosmovisor { + mkdir -p ${DAEMON_HOME}/cosmovisor/ + mkdir -p ${DAEMON_HOME}/cosmovisor/upgrades/ + python3 /scripts/install_cosmovisor.py +} + +function download_binary_version { + if [ "${NETWORK}" == "mainnet" ]; then + wget -q ${BINARY_LIST_MAINNET} + export DOWNLOAD_BINARIES=$(cat binary_list.json | tr -d '\n') + rm -rf binary_list.json + logt "BINARY_LIST: ${DOWNLOAD_BINARIES}" + elif [ "${NETWORK}" == "athens3" ]; then + wget -q ${BINARY_LIST_ATHENS3} + export DOWNLOAD_BINARIES=$(cat binary_list.json | tr -d '\n') + rm -rf binary_list.json + logt "BINARY_LIST: ${DOWNLOAD_BINARIES}" + fi + python3 /scripts/download_binaries.py +} + +function move_zetacored_binaries { + mkdir -p ${DAEMON_HOME}/cosmovisor || logt "Directory already exists ${DAEMON_HOME}/cosmovisor" + mkdir -p ${DAEMON_HOME}/cosmovisor/genesis || logt "Directory already exists ${DAEMON_HOME}/cosmovisor/genesis" + mkdir -p ${DAEMON_HOME}/cosmovisor/genesis/bin || logt "Directory already exists ${DAEMON_HOME}/cosmovisor/genesis/bin" + cp /usr/local/bin/zetacored ${DAEMON_HOME}/cosmovisor/genesis/bin/zetacored + + if [ "${RESTORE_TYPE}" == "statesync" ]; then + logt "Its statesync so cosmosvisor won't know which binary to start from so make sure it starts from the latest version reported in ABCI_INFO from statesync server rpc." + export VERSION_CHECK=$(curl -s ${STATE_SYNC_SERVER}/abci_info | jq -r '.result.response.version') + logt "CURRENT VERSION_CHECK: ${VERSION_CHECK}" + cp ${DAEMON_HOME}/cosmovisor/upgrades/v${VERSION_CHECK}/bin/zetacored ${DAEMON_HOME}/cosmovisor/genesis/bin/zetacored + fi +} + +function start_network { + ${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" +} + +function load_defaults { + #DEFAULT: Mainnet Statesync. + export DAEMON_HOME=${DAEMON_HOME:=/root/.zetacored} + export NETWORK=${NETWORK:=mainnet} + export RESTORE_TYPE=${RESTORE_TYPE:=statesync} + export SNAPSHOT_API=${SNAPSHOT_API:=https://snapshots.zetachain.com} + export TRUST_HEIGHT_DIFFERENCE_STATE_SYNC=${TRUST_HEIGHT_DIFFERENCE_STATE_SYNC:=40000} + export COSMOVISOR_VERSION=${COSMOVISOR_VERSION:=v1.5.0} + export CHAIN_ID=${CHAIN_ID:=zetachain_7000-1} + export COSMOVISOR_CHECKSUM=${COSMOVISOR_CHECKSUM:=626dfc58c266b85f84a7ed8e2fe0e2346c15be98cfb9f9b88576ba899ed78cdc} + export VISOR_NAME=${VISOR_NAME:=cosmovisor} + export DAEMON_NAME=${DAEMON_NAME:=zetacored} + export DAEMON_ALLOW_DOWNLOAD_BINARIES=${DAEMON_ALLOW_DOWNLOAD_BINARIES:=false} + export DAEMON_RESTART_AFTER_UPGRADE=${DAEMON_RESTART_AFTER_UPGRADE:=true} + export UNSAFE_SKIP_BACKUP=${UNSAFE_SKIP_BACKUP:=true} + export CLIENT_DAEMON_NAME=${CLIENT_DAEMON_NAME:=zetaclientd} + export CLIENT_DAEMON_ARGS=${CLIENT_DAEMON_ARGS:""} + export CLIENT_SKIP_UPGRADE=${CLIENT_SKIP_UPGRADE:=true} + export CLIENT_START_PROCESS=${CLIENT_START_PROCESS:=false} + export MONIKER=${MONIKER:=local-test} + export RE_DO_START_SEQUENCE=${RE_DO_START_SEQUENCE:=false} + + #ATHENS3 + export BINARY_LIST_ATHENS3=${BINARY_LIST_ATHENS3:=https://raw.githubusercontent.com/zeta-chain/network-config/main/athens3/binary_list.json} + export STATE_SYNC_RPC_NODE_FILE_ATHENS3=${STATE_SYNC_RPC_NODE_FILE_ATHENS3:=https://raw.githubusercontent.com/zeta-chain/network-config/main/athens3/state_sync_node} + export RPC_STATE_SYNC_RPC_LIST_FILE_ATHENS3=${RPC_STATE_SYNC_RPC_LIST_FILE_ATHENS3:=https://raw.githubusercontent.com/zeta-chain/network-config/main/athens3/rpc_state_sync_nodes} + export APP_TOML_FILE_ATHENS3=${APP_TOML_FILE_ATHENS3:=https://raw.githubusercontent.com/zeta-chain/network-config/main/athens3/app.toml} + export CONFIG_TOML_FILE_ATHENS3=${CONFIG_TOML_FILE_ATHENS3:=https://raw.githubusercontent.com/zeta-chain/network-config/main/athens3/config.toml} + export CLIENT_TOML_FILE_ATHENS3=${CLIENT_TOML_FILE_ATHENS3:=https://raw.githubusercontent.com/zeta-chain/network-config/main/athens3/client.toml} + export GENESIS_FILE_ATHENS3=${GENESIS_FILE_ATHENS3:=https://raw.githubusercontent.com/zeta-chain/network-config/main/athens3/genesis.json} + + #MAINNET + export BINARY_LIST_MAINNET=${BINARY_LIST_ATHENS3:=https://raw.githubusercontent.com/zeta-chain/network-config/main/mainnet/binary_list.json} + export STATE_SYNC_RPC_NODE_FILE_MAINNET=${STATE_SYNC_RPC_NODE_FILE_MAINNET:=https://raw.githubusercontent.com/zeta-chain/network-config/main/mainnet/state_sync_node} + export RPC_STATE_SYNC_RPC_LIST_FILE_MAINNET=${RPC_STATE_SYNC_RPC_LIST_FILE_MAINNET:=https://raw.githubusercontent.com/zeta-chain/network-config/main/mainnet/rpc_state_sync_nodes} + export APP_TOML_FILE_MAINNET=${APP_TOML_FILE_MAINNET:=https://raw.githubusercontent.com/zeta-chain/network-config/main/mainnet/app.toml} + export CONFIG_TOML_FILE_MAINNET=${CONFIG_TOML_FILE_MAINNET:=https://raw.githubusercontent.com/zeta-chain/network-config/main/mainnet/config.toml} + export CLIENT_TOML_FILE_MAINNET=${CLIENT_TOML_FILE_MAINNET:=https://raw.githubusercontent.com/zeta-chain/network-config/main/mainnet/client.toml} + export GENESIS_FILE_MAINNET=${GENESIS_FILE_MAINNET:=https://raw.githubusercontent.com/zeta-chain/network-config/main/mainnet/genesis.json} + +} + +logt "Load Default Values for ENV Vars if not set." +load_defaults + +if [[ -f "${DAEMON_HOME}/start_sequence_status" ]] && grep -q "START_SEQUENCE_COMPLETE" "${DAEMON_HOME}/start_sequence_status" && [[ "$RE_DO_START_SEQUENCE" != "true" ]]; then + logt "The start sequence is complete and no redo is required." + + if [ "${RESTORE_TYPE}" == "statesync" ]; then + logt "Setup Restore Type: ${RESTORE_TYPE}" + logt "During restarts, we re-do this to ensure to update the configs with valid values. When you call change config the stuff that gets set in this function for statesync needs to be set. Doesn't effect to re-set this." + setup_restore_type + fi + + logt "Modify Chain Configs" + change_config_values + + logt "Download Cosmosvisor." + download_cosmovisor + + logt "Move Zetacored Binaries." + move_zetacored_binaries + + logt "Start sequence has completed, echo into file so on restart it doesn't download snapshots again." + echo "START_SEQUENCE_COMPLETE" >> ${DAEMON_HOME}/start_sequence_status + + logt "Start Network" + start_network +else + logt "START_SEQUENCE_COMPLETE is not true, or RE_DO_START_SEQUENCE is set to true." + + if [[ "$RE_DO_START_SEQUENCE" == "true" ]]; then + logt "Clean any files that may exist in: ${DAEMON_HOME}" + rm -rf ${DAEMON_HOME}/* || logt "directory doesn't exist." + fi + + logt "Init Chain" + init_chain + + logt "Download Configs" + download_configs + + logt "Download Cosmovisor" + download_cosmovisor + + logt "Download Historical Binaries" + download_binary_version + + logt "Setup Restore Type: ${RESTORE_TYPE}" + setup_restore_type + + logt "Modify Chain Configs" + change_config_values + + logt "Move root binaries to current" + move_zetacored_binaries + + logt "Start sequence has completed, echo into file so on restart it doesn't download snapshots again." + echo "START_SEQUENCE_COMPLETE" >> ${DAEMON_HOME}/start_sequence_status + + logt "Start Network" + start_network +fi + diff --git a/contrib/local-mainnet/zetacored/configs/app.toml b/contrib/local-mainnet/zetacored/configs/app.toml deleted file mode 100644 index a91d81069f..0000000000 --- a/contrib/local-mainnet/zetacored/configs/app.toml +++ /dev/null @@ -1,77 +0,0 @@ -minimum-gas-prices = "10000000000azeta" -pruning = "nothing" -pruning-keep-recent = "0" -pruning-keep-every = "0" -pruning-interval = "0" -halt-height = 0 -halt-time = 0 -min-retain-blocks = 0 -inter-block-cache = true -index-events = [] -iavl-cache-size = 781250 -iavl-disable-fastnode = true - -[telemetry] -service-name = "tss" -enabled = true -enable-hostname = true -enable-hostname-label = true -enable-service-label = false -prometheus-retention-time = 10 -global-labels = [ ] - -[api] -enable = true -swagger = true -address = "tcp://0.0.0.0:1317" -max-open-connections = 1000 -rpc-read-timeout = 10 -rpc-write-timeout = 0 -rpc-max-body-bytes = 1000000 -enabled-unsafe-cors = false - -[rosetta] -enable = false -address = ":8080" -blockchain = "app" -network = "network" -retries = 3 -offline = false - -[grpc] -enable = true -address = "0.0.0.0:9090" - -[grpc-web] -enable = true -address = "127.0.0.1:9091" -enable-unsafe-cors = false - -[state-sync] -snapshot-interval = 0 -snapshot-keep-recent = 2 - -[evm] -tracer = "" -max-tx-gas-wanted = 0 - -[json-rpc] -enable = true -address = "0.0.0.0:8545" -ws-address = "0.0.0.0:8546" -api = "eth,net,web3,txpool,personal,debug" -gas-cap = 25000000 -evm-timeout = "5s" -txfee-cap = 1 -filter-cap = 200 -feehistory-cap = 100 -logs-cap = 10000 -block-range-cap = 10000 -http-timeout = "30s" -http-idle-timeout = "2m0s" -allow-unprotected-txs = false -max-open-connections = 0 -enable-indexer = false - -[tls] -certificate-path = "" diff --git a/contrib/local-mainnet/zetacored/configs/client.toml b/contrib/local-mainnet/zetacored/configs/client.toml deleted file mode 100644 index 1bb9cc28f8..0000000000 --- a/contrib/local-mainnet/zetacored/configs/client.toml +++ /dev/null @@ -1,5 +0,0 @@ -chain-id = "zetachain_7000-1" -keyring-backend = "test" -output = "text" -node = "tcp://localhost:26657" -broadcast-mode = "sync" \ No newline at end of file diff --git a/contrib/local-mainnet/zetacored/configs/config.toml b/contrib/local-mainnet/zetacored/configs/config.toml deleted file mode 100644 index 50611238fe..0000000000 --- a/contrib/local-mainnet/zetacored/configs/config.toml +++ /dev/null @@ -1,116 +0,0 @@ -proxy_app = "tcp://127.0.0.1:26658" -moniker = "main-rpc" -fast_sync = true -db_backend = "pebbledb" -db_dir = "data" -log_level = "info" -log_format = "plain" -genesis_file = "config/genesis.json" -priv_validator_key_file = "config/priv_validator_key.json" -priv_validator_state_file = "data/priv_validator_state.json" -priv_validator_laddr = "" -node_key_file = "config/node_key.json" -abci = "socket" -filter_peers = false - -[rpc] -laddr = "tcp://0.0.0.0:26657" -cors_allowed_origins = [] -cors_allowed_methods = ["HEAD", "GET", "POST", ] -cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time", ] -grpc_laddr = "" -grpc_max_open_connections = 900 -unsafe = false -max_open_connections = 900 -max_subscription_clients = 100 -max_subscriptions_per_client = 5 -experimental_subscription_buffer_size = 200 -experimental_websocket_write_buffer_size = 200 -experimental_close_on_slow_client = false -timeout_broadcast_tx_commit = "10s" -max_body_bytes = 1000000 -max_header_bytes = 1048576 -tls_cert_file = "" -tls_key_file = "" -pprof_laddr = "localhost:6060" - -[p2p] -laddr = "tcp://0.0.0.0:26656" -external_address = "72.19.172.89:26656" -seeds = "8d93468c6022fb3b263963bdea46b0a131d247cd@34.28.196.79:26656" -persistent_peers = "e04ee1d6b5cc1aa24f7c1ab55139d1cec9962e39@52.45.59.77:26656" -upnp = false -addr_book_file = "config/addrbook.json" -addr_book_strict = true -max_num_inbound_peers = 120 -max_num_outbound_peers = 60 -unconditional_peer_ids = "" -persistent_peers_max_dial_period = "0s" -flush_throttle_timeout = "100ms" -max_packet_msg_payload_size = 1024 -send_rate = 5120000 -recv_rate = 5120000 -pex = true -seed_mode = false -private_peer_ids = "" -allow_duplicate_ip = true -handshake_timeout = "20s" -dial_timeout = "3s" - -[mempool] -version = "v0" -recheck = true -broadcast = true -wal_dir = "" - -size = 5000 -max_txs_bytes = 1073741824 -cache_size = 10000 -keep-invalid-txs-in-cache = false -max_tx_bytes = 1048576 -max_batch_bytes = 0 -ttl-duration = "0s" -ttl-num-blocks = 0 - -[statesync] -enable = "true" -rpc_servers = "34.69.20.168:26657,34.69.20.168:26657" -trust_height = "1721170" -trust_hash = "249AF38ABF9934F8D8CCFCEAA46997AB30C1F6AD14E1C70183B2CE7B16485B2C" -trust_period = "168h0m0s" -discovery_time = "15s" -temp_dir = "" -chunk_request_timeout = "10s" -chunk_fetchers = "4" - -[fastsync] -version = "v0" - -[consensus] -wal_file = "data/cs.wal/wal" -timeout_propose = "3s" -timeout_propose_delta = "500ms" -timeout_prevote = "1s" -timeout_prevote_delta = "500ms" -timeout_precommit = "1s" -timeout_precommit_delta = "500ms" -timeout_commit = "5s" -double_sign_check_height = 0 -skip_timeout_commit = false -create_empty_blocks = true -create_empty_blocks_interval = "0s" -peer_gossip_sleep_duration = "100ms" -peer_query_maj23_sleep_duration = "2s" - -[storage] -discard_abci_responses = false - -[tx_index] -indexer = "kv" -psql-conn = "" - -[instrumentation] -prometheus = true -prometheus_listen_addr = ":26660" -max_open_connections = 3 -namespace = "tendermint" diff --git a/contrib/local-mainnet/zetacored/configs/genesis.json b/contrib/local-mainnet/zetacored/configs/genesis.json deleted file mode 100644 index 9a38f691bf..0000000000 --- a/contrib/local-mainnet/zetacored/configs/genesis.json +++ /dev/null @@ -1,1036 +0,0 @@ -{ - "genesis_time": "2023-10-19T19:00:00Z", - "chain_id": "zetachain_7000-1", - "initial_height": "1", - "consensus_params": { - "block": { - "max_bytes": "22020096", - "max_gas": "10000000", - "time_iota_ms": "1000" - }, - "evidence": { - "max_age_num_blocks": "100000", - "max_age_duration": "172800000000000", - "max_bytes": "1048576" - }, - "validator": { - "pub_key_types": [ - "ed25519" - ] - }, - "version": {} - }, - "app_hash": "", - "app_state": { - "auth": { - "params": { - "max_memo_characters": "256", - "tx_sig_limit": "7", - "tx_size_cost_per_byte": "10", - "sig_verify_cost_ed25519": "590", - "sig_verify_cost_secp256k1": "1000" - }, - "accounts": [ - { - "@type": "/ethermint.types.v1.EthAccount", - "base_account": { - "address": "zeta1hjct6q7npsspsg3dgvzk3sdf89spmlpf7rqmnw", - "pub_key": null, - "account_number": "0", - "sequence": "0" - }, - "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" - }, - { - "@type": "/ethermint.types.v1.EthAccount", - "base_account": { - "address": "zeta1p0uwsq4naus5r4l7l744upy0k8ezzj84mn40nf", - "pub_key": null, - "account_number": "0", - "sequence": "0" - }, - "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" - }, - { - "@type": "/ethermint.types.v1.EthAccount", - "base_account": { - "address": "zeta1l07weaxkmn6z69qm55t53v4rfr43eys4cjz54h", - "pub_key": null, - "account_number": "0", - "sequence": "0" - }, - "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" - }, - { - "@type": "/ethermint.types.v1.EthAccount", - "base_account": { - "address": "zeta1t5pgk2fucx3drkynzew9zln5z9r7s3wqqyy0pe", - "pub_key": null, - "account_number": "0", - "sequence": "0" - }, - "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" - }, - { - "@type": "/ethermint.types.v1.EthAccount", - "base_account": { - "address": "zeta1t0uj2z93jd2g3w94zl3jhfrn2ek6dnuk3v93j9", - "pub_key": null, - "account_number": "0", - "sequence": "0" - }, - "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" - }, - { - "@type": "/ethermint.types.v1.EthAccount", - "base_account": { - "address": "zeta1k6vh9y7ctn06pu5jngznv5dyy0rltl2qp0j30g", - "pub_key": null, - "account_number": "0", - "sequence": "0" - }, - "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" - }, - { - "@type": "/ethermint.types.v1.EthAccount", - "base_account": { - "address": "zeta19jr7nl82lrktge35f52x9g5y5prmvchmk40zhg", - "pub_key": null, - "account_number": "0", - "sequence": "0" - }, - "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" - }, - { - "@type": "/ethermint.types.v1.EthAccount", - "base_account": { - "address": "zeta1cxj07f3ju484ry2cnnhxl5tryyex7gev0yzxtj", - "pub_key": null, - "account_number": "0", - "sequence": "0" - }, - "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" - }, - { - "@type": "/ethermint.types.v1.EthAccount", - "base_account": { - "address": "zeta1v66xndg92tkt9ay70yyj3udaq0ej9wl765r7lf", - "pub_key": null, - "account_number": "0", - "sequence": "0" - }, - "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" - } - ] - }, - "authz": { - "authorization": [] - }, - "bank": { - "params": { - "send_enabled": [], - "default_send_enabled": false - }, - "balances": [ - { - "address": "zeta1p0uwsq4naus5r4l7l744upy0k8ezzj84mn40nf", - "coins": [ - { - "denom": "azeta", - "amount": "20000000000000000000" - } - ] - }, - { - "address": "zeta19jr7nl82lrktge35f52x9g5y5prmvchmk40zhg", - "coins": [ - { - "denom": "azeta", - "amount": "50000000000000000000" - } - ] - }, - { - "address": "zeta1t0uj2z93jd2g3w94zl3jhfrn2ek6dnuk3v93j9", - "coins": [ - { - "denom": "azeta", - "amount": "20000000000000000000" - } - ] - }, - { - "address": "zeta1t5pgk2fucx3drkynzew9zln5z9r7s3wqqyy0pe", - "coins": [ - { - "denom": "azeta", - "amount": "20000000000000000000" - } - ] - }, - { - "address": "zeta1v66xndg92tkt9ay70yyj3udaq0ej9wl765r7lf", - "coins": [ - { - "denom": "azeta", - "amount": "50000000000000000000" - } - ] - }, - { - "address": "zeta1k6vh9y7ctn06pu5jngznv5dyy0rltl2qp0j30g", - "coins": [ - { - "denom": "azeta", - "amount": "50000000000000000000" - } - ] - }, - { - "address": "zeta1hjct6q7npsspsg3dgvzk3sdf89spmlpf7rqmnw", - "coins": [ - { - "denom": "azeta", - "amount": "20000000000000000000" - } - ] - }, - { - "address": "zeta1cxj07f3ju484ry2cnnhxl5tryyex7gev0yzxtj", - "coins": [ - { - "denom": "azeta", - "amount": "50000000000000000000" - } - ] - }, - { - "address": "zeta1l07weaxkmn6z69qm55t53v4rfr43eys4cjz54h", - "coins": [ - { - "denom": "azeta", - "amount": "20000000000000000000" - } - ] - } - ], - "supply": [ - { - "denom": "azeta", - "amount": "300000000000000000000" - } - ], - "denom_metadata": [ - { - "description": "The native token of ZetaChain", - "denom_units": [ - { - "denom": "azeta", - "exponent": 0, - "aliases": [ - "attozeta" - ] - }, - { - "denom": "zeta", - "exponent": 18, - "aliases": [] - } - ], - "base": "azeta", - "display": "zeta", - "name": "ZetaChain", - "symbol": "ZETA", - "uri": "", - "uri_hash": "" - } - ] - }, - "crisis": { - "constant_fee": { - "denom": "azeta", - "amount": "1000" - } - }, - "crosschain": { - "params": { - "enabled": false - }, - "outTxTrackerList": [], - "tss": null, - "gasPriceList": [], - "chainNoncesList": [], - "CrossChainTxs": [], - "lastBlockHeightList": [], - "inTxHashToCctxList": [], - "tss_history": [] - }, - "distribution": { - "params": { - "community_tax": "0.0", - "base_proposer_reward": "0.010000000000000000", - "bonus_proposer_reward": "0.040000000000000000", - "withdraw_addr_enabled": true - }, - "fee_pool": { - "community_pool": [] - }, - "delegator_withdraw_infos": [], - "previous_proposer": "", - "outstanding_rewards": [], - "validator_accumulated_commissions": [], - "validator_historical_rewards": [], - "validator_current_rewards": [], - "delegator_starting_infos": [], - "validator_slash_events": [] - }, - "emissions": { - "params": { - "max_bond_factor": "1.25", - "min_bond_factor": "0.75", - "avg_block_time": "6.00", - "target_bond_ratio": "00.67", - "validator_emission_percentage": "0.75", - "observer_emission_percentage": "0.125", - "tss_signer_emission_percentage": "0.125", - "duration_factor_constant": "0.001877876953694702", - "observer_slash_amount": "100000000000000000" - }, - "withdrawableEmissions": [] - }, - "evidence": { - "evidence": [] - }, - "evm": { - "accounts": [], - "params": { - "evm_denom": "azeta", - "enable_create": true, - "enable_call": true, - "extra_eips": [], - "chain_config": { - "homestead_block": "0", - "dao_fork_block": "0", - "dao_fork_support": true, - "eip150_block": "0", - "eip150_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "eip155_block": "0", - "eip158_block": "0", - "byzantium_block": "0", - "constantinople_block": "0", - "petersburg_block": "0", - "istanbul_block": "0", - "muir_glacier_block": "0", - "berlin_block": "0", - "london_block": "0", - "arrow_glacier_block": "0", - "gray_glacier_block": "0", - "merge_netsplit_block": "0", - "shanghai_block": "0", - "cancun_block": "0" - }, - "allow_unprotected_txs": false - } - }, - "feemarket": { - "params": { - "no_base_fee": false, - "base_fee_change_denominator": 8, - "elasticity_multiplier": 2, - "enable_height": "0", - "base_fee": "1000000000", - "min_gas_price": "0.000000000000000000", - "min_gas_multiplier": "0.500000000000000000" - }, - "block_gas": "0" - }, - "fungible": { - "params": {}, - "foreignCoinsList": [], - "systemContract": null - }, - "genutil": { - "gen_txs": [ - { - "body": { - "messages": [ - { - "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", - "description": { - "moniker": "Blockdaemon", - "identity": "", - "website": "blockdaemon.com", - "security_contact": "support@blockdaemon.com", - "details": "" - }, - "commission": { - "rate": "0.100000000000000000", - "max_rate": "0.200000000000000000", - "max_change_rate": "0.010000000000000000" - }, - "min_self_delegation": "1", - "delegator_address": "zeta1t5pgk2fucx3drkynzew9zln5z9r7s3wqqyy0pe", - "validator_address": "zetavaloper1t5pgk2fucx3drkynzew9zln5z9r7s3wqyyunv0", - "pubkey": { - "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "DUKST69tW93h1OSZKQyNNQG1DnZoeY/XDfFuz0te0yg=" - }, - "value": { - "denom": "azeta", - "amount": "10000000000000000000" - } - } - ], - "memo": "c692e280a93124c678de1748914b146cf6210363@172.17.0.7:26656", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": { - "@type": "/ethermint.crypto.v1.ethsecp256k1.PubKey", - "key": "Ajsf++7EyYAUl4ZntfDhy7nHlXvm3hDDL0MKVwmoJ9z6" - }, - "mode_info": { - "single": { - "mode": "SIGN_MODE_DIRECT" - } - }, - "sequence": "0" - } - ], - "fee": { - "amount": [], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [ - "D6on5wk8WteTfxlyXkREw4fnnBSeiwFqRCDyMoH1y15fQ+AWW4szXf6SpWn5USbUNkMLPkM4s7mpD9D/mx6upgA=" - ] - }, - { - "body": { - "messages": [ - { - "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", - "description": { - "moniker": "Figment", - "identity": "E5F274B870BDA01D", - "website": "https://figment.io", - "security_contact": "security@figment.io", - "details": "Figment" - }, - "commission": { - "rate": "0.100000000000000000", - "max_rate": "1.000000000000000000", - "max_change_rate": "1.000000000000000000" - }, - "min_self_delegation": "1", - "delegator_address": "zeta1hjct6q7npsspsg3dgvzk3sdf89spmlpf7rqmnw", - "validator_address": "zetavaloper1hjct6q7npsspsg3dgvzk3sdf89spmlpf6rc87c", - "pubkey": { - "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "4P7Gx9WWjk+pYDe9jO/+njjlf5jMEoafwM3SQBj//pI=" - }, - "value": { - "denom": "azeta", - "amount": "10000000000000000000" - } - } - ], - "memo": "3ad52e6da939646c52533390b6e21fc988d12c9d@192.168.2.112:26656", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": { - "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "A/ME5Wre92HJOJH4wBFveSeq3Yj8wZJrn/pEWc3pcrSc" - }, - "mode_info": { - "single": { - "mode": "SIGN_MODE_LEGACY_AMINO_JSON" - } - }, - "sequence": "0" - } - ], - "fee": { - "amount": [], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [ - "gA6rkVoGWvcUhXeuPR+SL3ZylNGrQ92wBcy9nFpqBz5wG9bVvC5OsKVUnxMy0pBWRw98iHU+TkWpQsEOC31PKg==" - ] - }, - { - "body": { - "messages": [ - { - "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", - "description": { - "moniker": "InfStones", - "identity": "", - "website": "", - "security_contact": "", - "details": "" - }, - "commission": { - "rate": "0.100000000000000000", - "max_rate": "0.200000000000000000", - "max_change_rate": "0.010000000000000000" - }, - "min_self_delegation": "1", - "delegator_address": "zeta1t0uj2z93jd2g3w94zl3jhfrn2ek6dnuk3v93j9", - "validator_address": "zetavaloper1t0uj2z93jd2g3w94zl3jhfrn2ek6dnuk4vadln", - "pubkey": { - "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "/YSea9QT51BaUh2g/xzXpghOUui/yTYtBETHwR+/1Zg=" - }, - "value": { - "denom": "azeta", - "amount": "10000000000000000000" - } - } - ], - "memo": "d2674e8511c312a67f6826898480d1a7079d0f25@172.0.2.219:26656", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": { - "@type": "/ethermint.crypto.v1.ethsecp256k1.PubKey", - "key": "A6qTNepZbDodLk2Z0y77CHRn4A/YoVJxUeEgJtRtMlzJ" - }, - "mode_info": { - "single": { - "mode": "SIGN_MODE_DIRECT" - } - }, - "sequence": "0" - } - ], - "fee": { - "amount": [], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [ - "GDST6l1b2qM2AVQxGBgQ9BkGmbqh+55IRdnhqYPXpRFQAeGWB7ZtGFa1JXokvGxHQgebYdvsRl1/a6LMj5pkfgE=" - ] - }, - { - "body": { - "messages": [ - { - "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", - "description": { - "moniker": "bastion-2", - "identity": "", - "website": "https://bastiondigital.com/", - "security_contact": "security@bastiondigital.com", - "details": "" - }, - "commission": { - "rate": "0.100000000000000000", - "max_rate": "0.200000000000000000", - "max_change_rate": "0.010000000000000000" - }, - "min_self_delegation": "1", - "delegator_address": "zeta1l07weaxkmn6z69qm55t53v4rfr43eys4cjz54h", - "validator_address": "zetavaloper1l07weaxkmn6z69qm55t53v4rfr43eys4uj6gcp", - "pubkey": { - "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "/KKLqTvG+NsmHcKmPzXHKCscGmuNxTGfQ3WVdMOgOC0=" - }, - "value": { - "denom": "azeta", - "amount": "10000000000000000000" - } - } - ], - "memo": "c37f642698260707c0e25a8895f9d36735318ef3@172.31.57.153:26656", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": { - "@type": "/ethermint.crypto.v1.ethsecp256k1.PubKey", - "key": "ArsnYUKbYMRVuXZTtU2ApmRfU+y7/IF0fXjYr5VtWG0W" - }, - "mode_info": { - "single": { - "mode": "SIGN_MODE_DIRECT" - } - }, - "sequence": "0" - } - ], - "fee": { - "amount": [], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [ - "P1FY9Xalsue3TQz7oZStxxzexjM8LjQD10xcHsJJcdlX/toL1n2Muj/Prz9h8306KQrTkK3yexEjElxxy9WM2gA=" - ] - }, - { - "body": { - "messages": [ - { - "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", - "description": { - "moniker": "bastion", - "identity": "", - "website": "https://bastiondigital.com/", - "security_contact": "security@bastiondigital.com", - "details": "" - }, - "commission": { - "rate": "0.100000000000000000", - "max_rate": "0.200000000000000000", - "max_change_rate": "0.010000000000000000" - }, - "min_self_delegation": "1", - "delegator_address": "zeta1p0uwsq4naus5r4l7l744upy0k8ezzj84mn40nf", - "validator_address": "zetavaloper1p0uwsq4naus5r4l7l744upy0k8ezzj84lndn7l", - "pubkey": { - "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "4OBmT48Oox4IC+lyvsw5WrDTrY8+ntQ1FwkIlbZ1TtI=" - }, - "value": { - "denom": "azeta", - "amount": "10000000000000000000" - } - } - ], - "memo": "01de75368e56b38fc27a22c07236d50319ed129d@172.31.48.193:26656", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": { - "@type": "/ethermint.crypto.v1.ethsecp256k1.PubKey", - "key": "AyVhi69idWFuCGiJxsYHZ2IB4U/M64i7Q602PEVzZpNo" - }, - "mode_info": { - "single": { - "mode": "SIGN_MODE_DIRECT" - } - }, - "sequence": "0" - } - ], - "fee": { - "amount": [], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [ - "x91CvYs0ySWDZs7DvXnLN6SI06SBa+2LqL0d/BDJWtYdZ0ce8nwiBn54jMQqkCbjrqmsnhGH5c3g2bjtu2zhBwA=" - ] - }, - { - "body": { - "messages": [ - { - "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", - "description": { - "moniker": "MP1", - "identity": "", - "website": "", - "security_contact": "", - "details": "" - }, - "commission": { - "rate": "0.100000000000000000", - "max_rate": "0.200000000000000000", - "max_change_rate": "0.010000000000000000" - }, - "min_self_delegation": "1", - "delegator_address": "zeta1cxj07f3ju484ry2cnnhxl5tryyex7gev0yzxtj", - "validator_address": "zetavaloper1cxj07f3ju484ry2cnnhxl5tryyex7gevty66xy", - "pubkey": { - "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "DsZWn+sZ93S1B4G3mNb2a1V8akbmCWLysqQ3XaQjctc=" - }, - "value": { - "denom": "azeta", - "amount": "10000000000000000000" - } - } - ], - "memo": "7069d3e30752526ab512b43cdd7aca1012d9a142@52.35.128.130:26656", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": { - "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "Atnv3L9LKUn+uhJQSKz159H7T3Ip8BAJyoiK4/ABSUNz" - }, - "mode_info": { - "single": { - "mode": "SIGN_MODE_LEGACY_AMINO_JSON" - } - }, - "sequence": "0" - } - ], - "fee": { - "amount": [], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [ - "sffe9xziD6vesvv5bib7kD+UGYUIwjNx1PuA/PyfioEuUEYaCPfuz7aWD0cTNp5XEMm5nXjnDqYomB5iA7ucdw==" - ] - }, - { - "body": { - "messages": [ - { - "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", - "description": { - "moniker": "MP4", - "identity": "", - "website": "", - "security_contact": "", - "details": "" - }, - "commission": { - "rate": "0.100000000000000000", - "max_rate": "0.200000000000000000", - "max_change_rate": "0.010000000000000000" - }, - "min_self_delegation": "1", - "delegator_address": "zeta1v66xndg92tkt9ay70yyj3udaq0ej9wl765r7lf", - "validator_address": "zetavaloper1v66xndg92tkt9ay70yyj3udaq0ej9wl775mzjl", - "pubkey": { - "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "4pZgiUYPEW5o7UTc9QxE5rsXQ3uQqbTPVSjbzXJrLGM=" - }, - "value": { - "denom": "azeta", - "amount": "20000000000000000000" - } - } - ], - "memo": "4d7a52d68af698c296211dec34a26cddefeb0b06@44.236.207.180:26656", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": { - "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "A033XHSNuUwe0gA1GehbAN8G+lvz9zEFFEMOtMPac1gm" - }, - "mode_info": { - "single": { - "mode": "SIGN_MODE_LEGACY_AMINO_JSON" - } - }, - "sequence": "0" - } - ], - "fee": { - "amount": [], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [ - "eWLHyIM4yxOdDJWmdg6JoGAeZoST/5p/orkFtbt1Y28+Qi8yUpCUy3J+Tmh6Tq0kt2qyURzUQru75m3QGBRoAA==" - ] - }, - { - "body": { - "messages": [ - { - "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", - "description": { - "moniker": "OmniChain1", - "identity": "", - "website": "", - "security_contact": "", - "details": "" - }, - "commission": { - "rate": "0.100000000000000000", - "max_rate": "0.200000000000000000", - "max_change_rate": "0.010000000000000000" - }, - "min_self_delegation": "1", - "delegator_address": "zeta1k6vh9y7ctn06pu5jngznv5dyy0rltl2qp0j30g", - "validator_address": "zetavaloper1k6vh9y7ctn06pu5jngznv5dyy0rltl2q902dz7", - "pubkey": { - "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "P7Wpyskb7H1ybAGX6DZbjjOztuBfVqf7DkuPiyy5x6Q=" - }, - "value": { - "denom": "azeta", - "amount": "20000000000000000000" - } - } - ], - "memo": "d32b3e22cfcb72e11050db30a59a59cd05646046@34.225.36.174:26656", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": { - "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "AkaccaPHHvcOgOOo9lmsYHpS2d0UibouaY40mI7G3IaW" - }, - "mode_info": { - "single": { - "mode": "SIGN_MODE_LEGACY_AMINO_JSON" - } - }, - "sequence": "0" - } - ], - "fee": { - "amount": [], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [ - "gHJ25zQvJr4fdPi4/IS1DzyV1cSmfGVJfVIjL9X8lI8ZXMbB73FSFukC7yPq1ghxlsSyq3vK32zVIIjEfcGsLA==" - ] - }, - { - "body": { - "messages": [ - { - "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", - "description": { - "moniker": "OmniChain2", - "identity": "", - "website": "", - "security_contact": "", - "details": "" - }, - "commission": { - "rate": "0.100000000000000000", - "max_rate": "0.200000000000000000", - "max_change_rate": "0.010000000000000000" - }, - "min_self_delegation": "1", - "delegator_address": "zeta19jr7nl82lrktge35f52x9g5y5prmvchmk40zhg", - "validator_address": "zetavaloper19jr7nl82lrktge35f52x9g5y5prmvchmj4h767", - "pubkey": { - "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "XMwY/ubWmBihvwta4i6BoKp6j+L8HkpfBEiedXAkBEI=" - }, - "value": { - "denom": "azeta", - "amount": "20000000000000000000" - } - } - ], - "memo": "e04ee1d6b5cc1aa24f7c1ab55139d1cec9962e39@52.45.59.77:26656", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": { - "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "Ag3Ki+x4fR1/Rw38S4CizA73rf5g24PDoDCpbaBbTYSM" - }, - "mode_info": { - "single": { - "mode": "SIGN_MODE_LEGACY_AMINO_JSON" - } - }, - "sequence": "0" - } - ], - "fee": { - "amount": [], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [ - "UPcQ92gSdeAjF438vN8E+W6HbqE9EimprQTMOiBCgyURI0DVD4SlyHaJyWJsaXzwNW0bWkWpWwA0pje366KQUg==" - ] - } - ] - }, - "gov": { - "starting_proposal_id": "1", - "deposits": [], - "votes": [], - "proposals": [], - "deposit_params": { - "min_deposit": [ - { - "denom": "azeta", - "amount": "100000000000000000" - } - ], - "max_deposit_period": "1209600s" - }, - "voting_params": { - "voting_period": "86400s" - }, - "tally_params": { - "quorum": "0.4", - "threshold": "0.500000000000000000", - "veto_threshold": "0.334000000000000000" - } - }, - "group": { - "group_seq": "0", - "groups": [], - "group_members": [], - "group_policy_seq": "0", - "group_policies": [], - "proposal_seq": "0", - "proposals": [], - "votes": [] - }, - "mint": { - "params": { - "mint_denom": "azeta" - } - }, - "observer": { - "ballots": [], - "observers": [], - "nodeAccountList": [], - "crosschain_flags": { - "isInboundEnabled": true, - "isOutboundEnabled": true, - "gasPriceIncreaseFlags": null - }, - "params": { - "observer_params": [ - { - "chain": { - "chain_name": "btc_mainnet", - "chain_id": "8332" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "1000000000000000000.000000000000000000", - "is_supported": true - }, - { - "chain": { - "chain_name": "bsc_mainnet", - "chain_id": "56" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "1000000000000000000.000000000000000000", - "is_supported": true - }, - { - "chain": { - "chain_name": "eth_mainnet", - "chain_id": "1" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "1000000000000000000.000000000000000000", - "is_supported": true - } - ], - "admin_policy": [], - "ballot_maturity_blocks": "100" - }, - "keygen": { - "status": "PendingKeygen", - "granteePubkeys": [], - "blockNumber": "9223372036854775807" - }, - "last_observer_count": null, - "core_params_list": { - "core_params": [] - } - }, - "params": null, - "slashing": { - "params": { - "signed_blocks_window": "5000", - "min_signed_per_window": "0.500000000000000000", - "downtime_jail_duration": "600s", - "slash_fraction_double_sign": "0.050000000000000000", - "slash_fraction_downtime": "0.010000000000000000" - }, - "signing_infos": [], - "missed_blocks": [] - }, - "staking": { - "params": { - "unbonding_time": "1814400s", - "max_validators": 125, - "max_entries": 7, - "historical_entries": 10000, - "bond_denom": "azeta", - "min_commission_rate": "0.05" - }, - "last_total_power": "0", - "last_validator_powers": [], - "validators": [], - "delegations": [], - "unbonding_delegations": [], - "redelegations": [], - "exported": false - }, - "upgrade": {}, - "vesting": {} - } -} diff --git a/contrib/local-mainnet/zetacored/configs/start.sh b/contrib/local-mainnet/zetacored/configs/start.sh deleted file mode 100644 index f17883ef77..0000000000 --- a/contrib/local-mainnet/zetacored/configs/start.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash - -function logt(){ - echo "$(date) - $1" -} - -function download_binary() { - wget https://github.com/zeta-chain/node/releases/download/${BINARY_VERSION}/zetacored-darwin-amd64 -O /usr/local/bin/zetacored - chmod a+x /usr/local/bin/zetacored - zetacored version || echo "BINARY NOT INSTALLED" && exit 1 -} - -function chain_init() { - ZETACORED_DIR="$HOME/.zetacored" - # Check if the .zetacored directory exists - if [ -d "$ZETACORED_DIR" ]; then - echo ".zetacored directory already exists at $ZETACORED_DIR." - else - # Directory does not exist, initialize zetacored - zetacored init "$MONIKER" --chain-id "$CHAIN_ID" - echo ".zetacored initialized for $MONIKER with chain ID $CHAIN_ID." - fi -} - -function modify_chain_configs() { - sed -i -e "s/^enable = .*/enable = \"true\"/" /root/.zetacored/config/config.toml - sed -i -e "s/^rpc_servers = .*/rpc_servers = \"${RPC_STATE_SYNC_SERVERS}\"/" /root/.zetacored/config/config.toml - sed -i -e "s/^trust_height = .*/trust_height = \"${HEIGHT}\"/" /root/.zetacored/config/config.toml - sed -i -e "s/^trust_hash = .*/trust_hash = \"${TRUST_HASH}\"/" /root/.zetacored/config/config.toml - sed -i -e "s/^moniker = .*/moniker = \"${MONIKER}\"/" /root/.zetacored/config/config.toml - sed -i -e "s/^external_address = .*/external_address = \"${EXTERNAL_IP}:26656\"/" /root/.zetacored/config/config.toml - sed -i -e "s/^seeds = .*/seeds = \"${SEED}\"/" /root/.zetacored/config/config.toml - sed -i -e 's/^max_num_inbound_peers = .*/max_num_inbound_peers = 120/' /root/.zetacored/config/config.toml - sed -i -e 's/^max_num_outbound_peers = .*/max_num_outbound_peers = 60/' /root/.zetacored/config/config.toml - sed -i -e "s/^persistent_peers = .*/persistent_peers = \"${PERSISTENT_PEERS}\"/" /root/.zetacored/config/config.toml -} - -function setup_basic_keyring() { - if zetacored keys show "$MONIKER" --keyring-backend test > /dev/null 2>&1; then - echo "Key $MONIKER already exists." - else - zetacored keys add "$MONIKER" --keyring-backend test - echo "Key $MONIKER created." - fi -} - -function start_network() { - zetacored start --home /root/.zetacored/ \ - --log_level info \ - --moniker ${MONIKER} \ - --rpc.laddr tcp://0.0.0.0:26657 \ - --minimum-gas-prices 1.0azeta "--grpc.enable=true" -} - -function install_dependencies() { - apt-get update - apt-get install nano jq -y -} - -function check_configs_debug() { - logt "Check home config directory ensure configs present." - ls -lah /root/.zetacored/config - - logt "Check the zetacored binary is in /usr/local/bin" - ls -lah /usr/local/bin/ - - logt "Check zetacored root directory" - ls -lah /root/.zetacored - - logt "Config.toml" - cat /root/.zetacored/config/config.toml - logt "******" - - logt "Config.toml" - cat /root/.zetacored/config/app.toml - logt "******" - - logt "Config.toml" - cat /root/.zetacored/config/client.toml - logt "******" - - logt "Config.toml" - cat /root/.zetacored/config/genesis.json - logt "******" -} - -logt "Install Dependencies" -install_dependencies - -if [ "${DEBUG}" == "true" ]; then - check_configs_debug -fi - -logt "Setup script variables." -export STATE_SYNC_SERVER="${STATE_SYNC_SERVER}" -export TRUST_HEIGHT=$(curl -s http://${STATE_SYNC_SERVER}/block | jq -r '.result.block.header.height') -export HEIGHT=$((TRUST_HEIGHT-40000)) -export TRUST_HASH=$(curl -s "http://${STATE_SYNC_SERVER}/block?height=${HEIGHT}" | jq -r '.result.block_id.hash') -export RPC_STATE_SYNC_SERVERS="${RPC_STATE_SYNC_SERVERS}" -export SEED="${SEED_NODE}" -export PERSISTENT_PEERS="${PEERS}" -export EXTERNAL_IP=$(curl -4 icanhazip.com) - -if [ "$DOWNLOAD_BINARY" = true ]; then - logt "Download chain binary" - download_binary -else - logt "User built binary." -fi - -logt "Init the chain directory" -chain_init - -logt "Modify chain configs." -modify_chain_configs - -if [ "${DEBUG}" == "true" ]; then - check_configs_debug -fi - -logt "Start network" -start_network diff --git a/contrib/local-mainnet/zetacored/docker-compose.yml b/contrib/local-mainnet/zetacored/docker-compose.yml deleted file mode 100644 index 8425726517..0000000000 --- a/contrib/local-mainnet/zetacored/docker-compose.yml +++ /dev/null @@ -1,36 +0,0 @@ -version: '3.8' -services: - zetachain_mainnet_rpc: - platform: linux/amd64 - #This will build the binary from the GIT_REF you are locally on. - build: - context: ../.. - dockerfile: Dockerfile - #If you want to use the pre-built docker images you would comment out Build lines, and uncomment this line with the correct docker tag. - #image: zetachain/zeatcored:ubuntu-{CURRENT_RELEASE_VERSION} - container_name: zetachain_mainnet_rpc - environment: - CHAIN_ID: "zetachain_7000-1" - BINARY_VERSION: "N/A" - MONIKER: "main-rpc" - STATE_SYNC_SERVER: "34.69.20.168:26657" - RPC_STATE_SYNC_SERVERS: "34.69.20.168:26657,34.69.20.168:26657" - SEED_NODE: "8d93468c6022fb3b263963bdea46b0a131d247cd@34.28.196.79:26656" - PEERS: "e04ee1d6b5cc1aa24f7c1ab55139d1cec9962e39@52.45.59.77:26656" - DOWNLOAD_BINARY: "false" - DEBUG: "true" - ports: - - "26656:26656" - - "1317:1317" - - "8545:8545" - - "8546:8546" - - "26657:26657" - - "9090:9090" - - "9091:9091" - volumes: - - ./configs:/root/.zetacored/config - - zetacored_data:/root/.zetacored/data - entrypoint: bash /root/.zetacored/config/start.sh - -volumes: - zetacored_data: diff --git a/contrib/localnet/docker-compose-stresstest.yml b/contrib/localnet/docker-compose-stresstest.yml index 07cb1820f4..b8d65cdf6c 100644 --- a/contrib/localnet/docker-compose-stresstest.yml +++ b/contrib/localnet/docker-compose-stresstest.yml @@ -11,7 +11,7 @@ services: container_name: zetacore0 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetacore0 ports: - "1317:1317" @@ -29,7 +29,7 @@ services: container_name: zetacore1 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetacore1 networks: mynetwork: @@ -43,7 +43,7 @@ services: container_name: zetacore2 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetacore2 networks: mynetwork: @@ -57,7 +57,7 @@ services: container_name: zetacore3 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetacore3 networks: mynetwork: @@ -71,7 +71,7 @@ services: container_name: zetaclient0 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetaclient0 networks: mynetwork: @@ -88,7 +88,7 @@ services: container_name: zetaclient1 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetaclient1 networks: mynetwork: @@ -103,7 +103,7 @@ services: container_name: zetaclient2 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetaclient2 networks: mynetwork: @@ -118,7 +118,7 @@ services: container_name: zetaclient3 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetaclient3 networks: mynetwork: diff --git a/contrib/localnet/docker-compose-upgrade.yml b/contrib/localnet/docker-compose-upgrade.yml index c55f847e43..6f02feff70 100644 --- a/contrib/localnet/docker-compose-upgrade.yml +++ b/contrib/localnet/docker-compose-upgrade.yml @@ -11,7 +11,7 @@ services: container_name: zetacore0 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetacore0 ports: - "1317:1317" @@ -29,7 +29,7 @@ services: container_name: zetacore1 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetacore1 networks: mynetwork: @@ -43,7 +43,7 @@ services: container_name: zetaclient0 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetaclient0 networks: mynetwork: @@ -58,7 +58,7 @@ services: container_name: zetaclient1 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetaclient1 networks: mynetwork: diff --git a/contrib/localnet/docker-compose.yml b/contrib/localnet/docker-compose.yml index c43d77ff8b..34b2eeeb79 100644 --- a/contrib/localnet/docker-compose.yml +++ b/contrib/localnet/docker-compose.yml @@ -32,7 +32,7 @@ services: container_name: zetacore0 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetacore0 ports: - "1317:1317" @@ -52,7 +52,7 @@ services: container_name: zetacore1 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetacore1 networks: mynetwork: @@ -67,7 +67,7 @@ services: container_name: zetaclient0 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetaclient0 networks: mynetwork: @@ -83,7 +83,7 @@ services: container_name: zetaclient1 build: context: ../../. - dockerfile: Dockerfile + dockerfile: Dockerfile-localnet hostname: zetaclient1 networks: mynetwork: diff --git a/contrib/local-mainnet/bitcoind/docker-compose.yml b/contrib/mainnet/bitcoind/docker-compose.yml similarity index 83% rename from contrib/local-mainnet/bitcoind/docker-compose.yml rename to contrib/mainnet/bitcoind/docker-compose.yml index c38819ae96..399b2c5108 100644 --- a/contrib/local-mainnet/bitcoind/docker-compose.yml +++ b/contrib/mainnet/bitcoind/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: bitcoin: - image: zetachain/bitcoin:35-mainnet + image: zetachain/bitcoin:${DOCKER_TAG:-36-mainnet} platform: linux/amd64 environment: - bitcoin_username=test @@ -10,7 +10,7 @@ services: - 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/bitcoin.tar + - 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 diff --git a/contrib/mainnet/zetacored/docker-compose.yml b/contrib/mainnet/zetacored/docker-compose.yml new file mode 100644 index 0000000000..6df2a17616 --- /dev/null +++ b/contrib/mainnet/zetacored/docker-compose.yml @@ -0,0 +1,47 @@ +version: '3.8' +services: + zetachain_mainnet_rpc: + platform: linux/amd64 + #This will build the binary from the GIT_REF you are locally on. + # build: + # context: ../../.. + # dockerfile: Dockerfile + image: zetachain/zetacored:${DOCKER_TAG:-ubuntu-v14} + container_name: zetachain_mainnet_rpc + environment: + DAEMON_HOME: "/root/.zetacored" + NETWORK: mainnet + #RESTORE_TYPE=snapshot/snapshot-archive/statesync + RESTORE_TYPE: "statesync" + SNAPSHOT_API: https://snapshots.zetachain.com + TRUST_HEIGHT_DIFFERENCE_STATE_SYNC: 40000 + COSMOVISOR_VERSION: "v1.5.0" + CHAIN_ID: "zetachain_7000-1" + COSMOVISOR_CHECKSUM: "626dfc58c266b85f84a7ed8e2fe0e2346c15be98cfb9f9b88576ba899ed78cdc" + 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:/root/.zetacored/ + entrypoint: bash /scripts/start.sh + #for debugging + #entrypoint: ["/bin/sh", "-c"] + #command: ["while true; do sleep 86400; done"] +volumes: + zetacored_data: diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index ef6e1cbb74..c23f5030d9 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -16,6 +16,7 @@ const ( TestMessagePassingName = "message_passing" TestZRC20SwapName = "zrc20_swap" TestBitcoinWithdrawName = "bitcoin_withdraw" + TestBitcoinWithdrawRestrictedName = "bitcoin_withdraw_restricted" TestCrosschainSwapName = "crosschain_swap" TestMessagePassingRevertFailName = "message_passing_revert_fail" TestMessagePassingRevertSuccessName = "message_passing_revert_success" @@ -26,12 +27,16 @@ const ( TestDepositEtherLiquidityCapName = "deposit_eth_liquidity_cap" TestMyTestName = "my_test" - TestERC20WithdrawName = "erc20_withdraw" - TestERC20DepositName = "erc20_deposit" - TestEtherDepositName = "eth_deposit" - TestEtherWithdrawName = "eth_withdraw" - TestBitcoinDepositName = "bitcoin_deposit" - TestZetaDepositName = "zeta_deposit" + TestERC20WithdrawName = "erc20_withdraw" + TestERC20DepositName = "erc20_deposit" + // #nosec G101: Potential hardcoded credentials (gosec), not a credential + TestERC20DepositRestrictedName = "erc20_deposit_restricted" + TestEtherDepositName = "eth_deposit" + TestEtherWithdrawName = "eth_withdraw" + TestEtherWithdrawRestrictedName = "eth_withdraw_restricted" + TestBitcoinDepositName = "bitcoin_deposit" + TestZetaDepositName = "zeta_deposit" + TestZetaDepositRestrictedName = "zeta_deposit_restricted" TestDonationEtherName = "donation_ether" @@ -188,4 +193,24 @@ var AllE2ETests = []runner.E2ETest{ "stress test BTC deposit", TestStressBTCDeposit, }, + { + TestZetaDepositRestrictedName, + "deposit ZETA from Ethereum to ZEVM restricted address", + TestZetaDepositRestricted, + }, + { + TestERC20DepositRestrictedName, + "deposit ERC20 into ZEVM restricted address", + TestERC20DepositRestricted, + }, + { + TestEtherWithdrawRestrictedName, + "withdraw Ether from ZEVM to restricted address", + TestEtherWithdrawRestricted, + }, + { + TestBitcoinWithdrawRestrictedName, + "withdraw Bitcoin from ZEVM to restricted address", + TestBitcoinWithdrawRestricted, + }, } diff --git a/e2e/e2etests/test_bitcoin_withdraw.go b/e2e/e2etests/test_bitcoin_withdraw.go index f70a4653d2..6f302c1acf 100644 --- a/e2e/e2etests/test_bitcoin_withdraw.go +++ b/e2e/e2etests/test_bitcoin_withdraw.go @@ -4,22 +4,27 @@ import ( "fmt" "math/big" + "github.com/btcsuite/btcd/btcjson" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcutil" + "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/e2e/runner" "github.com/zeta-chain/zetacore/e2e/utils" + "github.com/zeta-chain/zetacore/zetaclient/testutils" ) func TestBitcoinWithdraw(r *runner.E2ERunner) { - // withdraw 0.1 BTC from ZRC20 to BTC address - // first, approve the ZRC20 contract to spend 1 BTC from the deployer address + // withdraw 0.01 BTC from ZRC20 to BTC address WithdrawBitcoin(r) } -func WithdrawBitcoin(r *runner.E2ERunner) { - amount := big.NewInt(0.1 * btcutil.SatoshiPerBitcoin) +func TestBitcoinWithdrawRestricted(r *runner.E2ERunner) { + // withdraw 0.01 BTC from ZRC20 to BTC restricted address + WithdrawBitcoinRestricted(r) +} - // approve the ZRC20 contract to spend 1 BTC from the deployer address +func withdrawBTCZRC20(r *runner.E2ERunner, to btcutil.Address, amount *big.Int) *btcjson.TxRawResult { + // approve the ZRC20 contract to spend 'amount' of BTC from the deployer address tx, err := r.BTCZRC20.Approve(r.ZevmAuth, r.BTCZRC20Addr, big.NewInt(amount.Int64()*2)) // approve more to cover withdraw fee if err != nil { panic(err) @@ -32,8 +37,8 @@ func WithdrawBitcoin(r *runner.E2ERunner) { // mine blocks stop := r.MineBlocks() - // withdraw 0.1 BTC from ZRC20 to BTC address - tx, err = r.BTCZRC20.Withdraw(r.ZevmAuth, []byte(r.BTCDeployerAddress.EncodeAddress()), amount) + // withdraw 'amount' of BTC from ZRC20 to BTC address + tx, err = r.BTCZRC20.Withdraw(r.ZevmAuth, []byte(to.EncodeAddress()), amount) if err != nil { panic(err) } @@ -43,7 +48,7 @@ func WithdrawBitcoin(r *runner.E2ERunner) { } // mine 10 blocks to confirm the withdraw tx - _, err = r.BtcRPCClient.GenerateToAddress(10, r.BTCDeployerAddress, nil) + _, err = r.BtcRPCClient.GenerateToAddress(10, to, nil) if err != nil { panic(err) } @@ -75,6 +80,29 @@ func WithdrawBitcoin(r *runner.E2ERunner) { // stop mining stop <- struct{}{} + + return rawTx +} + +func WithdrawBitcoin(r *runner.E2ERunner) { + amount := big.NewInt(0.01 * btcutil.SatoshiPerBitcoin) + withdrawBTCZRC20(r, r.BTCDeployerAddress, amount) +} + +func WithdrawBitcoinRestricted(r *runner.E2ERunner) { + amount := big.NewInt(0.01 * btcutil.SatoshiPerBitcoin) + + // use restricted BTC P2WPKH address + addressRestricted, err := common.DecodeBtcAddress(testutils.RestrictedBtcAddressTest, common.BtcRegtestChain().ChainId) + if err != nil { + panic(err) + } + + // the cctx should be cancelled + rawTx := withdrawBTCZRC20(r, addressRestricted, amount) + if len(rawTx.Vout) != 2 { + panic(fmt.Errorf("BTC cancelled outtx rawTx.Vout should have 2 outputs")) + } } // WithdrawBitcoinMultipleTimes ... diff --git a/e2e/e2etests/test_crosschain_swap.go b/e2e/e2etests/test_crosschain_swap.go index 5772d185b9..e492a75908 100644 --- a/e2e/e2etests/test_crosschain_swap.go +++ b/e2e/e2etests/test_crosschain_swap.go @@ -89,7 +89,7 @@ func TestCrosschainSwap(r *runner.E2ERunner) { r.Logger.Info("***** First test: USDT -> BTC") // Should deposit USDT for swap, swap for BTC and withdraw BTC - txHash := r.DepositERC20WithAmountAndMessage(big.NewInt(8e7), msg) + txHash := r.DepositERC20WithAmountAndMessage(r.DeployerAddress, big.NewInt(8e7), msg) cctx1 := utils.WaitCctxMinedByInTxHash(r.Ctx, txHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) // check the cctx status diff --git a/e2e/e2etests/test_erc20_deposit.go b/e2e/e2etests/test_erc20_deposit.go index bd91ac72d6..6efd066141 100644 --- a/e2e/e2etests/test_erc20_deposit.go +++ b/e2e/e2etests/test_erc20_deposit.go @@ -3,14 +3,21 @@ package e2etests import ( "math/big" + ethcommon "github.com/ethereum/go-ethereum/common" "github.com/zeta-chain/zetacore/e2e/runner" "github.com/zeta-chain/zetacore/e2e/utils" + "github.com/zeta-chain/zetacore/zetaclient/testutils" ) func TestERC20Deposit(r *runner.E2ERunner) { - hash := r.DepositERC20WithAmountAndMessage(big.NewInt(100000), []byte{}) + hash := r.DepositERC20WithAmountAndMessage(r.DeployerAddress, big.NewInt(100000), []byte{}) // wait for the cctx to be mined cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, hash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) r.Logger.CCTX(*cctx, "deposit") } + +func TestERC20DepositRestricted(r *runner.E2ERunner) { + // deposit ERC20 to restricted address + r.DepositERC20WithAmountAndMessage(ethcommon.HexToAddress(testutils.RestrictedEVMAddressTest), big.NewInt(100000), []byte{}) +} diff --git a/e2e/e2etests/test_erc20_refund.go b/e2e/e2etests/test_erc20_refund.go index 252c76162d..d4fec2b59e 100644 --- a/e2e/e2etests/test_erc20_refund.go +++ b/e2e/e2etests/test_erc20_refund.go @@ -137,7 +137,7 @@ func TestERC20DepositAndCallRefund(r *runner.E2ERunner) { func createZetaERC20LiquidityPool(r *runner.E2ERunner) error { amount := big.NewInt(1e10) - txHash := r.DepositERC20WithAmountAndMessage(amount, []byte{}) + txHash := r.DepositERC20WithAmountAndMessage(r.DeployerAddress, amount, []byte{}) utils.WaitCctxMinedByInTxHash(r.Ctx, txHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) tx, err := r.USDTZRC20.Approve(r.ZevmAuth, r.UniswapV2RouterAddr, big.NewInt(1e10)) diff --git a/e2e/e2etests/test_eth_withdraw.go b/e2e/e2etests/test_eth_withdraw.go index 1f6cd59897..fbc866fcce 100644 --- a/e2e/e2etests/test_eth_withdraw.go +++ b/e2e/e2etests/test_eth_withdraw.go @@ -3,9 +3,11 @@ package e2etests import ( "math/big" + ethcommon "github.com/ethereum/go-ethereum/common" "github.com/zeta-chain/zetacore/e2e/runner" "github.com/zeta-chain/zetacore/e2e/utils" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + "github.com/zeta-chain/zetacore/zetaclient/testutils" ) // TestEtherWithdraw tests the withdraw of ether @@ -44,3 +46,44 @@ func TestEtherWithdraw(r *runner.E2ERunner) { panic("cctx status is not outbound mined") } } + +// TestEtherWithdrawRestricted tests the withdrawal to a restricted receiver address +func TestEtherWithdrawRestricted(r *runner.E2ERunner) { + // approve + tx, err := r.ETHZRC20.Approve(r.ZevmAuth, r.ETHZRC20Addr, big.NewInt(1e18)) + if err != nil { + panic(err) + } + r.Logger.EVMTransaction(*tx, "approve") + + receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, tx, r.Logger, r.ReceiptTimeout) + if receipt.Status == 0 { + panic("approve failed") + } + r.Logger.EVMReceipt(*receipt, "approve") + + // withdraw + restrictedAddress := ethcommon.HexToAddress(testutils.RestrictedEVMAddressTest) + tx, err = r.ETHZRC20.Withdraw(r.ZevmAuth, restrictedAddress.Bytes(), big.NewInt(100000)) + if err != nil { + panic(err) + } + r.Logger.EVMTransaction(*tx, "withdraw to restricted address") + + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, tx, r.Logger, r.ReceiptTimeout) + if receipt.Status == 0 { + panic("withdraw failed") + } + r.Logger.EVMReceipt(*receipt, "withdraw") + r.Logger.ZRC20Withdrawal(r.ETHZRC20, *receipt, "withdraw") + + // verify the withdraw value + cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, receipt.TxHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) + r.Logger.CCTX(*cctx, "withdraw") + if cctx.CctxStatus.Status != crosschaintypes.CctxStatus_OutboundMined { + panic("cctx status is not outbound mined") + } + + // the cctx should be cancelled with zero value + verifyTransferAmountFromCCTX(r, cctx, 0) +} diff --git a/e2e/e2etests/test_stress_eth_deposit.go b/e2e/e2etests/test_stress_eth_deposit.go index ea5f3919f5..b568b460d5 100644 --- a/e2e/e2etests/test_stress_eth_deposit.go +++ b/e2e/e2etests/test_stress_eth_deposit.go @@ -25,7 +25,7 @@ func TestStressEtherDeposit(r *runner.E2ERunner) { // send the deposits for i := 0; i < numDeposits; i++ { i := i - hash := r.DepositERC20WithAmountAndMessage(big.NewInt(100000), []byte{}) + hash := r.DepositERC20WithAmountAndMessage(r.DeployerAddress, big.NewInt(100000), []byte{}) r.Logger.Print("index %d: starting deposit, tx hash: %s", i, hash.Hex()) eg.Go(func() error { diff --git a/e2e/e2etests/test_zeta_deposit.go b/e2e/e2etests/test_zeta_deposit.go index ac58399a21..71c10328e3 100644 --- a/e2e/e2etests/test_zeta_deposit.go +++ b/e2e/e2etests/test_zeta_deposit.go @@ -3,15 +3,22 @@ package e2etests import ( "math/big" + ethcommon "github.com/ethereum/go-ethereum/common" "github.com/zeta-chain/zetacore/e2e/runner" "github.com/zeta-chain/zetacore/e2e/utils" + "github.com/zeta-chain/zetacore/zetaclient/testutils" ) func TestZetaDeposit(r *runner.E2ERunner) { // Deposit 1 Zeta - hash := r.DepositZetaWithAmount(big.NewInt(1e18)) + hash := r.DepositZetaWithAmount(r.DeployerAddress, big.NewInt(1e18)) // wait for the cctx to be mined cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, hash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) r.Logger.CCTX(*cctx, "deposit") } + +func TestZetaDepositRestricted(r *runner.E2ERunner) { + // Deposit 1 Zeta to restricted address + r.DepositZetaWithAmount(ethcommon.HexToAddress(testutils.RestrictedEVMAddressTest), big.NewInt(1e18)) +} diff --git a/e2e/runner/evm.go b/e2e/runner/evm.go index 75eaf75c2b..47035e61f3 100644 --- a/e2e/runner/evm.go +++ b/e2e/runner/evm.go @@ -72,10 +72,10 @@ func (runner *E2ERunner) SendUSDTOnEvm(address ethcommon.Address, amountUSDT int func (runner *E2ERunner) DepositERC20() ethcommon.Hash { runner.Logger.Print("⏳ depositing ERC20 into ZEVM") - return runner.DepositERC20WithAmountAndMessage(big.NewInt(1e18), []byte{}) + return runner.DepositERC20WithAmountAndMessage(runner.DeployerAddress, big.NewInt(1e18), []byte{}) } -func (runner *E2ERunner) DepositERC20WithAmountAndMessage(amount *big.Int, msg []byte) ethcommon.Hash { +func (runner *E2ERunner) DepositERC20WithAmountAndMessage(to ethcommon.Address, amount *big.Int, msg []byte) ethcommon.Hash { // reset allowance, necessary for USDT tx, err := runner.USDTERC20.Approve(runner.GoerliAuth, runner.ERC20CustodyAddr, big.NewInt(0)) if err != nil { @@ -97,7 +97,7 @@ func (runner *E2ERunner) DepositERC20WithAmountAndMessage(amount *big.Int, msg [ } runner.Logger.Info("USDT Approve receipt tx hash: %s", tx.Hash().Hex()) - tx, err = runner.ERC20Custody.Deposit(runner.GoerliAuth, runner.DeployerAddress.Bytes(), runner.USDTERC20Addr, amount, msg) + tx, err = runner.ERC20Custody.Deposit(runner.GoerliAuth, to.Bytes(), runner.USDTERC20Addr, amount, msg) runner.Logger.Print("TX: %v", tx) if err != nil { panic(err) diff --git a/e2e/runner/zeta.go b/e2e/runner/zeta.go index b5df8145d9..e4bbf99ccc 100644 --- a/e2e/runner/zeta.go +++ b/e2e/runner/zeta.go @@ -51,11 +51,11 @@ func (runner *E2ERunner) DepositZeta() ethcommon.Hash { amount := big.NewInt(1e18) amount = amount.Mul(amount, big.NewInt(100)) // 100 Zeta - return runner.DepositZetaWithAmount(amount) + return runner.DepositZetaWithAmount(runner.DeployerAddress, amount) } // DepositZetaWithAmount deposits ZETA on ZetaChain from the ZETA smart contract on EVM with the specified amount -func (runner *E2ERunner) DepositZetaWithAmount(amount *big.Int) ethcommon.Hash { +func (runner *E2ERunner) DepositZetaWithAmount(to ethcommon.Address, amount *big.Int) ethcommon.Hash { tx, err := runner.ZetaEth.Approve(runner.GoerliAuth, runner.ConnectorEthAddr, amount) if err != nil { panic(err) @@ -78,7 +78,7 @@ func (runner *E2ERunner) DepositZetaWithAmount(amount *big.Int) ethcommon.Hash { // TODO: allow user to specify destination chain id // https://github.com/zeta-chain/node-private/issues/41 DestinationChainId: zetaChainID, - DestinationAddress: runner.DeployerAddress.Bytes(), + DestinationAddress: to.Bytes(), DestinationGasLimit: big.NewInt(250_000), Message: nil, ZetaValueAndGas: amount, diff --git a/readme.md b/readme.md index 16204d6629..7ae0f1337e 100644 --- a/readme.md +++ b/readme.md @@ -103,4 +103,76 @@ To create a release simply execute the publish-release workflow and follow the s - Step 4. Select if you want to skip the tests by checking the checkbox for skip tests. - Step 5. Once the testing steps pass it will create a Github Issue. This Github Issue needes to be approved by one of the approvers: kingpinXD,lumtis,brewmaster012 -Once the release is approved the pipeline will continue and will publish the releases with the title / version you specified in the user input. \ No newline at end of file +Once the release is approved the pipeline will continue and will publish the releases with the title / version you specified in the user input. + + +Here is the formatted documentation in Markdown: + +--- + +### Starting Full Zetacored Nodes + +#### Step 1: Choose the Network + +To start a node, use the `make` command with the `DOCKER_TAG` of the image you wish to use from Docker Hub. + +- **For Mainnet:** + + ```shell + # Use this command to start a mainnet node with a specific Docker tag + make mainnet-zetarpc-node DOCKER_TAG={THE_DOCKER_TAG_FROM_DOCKER_HUB_YOU_WANT_TO_USE} + # Example: + make mainnet-zetarpc-node DOCKER_TAG=ubuntu-v12.3.0-docker-test + ``` + +- **For Athens3:** + + ```shell + # The command is the same for Athens3, just ensure you're specifying the correct Docker tag + make mainnet-zetarpc-node DOCKER_TAG={THE_DOCKER_TAG_FROM_DOCKER_HUB_YOU_WANT_TO_USE} + # Example: + make mainnet-zetarpc-node DOCKER_TAG=ubuntu-v12.3.0-docker-test + ``` + +**Note:** The default configuration is to restore from state sync. This process will download the necessary configurations and information from [Zeta-Chain Network Config](https://github.com/zeta-chain/network-config) and configure the node for state sync restore. + +#### Changing the Sync Type + +If you wish to change the sync type, you will need to modify the `docker-compose.yml` file located in `contrib/{NETWORK}/zetacored/`. + +Change the following values according to your needs: + +```yaml +# Possible values for RESTORE_TYPE are "snapshot", "snapshot-archive", or "statesync" +RESTORE_TYPE: "statesync" +MONIKER: "local-test" +RE_DO_START_SEQUENCE: "false" +``` + +To perform a snapshot restore from the latest snapshot, simply change the `RESTORE_TYPE` to either `snapshot` or `snapshot-archive`. + +--- + +Here's the formatted documentation in Markdown for starting a full Bitcoind Mainnet node: + +--- + +### Starting Full Bitcoind Mainnet Node + +#### Step 1: Restore a Mainnet BTC Watcher Node + +To restore a mainnet BTC watcher node from a BTC snapshot, run the following `make` command and specify the `DOCKER_TAG` with the image you want to use from Docker Hub. + +```commandline +make mainnet-bitcoind-node DOCKER_TAG={DOCKER_TAG_FROM_DOCKER_HUB_TO_USE} +# Example: +make mainnet-bitcoind-node DOCKER_TAG=36-mainnet +``` + +#### Updating the TSS Address + +If you need to update the TSS (Threshold Signature Scheme) address being watched, please edit the `docker-compose.yml` file located at `contrib/mainnet/bitcoind/docker-compose.yml`. + +To update, simply change the user and password you wish to use, and the TSS address to watch. Then, run the command provided above to apply your changes. + +--- \ No newline at end of file