diff --git a/end2end-tests/cucumber-genesis/default.json b/end2end-tests/cucumber-genesis/default.json index 32abeaa5616d57801d967dcc85609569aa74a935..7eb7b13925f46831d3c052a1c8963ef2004ca241 100644 --- a/end2end-tests/cucumber-genesis/default.json +++ b/end2end-tests/cucumber-genesis/default.json @@ -53,5 +53,6 @@ "certs": ["Alice", "Bob"] } }, - "sudo_key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" + "sudo_key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "technical_committee": ["Alice", "Bob", "Charlie"] } diff --git a/end2end-tests/cucumber-genesis/wot.json b/end2end-tests/cucumber-genesis/wot.json index 205481324b92c9749c7d8bb962acab36de00b591..f4048b0b164c4c2b7239b37c30ccd78b4f84abda 100644 --- a/end2end-tests/cucumber-genesis/wot.json +++ b/end2end-tests/cucumber-genesis/wot.json @@ -58,5 +58,6 @@ "certs": ["Alice", "Bob"] } }, - "sudo_key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" + "sudo_key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + "technical_committee": ["Alice", "Bob", "Charlie"] } diff --git a/node/src/chain_spec/gdev.rs b/node/src/chain_spec/gdev.rs index 93290c01a55b3ea566507ac4fa276cb1441851c0..780cfb188f6c617e3f5629cabdbf57c1505a3d9d 100644 --- a/node/src/chain_spec/gdev.rs +++ b/node/src/chain_spec/gdev.rs @@ -22,7 +22,7 @@ use gdev_runtime::{ opaque::SessionKeys, AccountConfig, AccountId, AuthorityMembersConfig, BabeConfig, BalancesConfig, CertConfig, GenesisConfig, IdentityConfig, ImOnlineId, MembershipConfig, ParametersConfig, SessionConfig, SmithsCertConfig, SmithsMembershipConfig, SudoConfig, - SystemConfig, UniversalDividendConfig, WASM_BINARY, + SystemConfig, TechnicalCommitteeConfig, UniversalDividendConfig, WASM_BINARY, }; use sc_service::ChainType; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; @@ -355,6 +355,13 @@ fn gen_genesis_for_local_chain( // Assign network admin rights. key: Some(root_key), }, + technical_committee: TechnicalCommitteeConfig { + members: initial_smiths + .iter() + .map(|x| x.0.clone()) + .collect::<Vec<_>>(), + ..Default::default() + }, identity: IdentityConfig { identities: initial_identities .iter() @@ -391,7 +398,6 @@ fn gen_genesis_for_local_chain( apply_cert_period_at_genesis: false, certs_by_receiver: clique_wot(initial_smiths_len, smith_cert_validity_period), }, - smiths_collective: Default::default(), universal_dividend: UniversalDividendConfig { first_reeval: 100, first_ud, @@ -439,6 +445,7 @@ fn genesis_data_to_gdev_genesis_conf( smiths_certs_by_receiver, smiths_memberships, sudo_key, + technical_committee_members, } = genesis_data; gdev_runtime::GenesisConfig { @@ -466,6 +473,10 @@ fn genesis_data_to_gdev_genesis_conf( .collect::<Vec<_>>(), }, sudo: SudoConfig { key: sudo_key }, + technical_committee: TechnicalCommitteeConfig { + members: technical_committee_members, + ..Default::default() + }, identity: IdentityConfig { identities: identities .into_iter() @@ -496,7 +507,6 @@ fn genesis_data_to_gdev_genesis_conf( smiths_membership: SmithsMembershipConfig { memberships: smiths_memberships, }, - smiths_collective: Default::default(), universal_dividend: UniversalDividendConfig { first_reeval: first_ud_reeval, first_ud, diff --git a/node/src/chain_spec/gen_genesis_data.rs b/node/src/chain_spec/gen_genesis_data.rs index dd552e9be56a3d0c555b8588dd8be0d3be3bbac1..5b46cc55f7cfa1be43dcdeef2db068ec6729c0f9 100644 --- a/node/src/chain_spec/gen_genesis_data.rs +++ b/node/src/chain_spec/gen_genesis_data.rs @@ -38,6 +38,7 @@ pub struct GenesisData<Parameters: DeserializeOwned, SessionKeys: Decode> { pub smiths_certs_by_receiver: BTreeMap<u32, BTreeMap<u32, u32>>, pub smiths_memberships: BTreeMap<u32, MembershipData>, pub sudo_key: Option<AccountId>, + pub technical_committee_members: Vec<AccountId>, } #[derive(Default)] @@ -58,6 +59,7 @@ struct GenesisConfig<Parameters> { #[serde(rename = "smiths")] smith_identities: BTreeMap<String, SmithData>, sudo_key: Option<AccountId>, + technical_committee: Vec<String>, #[serde(default)] wallets: BTreeMap<AccountId, u64>, } @@ -134,6 +136,7 @@ where parameters, identities, smith_identities, + technical_committee, wallets, } = genesis_config; @@ -145,6 +148,7 @@ where let mut idty_index_of = BTreeMap::new(); let mut initial_monetary_mass = 0; let mut memberships = BTreeMap::new(); + let mut technical_committee_members = Vec::with_capacity(technical_committee.len()); //let mut total_dust = 0; // SIMPLE WALLETS // @@ -162,6 +166,16 @@ where ); } + // Technical Comittee // + + for idty_name in technical_committee { + if let Some(identity) = identities.get(&idty_name) { + technical_committee_members.push(identity.pubkey.clone()); + } else { + return Err(format!("Identity '{}' not exist", idty_name)); + } + } + // IDENTITIES // for (idty_name, identity) in &identities { @@ -320,6 +334,7 @@ where smiths_certs_by_receiver, smiths_memberships, sudo_key, + technical_committee_members, }; Ok(f(genesis_data)) diff --git a/resources/gdev.json b/resources/gdev.json index 45aa222ba1dcebe2d886ab840e44860dcb3a761b..02be64086a38d9edc89412cfb820cbc0105c18c3 100644 --- a/resources/gdev.json +++ b/resources/gdev.json @@ -183,5 +183,6 @@ "certs": ["Elois","tuxmain","HugoTrentesaux"] } }, - "sudo_key": "5Co5AWcBiz4HaAEpu8BxLdghnCob89rFGU5yQ65WP3t2jsyB" + "sudo_key": "5Co5AWcBiz4HaAEpu8BxLdghnCob89rFGU5yQ65WP3t2jsyB", + "technical_committee": ["Elois", "cgeek", "tuxmain", "HugoTrentesaux"] } diff --git a/resources/metadata.scale b/resources/metadata.scale index 745d186e552bbd0323d9e2e78cf80fd620892fe9..bfcf355fbb83ffe14485443a7ec787fd343d01f1 100644 Binary files a/resources/metadata.scale and b/resources/metadata.scale differ diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index 20dc90e790acc01fa39c977bd067a0eb29c71719..148ee661dccc878f36a5075269ddcf0a5c70b2a7 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -262,17 +262,17 @@ macro_rules! pallets_config { #[cfg(feature = "runtime-benchmarks")] parameter_types! { - pub const WorstCaseOrigin: pallet_collective::RawOrigin<AccountId, SmithsInstance> = - pallet_collective::RawOrigin::<AccountId, SmithsInstance>::Members(2, 3); + pub const WorstCaseOrigin: pallet_collective::RawOrigin<AccountId, TechnicalCommitteeInstance> = + pallet_collective::RawOrigin::<AccountId, TechnicalCommitteeInstance>::Members(2, 3); } impl pallet_upgrade_origin::Config for Runtime { type Event = Event; type Call = Call; - type UpgradableOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, SmithsInstance>; + type UpgradableOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCommitteeInstance>; type WeightInfo = common_runtime::weights::pallet_upgrade_origin::WeightInfo<Runtime>; #[cfg(feature = "runtime-benchmarks")] - type WorstCaseOriginType = pallet_collective::RawOrigin<AccountId, SmithsInstance>; + type WorstCaseOriginType = pallet_collective::RawOrigin<AccountId, TechnicalCommitteeInstance>; #[cfg(feature = "runtime-benchmarks")] type WorstCaseOrigin = WorstCaseOrigin; } @@ -499,8 +499,8 @@ macro_rules! pallets_config { type ValidityPeriod = SmithValidityPeriod; } - pub struct SmithMembersDefaultVote; - impl pallet_collective::DefaultVote for SmithMembersDefaultVote { + pub struct TechnicalCommitteeDefaultVote; + impl pallet_collective::DefaultVote for TechnicalCommitteeDefaultVote { fn default_vote( _prime_vote: Option<bool>, _yes_votes: u32, @@ -510,34 +510,18 @@ macro_rules! pallets_config { false } } - pub struct SmithMembersStorage; - impl sp_runtime::traits::IsMember<AccountId> for SmithMembersStorage { - fn is_member(account_id: &AccountId) -> bool { - use sp_runtime::traits::Convert as _; - if let Some(idty_index) = common_runtime::providers::IdentityIndexOf::<Runtime>::convert(account_id.clone()) { - pallet_membership::Pallet::<Runtime, Instance2>::is_member(&idty_index) - } else { - false - } - } - } - impl pallet_collective::MembersStorage<AccountId> for SmithMembersStorage { - fn members_count() -> u32 { - pallet_membership::Membership::<Runtime, Instance2>::count() - } - } parameter_types! { - pub const SmithsMotionDuration: BlockNumber = 7 * DAYS; + pub const TechnicalCommitteeMotionDuration: BlockNumber = 7 * DAYS; } impl pallet_collective::Config<Instance2> for Runtime { type Origin = Origin; type Proposal = Call; type Event = Event; - type MotionDuration = SmithsMotionDuration; + type MotionDuration = TechnicalCommitteeMotionDuration; type MaxProposals = frame_support::pallet_prelude::ConstU32<20>; - type MaxMembers = frame_support::pallet_prelude::ConstU32<1_000>; - type MembersStorage = SmithMembersStorage; - type DefaultVote = SmithMembersDefaultVote; + type MaxMembers = frame_support::pallet_prelude::ConstU32<100>; + type MembersStorage = pallet_collective::InternalMembersStorage<Runtime, Instance2>; + type DefaultVote = TechnicalCommitteeDefaultVote; type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>; } }; diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index 4255e3e6dd68e822badc905c699489d52fca8b88..da2ddd64321bc794c3b11bb2a2d91a8c330b3498 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -124,7 +124,7 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; -pub type SmithsInstance = Instance2; +pub type TechnicalCommitteeInstance = Instance2; pub struct BaseCallFilter; impl Contains<Call> for BaseCallFilter { @@ -230,6 +230,7 @@ construct_runtime!( Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20, UpgradeOrigin: pallet_upgrade_origin::{Pallet, Call, Event} = 21, Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 22, + TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Config<T>, Storage, Event<T>, Origin<T>} = 23, // Universal dividend UniversalDividend: pallet_universal_dividend::{Pallet, Call, Config<T>, Storage, Event<T>} = 30, @@ -244,7 +245,6 @@ construct_runtime!( SmithsSubWot: pallet_duniter_wot::<Instance2>::{Pallet} = 50, SmithsMembership: pallet_membership::<Instance2>::{Pallet, Call, Config<T>, Storage, Event<T>} = 52, SmithsCert: pallet_certification::<Instance2>::{Pallet, Call, Config<T>, Storage, Event<T>} = 53, - SmithsCollective: pallet_collective::<Instance2>::{Pallet, Call, Config<T>, Storage, Event<T>, Origin<T>} = 54, // Utilities AtomicSwap: pallet_atomic_swap::{Pallet, Call, Storage, Event<T>} = 60, diff --git a/runtime/g1/src/parameters.rs b/runtime/g1/src/parameters.rs index 24a32ac67236ff2e621ba94f5353a0581d99adc2..88b6cb704eb15b4ff11dd85c5867e9c6cc8bf8df 100644 --- a/runtime/g1/src/parameters.rs +++ b/runtime/g1/src/parameters.rs @@ -155,6 +155,6 @@ parameter_types! { // Treasury pub type TreasuryApproveOrigin = - pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, SmithsInstance>; + pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, TechnicalCommitteeInstance>; pub type TreasuryRejectOrigin = - pallet_collective::EnsureProportionMoreThan<_1, _3, AccountId, SmithsInstance>; + pallet_collective::EnsureProportionMoreThan<_1, _3, AccountId, TechnicalCommitteeInstance>; diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index 8476ea5e79ff7c3ad7ad8a05bc8fd86e0a74f26f..84cc9fbd0fbdd8c0d759b3c7fc9b6d80f3789d9a 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -129,7 +129,7 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; -pub type SmithsInstance = Instance2; +pub type TechnicalCommitteeInstance = Instance2; pub struct BaseCallFilter; #[cfg(not(feature = "runtime-benchmarks"))] @@ -181,7 +181,7 @@ pub enum ProxyType { AlmostAny = 0, TransferOnly = 1, CancelProxy = 2, - SmithsCollectivePropose = 3, + TechnicalCommitteePropose = 3, } impl Default for ProxyType { fn default() -> Self { @@ -207,10 +207,10 @@ impl frame_support::traits::InstanceFilter<Call> for ProxyType { Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) ) } - ProxyType::SmithsCollectivePropose => { + ProxyType::TechnicalCommitteePropose => { matches!( c, - Call::SmithsCollective(pallet_collective::Call::propose { .. }) + Call::TechnicalCommittee(pallet_collective::Call::propose { .. }) ) } } @@ -300,6 +300,7 @@ construct_runtime!( Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20, UpgradeOrigin: pallet_upgrade_origin::{Pallet, Call, Event} = 21, Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 22, + TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Config<T>, Storage, Event<T>, Origin<T>} = 23, // Universal dividend UniversalDividend: pallet_universal_dividend::{Pallet, Call, Config<T>, Storage, Event<T>} = 30, @@ -314,7 +315,6 @@ construct_runtime!( SmithsSubWot: pallet_duniter_wot::<Instance2>::{Pallet} = 50, SmithsMembership: pallet_membership::<Instance2>::{Pallet, Call, Config<T>, Storage, Event<T>} = 52, SmithsCert: pallet_certification::<Instance2>::{Pallet, Call, Config<T>, Storage, Event<T>} = 53, - SmithsCollective: pallet_collective::<Instance2>::{Pallet, Call, Config<T>, Storage, Event<T>, Origin<T>} = 54, // Utilities AtomicSwap: pallet_atomic_swap::{Pallet, Call, Storage, Event<T>} = 60, diff --git a/runtime/gdev/src/parameters.rs b/runtime/gdev/src/parameters.rs index a9fe4dbbcfae944e13efaa8dac079207518f36b2..d7687e76f1a894cd90f3a752aa59ebc3e1be55bd 100644 --- a/runtime/gdev/src/parameters.rs +++ b/runtime/gdev/src/parameters.rs @@ -105,6 +105,6 @@ parameter_types! { // Treasury pub type TreasuryApproveOrigin = - pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, SmithsInstance>; + pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, TechnicalCommitteeInstance>; pub type TreasuryRejectOrigin = - pallet_collective::EnsureProportionMoreThan<_1, _3, AccountId, SmithsInstance>; + pallet_collective::EnsureProportionMoreThan<_1, _3, AccountId, TechnicalCommitteeInstance>; diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs index 4baa629356fdee62ea773043f3f2d4ce0e623f96..dfe46aac7c9988a37cb4c4485bf0588fc3751cb6 100644 --- a/runtime/gtest/src/lib.rs +++ b/runtime/gtest/src/lib.rs @@ -125,7 +125,7 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; -pub type SmithsInstance = Instance2; +pub type TechnicalCommitteeInstance = Instance2; pub struct BaseCallFilter; impl Contains<Call> for BaseCallFilter { @@ -231,6 +231,7 @@ construct_runtime!( Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 20, UpgradeOrigin: pallet_upgrade_origin::{Pallet, Call, Event} = 21, Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 22, + TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Config<T>, Storage, Event<T>, Origin<T>} = 23, // Universal dividend UniversalDividend: pallet_universal_dividend::{Pallet, Call, Config<T>, Storage, Event<T>} = 30, @@ -245,7 +246,6 @@ construct_runtime!( SmithsSubWot: pallet_duniter_wot::<Instance2>::{Pallet} = 50, SmithsMembership: pallet_membership::<Instance2>::{Pallet, Call, Config<T>, Storage, Event<T>} = 52, SmithsCert: pallet_certification::<Instance2>::{Pallet, Call, Config<T>, Storage, Event<T>} = 53, - SmithsCollective: pallet_collective::<Instance2>::{Pallet, Call, Config<T>, Storage, Event<T>, Origin<T>} = 54, // Utilities AtomicSwap: pallet_atomic_swap::{Pallet, Call, Storage, Event<T>} = 60, diff --git a/runtime/gtest/src/parameters.rs b/runtime/gtest/src/parameters.rs index 745786181445ad3edc16ac959c810408589efbf9..fbf00964202c955ee4e8698f2ca44ebe986855b2 100644 --- a/runtime/gtest/src/parameters.rs +++ b/runtime/gtest/src/parameters.rs @@ -155,6 +155,6 @@ parameter_types! { // Treasury pub type TreasuryApproveOrigin = - pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, SmithsInstance>; + pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, TechnicalCommitteeInstance>; pub type TreasuryRejectOrigin = - pallet_collective::EnsureProportionMoreThan<_1, _3, AccountId, SmithsInstance>; + pallet_collective::EnsureProportionMoreThan<_1, _3, AccountId, TechnicalCommitteeInstance>; diff --git a/xtask/src/gen_calls_doc.rs b/xtask/src/gen_calls_doc.rs index 5dc50f0ccccc0df515d09cc6354fa894f45dff55..5b14ad445d158e15e58c285f77c69e7b9e154e18 100644 --- a/xtask/src/gen_calls_doc.rs +++ b/xtask/src/gen_calls_doc.rs @@ -64,7 +64,7 @@ impl CallCategory { ("SmithsCert", "force_add_cert" | "del_cert" | "remove_all_certs_received_by") => { Self::Root } - ("SmithsCollective", "set_members" | "disapprove_proposal") => Self::Root, + ("TechnicalCommittee", "set_members" | "disapprove_proposal") => Self::Root, ("Utility", "dispatch_as") => Self::Root, ("Treasury", "approve_proposal" | "reject_proposal") => Self::OtherOrigin, _ => Self::User,