Add commands to create and import a state checkpoint
This commit is contained in:
parent
4d7530c189
commit
da8bf00f78
@ -73,11 +73,12 @@ services:
|
||||
- ../config/watcher-gelato/watcher-config-template.toml:/app/environments/watcher-config-template.toml
|
||||
- ../config/watcher-gelato/start-server.sh:/app/start-server.sh
|
||||
- ../config/watcher-gelato/create-and-import-checkpoint.sh:/app/create-and-import-checkpoint.sh
|
||||
- gelato_watcher_state_gql:/app/state_checkpoint
|
||||
ports:
|
||||
- "0.0.0.0:3001:3001"
|
||||
- "0.0.0.0:3008:3008"
|
||||
- "0.0.0.0:9001:9001"
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-v", "localhost", "3001"]
|
||||
test: ["CMD", "nc", "-v", "localhost", "3008"]
|
||||
interval: 20s
|
||||
timeout: 5s
|
||||
retries: 15
|
||||
@ -87,3 +88,4 @@ services:
|
||||
|
||||
volumes:
|
||||
gelato_watcher_db_data:
|
||||
gelato_watcher_state_gql:
|
||||
|
@ -7,7 +7,22 @@ fi
|
||||
CERC_SNAPSHOT_GQL_ENDPOINT="${CERC_SNAPSHOT_GQL_ENDPOINT:-${DEFAULT_CERC_SNAPSHOT_GQL_ENDPOINT}}"
|
||||
CERC_SNAPSHOT_BLOCKHASH="${CERC_SNAPSHOT_BLOCKHASH:-${DEFAULT_CERC_SNAPSHOT_BLOCKHASH}}"
|
||||
|
||||
# TODO Create a checkpoint using GQL endpoint (check and skip if snapshot file already exists)
|
||||
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..."
|
||||
# TODO Import the checkpoint
|
||||
|
||||
# Import the state checkpoint
|
||||
# (skips if snapshot block is already indexed)
|
||||
yarn import-state --import-file "${CHECKPOINT_FILE_PATH}"
|
||||
|
@ -91,8 +91,8 @@ Clear volumes created by this stack:
|
||||
|
||||
```bash
|
||||
# List all relevant volumes
|
||||
docker volume ls -q --filter "name=.*gelato_watcher_db_data"
|
||||
docker volume ls -q --filter "name=.*gelato_watcher_db_data|.*gelato_watcher_state_gql"
|
||||
|
||||
# Remove all the listed volumes
|
||||
docker volume rm $(docker volume ls -q --filter "name=.*gelato_watcher_db_data")
|
||||
docker volume rm $(docker volume ls -q --filter "name=.*gelato_watcher_db_data|.*gelato_watcher_state_gql")
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user