2

I am referring this documentation on preparing a local relay chain in which they have provided a plain sample relay chain spec. Also, I have cloned this release locally. The documentation says that

For this tutorial, the local relay chain uses a sample chain specification file with two validator relay chain nodes—Alice and Bob—as authorities. Because a relay chain must have at least one more validator node running than the total number of connected parachain collators, you can only use the chain specification from this tutorial for a local relay chain network with a single parachain. If you wanted to connect two parachains with a single collator each, you would need to run three or more relay chain validator nodes. In general, you would need to modify the chain specification and hard-code additional validators to set up a local test network for two or more parachains.

My question is "How do I modify the chain spec and hardcode an additional relay chain validator to setup a local test network for two or more parachains?"

3 Answers 3

1

The long way is to modify the chain spec.rs (or the plain json chain spec) of the Relay chain and regenerate the raw chain spec. You can look at this:

The quick way is to use Zombienet and spin up a Relay chain with multiple validators quickly:

1
  • I tried with zombie net and it worked
    – RRR
    Jan 17 at 10:44
0

I believe you can quickly modify the genesis by using parachain-launch.

https://github.com/open-web3-stack/parachain-launch/blob/06da5c4aa749efce78473e8c02a07cfb118d1881/src/index.ts#L179

I think it can overwrite the genesis validators based on the link above.


Alternatively, you can clone the repository and modify this section: https://github.com/paritytech/polkadot-sdk/blob/f6ee4781f633f0f89598f7b230595afe401da8dc/polkadot/node/service/src/chain_spec.rs#L967.

I don't know which network you are using, but here you can add more initial_authorities for the Rococo Development network.

After modifying, compile the node and follow the tutorial to build the desired genesis file.

0

I tried using zombienet which helped me set up a test network. I do not want to use zombienet now. What I did was go here and add an extra key Charlie something like below

#[cfg(feature = "rococo-native")]
fn rococo_local_testnet_genesis(wasm_binary: &[u8]) -> rococo_runtime::RuntimeGenesisConfig {
    rococo_testnet_genesis(
        wasm_binary,
        vec![get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed("Bob"), get_authority_keys_from_seed("Charlie"),],
        get_account_id_from_seed::<sr25519::Public>("Alice"),
        None,
    )
}

Used the following command to generate a raw chain spec

./target/release/polkadot build-spec --chain rococo-local --disable-default-bootnode --raw > rococo-local.json

and got something like below

2024-01-17 16:25:40 Took active validators from set with wrong size
2024-01-17 16:25:40 Took active validators from set with wrong size
2024-01-17 16:25:40 Took active validators from set with wrong size.
2024-01-17 16:25:40 Took active validators from set with wrong size

What is the issue here? It's like zombienet did the job for me but when I am trying to do it I do not understand what is happening.

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.