Set up full and archive nodes for Midnight
Running a full or archive node allows you to sync with the Midnight blockchain, validate transactions, and maintain the chain's state without relying on third-party infrastructure. Full nodes are ideal for real-time interaction and efficient storage, while archive nodes provide comprehensive historical data for applications requiring deep blockchain analysis.
Full node vs. archive node
A full node syncs with the blockchain, validates transactions, and provides real-time state queries. It prunes historical states older than a configurable number of blocks (default: 256 blocks), making it suitable for most DApp development and real-time network interactions. Full nodes use disk space efficiently, requiring significantly less storage than archive nodes.
An archive node maintains the entire history of the blockchain, including all blocks and states since genesis. This comprehensive storage consumes substantial disk space but is essential for use cases requiring access to historical data, such as:
- Building block explorers
- Conducting in-depth blockchain analysis or debugging
- Querying historical transaction data
- Auditing complete chain history
Set up an archive node by adding the --state-pruning archive --blocks-pruning archive parameters.
Prerequisites
Before setting up your Midnight full 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 full node
The following steps show how to set up a full 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 full node
Use the following Docker command to set up your full node. Choose the configuration for your target network.
- Preview
- Preprod
docker run \
--name midnight-full-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" \
midnightntwrk/midnight-node:<VERSION> \
--chain /res/preview/chain-spec-raw.json \
--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-full-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" \
midnightntwrk/midnight-node:<VERSION> \
--chain /res/preprod/chain-spec-raw.json \
--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
For production deployments, enable SSL/TLS for PostgreSQL connections. Only set ALLOW_NON_SSL=true for local development environments.
Set up an archive node
The following steps show how to set up an archive 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 an archive node
To set up an archive node, add the pruning parameters to store all historical states. Choose the configuration for your target network.
- Preview
- Preprod
docker run \
--name midnight-archive-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" \
midnightntwrk/midnight-node:<VERSION> \
--chain /res/preview/chain-spec-raw.json \
--bootnodes /dns/bootnode-1.preview.midnight.network/tcp/30333/ws/p2p/12D3KooWK66i7dtGVNSwDh9tTeqov1q6LSdWsRLJvTyzTCaywYgK \
--bootnodes /dns/bootnode-2.preview.midnight.network/tcp/30333/ws/p2p/12D3KooWHqFfXFwb7WW4jwR8pr4BEf562v5M6c8K3CXAJq4Wx6ym \
--state-pruning archive \
--blocks-pruning archive \
--no-private-ip
docker run \
--name midnight-archive-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" \
midnightntwrk/midnight-node:<VERSION> \
--chain /res/preprod/chain-spec-raw.json \
--bootnodes /dns/bootnode-1.preprod.midnight.network/tcp/30333/ws/p2p/12D3KooWQxxUgq7ndPfAaCFNbAxtcKYxrAzTxDfRGNktF75SxdX5 \
--bootnodes /dns/bootnode-2.preprod.midnight.network/tcp/30333/ws/p2p/12D3KooWNrUBs22FfmgjqFMa9ZqKED2jnxwsXWw5E4q2XVwN35TJ \
--state-pruning archive \
--blocks-pruning archive \
--no-private-ip
Replace the same placeholder values as in the full node setup above.
Archive nodes require significantly more disk space than full nodes. Ensure you have sufficient storage capacity (4+ TB recommended for Mainnet) before running an archive node.
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.
Next steps
With the full node set up, you can start using the Node endpoints to interact with the Midnight blockchain.