1
0
stack-orchestrator/app/data/config/watcher-gelato/create-and-import-checkpoint.sh
prathamesh0 5c7d445500 Add a stack for Gelato watcher (#394)
* Add a stack for Gelato watcher

* Add option to create and use a state snapshot

* Add commands to create and import a state checkpoint

* Rename ipld-eth-server endpoint env variables

* Fix default env variable

Former-commit-id: 8b4b5deba88bc5008a623a3826a5d2c0d76aadb6
2023-05-16 09:09:08 +05:30

29 lines
1000 B
Bash
Executable File

#!/bin/bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
CERC_SNAPSHOT_GQL_ENDPOINT="${CERC_SNAPSHOT_GQL_ENDPOINT:-${DEFAULT_CERC_SNAPSHOT_GQL_ENDPOINT}}"
CERC_SNAPSHOT_BLOCKHASH="${CERC_SNAPSHOT_BLOCKHASH:-${DEFAULT_CERC_SNAPSHOT_BLOCKHASH}}"
CHECKPOINT_FILE_PATH="./state_checkpoint/state-gql-${CERC_SNAPSHOT_BLOCKHASH}"
if [ -f "${CHECKPOINT_FILE_PATH}" ]; then
# Skip checkpoint creation if the file already exists
echo "File at ${CHECKPOINT_FILE_PATH} already exists, skipping checkpoint creation..."
else
# Create a checkpoint using GQL endpoint
echo "Creating a state checkpoint using GQL endpoint..."
yarn create-state-gql \
--snapshot-block-hash "${CERC_SNAPSHOT_BLOCKHASH}" \
--gql-endpoint "${CERC_SNAPSHOT_GQL_ENDPOINT}" \
--output "${CHECKPOINT_FILE_PATH}"
fi
echo "Initializing watcher using a state snapshot..."
# Import the state checkpoint
# (skips if snapshot block is already indexed)
yarn import-state --import-file "${CHECKPOINT_FILE_PATH}"