Skip to content

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.
  1. Pull the Polkadot Parachain Docker image using the latest stable tag on Docker Hub:

    docker pull parity/polkadot-parachain:stable2609-1
    
  2. Verify the installation:

    docker run --rm parity/polkadot-parachain:stable2609-1 --version
    
  1. Download the polkadot-parachain binary using the latest stable Polkadot SDK release:

    wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-stable2609-1/polkadot-parachain
    
  2. Make it executable and move it to your system path:

    chmod +x polkadot-parachain
    sudo mv polkadot-parachain /usr/local/bin/
    sudo chown root:root /usr/local/bin/polkadot-parachain
    
  3. Verify installation:

    polkadot-parachain --version
    

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:

  1. Generate your node key using one of the following options:

    docker run --rm parity/subkey:latest generate-node-key > node.key
    
    polkadot-parachain key generate-node-key --file node.key
    
  2. Locate your peer ID in the displayed output. The peer ID is similar to this example:

    12D3KooWExcVYu7Mvjd4kxPVLwN2ZPnZ5NyLZ5ft477wqzfP2q6E
    

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:

  1. Create a directory for collator data and copy the chain spec and node key:

    mkdir -p collator-data
    cp chain-spec.json collator-data/
    cp node.key collator-data/
    
  2. 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
    
  3. View logs to monitor sync progress:

    docker logs -f polkadot-collator
    
  1. Create a dedicated user:

    sudo useradd -r -s /bin/bash polkadot
    
  2. Create the data directory, then copy your chain spec and node key into it:

    sudo mkdir -p /var/lib/polkadot-collator
    sudo cp chain-spec.json /var/lib/polkadot-collator/
    sudo cp node.key /var/lib/polkadot-collator/
    
  3. Set permissions:

    sudo chown -R polkadot:polkadot /var/lib/polkadot-collator
    
  4. Create a systemd service file:

    sudo nano /etc/systemd/system/polkadot-collator.service
    
  5. 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
    
  6. Start the service:

    sudo systemctl daemon-reload
    sudo systemctl enable polkadot-collator
    sudo systemctl start polkadot-collator
    
  7. Check the status:

    sudo systemctl status polkadot-collator
    
  8. View logs:

    sudo journalctl -u polkadot-collator -f
    
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:

    docker stop polkadot-collator
    
  • Start container:

    docker start polkadot-collator
    
  • Remove container:

    docker rm polkadot-collator
    
  • Check status:

    sudo systemctl status polkadot-collator
    
  • Stop service:

    sudo systemctl stop polkadot-collator
    
  • Enable service:

    sudo systemctl enable polkadot-collator
    
  • Start service:

    sudo systemctl start polkadot-collator
    

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:

    docker logs -f polkadot-collator
    
  • View recent logs (last 100 lines):

    docker logs --tail 100 polkadot-collator
    
  • Filter for errors:

    docker logs polkadot-collator 2>&1 | grep -i error
    
  • Filter for block production:

    docker logs polkadot-collator 2>&1 | grep -i "imported"
    
  • View recent logs:

    sudo journalctl -u polkadot-collator -n 100
    
  • Follow logs in real-time:

    sudo journalctl -u polkadot-collator -f
    
  • Filter for errors:

    sudo journalctl -u polkadot-collator | grep -i error
    
  • Filter for block production:

    sudo journalctl -u polkadot-collator | grep -i "imported"
    

Database Maintenance

Check database size periodically using the commands for your selected setup:

# Replace with your mounted data directory path
du -sh ./collator-data
du -sh /var/lib/polkadot-collator

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:

  1. Stop and remove the container:

    docker stop polkadot-collator
    docker rm polkadot-collator
    
  2. Back up data (recommended):

    cp -r ./collator-data ./collator-data.backup
    
  3. Pull the new Docker image:

    docker pull parity/polkadot-parachain:INSERT_NEW_TAG
    
  4. Start the collator again with the docker run command from Run the Collator, using the new image tag.

  1. Stop the service:

    sudo systemctl stop polkadot-collator
    
  2. Back up data (recommended):

    sudo cp -r /var/lib/polkadot-collator /var/lib/polkadot-collator.backup
    
  3. Download the new binary from GitHub releases:

    wget https://github.com/paritytech/polkadot-sdk/releases/download/INSERT_NEW_VERSION/polkadot-parachain
    chmod +x polkadot-parachain
    sudo mv polkadot-parachain /usr/local/bin/
    
  4. Verify polkadot-parachain version to confirm successful update:

    polkadot-parachain --version
    
  5. Restart the service:

    sudo systemctl start polkadot-collator
    
  6. Verify the service is running:

    sudo systemctl status polkadot-collator
    

Where to Go Next

Last update: November 17, 2026
| Created: November 17, 2026