Skip to content

keep the staking keys and client wallet of the previous node version on plugin update - #73

Merged
peterjah merged 2 commits into
mainfrom
node-wallets-migration
Oct 22, 2026
Merged

peterjah merged 2 commits into
mainfrom
node-wallets-migration

Conversation

@peterjah

Copy link
Copy Markdown
Contributor

Why

Each node version runs from its own folder (node-massa/MAIN.5.0, node-massa/DEVN.30.0, …), which also holds the node staking keys (massa-node/config/staking_wallets) and the client wallet (massa-client/wallets). When the plugin is updated with new node versions, Station unzips the new folders next to the old ones, and the plugin deletes the old ones at startup (RemoveOldNodeVersionsArtifacts). So after every update:

  • the node starts with no staking keys: staking stops until the user adds each address again, and rolls are deactivated if the node misses too many blocks meanwhile;
  • cleanAddressesNotInNodeButInDB deletes the rolls targets of these addresses from the database;
  • the client wallet is empty, so the node password is no longer checked against the previous one.

All stakers go through this with the MAIN.5.1 release (#72): nodes not on MAIN.5.1 stop following mainnet at MIP-0002 activation.

What

MigrateNodeVersionsData runs at startup, before the old version folders are removed. For each network, it copies massa-node/config/staking_wallets and massa-client/wallets from the highest previous version folder of that network (MAIN.* or DEVN.*) into the current one.

  • A folder is only copied when the current version does not have it or has it empty: a second start, or keys added after the update, are left untouched.
  • The copy goes through a temporary folder renamed at the end, so an interrupted copy does not block the next attempt.
  • If the migration fails, the old version folders are kept (the error is logged) and the migration is attempted again at the next start.

The files stay encrypted with the node password, so the node keeps staking the same addresses with the same password, and the rolls targets in the database are kept.

Tests

  • Unit tests: migration of both networks, no overwrite of a non-empty folder, second run, no previous version, version ordering (MAIN.4.10 > MAIN.4.2).
  • End to end on buildnet, in standalone mode:
    1. Plugin 0.4.6 layout (DEVN.30.0) with a client wallet, the same key in the node staking wallets, and a rolls target of 3 in the database. The DEVN.30.0 node itself no longer runs on buildnet: it bootstraps, then stops with "Please update your Massa node to support MIP version 2".
    2. Update as Station does it: new binary (this branch with release 0.4.7 with node MAIN.5.1 and DEVN.30.2 #72 on top) and manifest, fresh DEVN.30.2 folder unzipped next to DEVN.30.0.
    3. At startup, both wallets are copied to DEVN.30.2 and DEVN.30.0 is removed. The node starts with the previous password, bootstraps, node_get_staking_addresses returns the address, and GET /api/stakingAddresses lists it with target_rolls: 3.

@peterjah
peterjah merged commit b0ae49c into main Oct 22, 2026
8 checks passed
@peterjah
peterjah deleted the node-wallets-migration branch October 22, 2026 15: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