|
@@ -29,23 +29,29 @@ use sp_runtime::traits::{IdentifyAccount, Verify};
|
|
|
use sp_runtime::Perbill;
|
|
|
|
|
|
use node_runtime::{
|
|
|
- versioned_store::InputValidationLengthConstraint as VsInputValidation,
|
|
|
- AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig, ContentDirectoryConfig,
|
|
|
- ContentDirectoryWorkingGroupConfig, ContentWorkingGroupConfig, CouncilConfig,
|
|
|
- CouncilElectionConfig, DataObjectStorageRegistryConfig, DataObjectTypeRegistryConfig,
|
|
|
- ElectionParameters, GrandpaConfig, ImOnlineConfig, MembersConfig, ProposalsCodexConfig,
|
|
|
- SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig, StorageWorkingGroupConfig,
|
|
|
- SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY,
|
|
|
+ membership, AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig,
|
|
|
+ ContentDirectoryConfig, ContentDirectoryWorkingGroupConfig, ContentWorkingGroupConfig,
|
|
|
+ CouncilConfig, CouncilElectionConfig, DataDirectoryConfig, DataObjectStorageRegistryConfig,
|
|
|
+ DataObjectTypeRegistryConfig, ElectionParameters, ForumConfig, GrandpaConfig, ImOnlineConfig,
|
|
|
+ MembersConfig, Moment, ProposalsCodexConfig, SessionConfig, SessionKeys, Signature,
|
|
|
+ StakerStatus, StakingConfig, StorageWorkingGroupConfig, SudoConfig, SystemConfig,
|
|
|
+ VersionedStoreConfig, VersionedStorePermissionsConfig, DAYS, WASM_BINARY,
|
|
|
};
|
|
|
|
|
|
+// Exported to be used by chain-spec-builder
|
|
|
pub use node_runtime::{AccountId, GenesisConfig};
|
|
|
|
|
|
+pub mod content_config;
|
|
|
+pub mod forum_config;
|
|
|
+pub mod initial_balances;
|
|
|
+pub mod initial_members;
|
|
|
+pub mod proposals_config;
|
|
|
+
|
|
|
type AccountPublic = <Signature as Verify>::Signer;
|
|
|
|
|
|
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
|
|
|
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
|
|
|
|
|
|
-use node_runtime::common::constraints::InputValidationLengthConstraint;
|
|
|
use sc_chain_spec::ChainType;
|
|
|
|
|
|
/// The chain specification option. This is expected to come in from the CLI and
|
|
@@ -127,7 +133,14 @@ impl Alternative {
|
|
|
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
|
|
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
|
|
],
|
|
|
- crate::proposals_config::development(),
|
|
|
+ proposals_config::development(),
|
|
|
+ initial_members::none(),
|
|
|
+ forum_config::empty(get_account_id_from_seed::<sr25519::Public>("Alice")),
|
|
|
+ content_config::empty_versioned_store_config(),
|
|
|
+ content_config::empty_versioned_store_permissions_config(),
|
|
|
+ content_config::empty_data_directory_config(),
|
|
|
+ content_config::empty_content_working_group_config(),
|
|
|
+ vec![],
|
|
|
)
|
|
|
},
|
|
|
Vec::new(),
|
|
@@ -161,7 +174,14 @@ impl Alternative {
|
|
|
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
|
|
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
|
|
],
|
|
|
- crate::proposals_config::development(),
|
|
|
+ proposals_config::development(),
|
|
|
+ initial_members::none(),
|
|
|
+ forum_config::empty(get_account_id_from_seed::<sr25519::Public>("Alice")),
|
|
|
+ content_config::empty_versioned_store_config(),
|
|
|
+ content_config::empty_versioned_store_permissions_config(),
|
|
|
+ content_config::empty_data_directory_config(),
|
|
|
+ content_config::empty_content_working_group_config(),
|
|
|
+ vec![],
|
|
|
)
|
|
|
},
|
|
|
Vec::new(),
|
|
@@ -174,10 +194,6 @@ impl Alternative {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-fn new_vs_validation(min: u16, max_min_diff: u16) -> VsInputValidation {
|
|
|
- VsInputValidation { min, max_min_diff }
|
|
|
-}
|
|
|
-
|
|
|
pub fn chain_spec_properties() -> json::map::Map<String, json::Value> {
|
|
|
let mut properties: json::map::Map<String, json::Value> = json::map::Map::new();
|
|
|
properties.insert(
|
|
@@ -190,7 +206,9 @@ pub fn chain_spec_properties() -> json::map::Map<String, json::Value> {
|
|
|
);
|
|
|
properties
|
|
|
}
|
|
|
-
|
|
|
+// This method should be refactored after Alexandria to reduce number of arguments
|
|
|
+// as more args will likely be needed
|
|
|
+#[allow(clippy::too_many_arguments)]
|
|
|
pub fn testnet_genesis(
|
|
|
initial_authorities: Vec<(
|
|
|
AccountId,
|
|
@@ -203,11 +221,16 @@ pub fn testnet_genesis(
|
|
|
root_key: AccountId,
|
|
|
endowed_accounts: Vec<AccountId>,
|
|
|
cpcp: node_runtime::ProposalsConfigParameters,
|
|
|
+ members: Vec<membership::genesis::Member<u64, AccountId, Moment>>,
|
|
|
+ forum_config: ForumConfig,
|
|
|
+ versioned_store_config: VersionedStoreConfig,
|
|
|
+ versioned_store_permissions_config: VersionedStorePermissionsConfig,
|
|
|
+ data_directory_config: DataDirectoryConfig,
|
|
|
+ content_working_group_config: ContentWorkingGroupConfig,
|
|
|
+ initial_balances: Vec<(AccountId, Balance)>,
|
|
|
) -> GenesisConfig {
|
|
|
- const CENTS: Balance = 1;
|
|
|
- const DOLLARS: Balance = 100 * CENTS;
|
|
|
- const STASH: Balance = 20 * DOLLARS;
|
|
|
- const ENDOWMENT: Balance = 100_000 * DOLLARS;
|
|
|
+ const STASH: Balance = 5_000;
|
|
|
+ const ENDOWMENT: Balance = 100_000_000;
|
|
|
|
|
|
let default_text_constraint = node_runtime::working_group::default_text_constraint();
|
|
|
|
|
@@ -222,22 +245,26 @@ pub fn testnet_genesis(
|
|
|
.cloned()
|
|
|
.map(|k| (k, ENDOWMENT))
|
|
|
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
|
|
|
+ .chain(
|
|
|
+ initial_balances
|
|
|
+ .iter()
|
|
|
+ .map(|(account, balance)| (account.clone(), *balance)),
|
|
|
+ )
|
|
|
.collect(),
|
|
|
}),
|
|
|
pallet_staking: Some(StakingConfig {
|
|
|
validator_count: 20,
|
|
|
- minimum_validator_count: 1,
|
|
|
+ minimum_validator_count: initial_authorities.len() as u32,
|
|
|
stakers: initial_authorities
|
|
|
.iter()
|
|
|
.map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator))
|
|
|
.collect(),
|
|
|
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
|
|
|
slash_reward_fraction: Perbill::from_percent(10),
|
|
|
+ history_depth: 336,
|
|
|
..Default::default()
|
|
|
}),
|
|
|
- pallet_sudo: Some(SudoConfig {
|
|
|
- key: root_key.clone(),
|
|
|
- }),
|
|
|
+ pallet_sudo: Some(SudoConfig { key: root_key }),
|
|
|
pallet_babe: Some(BabeConfig {
|
|
|
authorities: vec![],
|
|
|
}),
|
|
@@ -265,21 +292,22 @@ pub fn testnet_genesis(
|
|
|
election: Some(CouncilElectionConfig {
|
|
|
auto_start: true,
|
|
|
election_parameters: ElectionParameters {
|
|
|
- announcing_period: 3 * DAYS,
|
|
|
+ announcing_period: 2 * DAYS,
|
|
|
voting_period: 1 * DAYS,
|
|
|
revealing_period: 1 * DAYS,
|
|
|
- council_size: 12,
|
|
|
+ council_size: 6,
|
|
|
candidacy_limit: 25,
|
|
|
- min_council_stake: 10 * DOLLARS,
|
|
|
- new_term_duration: 14 * DAYS,
|
|
|
- min_voting_stake: 1 * DOLLARS,
|
|
|
+ min_council_stake: 1_000,
|
|
|
+ new_term_duration: 10 * DAYS,
|
|
|
+ min_voting_stake: 100,
|
|
|
},
|
|
|
}),
|
|
|
membership: Some(MembersConfig {
|
|
|
default_paid_membership_fee: 100u128,
|
|
|
- members: vec![],
|
|
|
+ members,
|
|
|
}),
|
|
|
- forum: Some(crate::forum_config::from_serialized::create(root_key)),
|
|
|
+ forum: Some(forum_config),
|
|
|
+ data_directory: Some(data_directory_config),
|
|
|
data_object_type_registry: Some(DataObjectTypeRegistryConfig {
|
|
|
first_data_object_type_id: 1,
|
|
|
}),
|
|
@@ -300,40 +328,6 @@ pub fn testnet_genesis(
|
|
|
worker_application_human_readable_text_constraint: default_text_constraint,
|
|
|
worker_exit_rationale_text_constraint: default_text_constraint,
|
|
|
}),
|
|
|
- versioned_store: Some(VersionedStoreConfig {
|
|
|
- class_by_id: vec![],
|
|
|
- entity_by_id: vec![],
|
|
|
- next_class_id: 1,
|
|
|
- next_entity_id: 1,
|
|
|
- property_name_constraint: new_vs_validation(1, 99),
|
|
|
- property_description_constraint: new_vs_validation(1, 999),
|
|
|
- class_name_constraint: new_vs_validation(1, 99),
|
|
|
- class_description_constraint: new_vs_validation(1, 999),
|
|
|
- }),
|
|
|
- content_wg: Some(ContentWorkingGroupConfig {
|
|
|
- mint_capacity: 100_000,
|
|
|
- curator_opening_by_id: vec![],
|
|
|
- next_curator_opening_id: 0,
|
|
|
- curator_application_by_id: vec![],
|
|
|
- next_curator_application_id: 0,
|
|
|
- channel_by_id: vec![],
|
|
|
- next_channel_id: 1,
|
|
|
- channel_id_by_handle: vec![],
|
|
|
- curator_by_id: vec![],
|
|
|
- next_curator_id: 0,
|
|
|
- principal_by_id: vec![],
|
|
|
- next_principal_id: 0,
|
|
|
- channel_creation_enabled: true, // there is no extrinsic to change it so enabling at genesis
|
|
|
- unstaker_by_stake_id: vec![],
|
|
|
- channel_handle_constraint: InputValidationLengthConstraint::new(5, 20),
|
|
|
- channel_description_constraint: InputValidationLengthConstraint::new(1, 1024),
|
|
|
- opening_human_readable_text: InputValidationLengthConstraint::new(1, 2048),
|
|
|
- curator_application_human_readable_text: InputValidationLengthConstraint::new(1, 2048),
|
|
|
- curator_exit_rationale_text: InputValidationLengthConstraint::new(1, 2048),
|
|
|
- channel_avatar_constraint: InputValidationLengthConstraint::new(5, 1024),
|
|
|
- channel_banner_constraint: InputValidationLengthConstraint::new(5, 1024),
|
|
|
- channel_title_constraint: InputValidationLengthConstraint::new(5, 1024),
|
|
|
- }),
|
|
|
content_directory: Some({
|
|
|
ContentDirectoryConfig {
|
|
|
curator_group_by_id: vec![],
|
|
@@ -342,6 +336,9 @@ pub fn testnet_genesis(
|
|
|
next_curator_group_id: 1,
|
|
|
}
|
|
|
}),
|
|
|
+ versioned_store: Some(versioned_store_config),
|
|
|
+ versioned_store_permissions: Some(versioned_store_permissions_config),
|
|
|
+ content_wg: Some(content_working_group_config),
|
|
|
proposals_codex: Some(ProposalsCodexConfig {
|
|
|
set_validator_count_proposal_voting_period: cpcp
|
|
|
.set_validator_count_proposal_voting_period,
|
|
@@ -399,76 +396,87 @@ pub fn testnet_genesis(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// Tests are commented out until we find a solution to why
|
|
|
-// building dependencies for the tests are taking so long on Travis CI
|
|
|
+#[cfg(test)]
|
|
|
+pub(crate) mod tests {
|
|
|
+ use super::*;
|
|
|
+ use crate::service::{new_full, new_light};
|
|
|
+ use sc_service_test;
|
|
|
|
|
|
-// #[cfg(test)]
|
|
|
-// pub(crate) mod tests {
|
|
|
-// use super::*;
|
|
|
-// use crate::service::{new_full, new_light};
|
|
|
-// use sc_service_test;
|
|
|
-
|
|
|
-// fn local_testnet_genesis_instant_single() -> GenesisConfig {
|
|
|
-// testnet_genesis(
|
|
|
-// vec![get_authority_keys_from_seed("Alice")],
|
|
|
-// get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
|
-// vec![get_authority_keys_from_seed("Alice").0],
|
|
|
-// crate::proposals_config::development(),
|
|
|
-// )
|
|
|
-// }
|
|
|
+ fn local_testnet_genesis_instant_single() -> GenesisConfig {
|
|
|
+ testnet_genesis(
|
|
|
+ vec![get_authority_keys_from_seed("Alice")],
|
|
|
+ get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
|
+ vec![get_authority_keys_from_seed("Alice").0],
|
|
|
+ proposals_config::development(),
|
|
|
+ initial_members::none(),
|
|
|
+ forum_config::empty(get_account_id_from_seed::<sr25519::Public>("Alice")),
|
|
|
+ content_config::empty_versioned_store_config(),
|
|
|
+ content_config::empty_versioned_store_permissions_config(),
|
|
|
+ content_config::empty_data_directory_config(),
|
|
|
+ content_config::empty_content_working_group_config(),
|
|
|
+ vec![],
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
-// /// Local testnet config (single validator - Alice)
|
|
|
-// pub fn integration_test_config_with_single_authority() -> ChainSpec {
|
|
|
-// ChainSpec::from_genesis(
|
|
|
-// "Integration Test",
|
|
|
-// "test",
|
|
|
-// ChainType::Development,
|
|
|
-// local_testnet_genesis_instant_single,
|
|
|
-// vec![],
|
|
|
-// None,
|
|
|
-// None,
|
|
|
-// None,
|
|
|
-// Default::default(),
|
|
|
-// )
|
|
|
-// }
|
|
|
+ /// Local testnet config (single validator - Alice)
|
|
|
+ pub fn integration_test_config_with_single_authority() -> ChainSpec {
|
|
|
+ ChainSpec::from_genesis(
|
|
|
+ "Integration Test",
|
|
|
+ "test",
|
|
|
+ ChainType::Development,
|
|
|
+ local_testnet_genesis_instant_single,
|
|
|
+ vec![],
|
|
|
+ None,
|
|
|
+ None,
|
|
|
+ None,
|
|
|
+ Default::default(),
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
-// fn local_testnet_genesis() -> GenesisConfig {
|
|
|
-// testnet_genesis(
|
|
|
-// vec![
|
|
|
-// get_authority_keys_from_seed("Alice"),
|
|
|
-// get_authority_keys_from_seed("Bob"),
|
|
|
-// ],
|
|
|
-// get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
|
-// vec![
|
|
|
-// get_authority_keys_from_seed("Alice").0,
|
|
|
-// get_authority_keys_from_seed("Bob").0,
|
|
|
-// ],
|
|
|
-// crate::proposals_config::development(),
|
|
|
-// )
|
|
|
-// }
|
|
|
+ fn local_testnet_genesis() -> GenesisConfig {
|
|
|
+ testnet_genesis(
|
|
|
+ vec![
|
|
|
+ get_authority_keys_from_seed("Alice"),
|
|
|
+ get_authority_keys_from_seed("Bob"),
|
|
|
+ ],
|
|
|
+ get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
|
+ vec![
|
|
|
+ get_authority_keys_from_seed("Alice").0,
|
|
|
+ get_authority_keys_from_seed("Bob").0,
|
|
|
+ ],
|
|
|
+ proposals_config::development(),
|
|
|
+ initial_members::none(),
|
|
|
+ forum_config::empty(get_account_id_from_seed::<sr25519::Public>("Alice")),
|
|
|
+ content_config::empty_versioned_store_config(),
|
|
|
+ content_config::empty_versioned_store_permissions_config(),
|
|
|
+ content_config::empty_data_directory_config(),
|
|
|
+ content_config::empty_content_working_group_config(),
|
|
|
+ vec![],
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
-// /// Local testnet config (multivalidator Alice + Bob)
|
|
|
-// pub fn integration_test_config_with_two_authorities() -> ChainSpec {
|
|
|
-// ChainSpec::from_genesis(
|
|
|
-// "Integration Test",
|
|
|
-// "test",
|
|
|
-// ChainType::Development,
|
|
|
-// local_testnet_genesis,
|
|
|
-// vec![],
|
|
|
-// None,
|
|
|
-// None,
|
|
|
-// None,
|
|
|
-// Default::default(),
|
|
|
-// )
|
|
|
-// }
|
|
|
+ /// Local testnet config (multivalidator Alice + Bob)
|
|
|
+ pub fn integration_test_config_with_two_authorities() -> ChainSpec {
|
|
|
+ ChainSpec::from_genesis(
|
|
|
+ "Integration Test",
|
|
|
+ "test",
|
|
|
+ ChainType::Development,
|
|
|
+ local_testnet_genesis,
|
|
|
+ vec![],
|
|
|
+ None,
|
|
|
+ None,
|
|
|
+ None,
|
|
|
+ Default::default(),
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
-// #[test]
|
|
|
-// #[ignore]
|
|
|
-// fn test_connectivity() {
|
|
|
-// sc_service_test::connectivity(
|
|
|
-// integration_test_config_with_two_authorities(),
|
|
|
-// |config| new_full(config),
|
|
|
-// |config| new_light(config),
|
|
|
-// );
|
|
|
-// }
|
|
|
-// }
|
|
|
+ #[test]
|
|
|
+ #[ignore]
|
|
|
+ fn test_connectivity() {
|
|
|
+ sc_service_test::connectivity(
|
|
|
+ integration_test_config_with_two_authorities(),
|
|
|
+ |config| new_full(config),
|
|
|
+ |config| new_light(config),
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|