Skip to content
Snippets Groups Projects
Commit 650f9044 authored by Éloïs's avatar Éloïs
Browse files

feat(governance): replace smiths collective by technical committee (!92)

* feat(governance):  replace smiths collective by technical committee
parent 67184b79
Branches
Tags
1 merge request!92feat(governance):  replace smiths collective by technical committee
......@@ -53,5 +53,6 @@
"certs": ["Alice", "Bob"]
}
},
"sudo_key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
"sudo_key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
"technical_committee": ["Alice", "Bob", "Charlie"]
}
......@@ -58,5 +58,6 @@
"certs": ["Alice", "Bob"]
}
},
"sudo_key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
"sudo_key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
"technical_committee": ["Alice", "Bob", "Charlie"]
}
......@@ -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,
......
......@@ -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))
......
......@@ -183,5 +183,6 @@
"certs": ["Elois","tuxmain","HugoTrentesaux"]
}
},
"sudo_key": "5Co5AWcBiz4HaAEpu8BxLdghnCob89rFGU5yQ65WP3t2jsyB"
"sudo_key": "5Co5AWcBiz4HaAEpu8BxLdghnCob89rFGU5yQ65WP3t2jsyB",
"technical_committee": ["Elois", "cgeek", "tuxmain", "HugoTrentesaux"]
}
No preview for this file type
......@@ -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>;
}
};
......
......@@ -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,
......
......@@ -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>;
......@@ -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,
......
......@@ -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>;
......@@ -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,
......
......@@ -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>;
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment