Skip to content

Commit

Permalink
set initial seed in chainspec
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszaaa committed Jun 23, 2021
1 parent 5ce3986 commit e860e25
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
11 changes: 9 additions & 2 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
use hex_literal::hex;
use mangata_runtime::{
AccountId, AssetsInfoConfig, BabeConfig, BalancesConfig, BridgeConfig, BridgedAssetConfig,
GenesisConfig, GrandpaConfig, SessionConfig, SessionKeys, Signature, StakerStatus,
StakingConfig, SudoConfig, SystemConfig, TokensConfig, VerifierConfig, XykConfig, WASM_BINARY,
GenesisConfig, GrandpaConfig, RandomConfig, SessionConfig, SessionKeys, Signature,
StakerStatus, StakingConfig, SudoConfig, SystemConfig, TokensConfig, VerifierConfig, XykConfig,
WASM_BINARY,
};
use sc_service::ChainType;
use sp_consensus_babe::AuthorityId as BabeId;
Expand Down Expand Up @@ -143,6 +144,7 @@ pub fn development_config() -> Result<ChainSpec, String> {
10_000__000_000_000_000_000_000u128,
)],
true,
[0_u8; 32],
)
},
// Bootnodes
Expand Down Expand Up @@ -254,6 +256,7 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
10_000__000_000_000_000_000_000u128,
)],
true,
[0_u8; 32],
)
},
// Bootnodes
Expand Down Expand Up @@ -282,6 +285,7 @@ fn testnet_genesis(
endowed_accounts: Vec<AccountId>,
staking_accounts: Vec<(AccountId, u32, u128, u32, u128, u32, u128)>,
_enable_println: bool,
init_seed: [u8; 32],
) -> GenesisConfig {
GenesisConfig {
frame_system: Some(SystemConfig {
Expand Down Expand Up @@ -426,5 +430,8 @@ fn testnet_genesis(
})
.collect(),
}),
pallet_random_seed: Some(RandomConfig {
random_seed: init_seed,
}),
}
}
10 changes: 10 additions & 0 deletions pallets/random-seed/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ decl_storage! {
/// Current time for the current block.
pub Seed get(fn seed) : SeedType;
}
add_extra_genesis {
#[allow(clippy::type_complexity)]
config(random_seed): [u8; 32];
build(|config: &GenesisConfig|{
Seed::set(SeedType{
seed: config.random_seed,
proof: [0_u8; 64]
});
});
}
}

impl<T: Trait> Module<T> {
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ construct_runtime!(
System: frame_system::{Module, Call, Config, Storage, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Random: pallet_random_seed::{Module, Call, Storage, Inherent},
Random: pallet_random_seed::{Module, Call, Storage, Inherent, Config},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
Babe: pallet_babe::{Module, Call, Storage, Config, Inherent, ValidateUnsigned},
Expand Down

0 comments on commit e860e25

Please sign in to comment.