Skip to content

Commit 4a3f84a

Browse files
authored
Merge pull request #100 from sacherjj/moving-node-update
Updating node moving page.
2 parents 6e725f6 + 0ec1ad2 commit 4a3f84a

File tree

1 file changed

+83
-47
lines changed

1 file changed

+83
-47
lines changed

versioned_docs/version-2.0.0/operators/maintenance/moving-node.md

Lines changed: 83 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,91 +6,127 @@ title: Move a Node
66

77
This guide is for active validators who want to move their node to another machine.
88

9-
:::note
9+
## Setup two nodes running in parallel
1010

11-
Starting with node version 1.5, operators need to move the unit files at the database level. This step allows moving the node with nearly zero rewards loss.
11+
This method limits downtime and enables a smooth transition from the old to the new node. It keeps the node in sync with the tip of the chain.
1212

13-
:::
13+
Existing node should be running and in sync with network. We will call this `old node`. It is using your active `validator key`.
14+
Create a second node (`new node`) on another machine. This should sync with the network as `ttl`. This server needs a new key when started, we will call this `backup key`.
1415

15-
## Swapping Keys with a Hot Backup
16+
Important: You NEVER want to run two nodes using the same validator key. Our swap procedure will always stop a node running validator key first.
1617

17-
This method limits downtime and enables a smooth transition from the old to the new node. It keeps the node in sync with the tip of the chain.
18+
### Preparation of keys on both nodes
1819

19-
1. Once a node is running (`current_node`), create a second node (`backup_node`) on another machine. These two nodes will run in parallel.
20-
2. When the `backup_node` is up to date, stop the `current_node`.
21-
3. Move the unit files at the DB level using `rsync`. This step allows moving the node with nearly zero rewards loss.
22-
4. Stop the `backup_node`.
23-
5. Swap keys on the `backup_node`, now the new validator.
24-
6. Restart the `backup_node`.
25-
7. Swap keys on the `current_node`, now the new backup.
26-
8. Restart the `current_node`.
27-
28-
### Preparation for swapping
29-
30-
1. Let both nodes synchronize to the tip of the blockchain. Keep the current validating node running with the original validator keyset.
31-
32-
2. Prepare to swap keys by following these steps:
20+
Prepare to swap keys by following these steps:
3321

3422
- Create the following folder structure on both nodes under the `/etc/casper/validator_keys/` directory.
35-
- Create subdirectories for the `current_node` and `backup_node`.
23+
- Create subdirectories for the `validator` and `backup`.
3624
- Copy each node's keyset under the corresponding directories.
3725

3826
```bash
3927
/etc/casper/validator_keys/
4028
├── public_key.pem
4129
├── public_key_hex
4230
├── secret_key.pem
43-
├── current_node
31+
├── validator
4432
│ ├── public_key.pem
4533
│ ├── public_key_hex
4634
│ └── secret_key.pem
47-
└── backup_node
35+
└── backup
4836
| ├── public_key.pem
4937
| ├── public_key_hex
5038
| └── secret_key.pem
5139
```
5240

41+
By having both keys available, we can swap back if we have any issues.
42+
5343
This setup allows key swapping by running the `sudo -u casper cp * ../` command, as shown below.
5444

55-
### Swapping the nodes
45+
After creating the keys, check and fix file permissions by running `casper-node-util check_premissions` and use `sudo casper-node-util fix_permissions` if needed.
46+
47+
### Swapping the keys
5648

57-
1. When the `backup_node` is up to date, stop the `current_node`.
49+
To swap keys, we want the node to be stopped first.
5850

59-
2. On the `backup_node` (the future validator), use `rsync` to move the unit files from the `current_node`, located in `/var/lib/casper/casper-node/[NETWORK_NAME]/unit_files`.
51+
```bash
52+
sudo /etc/casper/node_util.py stop
53+
```
6054

61-
3. On the `backup_node`, run these commands to stop the node, swap keys, and restart the node:
55+
To enable a node to run as validator, we want to copy keys from `validator` directory.
6256

63-
```bash
64-
sudo systemctl stop casper-node-launcher
65-
cd /etc/casper/validator_keys/current_node
57+
```bash
58+
cd /etc/casper/validator_keys/validator
6659
sudo -u casper cp * ../
67-
sudo systemctl start casper-node-launcher
68-
```
60+
```
6961

70-
4. On the `current_node`, run these commands to stop the node and swap keys:
62+
To enable a node to run as backup, we want to copy keys from `backup` directory.
7163

72-
```bash
73-
sudo systemctl stop casper-node-launcher
74-
cd /etc/casper/validator_keys/backup_node
64+
```bash
65+
cd /etc/casper/validator_keys/backup
7566
sudo -u casper cp * ../
76-
```
67+
```
68+
69+
### Timing of swap for consensus
70+
71+
With Zug consensus, all needed state is persisted to the DB. This allows full network resume if all validators were stopped and started again. This does not
72+
allow moving consensus state as easy as moving unit_files. We are working on a utility to export this and allow importing on new node.
7773

78-
5. Restart the original validator node (`current_node`), which is now the new backup:
74+
If a node is moved without this data and started too soon, we get a situation where the new node signs blocks previously signed. This causes issues.
7975

80-
```bash
81-
sudo systemctl start casper-node-launcher
82-
```
76+
The best method to swap currently uses the Era boundaries to isolate finality signature sending.
8377

84-
### Understanding rewards impact
78+
This will describe how to manually find the last switch block time.
8579

86-
After swapping, the new validator node shows no round length until an era transition occurs and will lose all rewards from the point of the switch until the end of that era. The validator is not ejected but will receive rewards starting with the next era.
80+
We will use the `get-era-summary` command in the `casper-client` to find the last switch block. Then get the block to find the time.
81+
The commands will be shown separated, in case the give errors. If everything works, the single command at the end will give you the time.
8782

88-
:::tip
83+
```bash
84+
$ casper-client get-era-summary | jq -r .result.era_summary.block_hash
85+
2487f80a5b1aed5bd36e19f1ccad075a277d5159319da14b07c3d3d954d269dc
86+
```
87+
88+
We can take the block_hash (2487f80a5b1aed5bd36e19f1ccad075a277d5159319da14b07c3d3d954d269dc) to get that block and timestamp.
89+
90+
```bash
91+
$ casper-client get-block -b 2487f80a5b1aed5bd36e19f1ccad075a277d5159319da14b07c3d3d954d269dc | jq -r .result.block_with_signatures.block.Version2.header.timestamp
92+
2025-09-03T13:15:58.738Z
93+
```
94+
95+
This can be combined into a single command:
96+
97+
`casper-client get-block -b $(casper-client get-era-summary | jq -r .result.era_summary.block_hash | tr -d '/n') | jq -r .result.block_with_signatures.block.Version
98+
2.header.timestamp`
99+
100+
Time of the era will be 2 hours after this time. Current time in the same format can be shown with `date -Is`.
101+
102+
We want to start the change over just before the era transition.
103+
104+
### Swap operation
105+
106+
Starting at 5 minutes before era transition. Stop both nodes with:
107+
108+
`sudo /etc/casper/node_util.py stop`
109+
110+
We do not want to start again until after the Era transition, but we can prepare.
111+
112+
On the `old node` we replace the validator key, so if it restarts we do not have two of the same keys running.
113+
114+
```bash
115+
cd /etc/casper/validator_keys/backup
116+
sudo -u casper cp * ../
117+
```
118+
119+
On the `new node` we setup the validator key.
120+
121+
```bash
122+
cd /etc/casper/validator_keys/validator
123+
sudo -u casper cp * ../
124+
```
89125

90-
You could time the swap right before the era ends to minimize reward losses.
126+
Wait until the era transitions past the switch block. This can be monitored using the appropriate `cspr.live` website for the network.
91127

92-
:::
128+
Start the `new node`:
93129

94-
### Checking file permissions
130+
`sudo /etc/casper/node_util.py start`
95131

96-
After the swap, check and fix file permissions by running the `/etc/casper/node_util.py` utility.
132+
Start the `old node` if you want it as a backup.

0 commit comments

Comments
 (0)