3

I have a relay chain running with two validators. I wanted to connect a parachain with one collator node. I want to use my own key for the collator instead of using the predefined keys like //Alice etc.

Can anyone please point me to a guide to achieve this task?

1 Answer 1

3

To add a new collator key to your Polkadot parachain in a development setup, you can follow these steps:

Generate a new key pair for the collator using a tool such as subkey or polkadot-js.

Add the new key to your local node's keystore by running the following command:

polkadot-js keyring add <key-name> --type sr25519 --suri <path-to-my-key>

Replace <key-name> with the name you want to give to your new key and <path-to-my-key> with the path to the file containing your key.

Update your node's configuration file to include the new collator key. The configuration file is usually located in the ./config directory and is named chain_spec.rs. You will need to update the genesis section and add the new key to the validators array:

"genesis": {
    ...
    "validatorIds": [
        "<existing-validator-1>",
        "<existing-validator-2>",
        "<new-collator-key>"
    ]
    ...
}

Replace <existing-validator-1> and <existing-validator-2>

with the existing validator keys that you want to retain, and replace <new-collator-key> with the new key you just generated.

Restart your node to apply the changes.

Once you have completed these steps, your node should be able to function as a collator using the new key you added.

edit1: Have you gone through these steps?

Generate a new keypair for the collator node using the subkey command-line tool.

subkey generate --scheme sr25519

Add the generated key to the aura section of the collator's chain specification file.

"aura": {
  "authorities": ["your_generated_key"],
  "params": {
    "stepDuration": 6,
    "validators": 1
  }
}

Launch the collator node with the new key using the --validator and --key flags.

./collator_binary --validator --key "your_generated_key_seed"

Update the relay chain's chain specification file to include the parachain with the collator's node endpoint and ID.

"parachains": {
  "2001": {
    "bin": "path/to/parachain/binary",
    "id": 2001,
    "paraGenesis": "path/to/para/genesis",
    "collatorEndpoint": "/ip4/<collator_node_ip>/tcp/<collator_node_port>"
  }
}

Finally, start the relay chain and connect it with the parachain by referencing its ID.

./relaychain_binary --parachain-id 2001

I hope this helps.

2
  • Thanks @Kayvan for the quick response. I am following exactly the same procedure to register my collator with the relay chain but my parachain is not producing any blocks. When I connect the parachain with the relay chain with the custom collator at work (Alice, bob) it produces blocks but when I generate my own account keys and use these keys as collator, the parachain stop producing blocks. I am using following command to generate my keys: ./target/release/my-node key generate --scheme Sr25519 --password-interactive Commented Apr 12, 2023 at 17:41
  • Thank you very much! It worked. Now the parachain is producing blocks. Commented Apr 12, 2023 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.