ava-labs / avalanchego

Go implementation of an Avalanche node.
https://avax.network
BSD 3-Clause "New" or "Revised" License
2.13k stars 671 forks source link

--data-dir should only move the database files, and not the validator keys files #2945

Open asnogordo opened 7 months ago

asnogordo commented 7 months ago

Context and scope --data-dir should only move content related to the database, and the staking/key files should stay in their default location of ~/.avalanchego/staking/. There are risks with keeping the database data coupled to the key data, and I think it would be best to break them up by adding a --key-dir if validators want to specify a unique location outside of ~/.avalanchego/staking/.

It is very common for node operators to bootstrap a fresh node on another system to ensure optimal uptime of their validator, and then quickly swap volumes to minimize the outage time. However, when doing this, on the temporary system, new staking keys are generated. If you do a volume swap of the content of --data-dir, you risk wiping out your validator keys for a set of non-validator keys. Luckily I caught this and had a snapshot I could revert back to, but I see this as a serious risk for a validator to lose their staking rewards.

Discussion and alternatives add a --key-dir flag that defaults to the normal location. If people want to put it with their database, they can, but give some control and documentation.

As is, it should be called out in the documentation today that --data-dir also moves the key files. https://docs.avax.network/nodes/configure/avalanchego-config-flags#--data-dir-string

Open questions Questions that are still being discussed.

StephenButtolph commented 6 months ago

--data-dir should only move content related to the database

This is what the --db-dir flag is for. --data-dir is used for moving the default location of all sub-directories. I feel like both of these are fairly clearly documented. Would it help if we added some examples to the --data-dir description? Like:

"Sets the base data directory where default sub-directories, such as staking and db, will be placed unless otherwise specified. Defaults to $HOME/.avalanchego."

asnogordo commented 6 months ago

Thank Stephen. I think that is a good idea, and I do think it can be covered by updating the docs. It might also be worth a brief reference to each other since they are not right next to each other in the docs. It is easy to assume that --data-dir is the db directory.

--db-dir

"If you want to move the entire data directory including staking and db, check --data-dir"

--data-dir

"If you want to move just the database directory, check --db-dir"

github-actions[bot] commented 3 months ago

This issue has become stale because it has been open 60 days with no activity. Adding the lifecycle/frozen label will cause this issue to ignore lifecycle events.