Repository navigation
Conversation
node_key.json is generated once by neard init and holds the node's p2p identity; it cannot be recreated. config.json and validator_key.json were already covered.
Contributor
|
Dappnode bot has built and pinned the built packages to an IPFS node, for commit: 7ad520f This is a development version and should only be installed for testing purposes.
Hash: (by dappnodebot/build-action) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The DAppNode full backup (DNP_DAPPMANAGER #2511/#2512) copies only the paths a package declares in the manifest
backupfield. NEAR declaresconfig.json,validator_key.jsonandlatencieslogs.csv, but notnode_key.json.node_key.jsonis created once byneard init(random ed25519 key,generate_or_load_keyin nearcorenearcore/src/config.rs) and is the node's p2p identity (peer ID).start_near.shalso uses its presence to decide whether to runneard init. If it is lost, the node comes back with a new peer ID: anything that references the old one (boot node lists, peering, monitoring) breaks, and it cannot be regenerated.Approach
Add one
backupitem,node_key->/srv/near/node_key.json(servicenear). Layout ofNEAR_HOME=/srv/near(named volumenear) and how each file is covered:config.jsonneard init --download-config, then edited bystart_near.shand possibly by the usernode_key.jsonneard init, never regeneratedvalidator_key.jsonACCOUNT_ID,VALIDATOR_PUBLIC_KEYandVALIDATOR_SECRET_KEYon every start, deleted if they are unsetlatencieslogs.csvneard ping, diagnostic onlygenesis.jsonneardand written byinitdata/The validator secret also lives in the package env vars, which the full backup keeps in the package user settings, so after a restore
start_near.shwrites the samevalidator_key.jsonagain; the file item is a second copy.The existing
validator_keyitem already makes the dappmanager treat NEAR as a validator (backup item name/path containsvalidator): before restoring it asks the user to confirm the old node is off and it leaves NEAR stopped after restore. That is the behaviour we want here.Double-signing risk: a restored NEAR node has the same validator key and the same node key as the original. If both run at the same time they produce conflicting blocks, chunks and endorsements under one validator key and fight over one peer ID. The old node must be switched off for good before the restored one is started.
Compatibility with dappmanager versions without full backup
The released Dappmanager only has the per-package Backup tab. The new item works there as is:
docker cpofnode_key.jsonfrom the running container. The file is written once byneard initand never changed, so the live copy is exact. Items that fail (for examplelatencieslogs.csvbefore the firstneard ping) are skipped, and the backup fails only if every item fails.docker cpinto the running container, thendocker restart. The container runs as root (supervisord, nouser=), so the root-owned restored files are fine.neardreadsnode_key.jsononly at start and does not write it on shutdown. After the restartstart_near.shfinds the file, skipsneard init, and the node starts with the restored peer ID.validator_keyitem. Also,start_near.shrewritesvalidator_key.jsonfrom the package env vars on every start (or deletes it when they are unset), so the validator key in use after a Backup tab restore comes from those settings.Not run:
nearprotocol/nearcoreis amd64-only and this check ran on an arm64 host, so the above is from the Dappmanager source (backupGet.ts,backupRestore.ts,packageRestart.tsondevelop),start_near.sh, the supervisord config and the image config.No version bump: the field takes effect in the next release built from
main.Test instructions
/srv/near/node_key.jsonand/srv/near/validator_key.json(docker exec DAppNodePackage-near.near.dnp.dappnode.eth cat /srv/near/node_key.json).packages/near.dnp.dappnode.eth/backup/node_key.tar,validator_key.tarandconfig.tar, with no warning fornode_key.node_key.json,validator_key.jsonandconfig.jsonmatch the originals, then start the package and check that the peer ID in the logs is the original one.