-
Notifications
You must be signed in to change notification settings - Fork 687
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
chain-spec-builder: Add support for codeSubstitutes
#4685
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c8e76ad
Chain spec builder substitute
skunert c45be3a
Extract chain-spec-extension
skunert 7559188
Merge branch 'master' into skunert/chain-spec-builder-substitute
skunert ae2d7c1
Fix build
skunert fb588ea
More fixes
skunert cc978aa
Make relay_chain_optional
skunert b50a2c5
Refer to external extension but make optional
skunert 4259adb
Add prdoc, fix toml format
skunert 728304c
Merge branch 'master' into skunert/chain-spec-builder-substitute
skunert 79155a9
Change bump to minor
skunert 2f0a4e4
Merge branch 'master' into skunert/chain-spec-builder-substitute
skunert 49ddf11
Revert extension related changeS
skunert b078a7f
Update prdoc
skunert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 | ||
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json | ||
|
||
title: Chain-spec-builder supports `codeSubstitutes`. | ||
|
||
doc: | ||
- audience: Node Operator | ||
description: | | ||
A new subcommand `add-code-substitute` is available for the `chain-spec-builder` binary. It allows users to provide a runtime that should be used from a given | ||
block onwards. The `codeSubstitutes` field in the chain spec is used to force usage of a given runtime at a given block until the next runtime upgrade. It can be | ||
used to progress chains that are stalled due to runtime bugs that prevent block-building. However, parachain usage is only possible in combination with an updated | ||
validation function on the relay chain. | ||
|
||
crates: | ||
- name: staging-chain-spec-builder | ||
bump: minor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,7 @@ pub enum ChainSpecBuilderCmd { | |
ConvertToRaw(ConvertToRawCmd), | ||
ListPresets(ListPresetsCmd), | ||
DisplayPreset(DisplayPresetCmd), | ||
AddCodeSubstitute(AddCodeSubstituteCmd), | ||
} | ||
|
||
/// Create a new chain spec by interacting with the provided runtime wasm blob. | ||
|
@@ -222,6 +223,25 @@ pub struct UpdateCodeCmd { | |
pub runtime_wasm_path: PathBuf, | ||
} | ||
|
||
/// Add a code substitute in the chain spec. | ||
/// | ||
/// The `codeSubstitute` object of the chain spec will be updated with the block height as key and | ||
/// runtime code as value. This operation supports both plain and raw formats. The `codeSubstitute` | ||
/// field instructs the node to use the provided runtime code at the given block height. This is | ||
/// useful when the chain can not progress on its own due to a bug that prevents block-building. | ||
/// | ||
/// Note: For parachains, the validation function on the relaychain needs to be adjusted too, | ||
/// otherwise blocks built using the substituted parachain runtime will be rejected. | ||
#[derive(Parser, Debug, Clone)] | ||
pub struct AddCodeSubstituteCmd { | ||
/// Chain spec to be updated. | ||
pub input_chain_spec: PathBuf, | ||
/// New runtime wasm blob that should replace the existing code. | ||
pub runtime_wasm_path: PathBuf, | ||
/// The block height at which the code should be substituted. | ||
pub block_height: u64, | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also this does not modify the file in-place. Maybe would be good to add a note about this. (Same case as in updateCode). |
||
/// Converts the given chain spec into the raw format. | ||
#[derive(Parser, Debug, Clone)] | ||
pub struct ConvertToRawCmd { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: to avoid code duplication in
UpdateCode
andAddCodeSubstitute
match arms we could add a functionupdate_chain_spec_file_in_place
which could take a closure that modifies&mut chain_spec_json
provided as its input.