Skip to content

Commit

Permalink
MAke it actually run
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshOrndorff committed Dec 14, 2023
1 parent 9c2b602 commit d8968a0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 28 deletions.
1 change: 1 addition & 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 @@ -70,6 +70,7 @@ sp-blockchain = { branch = "release-polkadot-v1.5.0", git = "https://github.com/
sp-consensus = { branch = "release-polkadot-v1.5.0", git = "https://github.com/paritytech/polkadot-sdk" }
sp-consensus-pow = { branch = "release-polkadot-v1.5.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk" }
sp-core = { branch = "release-polkadot-v1.5.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk" }
sp-genesis-builder = { branch = "release-polkadot-v1.5.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk" }
sp-inherents = { branch = "release-polkadot-v1.5.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk" }
sp-io = { branch = "release-polkadot-v1.5.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk" }
sp-keystore = { branch = "release-polkadot-v1.5.0", git = "https://github.com/paritytech/polkadot-sdk" }
Expand Down
2 changes: 1 addition & 1 deletion multi-pow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct Threshold {
// This trait is not fully baked in the Substrate PoW code, so I will not use it for now.
impl TotalDifficulty for Threshold {
fn increment(&mut self, _: Threshold) {
unimplemented!()
// I'm pretty sure we don't do anything interesting with this... Let's see.
}
}

Expand Down
31 changes: 4 additions & 27 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,6 @@ pub fn testnet_config() -> Result<ChainSpec, String> {
.build())
}

// pub fn custom_config(
// chain_name: &str,
// chain_id: &str,
// endowed_accounts: Vec<AccountId>,
// initial_difficulty: u32,
// ) -> Result<ChainSpec, String> {
// let wasm_binary = WASM_BINARY.ok_or_else(|| "runtime WASM binary not available".to_string())?;

// Ok(ChainSpec::from_genesis(
// chain_name,
// chain_id,
// sc_service::ChainType::Live,
// move || genesis(wasm_binary, endowed_accounts.clone(), initial_difficulty),
// vec![],
// None,
// None,
// None,
// None,
// None,
// ))
// }

fn genesis(
endowed_accounts: Vec<AccountId>,
initial_difficulty: u32,
Expand All @@ -102,10 +80,9 @@ fn genesis(
// Configure endowed accounts with initial balance of 1 << 60.
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
},
"difficulty_adjustment": {
"initial_difficulty": initial_difficulty,
// ..Default::default()
},
// transaction_payment: Default::default(),
//TODO Figure out how to convert a u32 into a proper json value here.
// "difficultyAdjustment": {
// "initialDifficulty": serde_json::json!(initial_difficulty),
// },
})
}
2 changes: 2 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-consensus-pow = { workspace = true }
sp-core = { workspace = true }
sp-genesis-builder = { workspace = true }
sp-inherents = { workspace = true }
sp-io = { workspace = true }
sp-keystore = { optional = true, workspace = true }
Expand Down Expand Up @@ -58,6 +59,7 @@ std = [
"sp-block-builder/std",
"sp-consensus-pow/std",
"sp-core/std",
"sp-genesis-builder/std",
"sp-inherents/std",
"sp-io/std",
"sp-offchain/std",
Expand Down
11 changes: 11 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

use frame_support::genesis_builder_helper::{build_config, create_default_config};
pub use frame_support::{
construct_runtime, parameter_types,
traits::{
Expand Down Expand Up @@ -604,4 +605,14 @@ impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block
)
}
}

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

fn build_config(config: Vec<u8>) -> sp_genesis_builder::Result {
build_config::<RuntimeGenesisConfig>(config)
}
}
}

0 comments on commit d8968a0

Please sign in to comment.