Update to lastest Substrate master (#443)

This commit is contained in:
Bastian Köcher
2019-09-24 13:09:30 +02:00
committed by Robert Habermeier
parent 444a19ec5f
commit 4f4baa9b07
9 changed files with 249 additions and 271 deletions
+1 -5
View File
@@ -21,14 +21,10 @@
use rstd::prelude::*;
use codec::{Encode, Decode};
use srml_support::{decl_storage, decl_module, ensure};
use srml_support::{decl_storage, decl_module, ensure, dispatch::Result, traits::Get};
use primitives::{Hash, parachain::{AttestedCandidate, CandidateReceipt, Id as ParaId}};
use sr_staking_primitives::SessionIndex;
use {system, session};
use srml_support::{
StorageValue, StorageMap, StorageDoubleMap, dispatch::Result, traits::Get,
};
use inherents::{ProvideInherent, InherentData, RuntimeString, MakeFatalError, InherentIdentifier};
use system::ensure_none;
+1 -1
View File
@@ -18,7 +18,7 @@
use rstd::prelude::*;
use sr_io::{keccak_256, secp256k1_ecdsa_recover};
use srml_support::{StorageValue, StorageMap, decl_event, decl_storage, decl_module};
use srml_support::{decl_event, decl_storage, decl_module};
use srml_support::traits::{Currency, Get};
use system::ensure_none;
use codec::{Encode, Decode};
+9 -9
View File
@@ -67,7 +67,7 @@
//! funds ultimately end up in module's fund sub-account.
use srml_support::{
StorageValue, StorageMap, decl_module, decl_storage, decl_event, storage::child, ensure,
decl_module, decl_storage, decl_event, storage::child, ensure,
traits::{Currency, Get, OnUnbalanced, WithdrawReason, ExistenceRequirement}
};
use system::ensure_signed;
@@ -187,7 +187,7 @@ decl_event! {
decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
fn deposit_event() = default;
/// Create a new crowdfunding campaign for a parachain slot deposit for the current auction.
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
fn create(origin,
@@ -233,7 +233,7 @@ decl_module! {
Self::deposit_event(RawEvent::Created(index));
}
/// Contribute to a crowd sale. This will transfer some balance over to fund a parachain
/// slot. It will be withdrawable in two instances: the parachain becomes retired; or the
/// slot is
@@ -312,7 +312,7 @@ decl_module! {
Self::deposit_event(RawEvent::DeployDataFixed(index));
}
/// Complete onboarding process for a winning parachain fund. This can be called once by
/// any origin once a fund wins a slot and the fund has set its deploy data (using
/// `fix_deploy_data`).
@@ -337,7 +337,7 @@ decl_module! {
Self::deposit_event(RawEvent::Onboarded(index, para_id));
}
/// Note that a successful fund has lost its parachain slot, and place it into retirement.
fn begin_retirement(origin, #[compact] index: FundIndex) {
let _ = ensure_signed(origin)?;
@@ -388,7 +388,7 @@ decl_module! {
Self::deposit_event(RawEvent::Withdrew(who, index, balance));
}
/// Remove a fund after either: it was unsuccessful and it timed out; or it was successful
/// but it has been retired from its parachain slot. This places any deposits that were not
/// withdrawn into the treasury.
@@ -422,7 +422,7 @@ decl_module! {
Self::deposit_event(RawEvent::Dissolved(index));
}
fn on_finalize(n: T::BlockNumber) {
if let Some(n) = <slots::Module<T>>::is_ending(n) {
let auction_index = <slots::Module<T>>::auction_counter();
@@ -1041,7 +1041,7 @@ mod tests {
assert_eq!(Balances::free_balance(3), 2990);
});
}
#[test]
fn withdraw_handles_basic_errors() {
with_externalities(&mut new_test_ext(), || {
@@ -1079,7 +1079,7 @@ mod tests {
// Skip all the way to the end
run_to_block(50);
// Check current funds (contributions + deposit)
assert_eq!(Balances::free_balance(Crowdfund::fund_account_id(0)), 601);
+7 -28
View File
@@ -41,12 +41,11 @@ use client::{
use sr_primitives::{
ApplyResult, generic, Permill, Perbill, impl_opaque_keys, create_runtime_str, key_types,
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
weights::{Weight, DispatchInfo},
traits::{BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, SignedExtension},
curve::PiecewiseLinear,
weights::{Weight, DispatchInfo}, curve::PiecewiseLinear,
traits::{BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension},
};
use version::RuntimeVersion;
use grandpa::{AuthorityId as GrandpaId, fg_primitives::{self, ScheduledChange}};
use grandpa::{AuthorityId as GrandpaId, fg_primitives};
use babe_primitives::AuthorityId as BabeId;
use elections::VoteIndex;
#[cfg(any(feature = "std", test))]
@@ -662,45 +661,25 @@ impl_runtime_apis! {
}
impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_pending_change(digest: &DigestFor<Block>)
-> Option<ScheduledChange<BlockNumber>>
{
Grandpa::pending_change(digest)
}
fn grandpa_forced_change(digest: &DigestFor<Block>)
-> Option<(BlockNumber, ScheduledChange<BlockNumber>)>
{
Grandpa::forced_change(digest)
}
fn grandpa_authorities() -> Vec<(GrandpaId, u64)> {
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,
}
}
}
+1 -2
View File
@@ -31,8 +31,7 @@ use primitives::{Hash, Balance, parachain::{
}};
use {system, session};
use srml_support::{
StorageValue, StorageMap, Parameter, dispatch::Result,
traits::{Currency, Get, WithdrawReason, ExistenceRequirement}
Parameter, dispatch::Result, traits::{Currency, Get, WithdrawReason, ExistenceRequirement},
};
use inherents::{ProvideInherent, InherentData, RuntimeString, MakeFatalError, InherentIdentifier};
+2 -2
View File
@@ -23,8 +23,8 @@ use sr_primitives::traits::{CheckedSub, StaticLookup, Zero, One, CheckedConversi
use sr_primitives::weights::SimpleDispatchInfo;
use codec::{Encode, Decode};
use srml_support::{
decl_module, decl_storage, decl_event, StorageValue, StorageMap, ensure,
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get}
decl_module, decl_storage, decl_event, StorageMap, ensure,
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get},
};
use primitives::parachain::AccountIdConversion;
use crate::parachains::ParachainRegistrar;