Sensible scheduling for referenda (#2753)

* Nonlinear locking and cleanups

* Bump runtime version

* Minor cleanup

* Fix tests

* Fix council tests

* Fix flaw in turnout counting

* Initial work on referendum schedules

* Refactor council-democracy interface.

* Fix build

* Update srml/democracy/src/lib.rs

Co-Authored-By: Luke Schoen <ltfschoen@users.noreply.github.com>

* Update srml/democracy/src/lib.rs

Co-Authored-By: Luke Schoen <ltfschoen@users.noreply.github.com>

* Tests compile again

* Tests!

* Update todo

* Fix build

* Ensure votes arer not double-counted on member-transitions

* Extra logic for normal council changes

* Typo

* A few grumbles addressed.
This commit is contained in:
Gavin Wood
2019-06-05 12:36:28 +02:00
committed by GitHub
parent 89b312fe9c
commit 22a00a3353
16 changed files with 1186 additions and 747 deletions
+2 -1
View File
@@ -246,7 +246,8 @@ mod tests {
mod system {
pub trait Trait {
type Origin: Into<Option<RawOrigin<Self::AccountId>>> + From<RawOrigin<Self::AccountId>>;
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>>
+ From<RawOrigin<Self::AccountId>>;
type AccountId;
type BlockNumber;
}
+14 -8
View File
@@ -112,12 +112,12 @@ macro_rules! impl_outer_origin {
$name::system(x)
}
}
impl Into<Option<$system::Origin<$runtime>>> for $name {
fn into(self) -> Option<$system::Origin<$runtime>> {
impl Into<$crate::rstd::result::Result<$system::Origin<$runtime>, $name>> for $name {
fn into(self) -> $crate::rstd::result::Result<$system::Origin<$runtime>, Self> {
if let $name::system(l) = self {
Some(l)
Ok(l)
} else {
None
Err(self)
}
}
}
@@ -132,12 +132,18 @@ macro_rules! impl_outer_origin {
$name::$module(x)
}
}
impl Into<Option<$module::Origin $( <$generic_param $(, $generic_instance )? > )*>> for $name {
fn into(self) -> Option<$module::Origin $( <$generic_param $(, $generic_instance )? > )*> {
impl Into<$crate::rstd::result::Result<
$module::Origin $( <$generic_param $(, $generic_instance )? > )*,
$name
>> for $name {
fn into(self) -> $crate::rstd::result::Result<
$module::Origin $( <$generic_param $(, $generic_instance )? > )*,
Self
> {
if let $name::$module(l) = self {
Some(l)
Ok(l)
} else {
None
Err(self)
}
}
}
+15 -1
View File
@@ -26,12 +26,26 @@ use crate::runtime_primitives::traits::{
use super::for_each_tuple;
/// New trait for querying a single fixed value from a type.
/// A trait for querying a single fixed value from a type.
pub trait Get<T> {
/// Return a constant value.
fn get() -> T;
}
/// A trait for querying whether a type can be said to statically "contain" a value. Similar
/// in nature to `Get`, except it is designed to be lazy rather than active (you can't ask it to
/// enumerate all values that it contains) and work for multiple values rather than just one.
pub trait Contains<T> {
/// Return `true` if this "contains" the given value `t`.
fn contains(t: &T) -> bool;
}
impl<V: PartialEq, T: Get<V>> Contains<V> for T {
fn contains(t: &V) -> bool {
&Self::get() == t
}
}
/// The account with the given id was killed.
pub trait OnFreeBalanceZero<AccountId> {
/// The account was the given id was killed.
@@ -39,7 +39,8 @@ mod system {
use super::*;
pub trait Trait: 'static + Eq + Clone {
type Origin: Into<Option<RawOrigin<Self::AccountId>>> + From<RawOrigin<Self::AccountId>>;
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>>
+ From<RawOrigin<Self::AccountId>>;
type BlockNumber;
type Digest: Digest<Hash = H256>;
type Hash;
@@ -100,12 +101,9 @@ mod system {
}
pub fn ensure_root<OuterOrigin, AccountId>(o: OuterOrigin) -> Result<(), &'static str>
where OuterOrigin: Into<Option<RawOrigin<AccountId>>>
where OuterOrigin: Into<Result<RawOrigin<AccountId>, OuterOrigin>>
{
match o.into() {
Some(RawOrigin::Root) => Ok(()),
_ => Err("bad origin: expected to be a root origin"),
}
o.into().map(|_| ()).map_err(|_| "bad origin: expected to be a root origin")
}
}