Browse Source

tracking polkadot-master branch of substrate

Mokhtar Naamani 5 years ago
parent
commit
502e883bdc

+ 58 - 31
Cargo.toml

@@ -38,33 +38,36 @@ std = [
     'safe-mix/std',
     'offchain-primitives/std',
     'substrate-session/std',
+    'transaction-payment/std',
+    'node-primitives/std',
+    'randomness-collective-flip/std',
+    'system-rpc-runtime-api/std',
     'forum/std',
-    'node-primitives/std'
 ]
 
 [dependencies.babe]
 default-features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-babe'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.babe-primitives]
 default-features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'substrate-consensus-babe-primitives'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.balances]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-balances'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.substrate-client]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'substrate-client'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.codec]
 default-features = false
@@ -76,43 +79,43 @@ version = '1.0.0'
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-executive'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.grandpa]
 default-features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-grandpa'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.indices]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-indices'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.offchain-primitives]
 default-features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'substrate-offchain-primitives'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.primitives]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'substrate-primitives'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.rstd]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'sr-std'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.runtime-io]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'sr-io'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.safe-mix]
 default-features = false
@@ -121,108 +124,132 @@ version = '1.0'
 [dependencies.serde]
 features = ['derive']
 optional = true
-version = '1.0'
+version = '1.0.101'
 
 [dependencies.runtime-primitives]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'sr-primitives'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.substrate-session]
 default-features = false
 git = 'https://github.com/paritytech/substrate.git'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.sudo]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-sudo'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.srml-support]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-support'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.system]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-system'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.timestamp]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-timestamp'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.version]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'sr-version'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.authority-discovery-primitives]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'substrate-authority-discovery-primitives'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.authority-discovery]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-authority-discovery'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.authorship]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-authorship'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.finality-tracker]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-finality-tracker'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.im-online]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-im-online'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.session]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-session'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.offences]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-offences'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.sr-staking-primitives]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'sr-staking-primitives'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.staking]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'srml-staking'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
 
 [dependencies.node-primitives]
 default_features = false
 git = 'https://github.com/paritytech/substrate.git'
 package = 'node-primitives'
-rev = 'a2a0eb5398d6223e531455b4c155ef053a4a3a2b'
+rev = 'polkadot-master'
+
+[dependencies.transaction-payment]
+package = "srml-transaction-payment"
+git = 'https://github.com/paritytech/substrate.git'
+default_features = false
+rev = 'polkadot-master'
+
+[dependencies.randomness-collective-flip]
+package = "srml-randomness-collective-flip"
+git = 'https://github.com/paritytech/substrate.git'
+default_features = false
+rev = 'polkadot-master'
+
+[dependencies.system-rpc-runtime-api]
+package = "srml-system-rpc-runtime-api"
+git = 'https://github.com/paritytech/substrate.git'
+default_features = false
+rev = 'polkadot-master'
+
+[dependencies.staking-reward-curve]
+package = 'srml-staking-reward-curve'
+git = 'https://github.com/paritytech/substrate.git'
+default_features = false
+rev = 'polkadot-master'
 
 [build-dependencies.wasm-builder-runner]
 package = 'substrate-wasm-builder-runner'
@@ -232,6 +259,6 @@ version = '1.0.2'
 default_features = false
 git = 'https://github.com/mnaamani/substrate-forum-module'
 package = 'substrate-forum-module'
-branch = 'substrate-v2'
+branch = 'use-polkadot-master-substrate-version'
 # Before releasing Rome - finalize and tag release new forum and update this
 # tag = 'v1.0.0'

+ 4 - 5
src/governance/council.rs

@@ -64,7 +64,7 @@ impl<T: Trait> Module<T> {
 
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        fn deposit_event<T>() = default;
+        fn deposit_event() = default;
 
         fn on_finalize(now: T::BlockNumber) {
             if now == Self::term_ends_at() {
@@ -124,7 +124,6 @@ decl_module! {
 #[cfg(test)]
 mod tests {
     use crate::governance::mock::*;
-    use runtime_io::with_externalities;
     use srml_support::*;
 
     fn add_council_member_as_root(account: <Test as system::Trait>::AccountId) -> dispatch::Result {
@@ -133,7 +132,7 @@ mod tests {
 
     #[test]
     fn add_council_member_test() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             assert!(!Council::is_councilor(&1));
 
             assert_ok!(add_council_member_as_root(1));
@@ -147,7 +146,7 @@ mod tests {
 
     #[test]
     fn remove_council_member_test() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             assert_ok!(add_council_member_as_root(1));
             assert_ok!(add_council_member_as_root(2));
             assert_ok!(add_council_member_as_root(3));
@@ -165,7 +164,7 @@ mod tests {
 
     #[test]
     fn set_council_test() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             assert_ok!(Council::set_council(
                 system::RawOrigin::Root.into(),
                 vec![4, 5, 6]

+ 27 - 28
src/governance/election.rs

@@ -717,7 +717,7 @@ impl<T: Trait> Module<T> {
 
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        fn deposit_event<T>() = default;
+        fn deposit_event() = default;
 
         // No origin so this is a priviledged call
         fn on_finalize(now: T::BlockNumber) {
@@ -900,12 +900,11 @@ mod tests {
     use super::*;
     use crate::governance::mock::*;
     use codec::Encode;
-    use runtime_io::with_externalities;
     use srml_support::*;
 
     #[test]
     fn election_starts_when_council_term_ends() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             System::set_block_number(1);
 
             assert!(Council::is_term_ended());
@@ -953,7 +952,7 @@ mod tests {
 
     #[test]
     fn should_not_start_new_election_if_already_started() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             assert_ok!(Election::start_election(vec![]));
             assert_err!(
                 Election::start_election(vec![]),
@@ -980,7 +979,7 @@ mod tests {
 
     #[test]
     fn start_election_should_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             System::set_block_number(1);
             <AnnouncingPeriod<Test>>::put(20);
             let prev_round = Election::round();
@@ -997,7 +996,7 @@ mod tests {
 
     #[test]
     fn init_transferable_stake_should_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let existing_council = vec![
                 Seat {
                     member: 1,
@@ -1075,7 +1074,7 @@ mod tests {
 
     #[test]
     fn try_add_applicant_should_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             assert!(Election::applicants().len() == 0);
 
             let applicant = 20 as u64;
@@ -1097,7 +1096,7 @@ mod tests {
 
     #[test]
     fn increasing_applicant_stake_should_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let applicant = 20 as u64;
             let starting_stake = 100 as u64;
 
@@ -1124,7 +1123,7 @@ mod tests {
 
     #[test]
     fn using_transferable_seat_stake_should_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let applicant = 20 as u64;
             let _ = Balances::deposit_creating(&applicant, 5000);
 
@@ -1168,7 +1167,7 @@ mod tests {
 
     #[test]
     fn moving_to_voting_without_enough_applicants_should_not_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             System::set_block_number(1);
             <AnnouncingPeriod<Test>>::put(20);
             CouncilSize::put(10);
@@ -1209,7 +1208,7 @@ mod tests {
 
     #[test]
     fn top_applicants_move_to_voting_stage() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             <Applicants<Test>>::put(vec![10, 20, 30, 40]);
             let mut applicants = Election::applicants();
 
@@ -1247,7 +1246,7 @@ mod tests {
 
     #[test]
     fn refunding_applicant_stakes_should_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&1, 1000);
             let _ = Balances::deposit_creating(&2, 7000);
             let _ = Balances::reserve(&2, 5000);
@@ -1325,7 +1324,7 @@ mod tests {
 
     #[test]
     fn voting_should_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&20, 1000);
             let payload = vec![10u8];
             let commitment = <Test as system::Trait>::Hashing::hash(&payload[..]);
@@ -1352,7 +1351,7 @@ mod tests {
 
     #[test]
     fn votes_can_be_covered_by_transferable_stake() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&20, 1000);
 
             save_transferable_stake(
@@ -1384,7 +1383,7 @@ mod tests {
 
     #[test]
     fn voting_without_enough_balance_should_not_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&20, 100);
 
             save_transferable_stake(
@@ -1407,7 +1406,7 @@ mod tests {
 
     #[test]
     fn voting_with_existing_commitment_should_not_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&20, 1000);
 
             save_transferable_stake(
@@ -1450,7 +1449,7 @@ mod tests {
 
     #[test]
     fn revealing_vote_works() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let applicant = 20 as u64;
             let salt = vec![128u8];
             let commitment = make_commitment_for_applicant(applicant, &mut salt.clone());
@@ -1487,7 +1486,7 @@ mod tests {
 
     #[test]
     fn revealing_with_bad_salt_should_not_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let applicant = 20 as u64;
             let salt = vec![128u8];
             let commitment = make_commitment_for_applicant(applicant, &mut salt.clone());
@@ -1521,7 +1520,7 @@ mod tests {
 
     #[test]
     fn revealing_non_matching_commitment_should_not_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let applicant = 20 as u64;
             let salt = vec![128u8];
             let commitment = make_commitment_for_applicant(100, &mut salt.clone());
@@ -1541,7 +1540,7 @@ mod tests {
 
     #[test]
     fn revealing_for_non_applicant_should_not_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let applicant = 20 as u64;
             let salt = vec![128u8];
             let commitment = make_commitment_for_applicant(applicant, &mut salt.clone());
@@ -1567,7 +1566,7 @@ mod tests {
 
     #[test]
     fn revealing_by_non_committer_should_not_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let applicant = 20 as u64;
             let salt = vec![128u8];
             let commitment = make_commitment_for_applicant(applicant, &mut salt.clone());
@@ -1622,7 +1621,7 @@ mod tests {
 
     #[test]
     fn vote_tallying_should_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let votes = mock_votes(vec![
                 //  (voter, stake[new], stake[transferred], applicant)
                 (10, 100, 0, 100),
@@ -1686,7 +1685,7 @@ mod tests {
 
     #[test]
     fn filter_top_staked_applicants_should_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             // filter_top_staked depends on order of applicants
             <Applicants<Test>>::put(vec![100, 200, 300]);
 
@@ -1730,7 +1729,7 @@ mod tests {
 
     #[test]
     fn drop_unelected_applicants_should_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             <Applicants<Test>>::put(vec![100, 200, 300]);
 
             let _ = Balances::deposit_creating(&100, 2000);
@@ -1785,7 +1784,7 @@ mod tests {
 
     #[test]
     fn refunding_voting_stakes_should_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             // voters' balances
             let _ = Balances::deposit_creating(&10, 6000);
             let _ = Balances::reserve(&10, 5000);
@@ -1864,7 +1863,7 @@ mod tests {
 
     #[test]
     fn unlock_transferable_stakes_should_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             <ExistingStakeHolders<Test>>::put(vec![10, 20, 30]);
 
             let _ = Balances::deposit_creating(&10, 6000);
@@ -1907,7 +1906,7 @@ mod tests {
 
     #[test]
     fn council_elected_hook_should_work() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             let mut new_council: BTreeMap<u64, Seat<u64, u64>> = BTreeMap::new();
             new_council.insert(
                 200 as u64,
@@ -1940,7 +1939,7 @@ mod tests {
 
     #[test]
     fn simulation() {
-        with_externalities(&mut initial_test_ext(), || {
+        initial_test_ext().execute_with(|| {
             assert_eq!(Council::active_council().len(), 0);
             assert!(Election::stage().is_none());
 

+ 1 - 6
src/governance/mock.rs

@@ -57,7 +57,6 @@ impl system::Trait for Test {
     type AccountId = u64;
     type Lookup = IdentityLookup<Self::AccountId>;
     type Header = Header;
-    type WeightMultiplierUpdate = ();
     type Event = ();
     type BlockHashCount = BlockHashCount;
     type MaximumBlockWeight = MaximumBlockWeight;
@@ -102,15 +101,11 @@ impl balances::Trait for Test {
     /// The ubiquitous event type.
     type Event = ();
 
-    type TransactionPayment = ();
     type DustRemoval = ();
     type TransferPayment = ();
     type ExistentialDeposit = ExistentialDeposit;
     type TransferFee = TransferFee;
     type CreationFee = CreationFee;
-    type TransactionBaseFee = TransactionBaseFee;
-    type TransactionByteFee = TransactionByteFee;
-    type WeightToFee = ();
 }
 
 impl GovernanceCurrency for Test {
@@ -121,7 +116,7 @@ impl GovernanceCurrency for Test {
 
 // This function basically just builds a genesis storage key/value store according to
 // our desired mockup.
-pub fn initial_test_ext() -> runtime_io::TestExternalities<Blake2Hasher> {
+pub fn initial_test_ext() -> runtime_io::TestExternalities {
     let t = system::GenesisConfig::default()
         .build_storage::<Test>()
         .unwrap();

+ 29 - 33
src/governance/proposals.rs

@@ -1,7 +1,9 @@
 use codec::{Decode, Encode};
 use rstd::prelude::*;
-use runtime_io::print;
-use runtime_primitives::traits::{Hash, SaturatedConversion, Zero};
+use runtime_primitives::{
+    print,
+    traits::{Hash, SaturatedConversion, Zero},
+};
 #[cfg(feature = "std")]
 use serde::{Deserialize, Serialize};
 use srml_support::traits::{Currency, Get, ReservableCurrency};
@@ -217,7 +219,7 @@ decl_storage! {
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
 
-        fn deposit_event<T>() = default;
+        fn deposit_event() = default;
 
         /// Use next code to create a proposal from Substrate UI's web console:
         /// ```js
@@ -556,7 +558,6 @@ mod tests {
 
     use super::*;
     use primitives::{Blake2Hasher, H256};
-    use runtime_io::with_externalities;
     // 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 requried.
     use runtime_primitives::{
@@ -592,7 +593,6 @@ mod tests {
         type AccountId = u64;
         type Lookup = IdentityLookup<Self::AccountId>;
         type Header = Header;
-        type WeightMultiplierUpdate = ();
         type Event = ();
         type BlockHashCount = BlockHashCount;
         type MaximumBlockWeight = MaximumBlockWeight;
@@ -625,15 +625,11 @@ mod tests {
         /// The ubiquitous event type.
         type Event = ();
 
-        type TransactionPayment = ();
         type DustRemoval = ();
         type TransferPayment = ();
         type ExistentialDeposit = ExistentialDeposit;
         type TransferFee = TransferFee;
         type CreationFee = CreationFee;
-        type TransactionBaseFee = TransactionBaseFee;
-        type TransactionByteFee = TransactionByteFee;
-        type WeightToFee = ();
     }
 
     impl council::Trait for Test {
@@ -696,7 +692,7 @@ mod tests {
 
     // This function basically just builds a genesis storage key/value store according to
     // our desired mockup.
-    fn new_test_ext() -> runtime_io::TestExternalities<Blake2Hasher> {
+    fn new_test_ext() -> runtime_io::TestExternalities {
         let mut t = system::GenesisConfig::default()
             .build_storage::<Test>()
             .unwrap();
@@ -799,7 +795,7 @@ mod tests {
 
     #[test]
     fn check_default_values() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             assert_eq!(Proposals::approval_quorum(), DEFAULT_APPROVAL_QUORUM);
             assert_eq!(
                 Proposals::min_stake(),
@@ -826,7 +822,7 @@ mod tests {
 
     #[test]
     fn member_create_proposal() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -859,7 +855,7 @@ mod tests {
 
     #[test]
     fn not_member_cannot_create_proposal() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             // In this test a proposer has an empty balance
             // thus he is not considered as a member.
             assert_eq!(
@@ -871,7 +867,7 @@ mod tests {
 
     #[test]
     fn cannot_create_proposal_with_small_stake() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_eq!(
@@ -887,7 +883,7 @@ mod tests {
 
     #[test]
     fn cannot_create_proposal_when_stake_is_greater_than_balance() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_eq!(
@@ -903,7 +899,7 @@ mod tests {
 
     #[test]
     fn cannot_create_proposal_with_empty_values() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             // Empty name:
@@ -928,7 +924,7 @@ mod tests {
 
     #[test]
     fn cannot_create_proposal_with_too_long_values() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             // Too long name:
@@ -968,7 +964,7 @@ mod tests {
 
     #[test]
     fn owner_cancel_proposal() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -989,7 +985,7 @@ mod tests {
 
     #[test]
     fn owner_cannot_cancel_proposal_if_its_finalized() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -1016,7 +1012,7 @@ mod tests {
 
     #[test]
     fn not_owner_cannot_cancel_proposal() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
             let _ = Balances::deposit_creating(&PROPOSER2, initial_balance());
             assert_ok!(_create_default_proposal());
@@ -1032,7 +1028,7 @@ mod tests {
 
     #[test]
     fn councilor_vote_on_proposal() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -1056,7 +1052,7 @@ mod tests {
 
     #[test]
     fn councilor_cannot_vote_on_proposal_twice() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -1075,7 +1071,7 @@ mod tests {
 
     #[test]
     fn autovote_with_approve_when_councilor_creates_proposal() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&COUNCILOR1, initial_balance());
 
             assert_ok!(_create_proposal(Some(COUNCILOR1), None, None, None, None));
@@ -1092,7 +1088,7 @@ mod tests {
 
     #[test]
     fn not_councilor_cannot_vote_on_proposal() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -1105,7 +1101,7 @@ mod tests {
 
     #[test]
     fn councilor_cannot_vote_on_proposal_if_it_has_been_cancelled() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -1119,7 +1115,7 @@ mod tests {
 
     #[test]
     fn councilor_cannot_vote_on_proposal_if_tally_has_been_finalized() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -1159,7 +1155,7 @@ mod tests {
 
     #[test]
     fn approve_proposal_when_all_councilors_approved_it() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -1213,7 +1209,7 @@ mod tests {
 
     #[test]
     fn approve_proposal_when_all_councilors_voted_and_only_quorum_approved() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -1269,7 +1265,7 @@ mod tests {
 
     #[test]
     fn approve_proposal_when_voting_period_expired_if_only_quorum_voted() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -1331,7 +1327,7 @@ mod tests {
 
     #[test]
     fn reject_proposal_when_all_councilors_voted_and_quorum_not_reached() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -1390,7 +1386,7 @@ mod tests {
 
     #[test]
     fn reject_proposal_when_all_councilors_rejected_it() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -1447,7 +1443,7 @@ mod tests {
 
     #[test]
     fn slash_proposal_when_all_councilors_slashed_it() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());
@@ -1513,7 +1509,7 @@ mod tests {
     // and it will be processed in the same way as if it has been rejected.
     #[test]
     fn expire_proposal_when_not_all_councilors_voted_and_quorum_not_reached() {
-        with_externalities(&mut new_test_ext(), || {
+        new_test_ext().execute_with(|| {
             let _ = Balances::deposit_creating(&PROPOSER1, initial_balance());
 
             assert_ok!(_create_default_proposal());

+ 77 - 52
src/lib.rs

@@ -8,15 +8,18 @@
 #[cfg(feature = "std")]
 include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
 
-use babe::AuthorityId as BabeId;
-use grandpa::fg_primitives::{self, ScheduledChange};
+use authority_discovery_primitives::{
+    AuthorityId as EncodedAuthorityId, Signature as EncodedSignature,
+};
+use babe_primitives::{AuthorityId as BabeId, AuthoritySignature as BabeSignature};
+use codec::{Decode, Encode};
+use grandpa::fg_primitives;
 use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight};
 use im_online::sr25519::AuthorityId as ImOnlineId;
 use primitives::{crypto::key_types, OpaqueMetadata};
 use rstd::prelude::*;
-use runtime_primitives::traits::{
-    BlakeTwo256, Block as BlockT, DigestFor, NumberFor, StaticLookup, Verify,
-};
+use runtime_primitives::curve::PiecewiseLinear;
+use runtime_primitives::traits::{BlakeTwo256, Block as BlockT, NumberFor, StaticLookup, Verify};
 use runtime_primitives::weights::Weight;
 use runtime_primitives::{
     create_runtime_str, generic, impl_opaque_keys, transaction_validity::TransactionValidity,
@@ -26,6 +29,7 @@ use substrate_client::{
     block_builder::api::{self as block_builder_api, CheckInherentsResult, InherentData},
     impl_runtime_apis, runtime_api as client_api,
 };
+use system::offchain::TransactionSubmitter;
 #[cfg(feature = "std")]
 use version::NativeVersion;
 use version::RuntimeVersion;
@@ -35,7 +39,10 @@ pub use balances::Call as BalancesCall;
 #[cfg(any(feature = "std", test))]
 pub use runtime_primitives::BuildStorage;
 pub use runtime_primitives::{Perbill, Permill};
-pub use srml_support::{construct_runtime, parameter_types, StorageMap, StorageValue};
+
+pub use srml_support::{
+    construct_runtime, parameter_types, traits::Randomness, StorageMap, StorageValue,
+};
 pub use staking::StakerStatus;
 pub use timestamp::Call as TimestampCall;
 
@@ -178,8 +185,6 @@ impl system::Trait for Runtime {
     type Header = generic::Header<BlockNumber, BlakeTwo256>;
     /// The ubiquitous event type.
     type Event = Event;
-    /// Update weight (to fee) multiplier per-block.
-    type WeightMultiplierUpdate = ();
     /// The ubiquitous origin type.
     type Origin = Origin;
     /// Maximum number of block number to block hash mappings to keep (oldest pruned first).
@@ -201,6 +206,7 @@ parameter_types! {
 impl babe::Trait for Runtime {
     type EpochDuration = EpochDuration;
     type ExpectedBlockTime = ExpectedBlockTime;
+    type EpochChangeTrigger = babe::ExternalTrigger;
 }
 
 impl grandpa::Trait for Runtime {
@@ -244,19 +250,24 @@ impl balances::Trait for Runtime {
     /// What to do if an account's free balance gets zeroed.
     type OnFreeBalanceZero = (Staking, Session);
     /// What to do if a new account is created.
-    type OnNewAccount = Indices;
+    type OnNewAccount = (); // Indices; // disable use of Indices feature
     /// The ubiquitous event type.
     type Event = Event;
 
-    type TransactionPayment = ();
     type DustRemoval = ();
     type TransferPayment = ();
     type ExistentialDeposit = ExistentialDeposit;
     type TransferFee = TransferFee;
     type CreationFee = CreationFee;
+}
+
+impl transaction_payment::Trait for Runtime {
+    type Currency = Balances;
+    type OnTransactionPayment = ();
     type TransactionBaseFee = TransactionBaseFee;
     type TransactionByteFee = TransactionByteFee;
-    type WeightToFee = (); // computes fee to be default value of Balance/u128 = 0
+    type WeightToFee = ();
+    type FeeMultiplierUpdate = (); // FeeMultiplierUpdateHandler;
 }
 
 impl sudo::Trait for Runtime {
@@ -293,6 +304,9 @@ impl_opaque_keys! {
 // `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
+parameter_types! {
+    pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
+}
 
 impl session::Trait for Runtime {
     type OnSessionEnding = Staking;
@@ -303,6 +317,7 @@ impl session::Trait for Runtime {
     type ValidatorId = AccountId;
     type ValidatorIdOf = staking::StashOf<Self>;
     type SelectInitialValidators = Staking;
+    type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
 }
 
 impl session::historical::Trait for Runtime {
@@ -310,9 +325,21 @@ impl session::historical::Trait for Runtime {
     type FullIdentificationOf = staking::ExposureOf<Runtime>;
 }
 
+staking_reward_curve::build! {
+    const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
+        min_inflation: 0_025_000,
+        max_inflation: 0_100_000,
+        ideal_stake: 0_500_000,
+        falloff: 0_050_000,
+        max_piece_count: 40,
+        test_precision: 0_005_000,
+    );
+}
+
 parameter_types! {
     pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6;
     pub const BondingDuration: staking::EraIndex = 24 * 28;
+    pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
 }
 
 impl staking::Trait for Runtime {
@@ -326,15 +353,17 @@ impl staking::Trait for Runtime {
     type SessionsPerEra = SessionsPerEra;
     type BondingDuration = BondingDuration;
     type SessionInterface = Self;
+    type RewardCurve = RewardCurve;
 }
 
+type SubmitTransaction = TransactionSubmitter<ImOnlineId, Runtime, UncheckedExtrinsic>;
+
 impl im_online::Trait for Runtime {
     type AuthorityId = ImOnlineId;
     type Call = Call;
     type Event = Event;
-    type UncheckedExtrinsic = UncheckedExtrinsic;
+    type SubmitTransaction = SubmitTransaction;
     type ReportUnresponsiveness = Offences;
-    type CurrentElectedSet = staking::CurrentElectedStashAccounts<Runtime>;
 }
 
 impl offences::Trait for Runtime {
@@ -343,7 +372,9 @@ impl offences::Trait for Runtime {
     type OnOffenceHandler = Staking;
 }
 
-impl authority_discovery::Trait for Runtime {}
+impl authority_discovery::Trait for Runtime {
+    type AuthorityId = BabeId;
+}
 
 parameter_types! {
     pub const WindowSize: BlockNumber = 101;
@@ -429,7 +460,7 @@ impl storage::data_object_storage_registry::Trait for Runtime {
 }
 
 fn random_index(upper_bound: usize) -> usize {
-    let seed = <system::Module<Runtime>>::random_seed();
+    let seed = RandomnessCollectiveFlip::random_seed();
     let mut rand: u64 = 0;
     for offset in 0..8 {
         rand += (seed.as_ref()[offset] as u64) << offset;
@@ -548,6 +579,7 @@ construct_runtime!(
 		Authorship: authorship::{Module, Call, Storage, Inherent},
 		Indices: indices,
 		Balances: balances,
+        TransactionPayment: transaction_payment::{Module, Storage},
 		Staking: staking::{default, OfflineWorker},
 		Session: session::{Module, Call, Storage, Event, Config<T>},
         FinalityTracker: finality_tracker::{Module, Call, Inherent},
@@ -555,6 +587,7 @@ construct_runtime!(
         ImOnline: im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
 		AuthorityDiscovery: authority_discovery::{Module, Call, Config<T>},
 		Offences: offences::{Module, Call, Storage, Event},
+        RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},
 		Sudo: sudo,
         // Joystream
 		Proposals: proposals::{Module, Call, Storage, Event<T>, Config<T>},
@@ -590,7 +623,7 @@ pub type SignedExtra = (
     system::CheckEra<Runtime>,
     system::CheckNonce<Runtime>,
     system::CheckWeight<Runtime>,
-    balances::TakeFees<Runtime>,
+    transaction_payment::ChargeTransactionPayment<Runtime>,
 );
 /// Unchecked extrinsic type as expected by this runtime.
 pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
@@ -639,7 +672,7 @@ impl_runtime_apis! {
         }
 
         fn random_seed() -> <Block as BlockT>::Hash {
-            System::random_seed()
+            RandomnessCollectiveFlip::random_seed()
         }
     }
 
@@ -656,67 +689,59 @@ impl_runtime_apis! {
     }
 
     impl fg_primitives::GrandpaApi<Block> for Runtime {
-        fn grandpa_pending_change(digest: &DigestFor<Block>)
-            -> Option<ScheduledChange<NumberFor<Block>>>
-        {
-            Grandpa::pending_change(digest)
-        }
-
-        fn grandpa_forced_change(digest: &DigestFor<Block>)
-            -> Option<(NumberFor<Block>, ScheduledChange<NumberFor<Block>>)>
-        {
-            Grandpa::forced_change(digest)
-        }
-
         fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> {
             Grandpa::grandpa_authorities()
         }
     }
 
     impl babe_primitives::BabeApi<Block> for Runtime {
-        fn startup_data() -> babe_primitives::BabeConfiguration {
+        fn configuration() -> babe_primitives::BabeConfiguration {
             // The choice of `c` parameter (where `1 - c` represents the
             // probability of a slot being empty), is done in accordance to the
             // slot duration and expected target block time, for safely
             // resisting network delays of maximum two seconds.
             // <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
             babe_primitives::BabeConfiguration {
-                median_required_blocks: 1000,
                 slot_duration: Babe::slot_duration(),
+                epoch_length: EpochDuration::get(),
                 c: PRIMARY_PROBABILITY,
-            }
-        }
-
-        fn epoch() -> babe_primitives::Epoch {
-            babe_primitives::Epoch {
-                start_slot: Babe::epoch_start_slot(),
-                authorities: Babe::authorities(),
-                epoch_index: Babe::epoch_index(),
+                genesis_authorities: Babe::authorities(),
                 randomness: Babe::randomness(),
-                duration: EpochDuration::get(),
-                secondary_slots: Babe::secondary_slots().0,
+                secondary_slots: true,
             }
         }
     }
 
-    impl authority_discovery_primitives::AuthorityDiscoveryApi<Block, ImOnlineId> for Runtime {
-        fn authority_id() -> Option<ImOnlineId> {
-            AuthorityDiscovery::authority_id()
-        }
-        fn authorities() -> Vec<ImOnlineId> {
-            AuthorityDiscovery::authorities()
+    impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
+        fn authorities() -> Vec<EncodedAuthorityId> {
+            AuthorityDiscovery::authorities().into_iter()
+                .map(|id| id.encode())
+                .map(EncodedAuthorityId)
+                .collect()
         }
 
-        fn sign(payload: Vec<u8>, authority_id: ImOnlineId) -> Option<Vec<u8>> {
-            AuthorityDiscovery::sign(payload, authority_id)
+        fn sign(payload: &Vec<u8>) -> Option<(EncodedSignature, EncodedAuthorityId)> {
+              AuthorityDiscovery::sign(payload).map(|(sig, id)| {
+            (EncodedSignature(sig.encode()), EncodedAuthorityId(id.encode()))
+        })
         }
 
-        fn verify(payload: Vec<u8>, signature: Vec<u8>, public_key: ImOnlineId) -> bool {
-            AuthorityDiscovery::verify(payload, signature, public_key)
+        fn verify(payload: &Vec<u8>, signature: &EncodedSignature, authority_id: &EncodedAuthorityId) -> bool {
+            let signature = match BabeSignature::decode(&mut &signature.0[..]) {
+                Ok(s) => s,
+                _ => return false,
+            };
+
+            let authority_id = match BabeId::decode(&mut &authority_id.0[..]) {
+                Ok(id) => id,
+                _ => return false,
+            };
+
+            AuthorityDiscovery::verify(payload, signature, authority_id)
         }
     }
 
-    impl node_primitives::AccountNonceApi<Block> for Runtime {
+    impl system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
         fn account_nonce(account: AccountId) -> Index {
             System::account_nonce(account)
         }

+ 1 - 1
src/membership/members.rs

@@ -217,7 +217,7 @@ impl<T: Trait> Members<T> for Module<T> {
 
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        fn deposit_event<T>() = default;
+        fn deposit_event() = default;
 
         /// Non-members can buy membership
         pub fn buy_membership(origin, paid_terms_id: T::PaidTermId, user_info: UserInfo) {

+ 1 - 6
src/membership/mock.rs

@@ -40,7 +40,6 @@ impl system::Trait for Test {
     type AccountId = u64;
     type Lookup = IdentityLookup<Self::AccountId>;
     type Header = Header;
-    type WeightMultiplierUpdate = ();
     type Event = ();
     type BlockHashCount = BlockHashCount;
     type MaximumBlockWeight = MaximumBlockWeight;
@@ -73,15 +72,11 @@ impl balances::Trait for Test {
     /// The ubiquitous event type.
     type Event = ();
 
-    type TransactionPayment = ();
     type DustRemoval = ();
     type TransferPayment = ();
     type ExistentialDeposit = ExistentialDeposit;
     type TransferFee = TransferFee;
     type CreationFee = CreationFee;
-    type TransactionBaseFee = TransactionBaseFee;
-    type TransactionByteFee = TransactionByteFee;
-    type WeightToFee = ();
 }
 
 impl GovernanceCurrency for Test {
@@ -118,7 +113,7 @@ impl ExtBuilder {
         self.default_paid_membership_fee = default_paid_membership_fee;
         self
     }
-    pub fn build(self) -> runtime_io::TestExternalities<Blake2Hasher> {
+    pub fn build(self) -> runtime_io::TestExternalities {
         let mut t = system::GenesisConfig::default()
             .build_storage::<Test>()
             .unwrap();

+ 38 - 53
src/membership/tests.rs

@@ -2,7 +2,6 @@
 
 use super::mock::*;
 
-use runtime_io::with_externalities;
 use srml_support::*;
 
 fn assert_ok_unwrap<T>(value: Option<T>, err: &'static str) -> T {
@@ -59,12 +58,11 @@ fn initial_state() {
     const DEFAULT_FEE: u64 = 500;
     const DEFAULT_FIRST_ID: u32 = 1000;
 
-    with_externalities(
-        &mut ExtBuilder::default()
-            .default_paid_membership_fee(DEFAULT_FEE)
-            .first_member_id(DEFAULT_FIRST_ID)
-            .build(),
-        || {
+    ExtBuilder::default()
+        .default_paid_membership_fee(DEFAULT_FEE)
+        .first_member_id(DEFAULT_FIRST_ID)
+        .build()
+        .execute_with(|| {
             assert_eq!(Members::first_member_id(), DEFAULT_FIRST_ID);
             assert_eq!(Members::next_member_id(), DEFAULT_FIRST_ID);
 
@@ -75,8 +73,7 @@ fn initial_state() {
 
             assert_eq!(default_terms.id, DEFAULT_TERMS_ID);
             assert_eq!(default_terms.fee, DEFAULT_FEE);
-        },
-    );
+        });
 }
 
 #[test]
@@ -85,12 +82,11 @@ fn buy_membership() {
     const DEFAULT_FIRST_ID: u32 = 1000;
     const SURPLUS_BALANCE: u64 = 500;
 
-    with_externalities(
-        &mut ExtBuilder::default()
-            .default_paid_membership_fee(DEFAULT_FEE)
-            .first_member_id(DEFAULT_FIRST_ID)
-            .build(),
-        || {
+    ExtBuilder::default()
+        .default_paid_membership_fee(DEFAULT_FEE)
+        .first_member_id(DEFAULT_FIRST_ID)
+        .build()
+        .execute_with(|| {
             let initial_balance = DEFAULT_FEE + SURPLUS_BALANCE;
             set_alice_free_balance(initial_balance);
 
@@ -111,44 +107,39 @@ fn buy_membership() {
             assert_eq!(Some(profile.about), get_alice_info().about);
 
             assert_eq!(Balances::free_balance(&ALICE_ACCOUNT_ID), SURPLUS_BALANCE);
-        },
-    );
+        });
 }
 
 #[test]
 fn buy_membership_fails_without_enough_balance() {
     const DEFAULT_FEE: u64 = 500;
 
-    with_externalities(
-        &mut ExtBuilder::default()
-            .default_paid_membership_fee(DEFAULT_FEE)
-            .build(),
-        || {
+    ExtBuilder::default()
+        .default_paid_membership_fee(DEFAULT_FEE)
+        .build()
+        .execute_with(|| {
             let initial_balance = DEFAULT_FEE - 1;
             set_alice_free_balance(initial_balance);
 
             assert!(buy_default_membership_as_alice().is_err());
-        },
-    );
+        });
 }
 
 #[test]
 fn new_memberships_allowed_flag() {
     const DEFAULT_FEE: u64 = 500;
 
-    with_externalities(
-        &mut ExtBuilder::default()
-            .default_paid_membership_fee(DEFAULT_FEE)
-            .build(),
-        || {
+    ExtBuilder::default()
+        .default_paid_membership_fee(DEFAULT_FEE)
+        .build()
+        .execute_with(|| {
             let initial_balance = DEFAULT_FEE + 1;
             set_alice_free_balance(initial_balance);
 
             members::NewMembershipsAllowed::put(false);
 
             assert!(buy_default_membership_as_alice().is_err());
-        },
-    );
+        });
 }
 
 #[test]
@@ -156,11 +147,10 @@ fn account_cannot_create_multiple_memberships() {
     const DEFAULT_FEE: u64 = 500;
     const SURPLUS_BALANCE: u64 = 500;
 
-    with_externalities(
-        &mut ExtBuilder::default()
-            .default_paid_membership_fee(DEFAULT_FEE)
-            .build(),
-        || {
+    ExtBuilder::default()
+        .default_paid_membership_fee(DEFAULT_FEE)
+        .build()
+        .execute_with(|| {
             let initial_balance = DEFAULT_FEE + SURPLUS_BALANCE;
             set_alice_free_balance(initial_balance);
 
@@ -169,8 +159,7 @@ fn account_cannot_create_multiple_memberships() {
 
             // second attempt should fail
             assert!(buy_default_membership_as_alice().is_err());
-        },
-    );
+        });
 }
 
 #[test]
@@ -178,11 +167,10 @@ fn unique_handles() {
     const DEFAULT_FEE: u64 = 500;
     const SURPLUS_BALANCE: u64 = 500;
 
-    with_externalities(
-        &mut ExtBuilder::default()
-            .default_paid_membership_fee(DEFAULT_FEE)
-            .build(),
-        || {
+    ExtBuilder::default()
+        .default_paid_membership_fee(DEFAULT_FEE)
+        .build()
+        .execute_with(|| {
             let initial_balance = DEFAULT_FEE + SURPLUS_BALANCE;
             set_alice_free_balance(initial_balance);
 
@@ -191,8 +179,7 @@ fn unique_handles() {
 
             // should not be allowed to buy membership with that handle
             assert!(buy_default_membership_as_alice().is_err());
-        },
-    );
+        });
 }
 
 #[test]
@@ -200,11 +187,10 @@ fn update_profile() {
     const DEFAULT_FEE: u64 = 500;
     const SURPLUS_BALANCE: u64 = 500;
 
-    with_externalities(
-        &mut ExtBuilder::default()
-            .default_paid_membership_fee(DEFAULT_FEE)
-            .build(),
-        || {
+    ExtBuilder::default()
+        .default_paid_membership_fee(DEFAULT_FEE)
+        .build()
+        .execute_with(|| {
             let initial_balance = DEFAULT_FEE + SURPLUS_BALANCE;
             set_alice_free_balance(initial_balance);
 
@@ -228,13 +214,12 @@ fn update_profile() {
             assert_eq!(Some(profile.handle), get_bob_info().handle);
             assert_eq!(Some(profile.avatar_uri), get_bob_info().avatar_uri);
             assert_eq!(Some(profile.about), get_bob_info().about);
-        },
-    );
+        });
 }
 
 #[test]
 fn add_screened_member() {
-    with_externalities(&mut ExtBuilder::default().build(), || {
+    ExtBuilder::default().build().execute_with(|| {
         let screening_authority = 5;
         <members::ScreeningAuthority<Test>>::put(&screening_authority);
 

+ 1 - 1
src/memo.rs

@@ -24,7 +24,7 @@ decl_event! {
 
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        fn deposit_event<T>() = default;
+        fn deposit_event() = default;
 
         fn update_memo(origin, memo: Vec<u8>) {
             let sender = ensure_signed(origin)?;

+ 2 - 2
src/migration.rs

@@ -1,7 +1,7 @@
 use crate::forum;
 use crate::storage;
 use crate::VERSION;
-use runtime_io::print;
+use runtime_primitives::print;
 use srml_support::{decl_event, decl_module, decl_storage, StorageValue};
 use sudo;
 use system;
@@ -58,7 +58,7 @@ decl_event! {
 
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        fn deposit_event<T>() = default;
+        fn deposit_event() = default;
 
         fn on_initialize(_now: T::BlockNumber) {
             if Self::spec_version().map_or(true, |spec_version| VERSION.spec_version > spec_version) {

+ 1 - 3
src/roles/actors.rs

@@ -1,7 +1,6 @@
 use crate::currency::{BalanceOf, GovernanceCurrency};
 use codec::{Decode, Encode};
 use rstd::prelude::*;
-use runtime_io::print;
 use runtime_primitives::traits::{Bounded, MaybeDebug, Zero};
 use srml_support::traits::{
     Currency, LockIdentifier, LockableCurrency, WithdrawReason, WithdrawReasons,
@@ -256,7 +255,7 @@ impl<T: Trait> Module<T> {
 
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        fn deposit_event<T>() = default;
+        fn deposit_event() = default;
 
         fn on_initialize(now: T::BlockNumber) {
             // clear expired requests
@@ -420,7 +419,6 @@ decl_module! {
             let actor = Self::actor_by_account_id(&actor_account).unwrap();
             let role_parameters = Self::ensure_role_parameters(actor.role)?;
             Self::apply_unstake(actor_account, actor.role, actor.member_id, role_parameters.unbonding_period, role_parameters.min_stake);
-            print("sudo removed actor");
         }
     }
 }

+ 1 - 6
src/roles/mock.rs

@@ -40,7 +40,6 @@ impl system::Trait for Test {
     type AccountId = u64;
     type Lookup = IdentityLookup<Self::AccountId>;
     type Header = Header;
-    type WeightMultiplierUpdate = ();
     type Event = ();
     type BlockHashCount = BlockHashCount;
     type MaximumBlockWeight = MaximumBlockWeight;
@@ -67,15 +66,11 @@ impl balances::Trait for Test {
     /// The ubiquitous event type.
     type Event = ();
 
-    type TransactionPayment = ();
     type DustRemoval = ();
     type TransferPayment = ();
     type ExistentialDeposit = ExistentialDeposit;
     type TransferFee = TransferFee;
     type CreationFee = CreationFee;
-    type TransactionBaseFee = TransactionBaseFee;
-    type TransactionByteFee = TransactionByteFee;
-    type WeightToFee = ();
 }
 
 impl GovernanceCurrency for Test {
@@ -140,7 +135,7 @@ impl actors::ActorRemoved<Test> for () {
     fn actor_removed(_: &u64) {}
 }
 
-pub fn initial_test_ext() -> runtime_io::TestExternalities<Blake2Hasher> {
+pub fn initial_test_ext() -> runtime_io::TestExternalities {
     let t = system::GenesisConfig::default()
         .build_storage::<Test>()
         .unwrap();

+ 5 - 6
src/roles/tests.rs

@@ -2,7 +2,6 @@
 
 use super::mock::*;
 
-use runtime_io::with_externalities;
 use srml_support::*;
 
 fn init_storage_role() {
@@ -41,7 +40,7 @@ fn init_storage_parmeters() -> actors::RoleParameters<Test> {
 
 #[test]
 fn adding_roles() {
-    with_externalities(&mut initial_test_ext(), || {
+    initial_test_ext().execute_with(|| {
         init_storage_role();
         assert_eq!(Actors::available_roles(), vec![actors::Role::Storage]);
     });
@@ -49,7 +48,7 @@ fn adding_roles() {
 
 #[test]
 fn adding_role_parameters() {
-    with_externalities(&mut initial_test_ext(), || {
+    initial_test_ext().execute_with(|| {
         init_storage_role();
         let params = init_storage_parmeters();
         assert_eq!(Actors::parameters(actors::Role::Storage), Some(params));
@@ -58,7 +57,7 @@ fn adding_role_parameters() {
 
 #[test]
 fn make_entry_request() {
-    with_externalities(&mut initial_test_ext(), || {
+    initial_test_ext().execute_with(|| {
         init_storage_role();
         let storage_params = init_storage_parmeters();
 
@@ -114,7 +113,7 @@ fn make_entry_request() {
 
 #[test]
 fn staking() {
-    with_externalities(&mut initial_test_ext(), || {
+    initial_test_ext().execute_with(|| {
         init_storage_role();
         let storage_params = init_storage_parmeters();
         let actor_account = 5;
@@ -156,7 +155,7 @@ fn staking() {
 
 #[test]
 fn unstaking() {
-    with_externalities(&mut initial_test_ext(), || {
+    initial_test_ext().execute_with(|| {
         init_storage_role();
         let storage_params = init_storage_parmeters();
         let actor_account = 5;

+ 1 - 1
src/service_discovery/discovery.rs

@@ -78,7 +78,7 @@ impl<T: Trait> Module<T> {
 
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        fn deposit_event<T>() = default;
+        fn deposit_event() = default;
 
         pub fn set_ipns_id(origin, id: Vec<u8>, lifetime: Option<T::BlockNumber>) {
             let sender = ensure_signed(origin)?;

+ 1 - 2
src/service_discovery/mock.rs

@@ -43,7 +43,6 @@ impl system::Trait for Test {
     type AccountId = u64;
     type Lookup = IdentityLookup<Self::AccountId>;
     type Header = Header;
-    type WeightMultiplierUpdate = ();
     type Event = MetaEvent;
     type BlockHashCount = BlockHashCount;
     type MaximumBlockWeight = MaximumBlockWeight;
@@ -79,7 +78,7 @@ impl Roles<Test> for MockRoles {
     }
 }
 
-pub fn initial_test_ext() -> runtime_io::TestExternalities<Blake2Hasher> {
+pub fn initial_test_ext() -> runtime_io::TestExternalities {
     let t = system::GenesisConfig::default()
         .build_storage::<Test>()
         .unwrap();

+ 5 - 6
src/service_discovery/tests.rs

@@ -2,13 +2,12 @@
 
 use super::mock::*;
 
-use runtime_io::with_externalities;
 use srml_support::*;
 use system::{self, EventRecord, Phase};
 
 #[test]
 fn set_ipns_id() {
-    with_externalities(&mut initial_test_ext(), || {
+    initial_test_ext().execute_with(|| {
         let current_block_number = 1000;
         System::set_block_number(current_block_number);
 
@@ -48,7 +47,7 @@ fn set_ipns_id() {
 
 #[test]
 fn unset_ipns_id() {
-    with_externalities(&mut initial_test_ext(), || {
+    initial_test_ext().execute_with(|| {
         let alice = alice_account();
 
         <discovery::AccountInfoByAccountId<Test>>::insert(
@@ -77,7 +76,7 @@ fn unset_ipns_id() {
 
 #[test]
 fn is_account_info_expired() {
-    with_externalities(&mut initial_test_ext(), || {
+    initial_test_ext().execute_with(|| {
         let alice = alice_account();
         let expires_at = 1000;
         let id = "alice".as_bytes().to_vec();
@@ -99,7 +98,7 @@ fn is_account_info_expired() {
 
 #[test]
 fn set_default_lifetime() {
-    with_externalities(&mut initial_test_ext(), || {
+    initial_test_ext().execute_with(|| {
         let lifetime =
             <Test as system::Trait>::BlockNumber::from(discovery::MINIMUM_LIFETIME + 2000);
         // priviliged method should fail if not from root origin
@@ -125,7 +124,7 @@ fn set_default_lifetime() {
 
 #[test]
 fn set_bootstrap_endpoints() {
-    with_externalities(&mut initial_test_ext(), || {
+    initial_test_ext().execute_with(|| {
         let endpoints = vec!["endpoint1".as_bytes().to_vec()];
         // priviliged method should fail if not from root origin
         assert!(

+ 1 - 1
src/storage/data_directory.rs

@@ -148,7 +148,7 @@ decl_event! {
 
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        fn deposit_event<T>() = default;
+        fn deposit_event() = default;
 
         // TODO send file_name as param so we could create a Draft metadata in this fn
         pub fn add_content(

+ 1 - 1
src/storage/data_object_storage_registry.rs

@@ -126,7 +126,7 @@ impl<T: Trait> ContentHasStorage<T> for Module<T> {
 
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        fn deposit_event<T>() = default;
+        fn deposit_event() = default;
 
         pub fn add_relationship(origin, cid: T::ContentId) {
             // Origin has to be a storage provider

+ 1 - 1
src/storage/data_object_type_registry.rs

@@ -81,7 +81,7 @@ impl<T: Trait> traits::IsActiveDataObjectType<T> for Module<T> {
 
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        fn deposit_event<T>() = default;
+        fn deposit_event() = default;
 
         fn on_initialize() {
             // Create a default data object type if it was not created yet.

+ 1 - 1
src/storage/downloads.rs

@@ -95,7 +95,7 @@ decl_event! {
 
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        fn deposit_event<T>() = default;
+        fn deposit_event() = default;
 
         // Origin starts a download from distributor. It's the origin's responsibility to
         // start this, and hand the session ID to the distributor as proof they did.

+ 9 - 17
src/storage/mock.rs

@@ -4,7 +4,6 @@ pub use super::{data_directory, data_object_storage_registry, data_object_type_r
 pub use crate::currency::GovernanceCurrency;
 use crate::roles::actors;
 use crate::traits;
-use runtime_io::with_externalities;
 pub use system;
 
 pub use primitives::{Blake2Hasher, H256};
@@ -134,7 +133,6 @@ impl system::Trait for Test {
     type AccountId = u64;
     type Lookup = IdentityLookup<Self::AccountId>;
     type Header = Header;
-    type WeightMultiplierUpdate = ();
     type Event = MetaEvent;
     type BlockHashCount = BlockHashCount;
     type MaximumBlockWeight = MaximumBlockWeight;
@@ -167,15 +165,11 @@ impl balances::Trait for Test {
     /// The ubiquitous event type.
     type Event = MetaEvent;
 
-    type TransactionPayment = ();
     type DustRemoval = ();
     type TransferPayment = ();
     type ExistentialDeposit = ExistentialDeposit;
     type TransferFee = TransferFee;
     type CreationFee = CreationFee;
-    type TransactionBaseFee = TransactionBaseFee;
-    type TransactionByteFee = TransactionByteFee;
-    type WeightToFee = ();
 }
 
 impl GovernanceCurrency for Test {
@@ -249,7 +243,7 @@ impl ExtBuilder {
         self.first_metadata_id = first_metadata_id;
         self
     }
-    pub fn build(self) -> runtime_io::TestExternalities<Blake2Hasher> {
+    pub fn build(self) -> runtime_io::TestExternalities {
         let mut t = system::GenesisConfig::default()
             .build_storage::<Test>()
             .unwrap();
@@ -279,14 +273,13 @@ pub type TestDataObjectStorageRegistry = data_object_storage_registry::Module<Te
 pub type TestActors = actors::Module<Test>;
 
 pub fn with_default_mock_builder<R, F: FnOnce() -> R>(f: F) -> R {
-    with_externalities(
-        &mut ExtBuilder::default()
-            .first_data_object_type_id(TEST_FIRST_DATA_OBJECT_TYPE_ID)
-            .first_content_id(TEST_FIRST_CONTENT_ID)
-            .first_relationship_id(TEST_FIRST_RELATIONSHIP_ID)
-            .first_metadata_id(TEST_FIRST_METADATA_ID)
-            .build(),
-        || {
+    ExtBuilder::default()
+        .first_data_object_type_id(TEST_FIRST_DATA_OBJECT_TYPE_ID)
+        .first_content_id(TEST_FIRST_CONTENT_ID)
+        .first_relationship_id(TEST_FIRST_RELATIONSHIP_ID)
+        .first_metadata_id(TEST_FIRST_METADATA_ID)
+        .build()
+        .execute_with(|| {
             let roles: Vec<actors::Role> = vec![actors::Role::Storage];
             assert!(
                 TestActors::set_available_roles(system::RawOrigin::Root.into(), roles).is_ok(),
@@ -294,6 +287,5 @@ pub fn with_default_mock_builder<R, F: FnOnce() -> R>(f: F) -> R {
             );
 
             f()
-        },
-    )
+        })
 }