3

I noticed that the chain specification for Polkadot contains a paras field that is empty. I have not been able to find any documentation on what it is used for or if I can specify parachains there to avoid having to reserve a spot after the chain has been launched. I am aiming to run a local relay chain and parachains for testing purposes.

Will the paras field allow me to add parachains as part of the genesis state and is there anywhere I can find documentation on its usage?

0

2 Answers 2

3

You can add the parachains to the paras field in your chain-spec. For doing this you can follow this steps:

  1. Create the chain-spec in plain text `polkadot build-spec --chain rococo-local --disable-default-bootnode

    rococo-local-plain.json` (I will use rococo-local as chain)

  2. Edit this file and add your para into paras field, with this format
 paras: [
   [ <para_id>, [<para_head>,<para_wasm>, true]
 ]

Where: para_id : is your parachain id.

para_head : you can get it running polkadot-parachain export-genesis-state

para_wasm : you can get it running polkadot-parachain export-genesis-wasm And the last param (true) is to set the as parachain.

  1. You need then to get the raw file from your edited plain file

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

  2. Then you can start your relay-chain nodes using this chain-spec (rococo-local-raw.json).

  3. You need to start a collator of your parachain, using this chain-spec for the relay-chain and you can use one of the dev accounts for the collator. For example --alice

You can follow this tutorial to get the step-by-step instructions.

Also, this could be handled easily by zombienet and get your network running in one of the available providers (native, podman or kubernetes). Please, let me know if you have questions about zombienet and I can help you.

5
  • Thanks! This was what I suspected and wanted confirmation on/a description of. Is this documented anywhere? Commented Apr 11, 2023 at 17:32
  • In terms of Zombienet, I spent a month trying to get it running a few months back and ended up not using it. I attempted to use the Kubernetes provider without any luck and ended up learning Kubernetes and setting it up from scratch. (I wanted to learn k8s and the additional control will be useful for what I had planned, so it was not purely due to Zombienet). Edit: I was working on it on and off during that month and it was mainly a couple of hours a week and a lot of thinking and reading in between, while working on other things Commented Apr 11, 2023 at 17:38
  • Hey, thanks for your feedback. Zombienet should work easily with k8s (or using a local alternative like kind, docker desktop). Please open new questions if something doesn't works and I can answer there. Thanks again for your feedback!
    – pepoviola
    Commented Apr 11, 2023 at 19:05
  • UPDATE: I saw that you had added a new commit to the Zombienet repo, decided to give it another go, and it works! No changes to my setup from a week ago, where it did not work, so maybe the issue was solved by your commit. Thanks! Commented Apr 12, 2023 at 8:38
  • Awesome, thanks for your feedback!!
    – pepoviola
    Commented Apr 12, 2023 at 13:27
1

If you want to setup a Relay chain with parachain(s) locally I recommend you start here:

Once you are comfortable with how to setup a test network manually, you can then use Zombienet (which automates a lot of the manual work) to spin up a test network quickly:

Regarding your other question, chain spec fields are documented here:

The paras field you are referencing:

paras: Default::default(),

This is part of the Polkadot GenesisConfig.

This is referring to the GenesisConfig of the paras pallet found in Polkadot's runtime:

Paras: parachains_paras::{Pallet, Call, Storage, Event, Config, ValidateUnsigned} = 56,

You can find the paras GenisisConfig here:

#[pallet::genesis_config]
pub struct GenesisConfig {
    pub paras: Vec<(ParaId, ParaGenesisArgs)>,
}

#[cfg(feature = "std")]
impl Default for GenesisConfig {
    fn default() -> Self {
        GenesisConfig { paras: Default::default() }
    }
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig {
    fn build(&self) {
        let mut parachains = ParachainsCache::new();
        for (id, genesis_args) in &self.paras {
            if genesis_args.validation_code.0.is_empty() {
                panic!("empty validation code is not allowed in genesis");
            }
            Pallet::<T>::initialize_para_now(&mut parachains, *id, genesis_args);
        }
        // parachains are flushed on drop
    }
}
4
  • Thanks for your quick reply! I have gone through the full documentation of substrate.io, but attempting to add my own nodes have turned out to be a huge hurdle. I have created keys, initialized keystores, customized chain specifications, and the works. The network is running, but no authoring. In terms of Zombienet, I have not been able to get the Kubernetes provider working and ended up building my own virtual cluster. I hoped to find something else than source code, but it has been my main source of information so far. Do you know if the paras GenisisConfig will work? Commented Apr 11, 2023 at 13:12
  • "The network is running, but no authoring" - I would focus on this. My recommendation is to create another question with reproducible steps so we can debug your issue. The tutorial referenced should have all the steps to setup a Relay chain with parachains. In regards to setting up parachains via modifying the paras GenesisConfig I will see if I can get more info for you.
    – Bruno
    Commented Apr 11, 2023 at 13:29
  • Thanks, I think @pepoviola gave the answer I was looking for, but this was helpful as well. I think the main problem I keep running into is a lack of understanding of Substrate. The tutorials are well-written, but I have felt like they come up short in terms of the nitty-gritty "this is what you will need, and why, in order to start a real network without any training wheels (zombienet, dev accounts, ...)". I will most likely ask another question in a couple of days, outlining what I have done, what I expect, and what actually happens. Thank you for your time Commented Apr 11, 2023 at 17:30
  • This is fair feedback. If you can post SE questions when you find these "gaps" - this would be helpful for the community. TY.
    – Bruno
    Commented Apr 12, 2023 at 6:25

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.