Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add chain-spec for minimal/parachain template runtimes for direct use with Omni Node #6334

Open
iulianbarbu opened this issue Nov 1, 2024 · 13 comments
Assignees
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. C2-good-first-issue A task for a first time contributor to become familiar with the Polkadot-SDK. T17-Templates This PR/Issue is related to templates

Comments

@iulianbarbu
Copy link
Contributor

iulianbarbu commented Nov 1, 2024

When using zombienet with omni-node, node operators must setup the chain_spec_path specification field for parachains to a valid path. For minimal and parachain template we do that too, but given there isn't yet a chain spec, to get its path and use it in the zombienet spec, we first clarify how to generate the chain spec and hint to the zombienet spec file that needs to be updated with a valid chain spec path.

It would be great to update the templates so that:

  1. they include the development chain specs, and we keep them in sync with the runtime's code. Might need a separate GH workflow to check they are in sync. We should also update the zombienet-omni-node.toml files to contain a path to the included chain specs (short term)
  2. add a quickstart.sh with each template that runs through the commands required to start the node/generate its prereq (which includes installing the needed tools too) (long term)

cc @kianenigma

@iulianbarbu iulianbarbu added the T17-Templates This PR/Issue is related to templates label Nov 1, 2024
@iulianbarbu iulianbarbu changed the title Improve minimal/parachain templates usage regarding Omni Node Add chain-spec for minimal/parachain template runtimes for direct use with Omni Node Nov 4, 2024
@kianenigma kianenigma moved this to Milestone 1 in Polkadot Omni Node Nov 5, 2024
@kianenigma kianenigma added C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. C2-good-first-issue A task for a first time contributor to become familiar with the Polkadot-SDK. labels Nov 5, 2024
@EleisonC
Copy link

Hey @kianenigma and @iulianbarbu, is this issue still available? If so, I'd like to tackle it.

@iulianbarbu
Copy link
Contributor Author

Hey @EleisonC ! Thanks for the interest and yes, you can work on it. Let us know if you need help.

@EleisonC
Copy link

Hello @iulianbarbu thank you very much. I also want to mention I am new here. To get up to speed, I have been familiarizing myself with:

  • docs/contributor/CONTRIBUTING.md
  • polkadot_sdk_docs
  • polkadot_sdk_docs/polkadot_sdk(Currently)

While exploring I discovered the template folder polkadot-sdk/templates and I noticed both the minimal and parachain templates within that directory. Looked at both their zombienet-omni-node.toml files.

They include the development chain specs

You mentioned 👆🏾. My questions

  1. --relay-chain "dev" -> Specifies that the relay chain used in the configuration is the "dev" chain.
  2. --para-id 1000: Defines the parachain ID.
  3. --runtime target/release/wbuild/minimal-template-runtime/minimal_template_runtime.wasm: Points to the Wasm runtime code for the parachain.

I will need guidance here so I don't go to the wrong place or path.

@iulianbarbu
Copy link
Contributor Author

iulianbarbu commented Nov 12, 2024

hey @EleisonC ! You are on the right path with the investigation. Happy to share some of my understanding on the subject.

Is development chain specs supposed to be a JSON file?

Yes, chain specs are JSON files. In our case, development chain spec represents a certain chain spec we're interested in, that can be exposed by the runtimes as a genesis state preset. Some more details about chain specs and genesis state presets can be found here: https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/chain_spec_genesis/index.html.

What are the fields this file must have?

relay-chain and para-id are flags passed to chain-spec-builder, which will be inserted in the generated chain spec, and they should be part of the chain spec we want. These two fields specifically are important for the Omni Node (more details about it are here: https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/omni_node/index.html). The runtime flag is used by chain-spec-builder to read the runtime WASM blob and use it to extract certain chain specs from it (e.g. default, development etc).

There could be other fields involved in chain spec configs (depending on their form: full/patch). You should rely on chain-spec-builder to generate the development chain specs for both templates, as mentioned in the READMEs for both parachain/minimal templates, and then add them as is to the templates as JSON files, updating the zombienet-omni-node.toml file and the README accordingly. Ideally, a github workflow would be added to ensure the chain specs correspond to the runtimes or on a second thought, a rust test? (not super sure what's easier and works well, happy to hear suggestions).

Separately, the second point of the issue can be omitted, but if done so we should track it under a different issue before closing this one.

@EleisonC
Copy link

Alright thank you.🙏🏾

@EleisonC
Copy link

Screenshot 2024-11-13 at 17 10 37

Hey @iulianbarbu My objective is to generate a chain spec file for the first time. I have followed the ReadMe.md

  • cloned the minimal template as suggested here

git clone https://github.com/paritytech/polkadot-sdk-minimal-template.git minimal-template

  • I noticed it's not the exactly same as the https://github.com/paritytech/polkadot-sdk/blob/master/templates/minimal

  • The one I cloned first (https://github.com/paritytech/polkadot-sdk-minimal-template.git minimal-template) seems to have less detailed readMe

  • Installed staging-chain-spec-builder globally.

  • I went on to run the command chain-spec-builder create --relay-chain "dev" --para-id 1000 --runtime \ target/release/wbuild/minimal-template-runtime/minimal_template_runtime.wasm named-preset development

  • I then cloned the polkadot-sdk navigated to the minimal directory and ran the same command chain-spec-builder create --relay-chain "dev" --para-id 1000 --runtime \ target/release/wbuild/minimal-template-runtime/minimal_template_runtime.wasm named-preset development

But i still got the error [chain-spec-builder create](error: unexpected argument '--relay-chain' found)

What might I be missing?

@iulianbarbu
Copy link
Contributor Author

iulianbarbu commented Nov 13, 2024

Hey @EleisonC ! What's missing is the fact we haven't released the READMEs for the templates yet (what this does is that it will sync each template from polkadot-sdk monorepo with their respective repository on paritytech org). Sorry for the whole confusion, this thing should've been mentioned in the issue description. 🙈

At the same time, installing staging-chain-spec-builder according to the unreleased templates' READMEs will install 6.0.0, which is not the one the READMEs are based on. This is because we haven't released yet staging-chain-spec-builder with the changes on polkadot-sdk master branch. All polkadot-sdk master branch templates' READMEs' are speculative at this point (there is a pending release candidate which will address this partially, but the stable release which will have everything synced and references working correctly will happen sometime in December).

I recommend you to:

  1. Follow solely the templates' READMEs and templates themselves from polkadot-sdk master branch, but ignore the references to the dedicated templates directory, and if it comes to staging-chain-spec-builder, or other mentioned binaries and runtimes, please try to build them based on the polkadot-sdk master branch. It might take a while depending on your machine specs, and if you are not sure how to build them please reach out.
  2. Install staging-chain-spec-builder from polkadot-sdk master branch with cargo install --path substrate/bin/utils/chain-spec-builder.

@EleisonC
Copy link

EleisonC commented Nov 14, 2024

Hey @iulianbarbu, this was very informative! 😃. No worries about the confusion.

@EleisonC
Copy link

Screenshot 2024-11-14 at 19 51 07

Hey @iulianbarbu Currently I am trying to run via Zombienet with minimal-template-node with command ./zombienet --provider native spawn zombienet-multi-node.toml . But I get the error ⚠ Config file does not exist: polkadot-sdk/templates/minimal/zombienet-multi-node.toml . I am quite confused about how to generate this file polkadot-sdk/templates/minimal/zombienet-multi-node.toml file in the minimal templates folder like "zombienet-omni-node.toml". Also note that ./zombienet --provider native spawn zombienet-omni-node.toml works well shown in the above Screenshot

@EleisonC
Copy link

Screenshot 2024-11-14 at 20 28 50
I think i got it to work /zombienet --provider native spawn zombienet-multi-node.toml ~ ./zombienet --provider native spawn zombienet.toml and also add the chain_spec_path to that file too. I hope that is it.

@iulianbarbu
Copy link
Contributor Author

iulianbarbu commented Nov 14, 2024

Hey @EleisonC ! Indeed, seems like it is sorted out. Checking the logs of the nodes and scanning for errors is your best bet to ensure things are working as expected, but if you see this final table, it is already a good indication things started fine.

So I get that you were able to update the zombienet-omni-node.toml file with the chain spec, generated as mentioned in the minimal README. We should do the same for parachain, and lmk if things don't work.

@EleisonC
Copy link

Hey @iulianbarbu I raised a PR.
Quick question: Should I update the ReadMe sections for the templates to reflect the current temporary workflow?

Ideally, a github workflow would be added to ensure the chain specs correspond to the runtimes or on a second thought, a rust test

I’m considering adding a Rust test. Should this be included in this PR, or would it be better suited for a separate one?"

@iulianbarbu
Copy link
Contributor Author

Hey @iulianbarbu I raised a PR. Quick question: Should I update the ReadMe sections for the templates to reflect the current temporary workflow?

Ideally, a github workflow would be added to ensure the chain specs correspond to the runtimes or on a second thought, a rust test

I’m considering adding a Rust test. Should this be included in this PR, or would it be better suited for a separate one?"

Thanks for the PR! I'll take a look over it soon. It would be great to add the README changes and the rust test with this PR too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. C2-good-first-issue A task for a first time contributor to become familiar with the Polkadot-SDK. T17-Templates This PR/Issue is related to templates
Projects
Status: Milestone 1
Development

No branches or pull requests

3 participants