Set up boot node for Midnight
Boot nodes serve as initial connection points for nodes joining the Midnight Network. They help new nodes discover and connect to active peers in the network. While running a boot node is optional, doing so strengthens network decentralization and improves peer discovery.
Boot Node
A boot node is a node that helps other nodes connect to the Midnight blockchain by providing a list of active peer addresses. Any node can function as a boot node - it's determined by usage rather than unique configuration. When a node starts, it connects to known boot nodes to discover other peers in the network.
Prerequisites
Before setting up your Midnight boot node, ensure you have the following:
- Docker installed and configured.
- Cardano-db-sync instance set up with accessible PostgreSQL port.
- Sufficient resources (CPU, memory, and storage).
Set up a boot node
The following steps show how to set up a boot node on Midnight's Preview and Preprod networks.
Step 1: Configure PostgreSQL database
Set up a PostgreSQL instance with the following parameters:
- Host: PostgreSQL server address
- Port: Default 5432
- Username: Database user
- Password: Database password
- Database name: Name of the database (for example, cexplorer)
Step 2: Run the Docker command for a boot node
Use the following Docker command to set up your boot node. Replace placeholder values with your actual configuration.
- Preview
- Preprod
docker run \
--name midnight-boot-node \
--platform linux/amd64 \
-p 30333:30333 \
-v midnight-data:/node \
-e CFG_PRESET="preview" \
-e BASE_PATH="/node/chain/" \
-e POSTGRES_HOST="<your-postgres-host>" \
-e POSTGRES_PORT="5432" \
-e POSTGRES_USER="<your-db-user>" \
-e POSTGRES_PASSWORD="<your-db-password>" \
-e POSTGRES_DB="cexplorer" \
midnightnetwork/midnight-node:<VERSION> \
--chain=/res/preview/chain-spec-raw.json \
--listen-addr /ip4/0.0.0.0/tcp/30333 \
--bootnodes /dns/bootnode-1.preview.midnight.network/tcp/30333/ws/p2p/12D3KooWK66i7dtGVNSwDh9tTeqov1q6LSdWsRLJvTyzTCaywYgK \
--bootnodes /dns/bootnode-2.preview.midnight.network/tcp/30333/ws/p2p/12D3KooWHqFfXFwb7WW4jwR8pr4BEf562v5M6c8K3CXAJq4Wx6ym \
--no-private-ip
docker run \
--name midnight-boot-node \
--platform linux/amd64 \
-p 30333:30333 \
-v midnight-data:/node \
-e CFG_PRESET="preprod" \
-e BASE_PATH="/node/chain/" \
-e POSTGRES_HOST="<your-postgres-host>" \
-e POSTGRES_PORT="5432" \
-e POSTGRES_USER="<your-db-user>" \
-e POSTGRES_PASSWORD="<your-db-password>" \
-e POSTGRES_DB="cexplorer" \
midnightnetwork/midnight-node:<VERSION> \
--chain=/res/preprod/chain-spec-raw.json \
--listen-addr /ip4/0.0.0.0/tcp/30333 \
--bootnodes /dns/bootnode-1.preprod.midnight.network/tcp/30333/ws/p2p/12D3KooWQxxUgq7ndPfAaCFNbAxtcKYxrAzTxDfRGNktF75SxdX5 \
--bootnodes /dns/bootnode-2.preprod.midnight.network/tcp/30333/ws/p2p/12D3KooWNrUBs22FfmgjqFMa9ZqKED2jnxwsXWw5E4q2XVwN35TJ \
--no-private-ip
Replace the following:
<VERSION>- Node version from the release compatibility matrix<your-postgres-host>- PostgreSQL server address (usehost.docker.internalif Cardano-db-sync runs on the same machine)<your-db-user>- Database username configured in Cardano-db-sync<your-db-password>- Database password configured in Cardano-db-sync
Set ALLOW_NON_SSL=true only for local development environments without SSL certificates. Production deployments should always use SSL/TLS for PostgreSQL connections.
Known network boot nodes
Use the boot nodes corresponding to your target network environment.
- Preview
- Preprod
--bootnodes /dns/bootnode-1.preview.midnight.network/tcp/30333/ws/p2p/12D3KooWK66i7dtGVNSwDh9tTeqov1q6LSdWsRLJvTyzTCaywYgK \
--bootnodes /dns/bootnode-2.preview.midnight.network/tcp/30333/ws/p2p/12D3KooWHqFfXFwb7WW4jwR8pr4BEf562v5M6c8K3CXAJq4Wx6ym
--bootnodes /dns/bootnode-1.preprod.midnight.network/tcp/30333/ws/p2p/12D3KooWQxxUgq7ndPfAaCFNbAxtcKYxrAzTxDfRGNktF75SxdX5 \
--bootnodes /dns/bootnode-2.preprod.midnight.network/tcp/30333/ws/p2p/12D3KooWNrUBs22FfmgjqFMa9ZqKED2jnxwsXWw5E4q2XVwN35TJ
You can specify multiple boot nodes for redundancy. The node will attempt to connect to all provided boot nodes and use them to discover additional peers.
Verify the Node
The commands below show how to verify the node's connectivity and logs.
Check logs
Monitor the node's logs to ensure it syncs with the network:
docker logs -f <node-name>
Test connectivity
Ensure the node's P2P port (default: 30333) is open and reachable for network communication. Use tools like telnet, netcat, or nmap to verify the port status and ensure the node is properly connected to the network.