Run a Block-Producing Collator¶
Introduction¶
A collator is a parachain node started in collator mode. Unlike RPC or archive nodes, which serve state, collators produce blocks: they collect transactions, build parachain block candidates, generate the Proof-of-Validity (PoV) that relay chain validators need to check them, and submit the candidates for inclusion. Collators keep both the parachain and the relay chain in sync and handle cross-chain messages through XCM. They provide liveness and censorship resistance; security comes from the relay chain validators through the ELVES protocol.
This guide runs the polkadot-parachain binary with the --collator flag. It covers the node key, the chain specification, the collator startup flags, session key generation, and routine maintenance. The same flags work with Polkadot Omni Node for parachains that use it.
Which collators a parachain accepts is set by its runtime and governance. For the process to become a collator on a Polkadot system parachain, including invulnerables, bonds, and hardware expectations, see Run a Block-Producing Collator on the Polkadot Developer Docs.
Prerequisites¶
Before you start, make sure you have the following:
- Operating system: Ubuntu 22.04 LTS (recommended) or a similar Linux distribution.
- Docker: Required for the Docker deployment option.
- Open ports: 30333 for parachain P2P and 30334 for relay chain P2P.
Install the Binary¶
This guide provides two deployment options. Select the option that best fits your needs:
- Docker: Best for simpler setup and maintenance.
- systemd: Best for production environments requiring more control.
-
Pull the Polkadot Parachain Docker image using the latest stable tag on Docker Hub:
-
Verify the installation:
-
Download the
polkadot-parachainbinary using the latest stable Polkadot SDK release: -
Make it executable and move it to your system path:
-
Verify installation:
Generate Node Key¶
Validators and collators on Polkadot need a static network key (also known as the node key) to maintain a stable node identity. This key ensures that your node can maintain a consistent peer ID, even across restarts, which is crucial for maintaining reliable network connections.
Follow these steps to generate a node key:
-
Generate your node key using one of the following options:
-
Locate your peer ID in the displayed output. The peer ID is similar to this example:
Be sure to save the peer ID for future reference.
Obtain the Chain Specification¶
The collator needs the parachain's chain specification file, saved as chain-spec.json. See Obtain the Chain Specification for where to find it.
Run the Collator¶
In the following commands, replace INSERT_RELAY_CHAIN with the relay chain the parachain connects to, as a built-in chain identifier (such as polkadot, kusama, westend, or paseo) or the path to a relay chain specification file. With Docker, place a relay chain specification file in collator-data and pass its path under /data.
Using your preferred deployment method, take the following steps to set up and run your collator:
-
Create a directory for collator data and copy the chain spec and node key:
-
Launch the collator using Docker:
docker run -d --name polkadot-collator --restart unless-stopped \ -p 30333:30333 \ -p 30334:30334 \ -p 9944:9944 \ -p 9615:9615 \ -v $(pwd)/collator-data:/data \ parity/polkadot-parachain:stable2609-1 \ --collator \ --chain=/data/chain-spec.json \ --base-path=/data \ --port=30333 \ --rpc-port=9944 \ --prometheus-port=9615 \ --prometheus-external \ --node-key-file=/data/node.key \ --name="INSERT_YOUR_COLLATOR_NAME" \ --blocks-pruning=256 \ --state-pruning=256 \ --database=paritydb \ -- \ --chain=INSERT_RELAY_CHAIN \ --port=30334 \ --sync=fast \ --blocks-pruning=256 \ --state-pruning=256 \ --database=paritydb \ --pool-limit=0 \ --rpc-port=0 -
View logs to monitor sync progress:
-
Create a dedicated user:
-
Create the data directory, then copy your chain spec and node key into it:
-
Set permissions:
-
Create a systemd service file:
-
Add the following configuration:
systemd/system/polkadot-collator.service[Unit] Description=Parachain Collator After=network.target [Service] Type=simple User=polkadot Group=polkadot WorkingDirectory=/var/lib/polkadot-collator ExecStart=/usr/local/bin/polkadot-parachain \ --collator \ --chain=/var/lib/polkadot-collator/chain-spec.json \ --base-path=/var/lib/polkadot-collator \ --port=30333 \ --rpc-port=9944 \ --prometheus-port=9615 \ --node-key-file=/var/lib/polkadot-collator/node.key \ --name="INSERT_YOUR_COLLATOR_NAME" \ --blocks-pruning=256 \ --state-pruning=256 \ --database=paritydb \ -- \ --chain=INSERT_RELAY_CHAIN \ --port=30334 \ --sync=fast \ --blocks-pruning=256 \ --state-pruning=256 \ --database=paritydb \ --pool-limit=0 \ --rpc-port=0 Restart=always RestartSec=10 LimitNOFILE=65536 [Install] WantedBy=multi-user.target -
Start the service:
-
Check the status:
-
View logs:
Configuration Arguments
--collator: Enables block production mode.--node-key-file: Uses the generated node key for stable peer ID.--name: Your collator name, shown in logs and on any telemetry server the node reports to.--blocks-pruning=256: Keeps the last 256 blocks.--state-pruning=256: Keeps the state history of the last 256 blocks.--database=paritydb: Uses ParityDB for better performance.--sync=fast: Fast sync mode for the relay chain.--pool-limit=0: Disables transaction pool on relay chain (not needed for collators).--rpc-port=0(relay chain): Disables RPC on the embedded relay chain node (not needed for collators).
Your collator must sync both the relay chain and parachain before producing blocks. The relay chain uses fast sync to speed up synchronization. Overall sync time depends on network bandwidth, disk I/O speed, and the size of each chain.
Note
If you also operate relay chain nodes, such as RPC nodes, you can point the collator to their RPC endpoints using the --relay-chain-rpc-urls argument. This allows the collator to retrieve relay chain data from these nodes, reducing the resources required to sync and maintain the embedded relay chain node.
Warning
Do not register your session keys until both chains are fully synced. Monitor sync progress using the commands in the Log Management section.
Generate Session Keys¶
Session keys are cryptographic keys your collator uses to sign authorship information when producing blocks. They identify your collator on the network and must be registered on-chain before it can take part in block production.
Generate session keys by calling the author_rotateKeys RPC method on your node:
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys", "params":[]}' \
http://localhost:9944
The result field contains the hex-encoded public session keys. The node stores the private keys in its keystore.
If the chain's runtime requires a proof of key ownership at registration, call author_rotateKeysWithOwner instead and pass the owner data the runtime verifies, typically the account ID that registers the keys. It returns the session keys in keys and the ownership proof in proof:
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeysWithOwner", "params":["INSERT_ACCOUNT_ID"]}' \
http://localhost:9944
Save your session key output immediately
Each call generates new keys. It does not return previously generated keys, so if you lose the output, call the method again and register the new result.
Register the Session Keys¶
On parachains that use pallet-collator-selection and pallet-session, such as those built from the standard templates, you register session keys with the session.setKeys extrinsic, signed by your collator's account. Pass the keys value from Generate Session Keys and the proof value, or 0x00 as the proof if the runtime does not verify one. Whether your collator is then selected to produce blocks depends on the parachain's collator selection rules, which may be a governance-managed list or an on-chain candidacy. Check the parachain's documentation for its process.
Once your collator is selected, it starts producing blocks in the next session. Verify that it is active by checking the logs for block production messages such as "Prepared block for proposing" and "Imported #123". See Commands for Log Management.
Commands for Node Management¶
Use the following commands to manage your node:
-
Stop container:
-
Start container:
-
Remove container:
Commands for Log Management¶
Efficient log management is essential to ensure collator performance and uptime. Use the following commands to help you manage logs to monitor and maintain your collator:
-
View logs:
-
View recent logs (last 100 lines):
-
Filter for errors:
-
Filter for block production:
Database Maintenance¶
Check database size periodically using the commands for your selected setup:
The collator node automatically prunes based on configuration.
Updates and Upgrades¶
Updates can happen to either the runtime or the node binary. Runtime upgrades are applied on-chain and need no action on the node. Node upgrades require replacing the binary or image as follows:
-
Stop and remove the container:
-
Back up data (recommended):
-
Pull the new Docker image:
-
Start the collator again with the
docker runcommand from Run the Collator, using the new image tag.
-
Stop the service:
-
Back up data (recommended):
-
Download the new binary from GitHub releases:
-
Verify
polkadot-parachainversion to confirm successful update: -
Restart the service:
-
Verify the service is running:
Where to Go Next¶
- To collect metrics and set up alerts, see Monitor and Harden a Node.
- To test a collator against a local relay chain, see Run a Parachain Network.
| Created: November 17, 2026