Skip to content

Commit

Permalink
Refactor contrib/rpc and contrib/docker-scripts to use snapshots API (#…
Browse files Browse the repository at this point in the history
…2724)

Co-authored-by: Julian Rubino <julian@zetachain.com>
  • Loading branch information
julianrubino and Julian Rubino authored Aug 16, 2024
1 parent 2252e5e commit a4c1b18
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions contrib/docker-scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function load_defaults {
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 SNAPSHOT_API=${SNAPSHOT_API:=https://snapshots.rpc.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}
Expand Down Expand Up @@ -109,8 +109,8 @@ function setup_restore_type {
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_URL=$(curl -s ${SNAPSHOT_API}/mainnet/fullnode/latest.json | jq -r '.snapshots[0].link')
SNAPSHOT_FILENAME=$(curl -s ${SNAPSHOT_API}/mainnet/fullnode/latest.json | jq -r '.snapshots[0].filename')
SNAPSHOT_DIR=$(pwd)
logt "Download Snapshot from url: ${SNAPSHOT_URL}"
curl -o "${SNAPSHOT_FILENAME}" "${SNAPSHOT_URL}"
Expand All @@ -120,8 +120,8 @@ function setup_restore_type {
logt " Cleanup Snapshot"
rm -rf ${SNAPSHOT_DIR}/${SNAPSHOT_FILENAME}
elif [ "${NETWORK}" == "athens3" ]; then
SNAPSHOT_URL=$(curl -s ${SNAPSHOT_API}/latest-snapshot?network=athens3 | jq -r .latest_snapshot)
SNAPSHOT_FILENAME=$(basename "${SNAPSHOT_URL}")
SNAPSHOT_URL=$(curl -s ${SNAPSHOT_API}/testnet/fullnode/latest.json | jq -r '.snapshots[0].link')
SNAPSHOT_FILENAME=$(curl -s ${SNAPSHOT_API}/testnet/fullnode/latest.json | jq -r '.snapshots[0].filename')
SNAPSHOT_DIR=$(pwd)
logt "Download Snapshot from url: ${SNAPSHOT_URL}"
curl -o "${SNAPSHOT_FILENAME}" "${SNAPSHOT_URL}"
Expand All @@ -134,8 +134,8 @@ function setup_restore_type {
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 -r .latest_snapshot)
SNAPSHOT_FILENAME=$(basename "${SNAPSHOT_URL}")
SNAPSHOT_URL=$(curl -s ${SNAPSHOT_API}/mainnet/archive/latest.json | jq -r '.snapshots[0].link')
SNAPSHOT_FILENAME=$(curl -s ${SNAPSHOT_API}/mainnet/archive/latest.json | jq -r '.snapshots[0].filename')
SNAPSHOT_DIR=$(pwd)
logt "Download Snapshot from url: ${SNAPSHOT_URL}"
curl -o "${SNAPSHOT_FILENAME}" "${SNAPSHOT_URL}"
Expand All @@ -145,8 +145,8 @@ function setup_restore_type {
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 -r .latest_snapshot)
SNAPSHOT_FILENAME=$(basename "${SNAPSHOT_URL}")
SNAPSHOT_URL=$(curl -s ${SNAPSHOT_API}/testnet/archive/latest.json | jq -r '.snapshots[0].link')
SNAPSHOT_FILENAME=$(curl -s ${SNAPSHOT_API}/testnet/archive/latest.json | jq -r '.snapshots[0].filename')
SNAPSHOT_DIR=$(pwd)
logt "Download Snapshot from url: ${SNAPSHOT_URL}"
curl -o "${SNAPSHOT_FILENAME}" "${SNAPSHOT_URL}"
Expand Down Expand Up @@ -332,4 +332,4 @@ else

logt "Start Network"
start_network
fi
fi
2 changes: 1 addition & 1 deletion contrib/rpc/zetacored/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
DAEMON_HOME: "${DAEMON_HOME:-/root/.zetacored}"
NETWORK: ${NETWORK:-mainnet}
RESTORE_TYPE: "${RESTORE_TYPE:-snapshot}"
SNAPSHOT_API: ${SNAPSHOT_API:-https://snapshots.zetachain.com}
SNAPSHOT_API: ${SNAPSHOT_API:-https://snapshots.rpc.zetachain.com}
TRUST_HEIGHT_DIFFERENCE_STATE_SYNC: ${TRUST_HEIGHT_DIFFERENCE_STATE_SYNC:-40000}
CHAIN_ID: "${CHAIN_ID:-zetachain_7000-1}"
VISOR_NAME: "${VISOR_NAME:-cosmovisor}"
Expand Down
4 changes: 2 additions & 2 deletions contrib/rpc/zetacored/networks/.athens3
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export DAEMON_HOME="/root/.zetacored"
export NETWORK=athens3
export RESTORE_TYPE="snapshot"
export SNAPSHOT_API=https://snapshots.zetachain.com
export SNAPSHOT_API=https://snapshots.rpc.zetachain.com
export TRUST_HEIGHT_DIFFERENCE_STATE_SYNC=40000
export CHAIN_ID="athens_7001-1"
export VISOR_NAME="cosmovisor"
Expand All @@ -11,4 +11,4 @@ export DAEMON_RESTART_AFTER_UPGRADE="true"
export UNSAFE_SKIP_BACKUP="true"
export MONIKER=testnet-docker-rpc
export RE_DO_START_SEQUENCE="false"
export IS_LOCAL_DEVELOPMENT="false"
export IS_LOCAL_DEVELOPMENT="false"
4 changes: 2 additions & 2 deletions contrib/rpc/zetacored/networks/.athens3-localbuild
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export DAEMON_HOME="/root/.zetacored"
export NETWORK=athens3
export RESTORE_TYPE="snapshot"
export SNAPSHOT_API=https://snapshots.zetachain.com
export SNAPSHOT_API=https://snapshots.rpc.zetachain.com
export TRUST_HEIGHT_DIFFERENCE_STATE_SYNC=40000
export CHAIN_ID="athens_7001-1"
export VISOR_NAME="cosmovisor"
Expand All @@ -11,4 +11,4 @@ export DAEMON_RESTART_AFTER_UPGRADE="false"
export UNSAFE_SKIP_BACKUP="true"
export MONIKER=testnet-docker-rpc
export RE_DO_START_SEQUENCE="false"
export IS_LOCAL_DEVELOPMENT="true"
export IS_LOCAL_DEVELOPMENT="true"
2 changes: 1 addition & 1 deletion contrib/rpc/zetacored/networks/.mainnet
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export DAEMON_HOME="/root/.zetacored"
export NETWORK=mainnet
export RESTORE_TYPE="snapshot"
export SNAPSHOT_API=https://snapshots.zetachain.com
export SNAPSHOT_API=https://snapshots.rpc.zetachain.com
export TRUST_HEIGHT_DIFFERENCE_STATE_SYNC=40000
export CHAIN_ID="zetachain_7000-1"
export VISOR_NAME="cosmovisor"
Expand Down
2 changes: 1 addition & 1 deletion contrib/rpc/zetacored/networks/.mainnet-localbuild
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export DAEMON_HOME="/root/.zetacored"
export NETWORK=mainnet
export RESTORE_TYPE="snapshot"
export SNAPSHOT_API=https://snapshots.zetachain.com
export SNAPSHOT_API=https://snapshots.rpc.zetachain.com
export TRUST_HEIGHT_DIFFERENCE_STATE_SYNC=40000
export CHAIN_ID="zetachain_7000-1"
export VISOR_NAME="cosmovisor"
Expand Down
2 changes: 1 addition & 1 deletion docs/development/DEPLOY_NODES.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The environment variables for both Zetacored and Bitcoin nodes are defined in th
| `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` |
| `SNAPSHOT_API` | API URL for fetching snapshots | `https://snapshots.rpc.zetachain.com` |

#### Example Environment Variables for Bitcoin

Expand Down

0 comments on commit a4c1b18

Please sign in to comment.