Crates.io | staging-chain-spec-builder |
lib.rs | staging-chain-spec-builder |
version | 13.0.0 |
created_at | 2023-10-16 12:32:14.326137+00 |
updated_at | 2025-08-01 15:39:02.705158+00 |
description | Utility for building chain-specification files for Substrate-based runtimes based on `sp-genesis-builder` |
homepage | https://paritytech.github.io/polkadot-sdk/ |
repository | https://github.com/paritytech/polkadot-sdk.git |
max_upload_size | |
id | 1004734 |
size | 3,318,058 |
Substrate's chain spec builder utility.
A chain-spec is short for chain-specification
. See the sc-chain-spec
for more information.
Note: this binary is a more flexible alternative to the build-spec
subcommand, contained in typical Substrate-based nodes.
This particular binary is capable of interacting with sp-genesis-builder
implementation of any provided runtime allowing to build chain-spec JSON files.
See ChainSpecBuilderCmd
for a list of available commands.
cargo install staging-chain-spec-builder --locked
Note: chain-spec-builder
binary is published on crates.io under
staging-chain-spec-builder
due to a name conflict.
Please note that below usage is backed by integration tests. The commands' examples are wrapped
around by the bash!(...)
macro calls.
CreateCmd
's para-id
flagpara-id
flag is deprecated. Runtimes relying on generating the chain
specification with this tool should implement cumulus_primitives_core::GetParachainInfo
trait, a new runtime API designed to provide the parachain ID from the parachain-info
pallet. The para-id
flag will be removed and nodes support for extracting the
parachain id from the chain specification will stop from stable2512
.
For reference, generating a chain specification with a para_id
field can still
be done until stable2512
like below:
chain-spec-builder -c "/dev/stdout" create --relay-chain "dev" --para-id 1000 -r $runtime_path named-preset "staging"
Query the default genesis config from the provided runtime WASM blob and use it in the chain spec.
bash!(
chain-spec-builder -c "/dev/stdout" create -r $runtime_path default
)
Note: GenesisBuilder::get_preset
runtime function is called.
GenesisConfig
bash!(
chain-spec-builder display-preset -r $runtime_path
)
Note: GenesisBuilder::get_preset
runtime function is called.
GenesisConfig
preset with given namefn cmd_display_preset(runtime_path: &str) -> String {
bash!(
chain-spec-builder display-preset -r $runtime_path -p "staging"
)
}
Note: GenesisBuilder::get_preset
runtime function is called.
GenesisConfig
presets provided by runtimebash!(
chain-spec-builder list-presets -r $runtime_path
)
Note: GenesisBuilder::preset_names
runtime function is called.
Patch the runtime's default genesis config with the named preset provided by the runtime and generate the plain version of chain spec:
bash!(
chain-spec-builder -c "/dev/stdout" create --relay-chain "dev" -r $runtime_path named-preset "staging"
)
Note: GenesisBuilder::get_preset
runtime functions are called.
Patch the runtime's default genesis config with provided patch.json
and generate raw
storage (-s
) version of chain spec:
bash!(
chain-spec-builder -c "/dev/stdout" create -s -r $runtime_path patch "tests/input/patch.json"
)
Refer to patch file for some details on the patch file format.
Note: GenesisBuilder::get_preset
and
GenesisBuilder::build_state
runtime functions are called.
Build the chain spec using provided full genesis config json file. No defaults will be used:
bash!(
chain-spec-builder -c "/dev/stdout" create -s -r $runtime_path full "tests/input/full.json"
)
Refer to full config file for some details on the full file format.
Note: GenesisBuilder::build_state
runtime function is called.
bash!(
chain-spec-builder -c "/dev/stdout" create -r $runtime_path patch "tests/input/patch.json"
)
Refer to patch file for some details on the patch file format.
bash!(
chain-spec-builder -c "/dev/stdout" create -r $runtime_path full "tests/input/full.json"
)
Refer to full config file for some details on the full file format.
This section provides details on the files that can be used with create patch
or create full
subcommands.
The patch file for genesis config contains the key-value pairs valid for given runtime, that needs to be customized, e.g:
{
"balances": {
"balances": [
[
"5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty",
1000000000000000
],
[
"5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y",
1000000000000000
],
[
"5CcjiSgG2KLuKAsqkE2Nak1S2FbAcMr5SxRASUuwR3zSNV2b",
5000000000000000
]
]
},
"sudo": {
"key": "5Ff3iXP75ruzroPWRP2FYBHWnmGGBSb63857BgnzCoXNxfPo"
}
}
The rest of genesis config keys will be initialized with default values.
The full genesis config file must contain values for all the keys present in the genesis config for given runtime. The format of the file is similar to patch format. Example is not provided here as it heavily depends on the runtime.
The chain-spec-builder
provides also some extra utilities: VerifyCmd
,
ConvertToRawCmd
,
UpdateCodeCmd
.