Running Multiple Nodes
Add a node to your Safe
Each additional node needs its own identity file, added to your existing node module. You can add one node or several at once. There is no waitlist: once a node is added, you can run it.
You create the identities with Docker on any computer with Docker Desktop, then add the nodes in Safe{Wallet} with a wallet that is a signer of your Safe. You never paste a private key.
-
Create the identities
Create an empty
hopr-identityfolder and create the identities in it, as described in Create your node identity (steps 2.2 and 2.3). Every node needs its own identity, so set--numberto how many nodes you want to add:--number 1for one more node,--number 3for three. The files are namedhopr0.id,hopr1.id, and so on.The folder must contain only these new identity files, so the next step shows only the new nodes' addresses.
-
Read the new nodes' addresses
Linux / macOS (Terminal):
docker run --rm -it --pull always \-v ~/hopr-identity:/data \-e IDENTITY_PASSWORD='<YOUR_IDENTITY_PASSWORD>' \europe-west3-docker.pkg.dev/hoprassociation/docker-images/hopli:latest \identity read \--identity-directory /dataWindows (PowerShell):
docker run --rm -it --pull always `-v "$HOME\hopr-identity:/data" `-e 'IDENTITY_PASSWORD=<YOUR_IDENTITY_PASSWORD>' `europe-west3-docker.pkg.dev/hoprassociation/docker-images/hopli:latest `identity read `--identity-directory /dataThe output shows the node addresses in square brackets, one per identity, separated by commas. Copy the whole list, including the brackets: you paste it in step 1.4.4. Example for two identities:
Identity addresses: [0x24046f39f0a4ef55dbe975e70ea0c6ac9a2d970e, 0x8f1c2a6d3b4e5f60718293a4b5c6d7e8f9012345] -
Gather the values for adding the nodes
What Where to find it Your node module address The --moduleAddressvalue of your first node, orhopr.safe_module.module_addressin itshoprd.cfg.yamlfor Docker Compose.Your new nodes' addresses The list from step 1.2, with the square brackets. -
Add the nodes in Safe{Wallet}
You send one transaction from your Safe that calls
includeNodeson your node module. Your Safe doesn't need any xDai for this: the signer wallet that executes the transaction pays the fee, so that wallet needs a small amount of xDai.-
Open your Safe
Open your Safe in Safe{Wallet} with a wallet that is a signer of your Safe, as described in Open your Safe.
-
Open Transaction Builder
Click New transaction, then Transaction Builder. If Safe{Wallet} shows a disclaimer about third-party apps, read it, select the checkbox to agree, then click Continue.
-
Enter your node module address
In Enter Address or ENS Name, paste your node module address. The node module is a proxy contract, so Transaction Builder asks which ABI to use: click Use Implementation ABI.
-
Fill in the includeNodes call
- In Contract Method Selector, select
includeNodes. - In nodeAddresses (address[]), paste the list of addresses from step 1.2, with the square brackets, for example
[0x24046f39f0a4ef55dbe975e70ea0c6ac9a2d970e]. With several identities, the list adds all the new nodes in one transaction. - Leave the XDAI value at
0.
- In Contract Method Selector, select
-
Create the batch
Click Add new transaction, then Create Batch.
-
Send the batch
Check the transaction, click Send Batch, and sign and execute it with your wallet. If your Safe needs more than one confirmation, the other signers confirm the transaction in Safe{Wallet} before it can be executed.
-
-
Move the identity files to your node machines
Each node gets one identity file, renamed to
hopr.id:- Copy
hopr0.idinto the second node's folder:~/hoprd-2for Docker, orhoprd/confinside the HOPRd-node-2 folder for Docker Compose. Rename it tohopr.id. - If you created more identities, copy
hopr1.idinto the third node's folder (~/hoprd-3or HOPRd-node-3), and so on. Rename each one tohopr.id. - Keep a backup of every identity file and its password somewhere safe outside the node folders. Note which file went to which node, then delete the temporary
hopr-identityfolder.
- Copy
Select method to run additional node
Please select Docker method to run multiple nodes:
- Docker
- Docker compose
To run several nodes on the same machine, give each node its own folder, container name and ports. Ports must not overlap between nodes on the same machine.
Start from the Docker command and change these values for the second node:
| Setting | First node | Second node |
|---|---|---|
| Node folder | -v $HOME/hoprd/:/app/hoprd-db | -v $HOME/hoprd-2/:/app/hoprd-db |
| Container name | --name hoprd | --name hoprd-2 |
| P2P port | -p 9091:9091/tcp -p 9091:9091/udp and hopr.host.port: 9091 | -p 9092:9092/tcp -p 9092:9092/udp and hopr.host.port: 9092 |
| API port | -p 3001:3001 | -p 3002:3001 |
| Session port | -p 1422:1422/udp -p 1422:1422/tcp | -p 1423:1423/udp -p 1423:1423/tcp |
| Configuration file | ~/hoprd/hoprd-docker.cfg.yaml | ~/hoprd-2/hoprd-docker.cfg.yaml: a copy with hopr.host.port: 9092 and the second node's identity password |
| Identity file | ~/hoprd/hopr.id | ~/hoprd-2/hopr.id, the second node's own file |
Metrics setup is not supported when running multiple nodes on the same machine.
To operate multiple nodes on the same device or VPS, you must use distinct "compose" folders for each node and ensure that their assigned ports do not overlap. To set up an additional node, follow these steps to avoid conflicts and ensure proper operation:
-
Change the folder name
Change the folder name of your first node from compose to HOPRd-node-1.
-
Copy the first node folder
Make a copy of a first node folder HOPRd-node-1 and rename to HOPRd-node-2 to differentiate this node's environment.
-
Modify the environment variables
Make adjustments in the .env file within your new HOPRd-node-2 folder, assuming you are using the default ports:
- Change the HOPRD_API_PORT from
3001to3002. - Adjust the HOPRD_P2P_PORT from
9091to9092.
- Change the HOPRD_API_PORT from
-
Modify secret environment variables
Modify secret environment variables, make adjustments if needed under .env-secrets file within your new HOPRd-node-2 folder.
-
Modify the docker compose file
Make adjustments in the docker-compose.yml file within your new HOPRd-node-2 folder:
Under services.hoprd, change the container_name from
hoprdtohoprd-2. -
Configure your node
Inside the HOPRd-node-2 folder, open
hoprd/conf/hoprd.cfg.yamland changehopr.host.portfrom9091to9092. -
Copy the identity file
Copy the second node's identity file from Add a node to your Safe into
hoprd/confinside the HOPRd-node-2 folder and name ithopr.id. -
Launch Docker Compose
When running multiple nodes, for the second node, you only need to use the hoprd profile. Ensure you are in the HOPRd-node-2 folder when executing the command:
COMPOSE_PROFILES=hoprd docker compose up -d
These changes ensure that each node operates independently without interference, allowing for efficient management and scalability.
Fund your node with xDai
When the second node starts, it shows its address and waits until it has xDai. Find the address with docker logs hoprd-2 2>&1 | grep "blockchain_address" and send at least 0.01 xDai to it. Look for node announced successfully in docker logs -f hoprd-2.