Skip to content

Commit

Permalink
Merge pull request #481 from gluwa/cc3-fix-geneis-build
Browse files Browse the repository at this point in the history
fix: update genesis build source code for cc3 node
  • Loading branch information
rustlang-dev authored Sep 16, 2024
2 parents 457dba7 + 50aba6b commit dd0e563
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ substrate-test-runtime-client = { git = "https://github.com/paritytech/polkadot
substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" }
generate-bags = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" }
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" }
sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false }

# Frontier Client
fc-api = { git = "https://github.com/paritytech/frontier", rev = "80c768f688d86bfb350753f3e2aebc9d89037727" }
Expand Down
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ build = "build.rs"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
serde_json = { workspace = true }
async-trait = { workspace = true }
clap = { workspace = true }
futures = { workspace = true }
Expand Down
6 changes: 6 additions & 0 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,13 @@ pub fn development_config(enable_manual_seal: Option<bool>) -> ChainSpec {
SS58Prefix::get() as u64,
);

let config_json = serde_json::to_value(&rgc).expect("Could not build genesis config.");

return ChainSpec::builder(wasm_binary, None)
.with_name("Development")
.with_id("dev")
.with_chain_type(ChainType::Development)
.with_genesis_config(config_json)
.with_properties(properties())
.build();

Expand Down Expand Up @@ -243,10 +246,13 @@ pub fn local_testnet_config() -> ChainSpec {
SS58Prefix::get() as u64,
);

let config_json = serde_json::to_value(&rgc).expect("Could not build genesis config.");

return ChainSpec::builder(wasm_binary, None)
.with_name("Local Testnet")
.with_id("local_testnet")
.with_chain_type(ChainType::Local)
.with_genesis_config(config_json)
.with_properties(properties())
.build();

Expand Down
4 changes: 3 additions & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ impl SubstrateCli for Cli {
let ret = match id {
"dev" => {
let enable_manual_seal = self.sealing.map(|_| true);
Box::new(chain_spec::development_config(enable_manual_seal))
let x = Box::new(chain_spec::development_config(enable_manual_seal));
// panic!("eeeeeee");
x
}
"devnet" => Box::new(chain_spec::devnet_config()?),
"testnet" => Box::new(chain_spec::testnet_config()?),
Expand Down
1 change: 1 addition & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ scale-info = { workspace = true }
smallvec = "1.13.2"

# Substrate
sp-genesis-builder = { workspace = true }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-consensus-babe = { workspace = true }
Expand Down
18 changes: 18 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ use sp_core::{
crypto::{ByteArray, KeyTypeId},
OpaqueMetadata, H160, H256, U256,
};
use frame_support::{
genesis_builder_helper::{build_state, get_preset},
// traits::VariantCountOf,
};
use sp_runtime::{
generic, impl_opaque_keys,
traits::{
Expand Down Expand Up @@ -1678,6 +1682,20 @@ impl_runtime_apis! {
}
}

impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
build_state::<RuntimeGenesisConfig>(config)
}

fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
get_preset::<RuntimeGenesisConfig>(id, |_| None)
}

fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
vec![]
}
}

}

#[cfg(test)]
Expand Down

0 comments on commit dd0e563

Please sign in to comment.