Skip to content

Commit

Permalink
Merge pull request #259 from AurevoirXavier/try
Browse files Browse the repository at this point in the history
Patch #218
  • Loading branch information
hackfisher authored Feb 12, 2020
2 parents f403705 + de91969 commit a65b044
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 65 deletions.
1 change: 1 addition & 0 deletions .maintain/ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ case $TARGET in

# Unit test
"native")
rustup target add wasm32-unknown-unknown
cargo test --release --all --locked "$@"
;;

Expand Down
32 changes: 32 additions & 0 deletions Cargo.lock

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

15 changes: 8 additions & 7 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ use hex_literal::hex;
use node_runtime::constants::currency::*;
use node_runtime::Block;
use node_runtime::{
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, GrandpaConfig, ImOnlineConfig,
IndicesConfig, KtonConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig, SudoConfig, SystemConfig,
WASM_BINARY,
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig, GrandpaConfig,
ImOnlineConfig, IndicesConfig, KtonConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig, SudoConfig,
SystemConfig, WASM_BINARY,
};
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use sc_chain_spec::ChainSpecExtension;
Expand Down Expand Up @@ -137,6 +137,7 @@ pub fn darwinia_genesis(
} else {
vec![initial_authorities[0].clone().1, initial_authorities[1].clone().1]
};
let num_endowed_accounts = endowed_accounts.len();

const RING_ENDOWMENT: Balance = 20_000_000 * COIN;
const KTON_ENDOWMENT: Balance = 10 * COIN;
Expand Down Expand Up @@ -166,10 +167,10 @@ pub fn darwinia_genesis(
.collect::<Vec<_>>(),
}),
// pallet_democracy: Some(DemocracyConfig::default()),
// pallet_collective_Instance1: Some(CouncilConfig {
// members: endowed_accounts.iter().cloned().collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
// phantom: Default::default(),
// }),
pallet_collective_Instance1: Some(CouncilConfig {
members: endowed_accounts.iter().cloned().collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
phantom: Default::default(),
}),
// pallet_collective_Instance2: Some(TechnicalCommitteeConfig {
// members: endowed_accounts.iter().cloned().collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
// phantom: Default::default(),
Expand Down
8 changes: 4 additions & 4 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ node-primitives = { default-features = false, path = "../primitives" }
pallet-authority-discovery = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
pallet-authorship = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
pallet-babe = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
#pallet-collective = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
pallet-collective = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
pallet-contracts = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
pallet-contracts-rpc-runtime-api = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
frame-executive = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
Expand All @@ -44,7 +44,7 @@ pallet-grandpa = { version = "2.0.0", default-features = false, git = "https://g
pallet-im-online = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
pallet-indices = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
pallet-membership = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
#pallet-nicks = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
pallet-nicks = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
pallet-offences = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
pallet-randomness-collective-flip = { version = "2.0.0", default-features = false, git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
pallet-session = { version = "2.0.0", default-features = false, features = ["historical"], git = "/~https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
Expand Down Expand Up @@ -79,7 +79,7 @@ std = [
"pallet-babe/std",
"sp-block-builder/std",
"codec/std",
# "pallet-collective/std",
"pallet-collective/std",
"pallet-contracts-rpc-runtime-api/std",
"pallet-contracts/std",
"frame-executive/std",
Expand All @@ -89,7 +89,7 @@ std = [
"pallet-indices/std",
"sp-inherents/std",
"pallet-membership/std",
# "pallet-nicks/std",
"pallet-nicks/std",
"node-primitives/std",
"sp-offchain/std",
"pallet-offences/std",
Expand Down
38 changes: 19 additions & 19 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ impl pallet_session::historical::Trait for Runtime {
type FullIdentificationOf = ExposureOf<Runtime>;
}

//type CouncilCollective = pallet_collective::Instance1;
//impl pallet_collective::Trait<CouncilCollective> for Runtime {
// type Origin = Origin;
// type Proposal = Call;
// type Event = Event;
//}
type CouncilCollective = pallet_collective::Instance1;
impl pallet_collective::Trait<CouncilCollective> for Runtime {
type Origin = Origin;
type Proposal = Call;
type Event = Event;
}

//type TechnicalCollective = pallet_collective::Instance2;
//impl pallet_collective::Trait<TechnicalCollective> for Runtime {
Expand Down Expand Up @@ -379,15 +379,15 @@ parameter_types! {
pub const MaxLength: usize = 16;
}

//impl pallet_nicks::Trait for Runtime {
// type Event = Event;
// type Currency = Balances;
// type ReservationFee = ReservationFee;
// type Slashed = Treasury;
// type ForceOrigin = pallet_collective::EnsureMember<AccountId, CouncilCollective>;
// type MinLength = MinLength;
// type MaxLength = MaxLength;
//}
impl pallet_nicks::Trait for Runtime {
type Event = Event;
type Currency = Balances;
type ReservationFee = ReservationFee;
type Slashed = MockTreasury;
type ForceOrigin = pallet_collective::EnsureMember<AccountId, CouncilCollective>;
type MinLength = MinLength;
type MaxLength = MaxLength;
}

impl frame_system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtime {
type Public = <Signature as traits::Verify>::Signer;
Expand Down Expand Up @@ -465,8 +465,8 @@ impl pallet_staking::Trait for Runtime {
type BondingDurationInEra = BondingDurationInEra;
type BondingDurationInBlockNumber = BondingDurationInBlockNumber;
type SlashDeferDuration = SlashDeferDuration;
// /// A super-majority of the council can cancel the slash.
// type SlashCancelOrigin = pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>;
/// A super-majority of the council can cancel the slash.
type SlashCancelOrigin = pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>;
type SessionInterface = Self;
type RingCurrency = Balances;
type RingRewardRemainder = ();
Expand Down Expand Up @@ -494,7 +494,7 @@ construct_runtime!(
Indices: pallet_indices,
TransactionPayment: pallet_transaction_payment::{Module, Storage},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
// Council: pallet_collective::<Instance1>::{Module, Call, Storage, Origin<T>, 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>},
// TechnicalMembership: pallet_membership::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>},
FinalityTracker: pallet_finality_tracker::{Module, Call, Inherent},
Expand All @@ -506,7 +506,7 @@ construct_runtime!(
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
Offences: pallet_offences::{Module, Call, Storage, Event},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
// Nicks: pallet_nicks::{Module, Call, Storage, Event<T>},
Nicks: pallet_nicks::{Module, Call, Storage, Event<T>},

Balances: pallet_ring::{default, Error},
Kton: pallet_kton::{default, Error},
Expand Down
70 changes: 35 additions & 35 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,8 @@ pub trait Trait: frame_system::Trait {
/// applied immediately, without opportunity for intervention.
type SlashDeferDuration: Get<EraIndex>;

// /// The origin which can cancel a deferred slash. Root can always do this.
// type SlashCancelOrigin: EnsureOrigin<Self::Origin>;
/// The origin which can cancel a deferred slash. Root can always do this.
type SlashCancelOrigin: EnsureOrigin<Self::Origin>;

/// Interface for interacting with a session module.
type SessionInterface: self::SessionInterface<Self::AccountId>;
Expand Down Expand Up @@ -1501,39 +1501,39 @@ decl_module! {
ForceEra::put(Forcing::ForceAlways);
}

// /// Cancel enactment of a deferred slash. Can be called by either the root origin or
// /// the `T::SlashCancelOrigin`.
// /// passing the era and indices of the slashes for that era to kill.
// ///
// /// # <weight>
// /// - One storage write.
// /// # </weight>
// #[weight = SimpleDispatchInfo::FreeOperational]
// fn cancel_deferred_slash(origin, era: EraIndex, slash_indices: Vec<u32>) {
// T::SlashCancelOrigin::try_origin(origin)
// .map(|_| ())
// .or_else(ensure_root)?;
//
// let mut slash_indices = slash_indices;
// slash_indices.sort_unstable();
// let mut unapplied = <Self as Store>::UnappliedSlashes::get(&era);
//
// for (removed, index) in slash_indices.into_iter().enumerate() {
// let index = index as usize;
//
// // if `index` is not duplicate, `removed` must be <= index.
// ensure!(removed <= index, Error::<T>::DuplicateIndex);
//
// // all prior removals were from before this index, since the
// // list is sorted.
// let index = index - removed;
// ensure!(index < unapplied.len(), Error::<T>::InvalidSlashIndex);
//
// unapplied.remove(index);
// }
//
// <Self as Store>::UnappliedSlashes::insert(&era, &unapplied);
// }
/// Cancel enactment of a deferred slash. Can be called by either the root origin or
/// the `T::SlashCancelOrigin`.
/// passing the era and indices of the slashes for that era to kill.
///
/// # <weight>
/// - One storage write.
/// # </weight>
#[weight = SimpleDispatchInfo::FreeOperational]
fn cancel_deferred_slash(origin, era: EraIndex, slash_indices: Vec<u32>) {
T::SlashCancelOrigin::try_origin(origin)
.map(|_| ())
.or_else(ensure_root)?;

let mut slash_indices = slash_indices;
slash_indices.sort_unstable();
let mut unapplied = <Self as Store>::UnappliedSlashes::get(&era);

for (removed, index) in slash_indices.into_iter().enumerate() {
let index = index as usize;

// if `index` is not duplicate, `removed` must be <= index.
ensure!(removed <= index, Error::<T>::DuplicateIndex);

// all prior removals were from before this index, since the
// list is sorted.
let index = index - removed;
ensure!(index < unapplied.len(), Error::<T>::InvalidSlashIndex);

unapplied.remove(index);
}

<Self as Store>::UnappliedSlashes::insert(&era, &unapplied);
}
}
}

Expand Down

0 comments on commit a65b044

Please sign in to comment.