Skip to content

fix: wipe the node DB after restoring a backup on ssv >= v2.5.0 - #65

Merged
3alpha merged 2 commits into
mainfrom
fix/backup-slashing-protection
Nov 23, 2026
Merged

3alpha merged 2 commits into
mainfrom
fix/backup-slashing-protection

Conversation

@3alpha

@3alpha 3alpha commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Problem

The backup field (used by the Backup tab and by the DAppNode full backup) covers the operator key, its password, the operator ID (/data/operator/config) and the DKG output (/data/dkg/output), but not the node DB /data/operator/db. The question was whether slashing protection needs to be added to it.

What SSV v2.5.1 stores and where:

  • The operator node uses a single BadgerDB at /data/operator/db (db.Path). Slashing protection is not a separate store: it lives in that same DB under the keys <network>signer_data-highest_att-<share pubkey> and <network>signer_data-highest_prop-<share pubkey> (ssvsigner/ekm/signer_storage.go), next to the registry/network state. It only keeps the highest attestation and proposal per share (no history).
  • ssvnode has no export or import command for it (no EIP-3076 interchange), and BadgerDB cannot be opened by a second process while the node runs, so it cannot be backed up on its own.
  • When the node syncs a share from the contract into an empty DB, AddShare calls BumpSlashingProtection, which sets the highest attestation target to the current epoch and the highest proposal to the current slot, and SetMinParticipationEpoch(current epoch + 1) stops the share from signing until the next epoch (eth/eventhandler/handlers.go, comment: "we don't know if another instance of our operator has been running in the past and potentially signed something conflicting, so we err on the safe side"). The SSV node migration docs also say the DB is optional and can be re-synced from scratch.

So a copy of the DB taken while the node runs is both possibly inconsistent and less protective than a re-sync: its watermarks are older than what the old node signed afterwards, and the shares would sign straight away. The manifest backup should stay as it is.

There is, however, a bug that breaks restore. When the operator key is restored onto a node whose DB was created with another key (the usual case: a fresh install generates a new key and DB before the backup is restored over it), SSV refuses to start. The entrypoint is meant to handle that by wiping the DB and starting again, but it greps for the message logged by SSV < v2.5.0 (operator private key is not matching the one encrypted the storage). Since v2.5.0 SSV logs operator private key does not match the one that encrypted the storage, so the wipe never happens and the operator restarts in a loop after a restore.

Approach

  • operator/entrypoint.sh: match both the old and the new message, so a restored key gets a clean DB, which re-syncs and re-bumps the slashing protection to the current epoch.
  • operator/entrypoint.sh: only look for the message in the log lines written by the current run. node.log (/data/operator/logs, on the volume) keeps the lines of previous runs, so once a mismatch had been logged, every later failed start (for example could not start node ... failed to create beacon go-client while the beacon node is unreachable, which exits 1) matched the old line and wiped the DB again. The old pattern had the same flaw, but it never matched on v2.5.x, so fixing the message alone would have turned it on.
  • README.md: explain why the node DB is not backed up.

No manifest change and no version bump.

Compatibility with dappmanager versions without full backup

The package release may ship before dappnode/DNP_DAPPMANAGER#2511 and #2512. Today's DAppManager only has the per-package Backup tab: backup runs docker cp on each item from the running containers; restore runs docker exec <container> mkdir -p <dir> (needs a running container), docker cps the items into the running containers and docker restarts the package. This PR works with that flow:

  • The backed-up items are static files (operator key, password, operator ID, DKG output), so a copy from the running package is exact.
  • Restore copies the operator config into the running operator. ssvnode does not rewrite those files, and the restart starts the entrypoint again, which detects the key mismatch and wipes the DB as described above. The operator runs as root, so root-owned restored files are fine.
  • The package starts right after the restore, so switch off the old node before restoring (as in the test steps below). The README already says never to run both.

Checked locally with the operator image built from this branch (ssvlabs/ssv-node:v2.5.1, arm64, --network none): the v2.5.1 binary contains operator private key does not match the one that encrypted the storage, and fatal start errors are written to node.log. SSV only checks the key after reaching the beacon node, which is not possible offline, so the entrypoint logic was exercised with ssvnode start-node replaced by a stub that logs that message and exits 1 when the key does not match the DB: docker cp of /data/operator/config out of a running operator, docker exec mkdir + docker cp into another running operator with a different key and DB, docker restart. The entrypoint logged the mismatch warning, wiped the DB and started with the restored key. A later start failing with a beacon node error then wiped the DB again before the log fix, and kept it after.

Testing

Backup:

  1. On a node running ssv-hoodi (registered operator), download a backup from the Backup tab, or create a DAppNode full backup.
  2. Check that it contains operator-config (encrypted_private_key.json, private_key_password, operator_id.txt) and dkg-output, and no DB.

Restore onto a fresh install (the case this PR fixes):

  1. Switch off the old node (or stop its ssv-hoodi package) and wait at least one epoch.
  2. On another node, install ssv-hoodi built from this branch and let it start once: it generates a new operator key and a DB.
  3. Restore the backup (Backup tab, or full restore), then start the package.
  4. In the operator logs, check for [WARN] Detected private key mismatch, probably due to backup restoring. Removing DB and retrying..., then successfully loaded operator keys with the restored public key, and the registry sync.
  5. Check that the operator's validators perform duties again from the epoch after the sync. Without this PR, step 4 loops on could not start node ... operator private key does not match the one that encrypted the storage.

Restore onto the same node (same key): restoring the backup leaves the DB in place, and the node starts without wiping it.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Dappnode bot has built and pinned the built packages to an IPFS node, for commit: c4a9ba0

This is a development version and should only be installed for testing purposes.

  1. Package ssv.dnp.dappnode.eth

Install link

Hash: /ipfs/QmQ5fLRowHrCskJZysbKu2MPC7q6vmYt9PKFdmzMbSurQQ

(by dappnodebot/build-action)

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.
@3alpha
3alpha merged commit 81a50fb into main Nov 23, 2026
6 checks passed
@3alpha
3alpha deleted the fix/backup-slashing-protection branch November 23, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant