Skip to content

Commit

Permalink
Merge pull request #174 from Roznovjak/feat/setup_technical_committee
Browse files Browse the repository at this point in the history
feat!: setup technical committee
  • Loading branch information
green-jay authored Mar 25, 2021
2 parents a7199ca + 0af2643 commit 66aac23
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 44 deletions.
5 changes: 4 additions & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use hydra_dx_runtime::pallet_claims::EthereumAddress;
use hydra_dx_runtime::{
AccountId, AssetRegistryConfig, AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ClaimsConfig, CouncilConfig,
ElectionsConfig, FaucetConfig, GenesisConfig, GrandpaConfig, ImOnlineConfig, Perbill, SessionConfig, Signature,
StakerStatus, StakingConfig, SudoConfig, SystemConfig, TokensConfig, CORE_ASSET_ID, WASM_BINARY,
StakerStatus, StakingConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig, TokensConfig, CORE_ASSET_ID,
WASM_BINARY,
};
use pallet_staking::Forcing;
use sc_service::ChainType;
Expand Down Expand Up @@ -367,6 +368,7 @@ fn testnet_genesis(
}),
pallet_elections_phragmen: Some(ElectionsConfig { members: vec![] }),
pallet_collective_Instance1: Some(CouncilConfig::default()),
pallet_collective_Instance2: Some(TechnicalCommitteeConfig::default()),
pallet_claims: Some(ClaimsConfig {
claims: create_testnet_claims(),
}),
Expand Down Expand Up @@ -471,6 +473,7 @@ fn lerna_genesis(
}),
pallet_elections_phragmen: Some(ElectionsConfig { members: vec![] }),
pallet_collective_Instance1: Some(CouncilConfig::default()),
pallet_collective_Instance2: Some(TechnicalCommitteeConfig::default()),
pallet_claims: Some(ClaimsConfig { claims: vec![] }),
}
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod currency {
pub use primitives::Balance;

pub const HDX: Balance = 1_000_000_000_000;
pub const DOLLARS: Balance = HDX / 10; // 10 HDX ~= 1 $
pub const DOLLARS: Balance = HDX / 10; // 10 HDX ~= 1 $
pub const CENTS: Balance = DOLLARS / 100;
pub const MILLICENTS: Balance = CENTS / 1_000;
}
Expand Down
105 changes: 63 additions & 42 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use sp_std::prelude::*;
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;

use frame_system::{limits};
use frame_system::limits;
// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, parameter_types,
Expand Down Expand Up @@ -175,6 +175,7 @@ impl Filter<Call> for BaseFilter {
| Call::Claims(_)
| Call::Elections(_)
| Call::Babe(_)
| Call::TechnicalCommittee(_)
| Call::Treasury(_)
| Call::Tips(_)
| Call::Timestamp(_)
Expand Down Expand Up @@ -505,40 +506,40 @@ impl pallet_staking::Config for Runtime {
}

parameter_types! {
// phase durations. 1/4 of the last session for each.
pub const SignedPhase: u32 = EPOCH_DURATION_IN_BLOCKS / 4;
pub const UnsignedPhase: u32 = EPOCH_DURATION_IN_BLOCKS / 4;

// fallback: no need to do on-chain phragmen initially.
pub const Fallback: pallet_election_provider_multi_phase::FallbackStrategy =
pallet_election_provider_multi_phase::FallbackStrategy::Nothing;

pub SolutionImprovementThreshold: Perbill = Perbill::from_rational_approximation(1u32, 10_000);

// miner configs
pub const MultiPhaseUnsignedPriority: TransactionPriority = StakingUnsignedPriority::get() - 1u64;
pub const MinerMaxIterations: u32 = 10;
pub MinerMaxWeight: Weight = BlockWeights::get()
.get(DispatchClass::Normal)
.max_extrinsic.expect("Normal extrinsics have a weight limit configured; qed")
.saturating_sub(BlockExecutionWeight::get());
// phase durations. 1/4 of the last session for each.
pub const SignedPhase: u32 = EPOCH_DURATION_IN_BLOCKS / 4;
pub const UnsignedPhase: u32 = EPOCH_DURATION_IN_BLOCKS / 4;

// fallback: no need to do on-chain phragmen initially.
pub const Fallback: pallet_election_provider_multi_phase::FallbackStrategy =
pallet_election_provider_multi_phase::FallbackStrategy::Nothing;

pub SolutionImprovementThreshold: Perbill = Perbill::from_rational_approximation(1u32, 10_000);

// miner configs
pub const MultiPhaseUnsignedPriority: TransactionPriority = StakingUnsignedPriority::get() - 1u64;
pub const MinerMaxIterations: u32 = 10;
pub MinerMaxWeight: Weight = BlockWeights::get()
.get(DispatchClass::Normal)
.max_extrinsic.expect("Normal extrinsics have a weight limit configured; qed")
.saturating_sub(BlockExecutionWeight::get());
}

impl pallet_election_provider_multi_phase::Config for Runtime {
type Event = Event;
type Currency = Balances;
type SignedPhase = SignedPhase;
type UnsignedPhase = UnsignedPhase;
type SolutionImprovementThreshold = MinSolutionScoreBump;
type MinerMaxIterations = MinerMaxIterations;
type MinerMaxWeight = MinerMaxWeight;
type MinerTxPriority = MultiPhaseUnsignedPriority;
type DataProvider = Staking;
type OnChainAccuracy = Perbill;
type CompactSolution = pallet_staking::CompactAssignments;
type Fallback = Fallback;
type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight<Runtime>;
type BenchmarkingConfig = ();
type Event = Event;
type Currency = Balances;
type SignedPhase = SignedPhase;
type UnsignedPhase = UnsignedPhase;
type SolutionImprovementThreshold = MinSolutionScoreBump;
type MinerMaxIterations = MinerMaxIterations;
type MinerMaxWeight = MinerMaxWeight;
type MinerTxPriority = MultiPhaseUnsignedPriority;
type DataProvider = Staking;
type OnChainAccuracy = Perbill;
type CompactSolution = pallet_staking::CompactAssignments;
type Fallback = Fallback;
type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight<Runtime>;
type BenchmarkingConfig = ();
}

parameter_types! {
Expand Down Expand Up @@ -689,6 +690,24 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {
type WeightInfo = ();
}

parameter_types! {
pub const TechnicalMotionDuration: BlockNumber = 7 * DAYS;
pub const TechnicalMaxProposals: u32 = 100;
pub const TechnicalMaxMembers: u32 = 100;
}

type TechnicalCollective = pallet_collective::Instance2;
impl pallet_collective::Config<TechnicalCollective> for Runtime {
type Origin = Origin;
type Proposal = Call;
type Event = Event;
type MotionDuration = TechnicalMotionDuration;
type MaxProposals = TechnicalMaxProposals;
type MaxMembers = TechnicalMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = ();
}

impl pallet_authority_discovery::Config for Runtime {}

parameter_types! {
Expand Down Expand Up @@ -728,19 +747,19 @@ impl pallet_offences::Config for Runtime {
}

parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(10) * BlockWeights::get().max_block;
pub const MaxScheduledPerBlock: u32 = 50;
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(10) * BlockWeights::get().max_block;
pub const MaxScheduledPerBlock: u32 = 50;
}

impl pallet_scheduler::Config for Runtime {
type Event = Event;
type Origin = Origin;
type PalletsOrigin = OriginCaller;
type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = ();
type Event = Event;
type Origin = Origin;
type PalletsOrigin = OriginCaller;
type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = ();
}

// Create the runtime by composing the FRAME pallets that were previously configured.
Expand Down Expand Up @@ -768,6 +787,7 @@ construct_runtime!(
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
Elections: pallet_elections_phragmen::{Module, Call, Storage, Event<T>, Config<T>},
Council: pallet_collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
TechnicalCommittee: pallet_collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
Offences: pallet_offences::{Module, Call, Storage, Event},
Expand Down Expand Up @@ -1061,6 +1081,7 @@ impl_runtime_apis! {
add_benchmark!(params, batches, exchange, ExchangeBench::<Runtime>);
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
add_benchmark!(params, batches, pallet_collective, Council);
add_benchmark!(params, batches, pallet_bounties, Bounties);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Expand Down

0 comments on commit 66aac23

Please sign in to comment.