From fcf7fbb8b0dc04863ff72376275fee93cfd53c79 Mon Sep 17 00:00:00 2001 From: 3alpha <15694175+3alpha@users.noreply.github.com> Date: Mon, 23 Nov 2026 12:00:17 +0100 Subject: [PATCH 1/2] fix: wipe the node DB after restoring a backup on ssv >= v2.5.0 --- README.md | 2 ++ operator/entrypoint.sh | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 60dade7..3464c22 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ The package supports backup and restore functionality for both the operator and - **Operator Config**: The configuration and keys for the operator are stored in `/data/operator/config`. - **DKG Output**: The generated key shares from the DKG process are stored in `/data/dkg/output`. +The node database (`/data/operator/db`) is intentionally not part of the backup. It holds the SSV network state, which re-syncs from the SSV contract, and the slashing protection (highest attestation and proposal per validator share), which SSV keeps inside the same database and cannot export. When the restored operator key does not match the database, the database is wiped and re-synced. During that re-sync SSV sets the slashing protection of every share to the current epoch and slot and only lets the validators participate from the next epoch, which is safer than restoring an older copy of the database. Never run the old and the restored node at the same time. + It's recommended to download a backup immediately after completing the operator registration to secure all critical files. For more detailed steps, please refer to the [SSV Network documentation](https://docs.ssv.network/learn/introduction). diff --git a/operator/entrypoint.sh b/operator/entrypoint.sh index c400df7..3b9f085 100755 --- a/operator/entrypoint.sh +++ b/operator/entrypoint.sh @@ -130,7 +130,8 @@ start_operator() { EXIT_STATUS=$? # Backup restoring causes the operator to find a mismatch in the DB - if [ $EXIT_STATUS -ne 0 ] && grep -q "operator private key is not matching the one encrypted the storage" "${NODE_LOG_FILE}"; then + # The first message is logged by ssv < v2.5.0, the second one by ssv >= v2.5.0 + if [ $EXIT_STATUS -ne 0 ] && grep -qE "operator private key (is not matching the one encrypted|does not match the one that encrypted) the storage" "${NODE_LOG_FILE}"; then echo "[WARN] Detected private key mismatch, probably due to backup restoring. Removing DB and retrying..." # Added :? to prevent accidental deletion of root directory (if $OPERATOR_DB_DIR is empty or unset) rm -rf "${OPERATOR_DB_DIR:?}"/* From c4a9ba0f2d03e20db412507460b2763a7b4ea881 Mon Sep 17 00:00:00 2001 From: 3alpha <15694175+3alpha@users.noreply.github.com> Date: Mon, 23 Nov 2026 12:56:45 +0100 Subject: [PATCH 2/2] fix: only wipe the node DB on a key mismatch logged by the current run node.log keeps the lines of previous runs, so after one key mismatch every later failed start (for example while the beacon node is unreachable) matched the old line and wiped the DB again. Check only the log written since this start. --- operator/entrypoint.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/operator/entrypoint.sh b/operator/entrypoint.sh index 3b9f085..c1accf2 100755 --- a/operator/entrypoint.sh +++ b/operator/entrypoint.sh @@ -124,6 +124,9 @@ parse_numbers_in_operator_config() { start_operator() { echo "[INFO] Starting SSV operator..." + # node.log keeps the lines of previous runs: only check the ones written by this run + LOG_OFFSET=$(stat -c %s "${NODE_LOG_FILE}" 2>/dev/null || echo 0) + /go/bin/ssvnode start-node --config "${NODE_CONFIG_FILE}" "${EXTRA_OPTS}" & wait $! @@ -131,7 +134,7 @@ start_operator() { # Backup restoring causes the operator to find a mismatch in the DB # The first message is logged by ssv < v2.5.0, the second one by ssv >= v2.5.0 - if [ $EXIT_STATUS -ne 0 ] && grep -qE "operator private key (is not matching the one encrypted|does not match the one that encrypted) the storage" "${NODE_LOG_FILE}"; then + if [ $EXIT_STATUS -ne 0 ] && tail -c +$((LOG_OFFSET + 1)) "${NODE_LOG_FILE}" | grep -qE "operator private key (is not matching the one encrypted|does not match the one that encrypted) the storage"; then echo "[WARN] Detected private key mismatch, probably due to backup restoring. Removing DB and retrying..." # Added :? to prevent accidental deletion of root directory (if $OPERATOR_DB_DIR is empty or unset) rm -rf "${OPERATOR_DB_DIR:?}"/*