-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add tech com * add mandate to tech comm * bump spec version * remove sudo pallet * sudo and tech members migration * remove prime member migration as it gets cleared if we add more members later * clean unused import
- Loading branch information
1 parent
7247057
commit 630f421
Showing
6 changed files
with
106 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::{ | ||
pallets_core::RuntimeBlockWeights, pallets_governance::TechnicalCollectiveMembers, Runtime, | ||
}; | ||
use frame_support::{ | ||
debug, | ||
storage::unhashed, | ||
traits::{InitializeMembers, OnRuntimeUpgrade}, | ||
weights::Weight, | ||
StorageHasher, Twox128, | ||
}; | ||
use sp_std::vec::Vec; | ||
use ternoa_primitives::AccountId; | ||
|
||
pub struct SudoToTechComm; | ||
impl OnRuntimeUpgrade for SudoToTechComm { | ||
fn on_runtime_upgrade() -> Weight { | ||
debug::RuntimeLogger::init(); | ||
debug::print!("🕊️ Starting sudo migration..."); | ||
|
||
let mut sudo_key_storage_key = Vec::new(); | ||
sudo_key_storage_key.extend_from_slice(&Twox128::hash(b"Sudo")); | ||
sudo_key_storage_key.extend_from_slice(&Twox128::hash(b"Key")); | ||
|
||
let mut members_storage_key = Vec::new(); | ||
members_storage_key.extend_from_slice(&Twox128::hash(b"Instance0Membership")); | ||
members_storage_key.extend_from_slice(&Twox128::hash(b"Members")); | ||
|
||
if let Some(sudo_key) = unhashed::get::<AccountId>(&sudo_key_storage_key) { | ||
// Configure the tech membership with the old sudo key | ||
let mut members = Vec::new(); | ||
members.push(sudo_key.clone()); | ||
unhashed::put(&members_storage_key, &members); | ||
|
||
// Let the tech committee pallet know about the membership changes | ||
<<Runtime as pallet_membership::Config<TechnicalCollectiveMembers>>::MembershipInitialized as InitializeMembers<AccountId>>::initialize_members(&members); | ||
} | ||
|
||
// Clean sudo storage | ||
unhashed::kill(&sudo_key_storage_key); | ||
|
||
debug::print!("🕊️ Sudo migration done"); | ||
|
||
// Keep things simple, take a full block to execute when the migration is deployed | ||
RuntimeBlockWeights::get().max_block | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,45 @@ | ||
use crate::{Call, Event, Runtime}; | ||
use crate::{constants::time::DAYS, Call, Event, Origin, Runtime, TechnicalCommittee}; | ||
use frame_support::parameter_types; | ||
use sp_core::u32_trait::{_1, _2}; | ||
use ternoa_primitives::{AccountId, BlockNumber}; | ||
|
||
impl pallet_sudo::Config for Runtime { | ||
// Shared parameters with all collectives / committees | ||
parameter_types! { | ||
pub const MotionDuration: BlockNumber = 2 * DAYS; | ||
pub const MaxProposals: u32 = 100; | ||
pub const MaxMembers: u32 = 50; | ||
} | ||
|
||
// --- Technical committee | ||
pub type TechnicalCollective = pallet_collective::Instance0; | ||
pub type TechnicalCollectiveMembers = pallet_membership::Instance0; | ||
pub type MoreThanHalfOfTheTechnicalCollective = | ||
pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, TechnicalCollective>; | ||
|
||
impl pallet_collective::Config<TechnicalCollective> for Runtime { | ||
type Origin = Origin; | ||
type Proposal = Call; | ||
type Event = Event; | ||
type MotionDuration = MotionDuration; | ||
type MaxProposals = MaxProposals; | ||
type WeightInfo = (); | ||
type MaxMembers = MaxMembers; | ||
type DefaultVote = pallet_collective::PrimeDefaultVote; | ||
} | ||
|
||
impl pallet_membership::Config<TechnicalCollectiveMembers> for Runtime { | ||
type Event = Event; | ||
type AddOrigin = MoreThanHalfOfTheTechnicalCollective; | ||
type RemoveOrigin = MoreThanHalfOfTheTechnicalCollective; | ||
type SwapOrigin = MoreThanHalfOfTheTechnicalCollective; | ||
type ResetOrigin = MoreThanHalfOfTheTechnicalCollective; | ||
type PrimeOrigin = MoreThanHalfOfTheTechnicalCollective; | ||
type MembershipInitialized = TechnicalCommittee; | ||
type MembershipChanged = TechnicalCommittee; | ||
} | ||
|
||
impl pallet_mandate::Config for Runtime { | ||
type Event = Event; | ||
type Call = Call; | ||
type ExternalOrigin = MoreThanHalfOfTheTechnicalCollective; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters