Unverified Commit 9671a877 authored by Gavin Wood's avatar Gavin Wood Committed by GitHub
Browse files

Update Substrate (#808)



* Update to latest Substrate master

* upgrade decl_storage declaration

* Companion PR to Substrate#4752

Co-authored-by: default avatarBastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: thiolliere's avatarthiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Pierre Krieger's avatarPierre Krieger <pierre.krieger1708@gmail.com>
parent 4d19f4e6
This diff is collapsed.
......@@ -454,7 +454,7 @@ fn run_collator_node<S, E, P, Extrinsic>(
}
}.boxed();
service.spawn_essential_task(work);
service.spawn_essential_task("collation", work);
polkadot_cli::run_until_exit(runtime, service, exit)
}
......
......@@ -98,10 +98,12 @@ decl_storage! {
trait Store for Module<T: Trait> as Attestations {
/// A mapping from modular block number (n % AttestationPeriod)
/// to session index and the list of candidate hashes.
pub RecentParaBlocks: map T::BlockNumber => Option<IncludedBlocks<T>>;
pub RecentParaBlocks: map hasher(blake2_256) T::BlockNumber => Option<IncludedBlocks<T>>;
/// Attestations on a recent parachain block.
pub ParaBlockAttestations: double_map T::BlockNumber, hasher(blake2_128) Hash => Option<BlockAttestations<T>>;
pub ParaBlockAttestations:
double_map hasher(blake2_256) T::BlockNumber, hasher(blake2_128) Hash
=> Option<BlockAttestations<T>>;
// Did we already have more attestations included in this block?
DidUpdate: bool;
......
......@@ -118,7 +118,7 @@ decl_storage! {
trait Store for Module<T: Trait> as Claims {
Claims get(claims) build(|config: &GenesisConfig<T>| {
config.claims.iter().map(|(a, b)| (a.clone(), b.clone())).collect::<Vec<_>>()
}): map EthereumAddress => Option<BalanceOf<T>>;
}): map hasher(blake2_256) EthereumAddress => Option<BalanceOf<T>>;
Total get(total) build(|config: &GenesisConfig<T>| {
config.claims.iter().fold(Zero::zero(), |acc: BalanceOf<T>, &(_, n)| acc + n)
}): BalanceOf<T>;
......@@ -126,7 +126,9 @@ decl_storage! {
/// First balance is the total amount that should be held for vesting.
/// Second balance is how much should be unlocked per block.
/// The block number is when the vesting should start.
Vesting get(vesting) config(): map EthereumAddress => Option<(BalanceOf<T>, BalanceOf<T>, T::BlockNumber)>;
Vesting get(vesting) config():
map hasher(blake2_256) EthereumAddress
=> Option<(BalanceOf<T>, BalanceOf<T>, T::BlockNumber)>;
}
add_extra_genesis {
config(claims): Vec<(EthereumAddress, BalanceOf<T>)>;
......
......@@ -158,7 +158,8 @@ decl_storage! {
trait Store for Module<T: Trait> as Crowdfund {
/// Info on all of the funds.
Funds get(funds):
map FundIndex => Option<FundInfo<T::AccountId, BalanceOf<T>, T::Hash, T::BlockNumber>>;
map hasher(blake2_256) FundIndex
=> Option<FundInfo<T::AccountId, BalanceOf<T>, T::Hash, T::BlockNumber>>;
/// The total number of funds that have so far been allocated.
FundCount get(fund_count): FundIndex;
......
......@@ -158,27 +158,28 @@ decl_storage! {
/// All authorities' keys at the moment.
pub Authorities get(authorities): Vec<ValidatorId>;
/// The parachains registered at present.
pub Code get(parachain_code): map ParaId => Option<Vec<u8>>;
pub Code get(parachain_code): map hasher(blake2_256) ParaId => Option<Vec<u8>>;
/// The heads of the parachains registered at present.
pub Heads get(parachain_head): map ParaId => Option<Vec<u8>>;
pub Heads get(parachain_head): map hasher(blake2_256) ParaId => Option<Vec<u8>>;
/// The watermark heights of the parachains registered at present.
/// For every parachain, this is the block height from which all messages targeting
/// that parachain have been processed. Can be `None` only if the parachain doesn't exist.
pub Watermarks get(watermark): map ParaId => Option<T::BlockNumber>;
pub Watermarks get(watermark): map hasher(blake2_256) ParaId => Option<T::BlockNumber>;
/// Unrouted ingress. Maps (BlockNumber, to_chain) pairs to [(from_chain, egress_root)].
///
/// There may be an entry under (i, p) in this map for every i between the parachain's
/// watermark and the current block.
pub UnroutedIngress: map (T::BlockNumber, ParaId) => Option<Vec<(ParaId, Hash)>>;
pub UnroutedIngress:
map hasher(blake2_256) (T::BlockNumber, ParaId) => Option<Vec<(ParaId, Hash)>>;
/// Messages ready to be dispatched onto the relay chain. It is subject to
/// `MAX_MESSAGE_COUNT` and `WATERMARK_MESSAGE_SIZE`.
pub RelayDispatchQueue: map ParaId => Vec<UpwardMessage>;
pub RelayDispatchQueue: map hasher(blake2_256) ParaId => Vec<UpwardMessage>;
/// Size of the dispatch queues. Separated from actual data in order to avoid costly
/// decoding when checking receipt validity. First item in tuple is the count of messages
/// second if the total length (in bytes) of the message payloads.
pub RelayDispatchQueueSize: map ParaId => (u32, u32);
pub RelayDispatchQueueSize: map hasher(blake2_256) ParaId => (u32, u32);
/// The ordered list of ParaIds that have a `RelayDispatchQueue` entry.
NeedsDispatch: Vec<ParaId>;
......
......@@ -158,16 +158,16 @@ decl_storage! {
NextFreeId: ParaId = LOWEST_USER_ID;
/// Pending swap operations.
PendingSwap: map ParaId => Option<ParaId>;
PendingSwap: map hasher(blake2_256) ParaId => Option<ParaId>;
/// Map of all registered parathreads/chains.
Paras get(paras): map ParaId => Option<ParaInfo>;
Paras get(paras): map hasher(blake2_256) ParaId => Option<ParaInfo>;
/// The current queue for parathreads that should be retried.
RetryQueue get(retry_queue): Vec<Vec<(ParaId, CollatorId)>>;
/// Users who have paid a parathread's deposit
Debtors: map ParaId => T::AccountId;
Debtors: map hasher(blake2_256) ParaId => T::AccountId;
}
add_extra_genesis {
config(parachains): Vec<(ParaId, Vec<u8>, Vec<u8>)>;
......
......@@ -146,7 +146,7 @@ decl_storage! {
/// If a parachain doesn't exist *yet* but is scheduled to exist in the future, then it
/// will be left-padded with one or more zeroes to denote the fact that nothing is held on
/// deposit for the non-existent chain currently, but is held at some point in the future.
pub Deposits get(deposits): map ParaId => Vec<BalanceOf<T>>;
pub Deposits get(deposits): map hasher(blake2_256) ParaId => Vec<BalanceOf<T>>;
/// Information relating to the current auction, if there is one.
///
......@@ -158,26 +158,28 @@ decl_storage! {
/// The winning bids for each of the 10 ranges at each block in the final Ending Period of
/// the current auction. The map's key is the 0-based index into the Ending Period. The
/// first block of the ending period is 0; the last is `EndingPeriod - 1`.
pub Winning get(winning): map T::BlockNumber => Option<WinningData<T>>;
pub Winning get(winning): map hasher(blake2_256) T::BlockNumber => Option<WinningData<T>>;
/// Amounts currently reserved in the accounts of the bidders currently winning
/// (sub-)ranges.
pub ReservedAmounts get(reserved_amounts): map Bidder<T::AccountId> => Option<BalanceOf<T>>;
pub ReservedAmounts get(reserved_amounts):
map hasher(blake2_256) Bidder<T::AccountId> => Option<BalanceOf<T>>;
/// The set of Para IDs that have won and need to be on-boarded at an upcoming lease-period.
/// This is cleared out on the first block of the lease period.
pub OnboardQueue get(onboard_queue): map LeasePeriodOf<T> => Vec<ParaId>;
pub OnboardQueue get(onboard_queue): map hasher(blake2_256) LeasePeriodOf<T> => Vec<ParaId>;
/// The actual on-boarding information. Only exists when one of the following is true:
/// - It is before the lease period that the parachain should be on-boarded.
/// - The full on-boarding information has not yet been provided and the parachain is not
/// yet due to be off-boarded.
pub Onboarding get(onboarding): map ParaId =>
pub Onboarding get(onboarding):
map hasher(blake2_256) ParaId =>
Option<(LeasePeriodOf<T>, IncomingParachain<T::AccountId, T::Hash>)>;
/// Off-boarding account; currency held on deposit for the parachain gets placed here if the
/// parachain gets off-boarded; i.e. its lease period is up and it isn't renewed.
pub Offboarding get(offboarding): map ParaId => T::AccountId;
pub Offboarding get(offboarding): map hasher(blake2_256) ParaId => T::AccountId;
}
}
......
......@@ -804,6 +804,12 @@ sp_api::impl_runtime_apis! {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
SessionKeys::generate(seed)
}
fn decode_session_keys(
encoded: Vec<u8>,
) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
SessionKeys::decode_into_raw_public_keys(&encoded)
}
}
impl system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
......
......@@ -78,7 +78,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polkadot"),
impl_name: create_runtime_str!("parity-polkadot"),
authoring_version: 2,
spec_version: 1000,
spec_version: 1001,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
};
......@@ -725,6 +725,12 @@ sp_api::impl_runtime_apis! {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
SessionKeys::generate(seed)
}
fn decode_session_keys(
encoded: Vec<u8>,
) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
SessionKeys::decode_into_raw_public_keys(&encoded)
}
}
impl system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
......
......@@ -18,7 +18,11 @@
pub mod chain_spec;
use futures::{FutureExt, compat::Future01CompatExt};
use futures::{
FutureExt, TryFutureExt,
task::{Spawn, SpawnError, FutureObj},
compat::Future01CompatExt,
};
use sc_client::LongestChain;
use std::sync::Arc;
use std::time::Duration;
......@@ -172,9 +176,7 @@ macro_rules! new_full_start {
.with_transaction_pool(|config, client, _fetcher| {
let pool_api = sc_transaction_pool::FullChainApi::new(client.clone());
let pool = sc_transaction_pool::BasicPool::new(config, pool_api);
let maintainer = sc_transaction_pool::FullBasicPoolMaintainer::new(pool.pool().clone(), client);
let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer);
Ok(maintainable_pool)
Ok(pool)
})?
.with_import_queue(|_config, client, mut select_chain, _| {
let select_chain = select_chain.take()
......@@ -400,7 +402,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
max_block_data_size,
}.build();
service.spawn_essential_task(Box::pin(validation_service));
service.spawn_essential_task("validation-service", Box::pin(validation_service));
let proposer = consensus::ProposerFactory::new(
client.clone(),
......@@ -435,7 +437,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
};
let babe = babe::start_babe(babe_config)?;
service.spawn_essential_task(babe);
service.spawn_essential_task("babe", babe);
if authority_discovery_enabled {
let network = service.network();
......@@ -451,7 +453,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
service.keystore(),
dht_event_stream,
);
service.spawn_task(authority_discovery);
service.spawn_task("authority-discovery", authority_discovery);
}
}
......@@ -493,7 +495,8 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
};
service.spawn_essential_task(
grandpa::run_grandpa_voter(grandpa_config)?.compat().map(drop)
"grandpa-voter",
grandpa::run_grandpa_voter(grandpa_config)?
);
} else {
grandpa::setup_disabled_grandpa(
......@@ -585,10 +588,10 @@ where
let fetcher = fetcher
.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
let pool_api = sc_transaction_pool::LightChainApi::new(client.clone(), fetcher.clone());
let pool = sc_transaction_pool::BasicPool::new(config, pool_api);
let maintainer = sc_transaction_pool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher);
let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer);
Ok(maintainable_pool)
let pool = sc_transaction_pool::BasicPool::with_revalidation_type(
config, pool_api, sc_transaction_pool::RevalidationType::Light,
);
Ok(pool)
})?
.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _| {
let fetch_checker = fetcher
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment