mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
Update to lastest Substrate master (#443)
This commit is contained in:
committed by
Robert Habermeier
parent
444a19ec5f
commit
4f4baa9b07
Generated
+189
-182
File diff suppressed because it is too large
Load Diff
@@ -306,7 +306,7 @@ impl<P, E> Worker for CollationNode<P, E> where
|
|||||||
};
|
};
|
||||||
|
|
||||||
let is_known = move |block_hash: &Hash| {
|
let is_known = move |block_hash: &Hash| {
|
||||||
use client::BlockStatus;
|
use consensus_common::BlockStatus;
|
||||||
use polkadot_network::gossip::Known;
|
use polkadot_network::gossip::Known;
|
||||||
|
|
||||||
match known_oracle.block_status(&BlockId::hash(*block_hash)) {
|
match known_oracle.block_status(&BlockId::hash(*block_hash)) {
|
||||||
|
|||||||
@@ -21,14 +21,10 @@
|
|||||||
|
|
||||||
use rstd::prelude::*;
|
use rstd::prelude::*;
|
||||||
use codec::{Encode, Decode};
|
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 primitives::{Hash, parachain::{AttestedCandidate, CandidateReceipt, Id as ParaId}};
|
||||||
use sr_staking_primitives::SessionIndex;
|
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 inherents::{ProvideInherent, InherentData, RuntimeString, MakeFatalError, InherentIdentifier};
|
||||||
use system::ensure_none;
|
use system::ensure_none;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
use rstd::prelude::*;
|
use rstd::prelude::*;
|
||||||
use sr_io::{keccak_256, secp256k1_ecdsa_recover};
|
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 srml_support::traits::{Currency, Get};
|
||||||
use system::ensure_none;
|
use system::ensure_none;
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
//! funds ultimately end up in module's fund sub-account.
|
//! funds ultimately end up in module's fund sub-account.
|
||||||
|
|
||||||
use srml_support::{
|
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}
|
traits::{Currency, Get, OnUnbalanced, WithdrawReason, ExistenceRequirement}
|
||||||
};
|
};
|
||||||
use system::ensure_signed;
|
use system::ensure_signed;
|
||||||
|
|||||||
@@ -41,12 +41,11 @@ use client::{
|
|||||||
use sr_primitives::{
|
use sr_primitives::{
|
||||||
ApplyResult, generic, Permill, Perbill, impl_opaque_keys, create_runtime_str, key_types,
|
ApplyResult, generic, Permill, Perbill, impl_opaque_keys, create_runtime_str, key_types,
|
||||||
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
|
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
|
||||||
weights::{Weight, DispatchInfo},
|
weights::{Weight, DispatchInfo}, curve::PiecewiseLinear,
|
||||||
traits::{BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, SignedExtension},
|
traits::{BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension},
|
||||||
curve::PiecewiseLinear,
|
|
||||||
};
|
};
|
||||||
use version::RuntimeVersion;
|
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 babe_primitives::AuthorityId as BabeId;
|
||||||
use elections::VoteIndex;
|
use elections::VoteIndex;
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
@@ -662,45 +661,25 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl fg_primitives::GrandpaApi<Block> for Runtime {
|
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)> {
|
fn grandpa_authorities() -> Vec<(GrandpaId, u64)> {
|
||||||
Grandpa::grandpa_authorities()
|
Grandpa::grandpa_authorities()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl babe_primitives::BabeApi<Block> for Runtime {
|
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
|
// The choice of `c` parameter (where `1 - c` represents the
|
||||||
// probability of a slot being empty), is done in accordance to the
|
// probability of a slot being empty), is done in accordance to the
|
||||||
// slot duration and expected target block time, for safely
|
// slot duration and expected target block time, for safely
|
||||||
// resisting network delays of maximum two seconds.
|
// resisting network delays of maximum two seconds.
|
||||||
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
|
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
|
||||||
babe_primitives::BabeConfiguration {
|
babe_primitives::BabeConfiguration {
|
||||||
median_required_blocks: 1000,
|
|
||||||
slot_duration: Babe::slot_duration(),
|
slot_duration: Babe::slot_duration(),
|
||||||
|
epoch_length: EpochDuration::get(),
|
||||||
c: PRIMARY_PROBABILITY,
|
c: PRIMARY_PROBABILITY,
|
||||||
}
|
genesis_authorities: Babe::authorities(),
|
||||||
}
|
|
||||||
|
|
||||||
fn epoch() -> babe_primitives::Epoch {
|
|
||||||
babe_primitives::Epoch {
|
|
||||||
start_slot: Babe::epoch_start_slot(),
|
|
||||||
authorities: Babe::authorities(),
|
|
||||||
epoch_index: Babe::epoch_index(),
|
|
||||||
randomness: Babe::randomness(),
|
randomness: Babe::randomness(),
|
||||||
duration: EpochDuration::get(),
|
secondary_slots: true,
|
||||||
secondary_slots: Babe::secondary_slots().0,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ use primitives::{Hash, Balance, parachain::{
|
|||||||
}};
|
}};
|
||||||
use {system, session};
|
use {system, session};
|
||||||
use srml_support::{
|
use srml_support::{
|
||||||
StorageValue, StorageMap, Parameter, dispatch::Result,
|
Parameter, dispatch::Result, traits::{Currency, Get, WithdrawReason, ExistenceRequirement},
|
||||||
traits::{Currency, Get, WithdrawReason, ExistenceRequirement}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use inherents::{ProvideInherent, InherentData, RuntimeString, MakeFatalError, InherentIdentifier};
|
use inherents::{ProvideInherent, InherentData, RuntimeString, MakeFatalError, InherentIdentifier};
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ use sr_primitives::traits::{CheckedSub, StaticLookup, Zero, One, CheckedConversi
|
|||||||
use sr_primitives::weights::SimpleDispatchInfo;
|
use sr_primitives::weights::SimpleDispatchInfo;
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
use srml_support::{
|
use srml_support::{
|
||||||
decl_module, decl_storage, decl_event, StorageValue, StorageMap, ensure,
|
decl_module, decl_storage, decl_event, StorageMap, ensure,
|
||||||
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get}
|
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get},
|
||||||
};
|
};
|
||||||
use primitives::parachain::AccountIdConversion;
|
use primitives::parachain::AccountIdConversion;
|
||||||
use crate::parachains::ParachainRegistrar;
|
use crate::parachains::ParachainRegistrar;
|
||||||
|
|||||||
+33
-36
@@ -27,7 +27,7 @@ use polkadot_runtime::GenesisConfig;
|
|||||||
use polkadot_network::{gossip::{self as network_gossip, Known}, validation::ValidationNetwork};
|
use polkadot_network::{gossip::{self as network_gossip, Known}, validation::ValidationNetwork};
|
||||||
use service::{error::{Error as ServiceError}, Configuration, ServiceBuilder};
|
use service::{error::{Error as ServiceError}, Configuration, ServiceBuilder};
|
||||||
use transaction_pool::txpool::{Pool as TransactionPool};
|
use transaction_pool::txpool::{Pool as TransactionPool};
|
||||||
use babe::{import_queue, start_babe, Config};
|
use babe::{import_queue, start_babe};
|
||||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||||
use inherents::InherentDataProviders;
|
use inherents::InherentDataProviders;
|
||||||
use log::info;
|
use log::info;
|
||||||
@@ -79,8 +79,6 @@ macro_rules! new_full_start {
|
|||||||
($config:expr) => {{
|
($config:expr) => {{
|
||||||
let mut import_setup = None;
|
let mut import_setup = None;
|
||||||
let inherent_data_providers = inherents::InherentDataProviders::new();
|
let inherent_data_providers = inherents::InherentDataProviders::new();
|
||||||
let mut tasks_to_spawn = None;
|
|
||||||
|
|
||||||
let builder = service::ServiceBuilder::new_full::<
|
let builder = service::ServiceBuilder::new_full::<
|
||||||
Block, RuntimeApi, polkadot_executor::Executor
|
Block, RuntimeApi, polkadot_executor::Executor
|
||||||
>($config)?
|
>($config)?
|
||||||
@@ -90,33 +88,37 @@ macro_rules! new_full_start {
|
|||||||
.with_transaction_pool(|config, client|
|
.with_transaction_pool(|config, client|
|
||||||
Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::ChainApi::new(client)))
|
Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::ChainApi::new(client)))
|
||||||
)?
|
)?
|
||||||
.with_import_queue(|_config, client, mut select_chain, transaction_pool| {
|
.with_import_queue(|_config, client, mut select_chain, _| {
|
||||||
let select_chain = select_chain.take()
|
let select_chain = select_chain.take()
|
||||||
.ok_or_else(|| service::Error::SelectChainRequired)?;
|
.ok_or_else(|| service::Error::SelectChainRequired)?;
|
||||||
let (block_import, link_half) =
|
let (grandpa_block_import, grandpa_link) =
|
||||||
grandpa::block_import::<_, _, _, RuntimeApi, _, _>(
|
grandpa::block_import::<_, _, _, RuntimeApi, _, _>(
|
||||||
client.clone(), client.clone(), select_chain
|
client.clone(), &*client, select_chain
|
||||||
)?;
|
)?;
|
||||||
let justification_import = block_import.clone();
|
let justification_import = grandpa_block_import.clone();
|
||||||
|
|
||||||
let (import_queue, babe_link, babe_block_import, pruning_task) = babe::import_queue(
|
let (block_import, babe_link) = babe::block_import(
|
||||||
babe::Config::get_or_compute(&*client)?,
|
babe::Config::get_or_compute(&*client)?,
|
||||||
block_import,
|
grandpa_block_import,
|
||||||
|
client.clone(),
|
||||||
|
client.clone(),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let import_queue = babe::import_queue(
|
||||||
|
babe_link.clone(),
|
||||||
|
block_import.clone(),
|
||||||
Some(Box::new(justification_import)),
|
Some(Box::new(justification_import)),
|
||||||
None,
|
None,
|
||||||
client.clone(),
|
client.clone(),
|
||||||
client,
|
client,
|
||||||
inherent_data_providers.clone(),
|
inherent_data_providers.clone(),
|
||||||
Some(transaction_pool)
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
import_setup = Some((babe_block_import.clone(), link_half, babe_link));
|
import_setup = Some((block_import, grandpa_link, babe_link));
|
||||||
tasks_to_spawn = Some(vec![Box::new(pruning_task)]);
|
|
||||||
|
|
||||||
Ok(import_queue)
|
Ok(import_queue)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
(builder, import_setup, inherent_data_providers, tasks_to_spawn)
|
(builder, import_setup, inherent_data_providers)
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +146,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
let disable_grandpa = config.disable_grandpa;
|
let disable_grandpa = config.disable_grandpa;
|
||||||
let name = config.name.clone();
|
let name = config.name.clone();
|
||||||
|
|
||||||
let (builder, mut import_setup, inherent_data_providers, mut tasks_to_spawn) = new_full_start!(config);
|
let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config);
|
||||||
|
|
||||||
let service = builder
|
let service = builder
|
||||||
.with_network_protocol(|config| Ok(PolkadotProtocol::new(config.custom.collating_for.clone())))?
|
.with_network_protocol(|config| Ok(PolkadotProtocol::new(config.custom.collating_for.clone())))?
|
||||||
@@ -156,17 +158,6 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
let (block_import, link_half, babe_link) = import_setup.take()
|
let (block_import, link_half, babe_link) = import_setup.take()
|
||||||
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
|
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
|
||||||
|
|
||||||
// spawn any futures that were created in the previous setup steps
|
|
||||||
if let Some(tasks) = tasks_to_spawn.take() {
|
|
||||||
for task in tasks {
|
|
||||||
service.spawn_task(
|
|
||||||
task.select(service.on_exit())
|
|
||||||
.map(|_| ())
|
|
||||||
.map_err(|_| ())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if is_collator {
|
if is_collator {
|
||||||
info!(
|
info!(
|
||||||
"The node cannot start as an authority because it is also configured to run as a collator."
|
"The node cannot start as an authority because it is also configured to run as a collator."
|
||||||
@@ -185,7 +176,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
let gossip_validator_select_chain = select_chain.clone();
|
let gossip_validator_select_chain = select_chain.clone();
|
||||||
|
|
||||||
let is_known = move |block_hash: &Hash| {
|
let is_known = move |block_hash: &Hash| {
|
||||||
use client::BlockStatus;
|
use consensus_common::BlockStatus;
|
||||||
|
|
||||||
match known_oracle.block_status(&BlockId::hash(*block_hash)) {
|
match known_oracle.block_status(&BlockId::hash(*block_hash)) {
|
||||||
Err(_) | Ok(BlockStatus::Unknown) | Ok(BlockStatus::Queued) => None,
|
Err(_) | Ok(BlockStatus::Unknown) | Ok(BlockStatus::Queued) => None,
|
||||||
@@ -253,7 +244,6 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
let select_chain = service.select_chain().ok_or(ServiceError::SelectChainRequired)?;
|
let select_chain = service.select_chain().ok_or(ServiceError::SelectChainRequired)?;
|
||||||
|
|
||||||
let babe_config = babe::BabeParams {
|
let babe_config = babe::BabeParams {
|
||||||
config: Config::get_or_compute(&*client)?,
|
|
||||||
keystore: service.keystore(),
|
keystore: service.keystore(),
|
||||||
client,
|
client,
|
||||||
select_chain,
|
select_chain,
|
||||||
@@ -262,7 +252,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
sync_oracle: service.network(),
|
sync_oracle: service.network(),
|
||||||
inherent_data_providers: inherent_data_providers.clone(),
|
inherent_data_providers: inherent_data_providers.clone(),
|
||||||
force_authoring: force_authoring,
|
force_authoring: force_authoring,
|
||||||
time_source: babe_link,
|
babe_link,
|
||||||
};
|
};
|
||||||
|
|
||||||
let babe = start_babe(babe_config)?;
|
let babe = start_babe(babe_config)?;
|
||||||
@@ -332,28 +322,35 @@ pub fn new_light(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
.with_transaction_pool(|config, client|
|
.with_transaction_pool(|config, client|
|
||||||
Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client)))
|
Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client)))
|
||||||
)?
|
)?
|
||||||
.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, transaction_pool| {
|
.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _| {
|
||||||
let fetch_checker = fetcher
|
let fetch_checker = fetcher
|
||||||
.map(|fetcher| fetcher.checker().clone())
|
.map(|fetcher| fetcher.checker().clone())
|
||||||
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
|
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
|
||||||
let block_import = grandpa::light_block_import::<_, _, _, RuntimeApi, _>(
|
let grandpa_block_import = grandpa::light_block_import::<_, _, _, RuntimeApi, _>(
|
||||||
client.clone(), backend, Arc::new(fetch_checker), client.clone()
|
client.clone(), backend, Arc::new(fetch_checker), client.clone()
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let finality_proof_import = block_import.clone();
|
let finality_proof_import = grandpa_block_import.clone();
|
||||||
let finality_proof_request_builder =
|
let finality_proof_request_builder =
|
||||||
finality_proof_import.create_finality_proof_request_builder();
|
finality_proof_import.create_finality_proof_request_builder();
|
||||||
|
|
||||||
|
|
||||||
|
let (babe_block_import, babe_link) = babe::block_import(
|
||||||
|
babe::Config::get_or_compute(&*client)?,
|
||||||
|
grandpa_block_import,
|
||||||
|
client.clone(),
|
||||||
|
client.clone(),
|
||||||
|
)?;
|
||||||
|
|
||||||
// FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`.
|
// FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`.
|
||||||
let (import_queue, ..) = import_queue(
|
let import_queue = import_queue(
|
||||||
Config::get_or_compute(&*client)?,
|
babe_link,
|
||||||
block_import,
|
babe_block_import,
|
||||||
None,
|
None,
|
||||||
Some(Box::new(finality_proof_import)),
|
Some(Box::new(finality_proof_import)),
|
||||||
client.clone(),
|
client.clone(),
|
||||||
client,
|
client,
|
||||||
inherent_data_providers.clone(),
|
inherent_data_providers.clone(),
|
||||||
Some(transaction_pool)
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok((import_queue, finality_proof_request_builder))
|
Ok((import_queue, finality_proof_request_builder))
|
||||||
|
|||||||
Reference in New Issue
Block a user