polkadot icon indicating copy to clipboard operation
polkadot copied to clipboard

`chain-spec`: support for `json` config/patch (and `GenesisBuilder` API)

Open michalkucharczyk opened this issue 2 years ago • 8 comments

This PR is a step towards adding support of RuntimeGenesisConfig into the wasm runtime:

In this PR:

  • all references to RuntimeGenesisConfig in node/service are removed,

  • RococoGenesisExt is removed. It was the hack to allow overwriting EpochDurationInBlocks. Removal of RococGenesisExt prevents from manipulating the state to change the runtime constants, what allows to keep metadata const.

  • all (kusama|polkadot|versi|rococo|wococo)_(staging|dev)_genesis_config functions now return the JSON patch for default runtime GenesisConfig,

  • ChainSpecBuilder is used, ChainSpec::from_genesis is removed,

  • rococo-runtime changes:

    • Explicit building of fast-runtime version of rococo-runtime is no longer done.
    • Environment variables which control the time::EpochDurationInBlocks value were added:
      • ROCOCO_FAST_RUNTIME - enables the fast runtime version of runtime with default value of EpochDurationInBlocks set to 10. Value of env does not matter.
      • ROCOCO_EPOCH_DURATION - enables the fast runtime version with provided value of EpochDurationInBlocks (epoch duration will be set to the value of env).

    rococo-runtime building examples:

    • to build runtime for versi_staging_testnet which had EpochDurationInBlocks set to 100:
      ROCOCO_EPOCH_DURATION=100 cargo build -p rococo-runtime
      
    • to build runtime for wococo_development
      ROCOCO_EPOCH_DURATION=10 cargo build -p rococo-runtime
      or
      ROCOCO_FAST_RUNTIME=1 cargo build -p rococo-runtime
      
    • to build versi-staging chain spec:
      ROCOCO_EPOCH_DURATION=100 cargo run -p polkadot -- build-spec --chain versi-staging --raw 
      
    • to build wococo-dev chain spec:
      ROCOCO_EPOCH_DURATION=10 cargo run -p polkadot -- build-spec --chain wococo-dev --raw 
      

Companion for: paritytech/substrate#14562 cumulus companion: paritytech/cumulus#2936

Step towards: https://github.com/paritytech/polkadot-sdk/issues/25

michalkucharczyk avatar Jul 17 '23 15:07 michalkucharczyk

bot rebase

michalkucharczyk avatar Jul 25 '23 14:07 michalkucharczyk

Rebased

bot rebase

michalkucharczyk avatar Aug 01 '23 06:08 michalkucharczyk

Rebased

bot rebase

michalkucharczyk avatar Aug 02 '23 18:08 michalkucharczyk

Rebased

The CI pipeline was cancelled due to failure one of the required jobs. Job name: test-linux-stable Logs: https://gitlab.parity.io/parity/mirrors/polkadot/-/jobs/3322577

paritytech-cicd-pr avatar Aug 03 '23 05:08 paritytech-cicd-pr

@paritytech/devrel , @the-right-joyce

I wanted to give you a heads-up about some changes that have just been made in this PR. I've modified the default EpochDurationInBlocks for several ChainSpecs, namely: versi-local, wococo-local, rococo-local, wococo-dev, versi-dev, rococo-dev (where duration was previously set to 10), and versi-staging (where duration was previously set to 100).

You can find additional details in the PR description.

This change could affect tutorials (and docs maybe?) that rely on timing within these runtimes. Therefore, I request you to please review and update them accordingly, and include information on how to adjust timings based on these changes.

Thank you for your attention.

michalkucharczyk avatar Aug 04 '23 07:08 michalkucharczyk