-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Serialisable genesis config #229
Conversation
polkadot/cli/src/lib.rs
Outdated
.unwrap_or_else(|f| (Box::new(move || | ||
read_storage_json(&f) | ||
.map(|s| { info!("{} storage items read from {}", s.len(), f); s }) | ||
.unwrap_or_else(|| panic!("Bad genesis state file: {}", f)) | ||
), vec![])); | ||
|
||
if matches.is_present("build-genesis") { |
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.
can it still output the raw genesis? this is crucial.
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.
added this as polkatod build-spec --raw
OK - so the idea is that it can be used in two main ways:
A third, less important use case is:
|
Is the above what this PR achieves? |
@gavofyork Yes, all three scenarios are supported with the following notes:
|
Yeah we should probably just rename it to |
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.
Would be good to have local, dev and poc-2 (aka staging) just be JSON files.
polkadot/cli/src/lib.rs
Outdated
info!("Chain specification: {}", chain_spec); | ||
|
||
config.chain_name = chain_spec.clone().into(); | ||
let spec = load_spec(&matches); |
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.
This is expensive, isn't it? If it loads a potentially huge raw genesis map or genesis config and builds genesis from it, then it's needless most of the time. Stuff should only be loaded if genesis block is needed to be built as it was before.
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.
Before it was loaded unconditionally as well, wasn't? genesis_storage
is required in config
currently. I'll add an issue to optimise this later, as it requires partial json parsing.
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.
no - genesis_storage
was a function that only bothered doing the work if the genesis needed to be computed.
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.
would prefer to have the load-on-demand not phased-out in this pr, but if it's really going to add significant complexity, then i guess it could wait for a second pr.
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.
Implemented
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.
Code looks good. Couple of minor nits.
polkadot/cli/src/chain_spec.rs
Outdated
ChainSpec::LocalTestnet => service::ChainSpec::local_testnet_config(), | ||
ChainSpec::PoC2Testnet => service::ChainSpec::poc_2_testnet_config(), | ||
ChainSpec::Custom(f) => { | ||
service::ChainSpec::from_json_file(PathBuf::from(f))? |
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.
superfluous (and incorrectly indented) code block
polkadot/service/src/config.rs
Outdated
fn default() -> Configuration { | ||
Configuration { | ||
impl Configuration { | ||
/// Create default condif for given chain spec. |
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.
"config"?
* Support Indices * Support Indices in staking module * Update substrate * Format code * Make 2s gossip * Merge develop
* update orml to newest version * add wasmtime support
Fix the incorrect SubspaceApi version
Chain spec now contains bootnodes and genesis sections. Genesis can be either raw storage, or serialised
GenesisConfig
.