Skip to content

Commit

Permalink
Merge pull request #397 from opentensor/fix/genesis-config-v1.10
Browse files Browse the repository at this point in the history
fix: genesis config builder
  • Loading branch information
sam0x17 committed May 6, 2024
2 parents 2cc70b3 + ef2ade3 commit a769cce
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 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 @@ -82,6 +82,7 @@ sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag =
sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.10.0" }
sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.10.0", default-features = false }
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.10.0" }
sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.10.0", default-features = false }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.10.0", default-features = false }
sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.10.0", default-features = false }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.10.0", default-features = false }
Expand Down
10 changes: 5 additions & 5 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
.with_name("Bittensor")
.with_id("bittensor")
.with_chain_type(ChainType::Live)
.with_genesis_config(finney_genesis(
.with_genesis_config_patch(finney_genesis(
// Initial PoA authorities (Validators)
// aura | grandpa
vec![
Expand Down Expand Up @@ -292,7 +292,7 @@ pub fn finney_testnet_config() -> Result<ChainSpec, String> {
.with_name("Bittensor")
.with_id("bittensor")
.with_chain_type(ChainType::Development)
.with_genesis_config(testnet_genesis(
.with_genesis_config_patch(testnet_genesis(
// Initial PoA authorities (Validators)
// aura | grandpa
vec![
Expand Down Expand Up @@ -349,7 +349,7 @@ pub fn localnet_config() -> Result<ChainSpec, String> {
.with_name("Bittensor")
.with_id("bittensor")
.with_chain_type(ChainType::Development)
.with_genesis_config(localnet_genesis(
.with_genesis_config_patch(localnet_genesis(
// Initial PoA authorities (Validators)
// aura | grandpa
vec![
Expand Down Expand Up @@ -430,10 +430,10 @@ fn localnet_genesis(
"sudo": {
"key": Some(get_account_id_from_seed::<sr25519::Public>("Alice"))
},
"triumvirate_members": {
"triumvirateMembers": {
"members": trimvirate_members
},
"senate_members": {
"senateMembers": {
"members": senate_members,
},
})
Expand Down
4 changes: 3 additions & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ sp-block-builder = { workspace = true }
sp-consensus-aura = { workspace = true }
sp-core = { workspace = true }
sp-storage = { workspace = true }
sp-genesis-builder = { workspace = true }
sp-inherents = { workspace = true }
sp-offchain = { workspace = true }
sp-runtime = { workspace = true }
Expand Down Expand Up @@ -140,7 +141,8 @@ std = [
"sp-io/std",
"sp-tracing/std",
"log/std",
"sp-storage/std"
"sp-storage/std",
"sp-genesis-builder/std"
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
Expand Down
25 changes: 16 additions & 9 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
mod migrations;

use codec::{Decode, Encode, MaxEncodedLen};

use migrations::{account_data_migration, init_storage_versions};
use pallet_commitments::CanCommit;
use pallet_grandpa::{
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
};

use frame_support::{
dispatch::DispatchResultWithPostInfo,
genesis_builder_helper::{build_config, create_default_config},
pallet_prelude::{DispatchError, Get},
traits::{fungible::HoldConsideration, LinearStoragePrice, OnRuntimeUpgrade},
};
use frame_system::{EnsureNever, EnsureRoot, RawOrigin};

use migrations::{account_data_migration, init_storage_versions};
use pallet_commitments::CanCommit;
use pallet_grandpa::{
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
};
use pallet_registry::CanRegisterIdentity;
use scale_info::TypeInfo;
use smallvec::smallvec;
Expand All @@ -37,7 +35,6 @@ use sp_runtime::{
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, MultiSignature,
};

use sp_std::cmp::Ordering;
use sp_std::prelude::*;
#[cfg(feature = "std")]
Expand Down Expand Up @@ -1277,6 +1274,16 @@ impl_runtime_apis! {
}
}

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)
}
}

impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(
source: TransactionSource,
Expand Down

0 comments on commit a769cce

Please sign in to comment.