Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pallet-collective = { version = "4.0.0-dev", default-features = false, git = "ht
pallet-contracts = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-contracts-primitives = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-contracts-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-conviction-voting = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-election-provider-multi-phase = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-im-online = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-nicks = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
Expand All @@ -62,6 +63,7 @@ pallet-nomination-pools-runtime-api = { version = "1.0.0-dev", default-features
pallet-membership = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-offences = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-randomness-collective-flip = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-referenda = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-scheduler = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-session = { version = "4.0.0-dev", default-features = false, features = [ "historical" ], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-staking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
Expand Down Expand Up @@ -107,6 +109,7 @@ std = [
"pallet-contracts/std",
"pallet-contracts-primitives/std",
"pallet-contracts-rpc-runtime-api/std",
"pallet-conviction-voting/std",
"pallet-election-provider-multi-phase/std",
"pallet-grandpa/std",
"pallet-im-online/std",
Expand All @@ -121,6 +124,7 @@ std = [
"pallet-transaction-payment/std",
"pallet-nicks/std",
"pallet-offences/std",
"pallet-referenda/std",
"pallet-scheduler/std",
"pallet-session/std",
"pallet-staking/std",
Expand Down Expand Up @@ -171,10 +175,12 @@ try-runtime = [
"pallet-bounties/try-runtime",
"pallet-child-bounties/try-runtime",
"pallet-collective/try-runtime",
"pallet-conviction-voting/try-runtime",
"pallet-election-provider-multi-phase/try-runtime",
"pallet-im-online/try-runtime",
"pallet-membership/try-runtime",
"pallet-offences/try-runtime",
"pallet-referenda/try-runtime",
"pallet-session/try-runtime",
"pallet-staking/try-runtime",
"pallet-treasury/try-runtime",
Expand Down
91 changes: 90 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ use codec::Decode;
use frame_election_provider_support::{
onchain, BalancingConfig, ElectionDataProvider, SequentialPhragmen, VoteWeight,
};
use frame_support::{traits::ConstU16, weights::DispatchClass, PalletId};
use frame_support::{
traits::{ConstU16, TotalIssuanceOf},
weights::DispatchClass,
PalletId,
};
use frame_system::EnsureSigned;
pub use node_primitives::{AccountId, Balance, BlockNumber, Hash, Index, Moment, Signature};
use pallet_contracts::{DefaultAddressGenerator, DefaultContractAccessWeight};
use pallet_grandpa::{
Expand Down Expand Up @@ -868,6 +873,88 @@ impl pallet_transaction_payment::Config for Runtime {
type FeeMultiplierUpdate = ();
}

parameter_types! {
pub const VoteLockingPeriod: BlockNumber = 30 * DAYS;
}

// TODO - Update settings
impl pallet_conviction_voting::Config for Runtime {
type WeightInfo = pallet_conviction_voting::weights::SubstrateWeight<Self>;
type Event = Event;
type Currency = Balances;
type VoteLockingPeriod = VoteLockingPeriod;
type MaxVotes = ConstU32<512>;
type MaxTurnout = TotalIssuanceOf<Balances, Self::AccountId>;
type Polls = Referenda;
}

parameter_types! {
pub const AlarmInterval: BlockNumber = 1;
pub const SubmissionDeposit: Balance = 100 * DOLLARS;
pub const UndecidingTimeout: BlockNumber = 28 * DAYS;
}

pub struct TracksInfo;
impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
type Id = u16;
type Origin = <Origin as frame_support::traits::OriginTrait>::PalletsOrigin;
fn tracks() -> &'static [(Self::Id, pallet_referenda::TrackInfo<Balance, BlockNumber>)] {
static DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 1] = [(
0u16,
pallet_referenda::TrackInfo {
name: "root",
max_deciding: 1,
decision_deposit: 10,
prepare_period: 4,
decision_period: 4,
confirm_period: 2,
min_enactment_period: 4,
min_approval: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(50),
ceil: Perbill::from_percent(100),
},
min_support: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(0),
ceil: Perbill::from_percent(100),
},
},
)];
&DATA[..]
}
fn track_for(id: &Self::Origin) -> Result<Self::Id, ()> {
if let Ok(system_origin) = frame_system::RawOrigin::try_from(id.clone()) {
match system_origin {
frame_system::RawOrigin::Root => Ok(0),
_ => Err(()),
}
} else {
Err(())
}
}
}

// TODO - Update settings
impl pallet_referenda::Config for Runtime {
type WeightInfo = pallet_referenda::weights::SubstrateWeight<Self>;
type Call = Call;
type Event = Event;
type Scheduler = Scheduler;
type Currency = pallet_balances::Pallet<Self>;
type SubmitOrigin = EnsureSigned<AccountId>;
type CancelOrigin = EnsureRoot<AccountId>;
type KillOrigin = EnsureRoot<AccountId>;
type Slash = ();
type Votes = pallet_conviction_voting::VotesOf<Runtime>;
type Tally = pallet_conviction_voting::TallyOf<Runtime>;
type SubmissionDeposit = SubmissionDeposit;
type MaxQueued = ConstU32<100>;
type UndecidingTimeout = UndecidingTimeout;
type AlarmInterval = AlarmInterval;
type Tracks = TracksInfo;
}

impl pallet_sudo::Config for Runtime {
type Event = Event;
type Call = Call;
Expand Down Expand Up @@ -931,6 +1018,8 @@ construct_runtime!(
Bounties: pallet_bounties,
ChildBounties: pallet_child_bounties,
TechnicalMembership: pallet_membership::<Instance1>,
Referenda: pallet_referenda,
ConvictionVoting: pallet_conviction_voting,
}
);

Expand Down