Commit cf7b4564 authored by Bastian Köcher's avatar Bastian Köcher Committed by asynchronous rob
Browse files

Update to latest Substrate master + warning fixes (#292)



* Update to latest Substrate master + warning fixes

* Update runtime/src/lib.rs
Co-Authored-By: thiolliere's avatarthiolliere <gui.thiolliere@gmail.com>
parent 4924efe4
Pipeline #40910 passed with stages
in 23 minutes and 29 seconds
This diff is collapsed.
......@@ -10,8 +10,8 @@ futures = "0.1.17"
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
parity-codec = "3.0"
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
consensus_authorities = { package = "substrate-consensus-authorities", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
consensus_common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
aura = { package = "substrate-consensus-aura", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
polkadot-runtime = { path = "../runtime", version = "0.1" }
polkadot-primitives = { path = "../primitives", version = "0.1" }
polkadot-cli = { path = "../cli" }
......
......@@ -63,8 +63,8 @@ use polkadot_cli::{Worker, IntoExit, ProvideRuntimeApi, TaskExecutor};
use polkadot_network::validation::{ValidationNetwork, SessionParams};
use polkadot_network::NetworkService;
use tokio::timer::Timeout;
use consensus_authorities::AuthoritiesApi;
use consensus_common::SelectChain;
use aura::AuraApi;
pub use polkadot_cli::VersionInfo;
pub use polkadot_network::validation::Incoming;
......@@ -189,7 +189,7 @@ impl<P: 'static, E: 'static> RelayChainContext for ApiContext<P, E> where
E: Future<Item=(),Error=()> + Clone + Send + Sync + 'static,
{
type Error = String;
type FutureEgress = Box<Future<Item=ConsolidatedIngress, Error=String> + Send>;
type FutureEgress = Box<dyn Future<Item=ConsolidatedIngress, Error=String> + Send>;
fn unrouted_egress(&self, _id: ParaId) -> Self::FutureEgress {
// TODO: https://github.com/paritytech/polkadot/issues/253
......@@ -227,7 +227,7 @@ impl<P, E> Worker for CollationNode<P, E> where
E: Future<Item=(),Error=()> + Clone + Send + Sync + 'static,
<P::ProduceCandidate as IntoFuture>::Future: Send + 'static,
{
type Work = Box<Future<Item=(),Error=()> + Send>;
type Work = Box<dyn Future<Item=(),Error=()> + Send>;
fn configuration(&self) -> CustomConfiguration {
let mut config = CustomConfiguration::default();
......@@ -409,7 +409,7 @@ mod tests {
impl RelayChainContext for DummyRelayChainContext {
type Error = ();
type FutureEgress = Box<Future<Item=ConsolidatedIngress,Error=()>>;
type FutureEgress = Box<dyn Future<Item=ConsolidatedIngress,Error=()>>;
fn unrouted_egress(&self, para_id: ParaId) -> Self::FutureEgress {
match self.ingress.get(&para_id) {
......
......@@ -158,14 +158,14 @@ pub fn register_validator<O: KnownOracle + 'static>(
/// Create this using `register_validator`.
#[derive(Clone)]
pub struct RegisteredMessageValidator {
inner: Arc<MessageValidator<KnownOracle>>,
inner: Arc<MessageValidator<dyn KnownOracle>>,
}
impl RegisteredMessageValidator {
#[cfg(test)]
pub(crate) fn new_test<O: KnownOracle + 'static>(
oracle: O,
report_handle: Box<Fn(&PeerId, i32) + Send + Sync>,
report_handle: Box<dyn Fn(&PeerId, i32) + Send + Sync>,
) -> Self {
let validator = Arc::new(MessageValidator::new_test(oracle, report_handle));
......@@ -423,7 +423,7 @@ impl<O: ?Sized + KnownOracle> Inner<O> {
/// An unregistered message validator. Register this with `register_validator`.
pub struct MessageValidator<O: ?Sized> {
report_handle: Box<Fn(&PeerId, i32) + Send + Sync>,
report_handle: Box<dyn Fn(&PeerId, i32) + Send + Sync>,
inner: RwLock<Inner<O>>,
}
......@@ -431,7 +431,7 @@ impl<O: KnownOracle + ?Sized> MessageValidator<O> {
#[cfg(test)]
fn new_test(
oracle: O,
report_handle: Box<Fn(&PeerId, i32) + Send + Sync>,
report_handle: Box<dyn Fn(&PeerId, i32) + Send + Sync>,
) -> Self where O: Sized{
MessageValidator {
report_handle,
......@@ -449,19 +449,19 @@ impl<O: KnownOracle + ?Sized> MessageValidator<O> {
}
impl<O: KnownOracle + ?Sized> network_gossip::Validator<Block> for MessageValidator<O> {
fn new_peer(&self, _context: &mut ValidatorContext<Block>, who: &PeerId, _roles: Roles) {
fn new_peer(&self, _context: &mut dyn ValidatorContext<Block>, who: &PeerId, _roles: Roles) {
let mut inner = self.inner.write();
inner.peers.insert(who.clone(), PeerData {
live: HashMap::new(),
});
}
fn peer_disconnected(&self, _context: &mut ValidatorContext<Block>, who: &PeerId) {
fn peer_disconnected(&self, _context: &mut dyn ValidatorContext<Block>, who: &PeerId) {
let mut inner = self.inner.write();
inner.peers.remove(who);
}
fn validate(&self, context: &mut ValidatorContext<Block>, sender: &PeerId, mut data: &[u8])
fn validate(&self, context: &mut dyn ValidatorContext<Block>, sender: &PeerId, mut data: &[u8])
-> GossipValidationResult<Hash>
{
let (res, cost_benefit) = match GossipMessage::decode(&mut data) {
......@@ -486,7 +486,7 @@ impl<O: KnownOracle + ?Sized> network_gossip::Validator<Block> for MessageValida
res
}
fn message_expired<'a>(&'a self) -> Box<FnMut(Hash, &[u8]) -> bool + 'a> {
fn message_expired<'a>(&'a self) -> Box<dyn FnMut(Hash, &[u8]) -> bool + 'a> {
let inner = self.inner.read();
Box::new(move |topic, _data| {
......@@ -495,7 +495,7 @@ impl<O: KnownOracle + ?Sized> network_gossip::Validator<Block> for MessageValida
})
}
fn message_allowed<'a>(&'a self) -> Box<FnMut(&PeerId, MessageIntent, &Hash, &[u8]) -> bool + 'a> {
fn message_allowed<'a>(&'a self) -> Box<dyn FnMut(&PeerId, MessageIntent, &Hash, &[u8]) -> bool + 'a> {
let mut inner = self.inner.write();
Box::new(move |who, intent, topic, data| {
let &mut Inner { ref mut peers, ref mut our_view, .. } = &mut *inner;
......
......@@ -175,7 +175,7 @@ pub enum Message {
Collation(Hash, Collation),
}
fn send_polkadot_message(ctx: &mut Context<Block>, to: PeerId, message: Message) {
fn send_polkadot_message(ctx: &mut dyn Context<Block>, to: PeerId, message: Message) {
trace!(target: "p_net", "Sending polkadot message to {}: {:?}", to, message);
let encoded = message.encode();
ctx.send_chain_specific(to, encoded)
......@@ -215,7 +215,7 @@ impl PolkadotProtocol {
/// Fetch block data by candidate receipt.
fn fetch_pov_block(
&mut self,
ctx: &mut Context<Block>,
ctx: &mut dyn Context<Block>,
candidate: &CandidateReceipt,
relay_parent: Hash,
canon_roots: StructuredUnroutedIngress,
......@@ -238,7 +238,7 @@ impl PolkadotProtocol {
/// Note new validation session.
fn new_validation_session(
&mut self,
ctx: &mut Context<Block>,
ctx: &mut dyn Context<Block>,
params: validation::SessionParams,
) -> validation::ValidationSession {
......@@ -265,7 +265,7 @@ impl PolkadotProtocol {
self.live_validation_sessions.remove(parent_hash)
}
fn dispatch_pending_requests(&mut self, ctx: &mut Context<Block>) {
fn dispatch_pending_requests(&mut self, ctx: &mut dyn Context<Block>) {
let mut new_pending = Vec::new();
let validator_keys = &mut self.validators;
let next_req_id = &mut self.next_req_id;
......@@ -316,7 +316,7 @@ impl PolkadotProtocol {
self.pending = new_pending;
}
fn on_polkadot_message(&mut self, ctx: &mut Context<Block>, who: PeerId, msg: Message) {
fn on_polkadot_message(&mut self, ctx: &mut dyn Context<Block>, who: PeerId, msg: Message) {
trace!(target: "p_net", "Polkadot message from {}: {:?}", who, msg);
match msg {
Message::SessionKey(key) => self.on_session_key(ctx, who, key),
......@@ -352,7 +352,7 @@ impl PolkadotProtocol {
}
}
fn on_session_key(&mut self, ctx: &mut Context<Block>, who: PeerId, key: SessionKey) {
fn on_session_key(&mut self, ctx: &mut dyn Context<Block>, who: PeerId, key: SessionKey) {
{
let info = match self.peers.get_mut(&who) {
Some(peer) => peer,
......@@ -396,7 +396,7 @@ impl PolkadotProtocol {
fn on_pov_block(
&mut self,
ctx: &mut Context<Block>,
ctx: &mut dyn Context<Block>,
who: PeerId,
req_id: RequestId,
pov_block: Option<PoVBlock>,
......@@ -429,7 +429,7 @@ impl PolkadotProtocol {
}
// when a validator sends us (a collator) a new role.
fn on_new_role(&mut self, ctx: &mut Context<Block>, who: PeerId, role: Role) {
fn on_new_role(&mut self, ctx: &mut dyn Context<Block>, who: PeerId, role: Role) {
let info = match self.peers.get_mut(&who) {
Some(peer) => peer,
None => {
......@@ -467,7 +467,7 @@ impl Specialization<Block> for PolkadotProtocol {
Status { collating_for: self.collating_for.clone() }.encode()
}
fn on_connect(&mut self, ctx: &mut Context<Block>, who: PeerId, status: FullStatus) {
fn on_connect(&mut self, ctx: &mut dyn Context<Block>, who: PeerId, status: FullStatus) {
let local_status = match Status::decode(&mut &status.chain_status[..]) {
Some(status) => status,
None => {
......@@ -515,7 +515,7 @@ impl Specialization<Block> for PolkadotProtocol {
self.dispatch_pending_requests(ctx);
}
fn on_disconnect(&mut self, ctx: &mut Context<Block>, who: PeerId) {
fn on_disconnect(&mut self, ctx: &mut dyn Context<Block>, who: PeerId) {
if let Some(info) = self.peers.remove(&who) {
if let Some((acc_id, _)) = info.collating_for {
let new_primary = self.collators.on_disconnect(acc_id)
......@@ -559,7 +559,12 @@ impl Specialization<Block> for PolkadotProtocol {
}
}
fn on_message(&mut self, ctx: &mut Context<Block>, who: PeerId, message: &mut Option<message::Message<Block>>) {
fn on_message(
&mut self,
ctx: &mut dyn Context<Block>,
who: PeerId,
message: &mut Option<message::Message<Block>>
) {
match message.take() {
Some(generic_message::Message::ChainSpecific(raw)) => {
match Message::decode(&mut raw.as_slice()) {
......@@ -581,7 +586,7 @@ impl Specialization<Block> for PolkadotProtocol {
fn on_abort(&mut self) { }
fn maintain_peers(&mut self, ctx: &mut Context<Block>) {
fn maintain_peers(&mut self, ctx: &mut dyn Context<Block>) {
self.collators.collect_garbage(None);
self.local_collations.collect_garbage(None);
self.dispatch_pending_requests(ctx);
......@@ -600,7 +605,7 @@ impl Specialization<Block> for PolkadotProtocol {
}
}
fn on_block_imported(&mut self, _ctx: &mut Context<Block>, hash: Hash, header: &Header) {
fn on_block_imported(&mut self, _ctx: &mut dyn Context<Block>, hash: Hash, header: &Header) {
self.collators.collect_garbage(Some(&hash));
self.local_collations.collect_garbage(Some(&header.parent_hash));
}
......@@ -608,7 +613,13 @@ impl Specialization<Block> for PolkadotProtocol {
impl PolkadotProtocol {
// we received a collation from a peer
fn on_collation(&mut self, ctx: &mut Context<Block>, from: PeerId, relay_parent: Hash, collation: Collation) {
fn on_collation(
&mut self,
ctx: &mut dyn Context<Block>,
from: PeerId,
relay_parent: Hash,
collation: Collation
) {
let collation_para = collation.receipt.parachain_index;
let collated_acc = collation.receipt.collator.clone();
......@@ -656,7 +667,7 @@ impl PolkadotProtocol {
}
// disconnect a collator by account-id.
fn disconnect_bad_collator(&mut self, ctx: &mut Context<Block>, collator_id: CollatorId) {
fn disconnect_bad_collator(&mut self, ctx: &mut dyn Context<Block>, collator_id: CollatorId) {
if let Some((who, _)) = self.collator_peer(collator_id) {
ctx.report_peer(who, cost::BAD_COLLATION)
}
......@@ -667,7 +678,7 @@ impl PolkadotProtocol {
/// Add a local collation and broadcast it to the necessary peers.
pub fn add_local_collation(
&mut self,
ctx: &mut Context<Block>,
ctx: &mut dyn Context<Block>,
relay_parent: Hash,
targets: HashSet<SessionKey>,
collation: Collation,
......
......@@ -154,13 +154,13 @@ impl NetworkService for TestNetwork {
}
fn with_gossip<F: Send + 'static>(&self, with: F)
where F: FnOnce(&mut GossipService, &mut NetContext<Block>)
where F: FnOnce(&mut dyn GossipService, &mut dyn NetContext<Block>)
{
unimplemented!()
}
fn with_spec<F: Send + 'static>(&self, with: F)
where F: FnOnce(&mut PolkadotProtocol, &mut NetContext<Block>)
where F: FnOnce(&mut PolkadotProtocol, &mut dyn NetContext<Block>)
{
let mut context = TestContext::default();
let res = with(&mut *self.proto.lock(), &mut context);
......
......@@ -78,11 +78,11 @@ impl Executor for TaskExecutor {
/// A gossip network subservice.
pub trait GossipService {
fn send_message(&mut self, ctx: &mut NetContext<Block>, who: &PeerId, message: ConsensusMessage);
fn send_message(&mut self, ctx: &mut dyn NetContext<Block>, who: &PeerId, message: ConsensusMessage);
}
impl GossipService for consensus_gossip::ConsensusGossip<Block> {
fn send_message(&mut self, ctx: &mut NetContext<Block>, who: &PeerId, message: ConsensusMessage) {
fn send_message(&mut self, ctx: &mut dyn NetContext<Block>, who: &PeerId, message: ConsensusMessage) {
consensus_gossip::ConsensusGossip::send_message(self, ctx, who, message)
}
}
......@@ -135,7 +135,7 @@ impl NetworkService for super::NetworkService {
}
fn with_spec<F: Send + 'static>(&self, with: F)
where F: FnOnce(&mut PolkadotProtocol, &mut NetContext<Block>)
where F: FnOnce(&mut PolkadotProtocol, &mut dyn NetContext<Block>)
{
super::NetworkService::with_spec(self, with)
}
......@@ -260,7 +260,7 @@ impl<P, E, N, T> ParachainNetwork for ValidationNetwork<P, E, N, T> where
{
type Error = String;
type TableRouter = Router<P, E, N, T>;
type BuildTableRouter = Box<Future<Item=Self::TableRouter,Error=String> + Send>;
type BuildTableRouter = Box<dyn Future<Item=Self::TableRouter, Error=String> + Send>;
fn communication_for(
&self,
......
......@@ -77,8 +77,11 @@ pub type SessionKey = ed25519::Public;
/// that 32 bits may be multiplied with a balance in 128 bits without worrying about overflow.
pub type Balance = u128;
/// The Ed25519 pub key of an session that belongs to an Aura authority of the chain.
pub type AuraId = ed25519::Public;
/// Header type.
pub type Header = generic::Header<BlockNumber, BlakeTwo256, generic::DigestItem<Hash, SessionKey, SessionSignature>>;
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Block type.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// Block ID.
......
......@@ -24,7 +24,6 @@ consensus_aura = { package = "substrate-consensus-aura-primitives", git = "https
offchain_primitives = { package = "substrate-offchain-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
aura = { package = "srml-aura", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
balances = { package = "srml-balances", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
consensus = { package = "srml-consensus", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
council = { package = "srml-council", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
democracy = { package = "srml-democracy", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
executive = { package = "srml-executive", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
......@@ -38,7 +37,6 @@ system = { package = "srml-system", git = "https://github.com/paritytech/substra
timestamp = { package = "srml-timestamp", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
treasury = { package = "srml-treasury", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
version = { package = "sr-version", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
consensus_authorities = { package = "substrate-consensus-authorities", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
[dev-dependencies]
hex-literal = "0.2.0"
......@@ -63,7 +61,6 @@ std = [
"sr-io/std",
"srml-support/std",
"balances/std",
"consensus/std",
"council/std",
"democracy/std",
"executive/std",
......@@ -81,7 +78,6 @@ std = [
"serde/std",
"log",
"safe-mix/std",
"consensus_authorities/std",
"consensus_aura/std",
"aura/std",
]
......@@ -193,7 +193,7 @@ mod tests {
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use sr_primitives::{
BuildStorage, traits::{BlakeTwo256, IdentityLookup}, testing::{Digest, DigestItem, Header}
BuildStorage, traits::{BlakeTwo256, IdentityLookup}, testing::Header
};
use balances;
use srml_support::{impl_outer_origin, assert_ok, assert_err, assert_noop};
......@@ -213,12 +213,10 @@ mod tests {
type BlockNumber = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type Digest = Digest;
type AccountId = u64;
type Lookup = IdentityLookup<u64>;
type Header = Header;
type Event = ();
type Log = DigestItem;
}
impl balances::Trait for Test {
type Balance = u64;
......
......@@ -37,7 +37,7 @@ decl_module! {
/// curated GRANDPA set.
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
/// Changes the GRANDPA voter set.
fn set_voters(origin, voters: Vec<(T::SessionKey, u64)>) {
fn set_voters(origin, voters: Vec<(grandpa::AuthorityId, u64)>) {
system::ensure_root(origin)?;
grandpa::Module::<T>::schedule_change(voters, T::BlockNumber::zero(), None)?;
}
......
......@@ -27,10 +27,10 @@ mod slot_range;
mod slots;
use rstd::prelude::*;
use substrate_primitives::u32_trait::{_2, _4};
use substrate_primitives::u32_trait::{_1, _2, _3, _4};
use primitives::{
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, SessionKey, Signature,
parachain, SessionSignature,
parachain, AuraId
};
use client::{
block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult},
......@@ -38,13 +38,11 @@ use client::{
};
use sr_primitives::{
ApplyResult, generic, transaction_validity::TransactionValidity, create_runtime_str,
traits::{
BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, Convert, AuthorityIdFor
}
traits::{BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, Convert}, impl_opaque_keys
};
use version::RuntimeVersion;
use grandpa::fg_primitives::{self, ScheduledChange};
use council::{motions as council_motions, voting as council_voting};
use council::motions as council_motions;
#[cfg(feature = "std")]
use council::seats as council_seats;
#[cfg(any(feature = "std", test))]
......@@ -56,7 +54,6 @@ use srml_support::{parameter_types, construct_runtime};
pub use staking::StakerStatus;
#[cfg(any(feature = "std", test))]
pub use sr_primitives::BuildStorage;
pub use consensus::Call as ConsensusCall;
pub use timestamp::Call as TimestampCall;
pub use balances::Call as BalancesCall;
pub use parachains::{Call as ParachainsCall, INHERENT_IDENTIFIER as PARACHAIN_INHERENT_IDENTIFIER};
......@@ -89,16 +86,15 @@ impl system::Trait for Runtime {
type BlockNumber = BlockNumber;
type Hash = Hash;
type Hashing = BlakeTwo256;
type Digest = generic::Digest<Log>;
type AccountId = AccountId;
type Lookup = Indices;
type Header = generic::Header<BlockNumber, BlakeTwo256, Log>;
type Header = generic::Header<BlockNumber, BlakeTwo256>;
type Event = Event;
type Log = Log;
}
impl aura::Trait for Runtime {
type HandleReport = aura::StakingSlasher<Runtime>;
type AuthorityId = AuraId;
}
impl indices::Trait for Runtime {
......@@ -118,24 +114,33 @@ impl balances::Trait for Runtime {
type TransferPayment = ();
}
impl consensus::Trait for Runtime {
type Log = Log;
type SessionKey = SessionKey;
// the aura module handles offline-reports internally
// rather than using an explicit report system.
type InherentOfflineReport = ();
}
impl timestamp::Trait for Runtime {
type Moment = u64;
type OnTimestampSet = Aura;
}
parameter_types! {
pub const Period: BlockNumber = 10 * MINUTES;
pub const Offset: BlockNumber = 0;
}
type SessionHandlers = (Grandpa, Aura);
impl_opaque_keys! {
pub struct SessionKeys(grandpa::AuthorityId, AuraId);
}
// NOTE: `SessionHandler` and `SessionKeys` are co-dependent: One key will be used for each handler.
// The number and order of items in `SessionHandler` *MUST* be the same number and order of keys in
// `SessionKeys`.
// TODO: Introduce some structure to tie these together to make it a bit less of a footgun. This
// should be easy, since OneSessionHandler trait provides the `Key` as an associated type. #2858
impl session::Trait for Runtime {
type ConvertAccountIdToSessionKey = ();
type OnSessionChange = Staking;
type OnSessionEnding = Staking;
type SessionHandler = SessionHandlers;
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
type Event = Event;
type Keys = SessionKeys;
}
/// Converter for currencies to votes.
......@@ -153,14 +158,20 @@ impl Convert<u128, u128> for CurrencyToVoteHandler {
fn convert(x: u128) -> u128 { x * Self::factor() }
}
parameter_types! {
pub const SessionsPerEra: session::SessionIndex = 6;
pub const BondingDuration: staking::EraIndex = 24 * 28;
}
impl staking::Trait for Runtime {
type OnRewardMinted = Treasury;
type CurrencyToVote = CurrencyToVoteHandler;
type Event = Event;
type Currency = balances::Module<Self>;
type Currency = Balances;
type Slash = ();
type Reward = ();
type SessionsPerEra = SessionsPerEra;
type BondingDuration = BondingDuration;
}
const MINUTES: BlockNumber = 6;
......@@ -169,28 +180,36 @@ const BUCKS: Balance = 1_000_000_000_000;
parameter_types! {
pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
pub const EmergencyVotingPeriod: BlockNumber = 3 * 24 * 60 * MINUTES;
pub const MinimumDeposit: Balance = 100 * BUCKS;
pub const EnactmentPeriod: BlockNumber = 30 * 24 * 60 * MINUTES;
pub const CooloffPeriod: BlockNumber = 30 * 24 * 60 * MINUTES;
}
impl democracy::Trait for Runtime {
type Currency = balances::Module<Self>;
type Proposal = Call;
type Event = Event;
type Currency = Balances;
type EnactmentPeriod = EnactmentPeriod;
type LaunchPeriod = LaunchPeriod;
type VotingPeriod = VotingPeriod;
type EmergencyVotingPeriod = EmergencyVotingPeriod;
type MinimumDeposit = MinimumDeposit;
type ExternalOrigin = council_motions::EnsureProportionAtLeast<_1, _2, AccountId>;
type ExternalMajorityOrigin = council_motions::EnsureProportionAtLeast<_2, _3, AccountId>;
type EmergencyOrigin = council_motions::EnsureProportionAtLeast<_1, _1, AccountId>;
type CancellationOrigin = council_motions::EnsureProportionAtLeast<_2, _3, AccountId>;
type VetoOrigin = council_motions::EnsureMember<AccountId>;
type CooloffPeriod = CooloffPeriod;
}
impl council::Trait for Runtime {
type Event = Event;
type BadPresentation = ();
type BadReaper = ();
}
impl council::voting::Trait for Runtime {
type Event = Event;
type BadVoterIndex = ();
type LoserCandidate = ();
type OnMembersChanged = CouncilMotions;
}
impl council::motions::Trait for Runtime {
......@@ -201,16 +220,14 @@ impl council::motions::Trait for Runtime {
impl treasury::Trait for Runtime {
type Currency = balances::Module<Self>;
type ApproveOrigin = council_motions::EnsureMembers<_4>;
type RejectOrigin = council_motions::EnsureMembers<_2>;
type ApproveOrigin = council_motions::EnsureMembers<_4, AccountId>;
type RejectOrigin = council_motions::EnsureMembers<_2, AccountId>;
type Event = Event;
type MintedForSpending = ();
type ProposalRejection = ();
}
impl grandpa::Trait for Runtime {
type SessionKey = SessionKey;
type Log = Log;
type Event = Event;
}
......@@ -240,26 +257,23 @@ impl sudo::Trait for Runtime {
}
construct_runtime!(
pub enum Runtime with Log(InternalLog: DigestItem<Hash, SessionKey, SessionSignature>) where
pub enum Runtime where
Block = Block,
NodeBlock = primitives::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system::{default, Log(ChangesTrieRoot)},
Aura: aura::{Module},
System: system,
Aura: aura::{Module, Config<T>, Inherent(Timestamp)},
Timestamp: timestamp::{Module, Call, Storage, Config<T>, Inherent},
// consensus' Inherent is not provided because it assumes instant-finality blocks.
Consensus: consensus::{Module, Call, Storage, Config<T>, Log(AuthoritiesChange) },
Indices: indices,
Balances: balances,