Skip to content

Commit

Permalink
Add development chain-spec file for minimal/parachain templates for O…
Browse files Browse the repository at this point in the history
…mni Node compatibility (#6529)

# Description

This PR adds development chain specs for the minimal and parachain
templates.
[#6334](#6334)


## Integration

This PR adds development chain specs for the minimal and para chain
template runtimes, ensuring synchronization with runtime code. It
updates zombienet-omni-node.toml, zombinet.toml files to include valid
chain spec paths, simplifying configuration for zombienet in the
parachain and minimal template.

## Review Notes

1. Overview of Changes:
- Added development chain specs for use in the minimal and parachain
template.
- Updated zombienet-omni-node.toml and zombinet.toml files in the
minimal and parachain templates to include paths to the new dev chain
specs.

2. Integration Guidance:
**NB: Follow the templates' READMEs from the polkadot-SDK master branch.
Please build the binaries and runtimes based on the polkadot-SDK master
branch.**
- Ensure you have set up your runtimes `parachain-template-runtime` and
`minimal-template-runtime`
- Ensure you have installed the nodes required ie
`parachain-template-node` and `minimal-template-node`
- Set up [Zombinet](https://paritytech.github.io/zombienet/intro.html)
- For running the parachains, you will need to install the polkadot
`cargo install --path polkadot` remember from the polkadot-SDK master
branch.
- Inside the template folders minimal or parachain, run the command to
start with `Zombienet with Omni Node`, `Zombienet with
minimal-template-node` or `Zombienet with parachain-template-node`

*Include your leftover TODOs, if any, here.*
* [ ] Test the syncing of chain specs with runtime's code.

---------

Signed-off-by: EleisonC <ckalule7@gmail.com>
Co-authored-by: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com>
Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 27, 2025
1 parent b2004ed commit d85147d
Show file tree
Hide file tree
Showing 8 changed files with 284 additions and 9 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/misc-sync-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,66 @@ on:
default: ""

jobs:
prepare-chain-spec-artifacts:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- template: minimal
package_name: 'minimal-template-runtime'
runtime_path: './templates/minimal/runtime'
runtime_wasm_path: minimal-template-runtime/minimal_template_runtime.compact.compressed.wasm
relay_chain: 'dev'
- template: parachain
package_name: 'parachain-template-runtime'
runtime_path: './templates/parachain/runtime'
runtime_wasm_path: parachain-template-runtime/parachain_template_runtime.compact.compressed.wasm
relay_chain: 'rococo-local'
steps:
- uses: actions/checkout@v4
with:
ref: "${{ github.event.inputs.stable_release_branch }}"

- name: Setup build environment
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
cargo install --git https://github.com/chevdor/srtool-cli --locked
cargo install --path substrate/bin/utils/chain-spec-builder --locked
srtool pull
- name: Build runtime and generate chain spec
run: |
# Prepare directories
sudo mkdir -p ${{ matrix.template.runtime_path }}/target
sudo chmod -R 777 ${{ matrix.template.runtime_path }}/target
# Build runtime
srtool build --package ${{ matrix.template.package_name }} --runtime-dir ${{ matrix.template.runtime_path }} --root
# Generate chain spec
# Note that para-id is set to 1000 for both minimal/parachain templates.
# `parachain-runtime` is hardcoded to use this parachain id.
# `minimal` template isn't using it, but when started with Omni Node, this para id is required (any number can do it, so setting it to 1000 for convenience).
chain-spec-builder -c dev_chain_spec.json create \
--relay-chain "${{ matrix.template.relay_chain }}" \
--para-id 1000 \
--runtime "${{ matrix.template.runtime_path }}/target/srtool/release/wbuild/${{ matrix.template.runtime_wasm_path }}" \
named-preset development
- name: Prepare upload directory
run: |
mkdir -p artifacts-${{ matrix.template }}
cp dev_chain_spec.json artifacts-${{ matrix.template }}/dev_chain_spec.json
- name: Upload template directory
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.template }}
path: artifacts-${{ matrix.template }}/dev_chain_spec.json

sync-templates:
needs: prepare-chain-spec-artifacts
runs-on: ubuntu-latest
environment: master
strategy:
Expand All @@ -52,6 +111,12 @@ jobs:
with:
path: polkadot-sdk
ref: "${{ github.event.inputs.stable_release_branch }}"
- name: Download template artifacts
uses: actions/download-artifact@v4
with:
name: artifacts-${{ matrix.template }}
path: templates/${{ matrix.template }}/
if: matrix.template != 'solochain'
- name: Generate a token for the template repository
id: app_token
uses: actions/create-github-app-token@v1.9.3
Expand Down
11 changes: 7 additions & 4 deletions templates/minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ such as a [Balances pallet](https://paritytech.github.io/polkadot-sdk/master/pal

- 👤 The template has no consensus configured - it is best for experimenting with a single node network.


## Template Structure

A Polkadot SDK based project such as this one consists of:
Expand All @@ -61,7 +62,7 @@ compiled unless building the entire workspace).
- 🛠️ Depending on your operating system and Rust version, there might be additional
packages required to compile this template - please take note of the Rust compiler output.

Fetch minimal template code:
Fetch minimal template code.

```sh
git clone https://github.com/paritytech/polkadot-sdk-minimal-template.git minimal-template
Expand Down Expand Up @@ -147,11 +148,13 @@ docker run --rm polkadot-sdk-minimal-template
We can install `zombienet` as described [here](https://paritytech.github.io/zombienet/install.html#installation),
and `zombienet-omni-node.toml` contains the network specification we want to start.


#### Update `zombienet-omni-node.toml` with a valid chain spec path

Before starting the network with zombienet we must update the network specification
with a valid chain spec path. If we need to generate one, we can look up at the previous
section for chain spec creation [here](#use-chain-spec-builder-to-generate-the-chain_specjson-file).
To simplify the process of starting the minimal template with ZombieNet and Omni Node, we've included a
pre-configured development chain spec (dev_chain_spec.json) in the minimal template. The zombienet-omni-node.toml
file in this template points to it, but you can update it to a new path for the chain spec generated on your machine.
To generate a chain spec refer to [staging-chain-spec-builder](https://crates.io/crates/staging-chain-spec-builder)

Then make the changes in the network specification like so:

Expand Down
85 changes: 85 additions & 0 deletions templates/minimal/dev_chain_spec.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions templates/minimal/zombienet-omni-node.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[relaychain]
default_command = "polkadot-omni-node"
chain = "dev"
chain_spec_path = "<path/to/chain_spec.json>"
default_args = ["--dev"]
chain_spec_path = "./dev_chain_spec.json"
default_args = ["--dev-block-time 3000"]

[[relaychain.nodes]]
name = "alice"
Expand Down
9 changes: 8 additions & 1 deletion templates/parachain/README.docify.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,17 @@ export PATH="$PATH:<path/to/binaries>"

#### Update `zombienet-omni-node.toml` with a valid chain spec path

To simplify the process of using the parachain-template with zombienet and Omni Node, we've added a pre-configured
development chain spec (dev_chain_spec.json) to the parachain template. The zombienet-omni-node.toml file of this
template points to it, but you can update it to an updated chain spec generated on your machine. To generate a
chain spec refer to [staging-chain-spec-builder](https://crates.io/crates/staging-chain-spec-builder)

Then make the changes in the network specification like so:

```toml
# ...
[[parachains]]
id = {{PARACHAIN_ID}}
id = "<PARACHAIN_ID>"
chain_spec_path = "<TO BE UPDATED WITH A VALID PATH>"
# ...
```
Expand Down
9 changes: 8 additions & 1 deletion templates/parachain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,17 @@ export PATH="$PATH:<path/to/binaries>"

#### Update `zombienet-omni-node.toml` with a valid chain spec path

To simplify the process of using the parachain-template with zombienet and Omni Node, we've added a pre-configured
development chain spec (dev_chain_spec.json) to the parachain template. The zombienet-omni-node.toml file of this
template points to it, but you can update it to an updated chain spec generated on your machine. To generate a
chain spec refer to [staging-chain-spec-builder](https://crates.io/crates/staging-chain-spec-builder)

Then make the changes in the network specification like so:

```toml
# ...
[[parachains]]
id = {{PARACHAIN_ID}}
id = "<PARACHAIN_ID>"
chain_spec_path = "<TO BE UPDATED WITH A VALID PATH>"
# ...
```
Expand Down
108 changes: 108 additions & 0 deletions templates/parachain/dev_chain_spec.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion templates/parachain/zombienet-omni-node.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ws_port = 9955

[[parachains]]
id = 1000
chain_spec_path = "<path/to/chain_spec.json>"
chain_spec_path = "./dev_chain_spec.json"

[parachains.collator]
name = "charlie"
Expand Down

0 comments on commit d85147d

Please sign in to comment.