Skip to content

Commit a65b044

Browse files
authored
Merge pull request #259 from AurevoirXavier/try
Patch #218
2 parents f403705 + de91969 commit a65b044

File tree

6 files changed

+99
-65
lines changed

6 files changed

+99
-65
lines changed

.maintain/ci/script.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ case $TARGET in
1818

1919
# Unit test
2020
"native")
21+
rustup target add wasm32-unknown-unknown
2122
cargo test --release --all --locked "$@"
2223
;;
2324

Cargo.lock

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node/cli/src/chain_spec.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ use hex_literal::hex;
2121
use node_runtime::constants::currency::*;
2222
use node_runtime::Block;
2323
use node_runtime::{
24-
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, GrandpaConfig, ImOnlineConfig,
25-
IndicesConfig, KtonConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig, SudoConfig, SystemConfig,
26-
WASM_BINARY,
24+
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig, GrandpaConfig,
25+
ImOnlineConfig, IndicesConfig, KtonConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig, SudoConfig,
26+
SystemConfig, WASM_BINARY,
2727
};
2828
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
2929
use sc_chain_spec::ChainSpecExtension;
@@ -137,6 +137,7 @@ pub fn darwinia_genesis(
137137
} else {
138138
vec![initial_authorities[0].clone().1, initial_authorities[1].clone().1]
139139
};
140+
let num_endowed_accounts = endowed_accounts.len();
140141

141142
const RING_ENDOWMENT: Balance = 20_000_000 * COIN;
142143
const KTON_ENDOWMENT: Balance = 10 * COIN;
@@ -166,10 +167,10 @@ pub fn darwinia_genesis(
166167
.collect::<Vec<_>>(),
167168
}),
168169
// pallet_democracy: Some(DemocracyConfig::default()),
169-
// pallet_collective_Instance1: Some(CouncilConfig {
170-
// members: endowed_accounts.iter().cloned().collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
171-
// phantom: Default::default(),
172-
// }),
170+
pallet_collective_Instance1: Some(CouncilConfig {
171+
members: endowed_accounts.iter().cloned().collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
172+
phantom: Default::default(),
173+
}),
173174
// pallet_collective_Instance2: Some(TechnicalCommitteeConfig {
174175
// members: endowed_accounts.iter().cloned().collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
175176
// phantom: Default::default(),

bin/node/runtime/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ node-primitives = { default-features = false, path = "../primitives" }
3535
pallet-authority-discovery = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
3636
pallet-authorship = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
3737
pallet-babe = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
38-
#pallet-collective = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
38+
pallet-collective = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
3939
pallet-contracts = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
4040
pallet-contracts-rpc-runtime-api = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
4141
frame-executive = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
@@ -44,7 +44,7 @@ pallet-grandpa = { version = "2.0.0", default-features = false, git = "https://g
4444
pallet-im-online = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
4545
pallet-indices = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
4646
pallet-membership = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
47-
#pallet-nicks = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
47+
pallet-nicks = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
4848
pallet-offences = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
4949
pallet-randomness-collective-flip = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
5050
pallet-session = { version = "2.0.0", default-features = false, features = ["historical"], git = "https://github.com/paritytech/substrate.git", rev = "c2fccb36ffacd118fc3502aa93453580a07dc402" }
@@ -79,7 +79,7 @@ std = [
7979
"pallet-babe/std",
8080
"sp-block-builder/std",
8181
"codec/std",
82-
# "pallet-collective/std",
82+
"pallet-collective/std",
8383
"pallet-contracts-rpc-runtime-api/std",
8484
"pallet-contracts/std",
8585
"frame-executive/std",
@@ -89,7 +89,7 @@ std = [
8989
"pallet-indices/std",
9090
"sp-inherents/std",
9191
"pallet-membership/std",
92-
# "pallet-nicks/std",
92+
"pallet-nicks/std",
9393
"node-primitives/std",
9494
"sp-offchain/std",
9595
"pallet-offences/std",

bin/node/runtime/src/lib.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,12 @@ impl pallet_session::historical::Trait for Runtime {
246246
type FullIdentificationOf = ExposureOf<Runtime>;
247247
}
248248

249-
//type CouncilCollective = pallet_collective::Instance1;
250-
//impl pallet_collective::Trait<CouncilCollective> for Runtime {
251-
// type Origin = Origin;
252-
// type Proposal = Call;
253-
// type Event = Event;
254-
//}
249+
type CouncilCollective = pallet_collective::Instance1;
250+
impl pallet_collective::Trait<CouncilCollective> for Runtime {
251+
type Origin = Origin;
252+
type Proposal = Call;
253+
type Event = Event;
254+
}
255255

256256
//type TechnicalCollective = pallet_collective::Instance2;
257257
//impl pallet_collective::Trait<TechnicalCollective> for Runtime {
@@ -379,15 +379,15 @@ parameter_types! {
379379
pub const MaxLength: usize = 16;
380380
}
381381

382-
//impl pallet_nicks::Trait for Runtime {
383-
// type Event = Event;
384-
// type Currency = Balances;
385-
// type ReservationFee = ReservationFee;
386-
// type Slashed = Treasury;
387-
// type ForceOrigin = pallet_collective::EnsureMember<AccountId, CouncilCollective>;
388-
// type MinLength = MinLength;
389-
// type MaxLength = MaxLength;
390-
//}
382+
impl pallet_nicks::Trait for Runtime {
383+
type Event = Event;
384+
type Currency = Balances;
385+
type ReservationFee = ReservationFee;
386+
type Slashed = MockTreasury;
387+
type ForceOrigin = pallet_collective::EnsureMember<AccountId, CouncilCollective>;
388+
type MinLength = MinLength;
389+
type MaxLength = MaxLength;
390+
}
391391

392392
impl frame_system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtime {
393393
type Public = <Signature as traits::Verify>::Signer;
@@ -465,8 +465,8 @@ impl pallet_staking::Trait for Runtime {
465465
type BondingDurationInEra = BondingDurationInEra;
466466
type BondingDurationInBlockNumber = BondingDurationInBlockNumber;
467467
type SlashDeferDuration = SlashDeferDuration;
468-
// /// A super-majority of the council can cancel the slash.
469-
// type SlashCancelOrigin = pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>;
468+
/// A super-majority of the council can cancel the slash.
469+
type SlashCancelOrigin = pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>;
470470
type SessionInterface = Self;
471471
type RingCurrency = Balances;
472472
type RingRewardRemainder = ();
@@ -494,7 +494,7 @@ construct_runtime!(
494494
Indices: pallet_indices,
495495
TransactionPayment: pallet_transaction_payment::{Module, Storage},
496496
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
497-
// Council: pallet_collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
497+
Council: pallet_collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
498498
// TechnicalCommittee: pallet_collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
499499
// TechnicalMembership: pallet_membership::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>},
500500
FinalityTracker: pallet_finality_tracker::{Module, Call, Inherent},
@@ -506,7 +506,7 @@ construct_runtime!(
506506
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
507507
Offences: pallet_offences::{Module, Call, Storage, Event},
508508
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
509-
// Nicks: pallet_nicks::{Module, Call, Storage, Event<T>},
509+
Nicks: pallet_nicks::{Module, Call, Storage, Event<T>},
510510

511511
Balances: pallet_ring::{default, Error},
512512
Kton: pallet_kton::{default, Error},

frame/staking/src/lib.rs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,8 @@ pub trait Trait: frame_system::Trait {
668668
/// applied immediately, without opportunity for intervention.
669669
type SlashDeferDuration: Get<EraIndex>;
670670

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

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

1504-
// /// Cancel enactment of a deferred slash. Can be called by either the root origin or
1505-
// /// the `T::SlashCancelOrigin`.
1506-
// /// passing the era and indices of the slashes for that era to kill.
1507-
// ///
1508-
// /// # <weight>
1509-
// /// - One storage write.
1510-
// /// # </weight>
1511-
// #[weight = SimpleDispatchInfo::FreeOperational]
1512-
// fn cancel_deferred_slash(origin, era: EraIndex, slash_indices: Vec<u32>) {
1513-
// T::SlashCancelOrigin::try_origin(origin)
1514-
// .map(|_| ())
1515-
// .or_else(ensure_root)?;
1516-
//
1517-
// let mut slash_indices = slash_indices;
1518-
// slash_indices.sort_unstable();
1519-
// let mut unapplied = <Self as Store>::UnappliedSlashes::get(&era);
1520-
//
1521-
// for (removed, index) in slash_indices.into_iter().enumerate() {
1522-
// let index = index as usize;
1523-
//
1524-
// // if `index` is not duplicate, `removed` must be <= index.
1525-
// ensure!(removed <= index, Error::<T>::DuplicateIndex);
1526-
//
1527-
// // all prior removals were from before this index, since the
1528-
// // list is sorted.
1529-
// let index = index - removed;
1530-
// ensure!(index < unapplied.len(), Error::<T>::InvalidSlashIndex);
1531-
//
1532-
// unapplied.remove(index);
1533-
// }
1534-
//
1535-
// <Self as Store>::UnappliedSlashes::insert(&era, &unapplied);
1536-
// }
1504+
/// Cancel enactment of a deferred slash. Can be called by either the root origin or
1505+
/// the `T::SlashCancelOrigin`.
1506+
/// passing the era and indices of the slashes for that era to kill.
1507+
///
1508+
/// # <weight>
1509+
/// - One storage write.
1510+
/// # </weight>
1511+
#[weight = SimpleDispatchInfo::FreeOperational]
1512+
fn cancel_deferred_slash(origin, era: EraIndex, slash_indices: Vec<u32>) {
1513+
T::SlashCancelOrigin::try_origin(origin)
1514+
.map(|_| ())
1515+
.or_else(ensure_root)?;
1516+
1517+
let mut slash_indices = slash_indices;
1518+
slash_indices.sort_unstable();
1519+
let mut unapplied = <Self as Store>::UnappliedSlashes::get(&era);
1520+
1521+
for (removed, index) in slash_indices.into_iter().enumerate() {
1522+
let index = index as usize;
1523+
1524+
// if `index` is not duplicate, `removed` must be <= index.
1525+
ensure!(removed <= index, Error::<T>::DuplicateIndex);
1526+
1527+
// all prior removals were from before this index, since the
1528+
// list is sorted.
1529+
let index = index - removed;
1530+
ensure!(index < unapplied.len(), Error::<T>::InvalidSlashIndex);
1531+
1532+
unapplied.remove(index);
1533+
}
1534+
1535+
<Self as Store>::UnappliedSlashes::insert(&era, &unapplied);
1536+
}
15371537
}
15381538
}
15391539

0 commit comments

Comments
 (0)