Companion for paritytech/substrate#12219 (#1610)

* Remove CanAuthorWith trait

CanAuthotWith trait removed. Also all dependencies, parameters, type
paramers were removed. This is related to removal of native runtime.

* Companion for paritytech/substrate#12219

* Fixes

* polkadot-runtime-common updated

cargo update -p polkadot-runtime-common

* warning fixed

* Update cid

* update lockfile for {"polkadot", "substrate"}

* Update substrate

* update lockfile for {"polkadot", "substrate"}

* Update polkadot

* Fix tests

* 🤦

Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
Co-authored-by: parity-processbot <>
Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
Keith Yeung
2022-09-14 15:59:03 +08:00
committed by GitHub
parent 68ba7e544d
commit 2072bdf777
20 changed files with 486 additions and 361 deletions
+407 -287
View File
File diff suppressed because it is too large Load Diff
@@ -25,7 +25,7 @@ use sc_telemetry::TelemetryHandle;
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::HeaderBackend;
use sp_consensus::{CanAuthorWith, Error as ConsensusError};
use sp_consensus::Error as ConsensusError;
use sp_consensus_aura::AuraApi;
use sp_core::crypto::Pair;
use sp_inherents::CreateInherentDataProviders;
@@ -34,7 +34,7 @@ use std::{fmt::Debug, hash::Hash, sync::Arc};
use substrate_prometheus_endpoint::Registry;
/// Parameters of [`import_queue`].
pub struct ImportQueueParams<'a, I, C, CIDP, S, CAW> {
pub struct ImportQueueParams<'a, I, C, CIDP, S> {
/// The block import to use.
pub block_import: I,
/// The client to interact with the chain.
@@ -45,23 +45,20 @@ pub struct ImportQueueParams<'a, I, C, CIDP, S, CAW> {
pub spawner: &'a S,
/// The prometheus registry.
pub registry: Option<&'a Registry>,
/// Can we author with the current node?
pub can_author_with: CAW,
/// The telemetry handle.
pub telemetry: Option<TelemetryHandle>,
}
/// Start an import queue for the Aura consensus algorithm.
pub fn import_queue<'a, P, Block, I, C, S, CAW, CIDP>(
pub fn import_queue<'a, P, Block, I, C, S, CIDP>(
ImportQueueParams {
block_import,
client,
create_inherent_data_providers,
spawner,
registry,
can_author_with,
telemetry,
}: ImportQueueParams<'a, I, C, CIDP, S, CAW>,
}: ImportQueueParams<'a, I, C, CIDP, S>,
) -> Result<DefaultImportQueue<Block, C>, sp_consensus::Error>
where
Block: BlockT,
@@ -82,48 +79,41 @@ where
P::Public: Clone + Eq + Send + Sync + Hash + Debug + Codec,
P::Signature: Codec,
S: sp_core::traits::SpawnEssentialNamed,
CAW: CanAuthorWith<Block> + Send + Sync + 'static,
CIDP: CreateInherentDataProviders<Block, ()> + Sync + Send + 'static,
CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync,
{
sc_consensus_aura::import_queue::<P, _, _, _, _, _, _>(sc_consensus_aura::ImportQueueParams {
sc_consensus_aura::import_queue::<P, _, _, _, _, _>(sc_consensus_aura::ImportQueueParams {
block_import: cumulus_client_consensus_common::ParachainBlockImport::new(block_import),
justification_import: None,
client,
create_inherent_data_providers,
spawner,
registry,
can_author_with,
check_for_equivocation: sc_consensus_aura::CheckForEquivocation::No,
telemetry,
})
}
/// Parameters of [`build_verifier`].
pub struct BuildVerifierParams<C, CIDP, CAW> {
pub struct BuildVerifierParams<C, CIDP> {
/// The client to interact with the chain.
pub client: Arc<C>,
/// The inherent data providers, to create the inherent data.
pub create_inherent_data_providers: CIDP,
/// Can we author with the current node?
pub can_author_with: CAW,
/// The telemetry handle.
pub telemetry: Option<TelemetryHandle>,
}
/// Build the [`AuraVerifier`].
pub fn build_verifier<P, C, CIDP, CAW>(
BuildVerifierParams {
client,
create_inherent_data_providers,
can_author_with,
telemetry,
}: BuildVerifierParams<C, CIDP, CAW>,
) -> AuraVerifier<C, P, CAW, CIDP> {
pub fn build_verifier<P, C, CIDP>(
BuildVerifierParams { client, create_inherent_data_providers, telemetry }: BuildVerifierParams<
C,
CIDP,
>,
) -> AuraVerifier<C, P, CIDP> {
sc_consensus_aura::build_verifier(sc_consensus_aura::BuildVerifierParams {
client,
create_inherent_data_providers,
can_author_with,
telemetry,
check_for_equivocation: sc_consensus_aura::CheckForEquivocation::No,
})
@@ -77,7 +77,7 @@ pub mod pallet {
pub use crate::weights::WeightInfo;
use core::ops::Div;
use frame_support::{
dispatch::DispatchResultWithPostInfo,
dispatch::{DispatchClass, DispatchResultWithPostInfo},
inherent::Vec,
pallet_prelude::*,
sp_runtime::{
@@ -88,7 +88,6 @@ pub mod pallet {
Currency, EnsureOrigin, ExistenceRequirement::KeepAlive, ReservableCurrency,
ValidatorRegistration,
},
weights::DispatchClass,
BoundedVec, PalletId,
};
use frame_system::{pallet_prelude::*, Config as SystemConfig};
+3 -2
View File
@@ -24,7 +24,8 @@
use codec::{Decode, DecodeLimit, Encode};
use cumulus_primitives_core::{relay_chain::BlockNumber as RelayBlockNumber, DmpMessageHandler};
use frame_support::{
dispatch::Weight, traits::EnsureOrigin, weights::constants::WEIGHT_PER_MILLIS,
traits::EnsureOrigin,
weights::{constants::WEIGHT_PER_MILLIS, Weight},
};
pub use pallet::*;
use scale_info::TypeInfo;
@@ -760,7 +761,7 @@ mod tests {
super::Call::<Test>::service_overweight { index: 0, weight_limit: Weight::zero() }
.get_dispatch_info()
.weight;
use frame_support::weights::GetDispatchInfo;
use frame_support::dispatch::GetDispatchInfo;
let info =
DmpQueue::service_overweight(Origin::root(), 0, Weight::from_ref_time(20000))
.unwrap();
+2 -2
View File
@@ -36,12 +36,12 @@ use cumulus_primitives_core::{
};
use cumulus_primitives_parachain_inherent::{MessageQueueChain, ParachainInherentData};
use frame_support::{
dispatch::{DispatchError, DispatchResult},
dispatch::{DispatchError, DispatchResult, Pays, PostDispatchInfo},
ensure,
inherent::{InherentData, InherentIdentifier, ProvideInherent},
storage,
traits::Get,
weights::{Pays, PostDispatchInfo, Weight},
weights::Weight,
};
use frame_system::{ensure_none, ensure_root};
use polkadot_parachain::primitives::RelayChainBlockNumber;
+4 -1
View File
@@ -18,7 +18,10 @@
use codec::{Decode, Encode};
use cumulus_pallet_parachain_system as parachain_system;
use frame_support::{dispatch::DispatchResult, pallet_prelude::*, weights::DispatchInfo};
use frame_support::{
dispatch::{DispatchInfo, DispatchResult},
pallet_prelude::*,
};
use frame_system::pallet_prelude::*;
pub use pallet::*;
use polkadot_primitives::v2::PersistedValidationData;
@@ -25,7 +25,6 @@ use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayC
use cumulus_relay_chain_rpc_interface::{create_client_and_start_worker, RelayChainRpcInterface};
// Substrate Imports
use sc_client_api::ExecutorProvider;
use sc_executor::NativeElseWasmExecutor;
use sc_network::NetworkService;
use sc_network_common::service::NetworkBlock;
@@ -424,7 +423,6 @@ pub fn parachain_build_import_queue(
_,
_,
_,
_,
>(cumulus_client_consensus_aura::ImportQueueParams {
block_import: client.clone(),
client: client.clone(),
@@ -440,7 +438,6 @@ pub fn parachain_build_import_queue(
Ok((time, slot))
},
registry: config.prometheus_registry(),
can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),
spawner: &task_manager.spawn_essential_handle(),
telemetry,
})
@@ -26,11 +26,13 @@ use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use frame_support::{
construct_runtime, parameter_types,
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::Everything,
weights::{
constants::WEIGHT_PER_SECOND, ConstantMultiplier, DispatchClass, Weight,
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
constants::WEIGHT_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient,
WeightToFeeCoefficients, WeightToFeePolynomial,
},
PalletId,
};
@@ -46,9 +46,11 @@ use sp_version::RuntimeVersion;
use codec::{Decode, Encode, MaxEncodedLen};
use constants::{currency::*, fee::WeightToFee};
use frame_support::{
construct_runtime, parameter_types,
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::{AsEnsureOriginWithArg, EitherOfDiverse, InstanceFilter},
weights::{ConstantMultiplier, DispatchClass, Weight},
weights::{ConstantMultiplier, Weight},
PalletId, RuntimeDebug,
};
use frame_system::{
@@ -75,9 +75,11 @@ use sp_version::RuntimeVersion;
use codec::{Decode, Encode, MaxEncodedLen};
use constants::{currency::*, fee::WeightToFee};
use frame_support::{
construct_runtime, parameter_types,
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::{AsEnsureOriginWithArg, EitherOfDiverse, InstanceFilter},
weights::{ConstantMultiplier, DispatchClass, Weight},
weights::{ConstantMultiplier, Weight},
PalletId, RuntimeDebug,
};
use frame_system::{
@@ -46,9 +46,11 @@ use sp_version::RuntimeVersion;
use codec::{Decode, Encode, MaxEncodedLen};
use constants::{currency::*, fee::WeightToFee};
use frame_support::{
construct_runtime, parameter_types,
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::{AsEnsureOriginWithArg, InstanceFilter},
weights::{ConstantMultiplier, DispatchClass, Weight},
weights::{ConstantMultiplier, Weight},
PalletId, RuntimeDebug,
};
use frame_system::{
@@ -61,9 +61,11 @@ use sp_version::RuntimeVersion;
use codec::{Decode, Encode, MaxEncodedLen};
use constants::{currency::*, fee::WeightToFee};
use frame_support::{
construct_runtime, parameter_types,
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::{ConstU16, ConstU32, ConstU64, ConstU8, EitherOfDiverse, InstanceFilter},
weights::{ConstantMultiplier, DispatchClass, Weight},
weights::{ConstantMultiplier, Weight},
PalletId, RuntimeDebug,
};
use frame_system::{
@@ -47,9 +47,11 @@ use sp_version::RuntimeVersion;
use constants::{currency::*, fee::WeightToFee};
use frame_support::{
construct_runtime, parameter_types,
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::{ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, Everything},
weights::{ConstantMultiplier, DispatchClass, Weight},
weights::{ConstantMultiplier, Weight},
PalletId,
};
use frame_system::limits::{BlockLength, BlockWeights};
@@ -43,11 +43,13 @@ use sp_version::RuntimeVersion;
// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, parameter_types,
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::{IsInVec, Randomness},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
DispatchClass, IdentityFee, Weight,
IdentityFee, Weight,
},
StorageValue,
};
@@ -50,11 +50,13 @@ use sp_version::RuntimeVersion;
// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, parameter_types,
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::{Everything, IsInVec, Randomness},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
DispatchClass, IdentityFee, Weight,
IdentityFee, Weight,
},
StorageValue,
};
@@ -32,11 +32,13 @@ pub mod xcm_config;
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use frame_support::{
construct_runtime, parameter_types,
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::Everything,
weights::{
constants::WEIGHT_PER_SECOND, ConstantMultiplier, DispatchClass, Weight,
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
constants::WEIGHT_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient,
WeightToFeeCoefficients, WeightToFeePolynomial,
},
PalletId,
};
@@ -38,11 +38,13 @@ use sp_version::RuntimeVersion;
// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, match_types, parameter_types,
construct_runtime,
dispatch::DispatchClass,
match_types, parameter_types,
traits::{EitherOfDiverse, Everything, IsInVec, Randomness},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
ConstantMultiplier, DispatchClass, IdentityFee, Weight,
ConstantMultiplier, IdentityFee, Weight,
},
StorageValue,
};
+2 -9
View File
@@ -710,7 +710,6 @@ pub fn rococo_parachain_build_import_queue(
_,
_,
_,
_,
>(cumulus_client_consensus_aura::ImportQueueParams {
block_import: client.clone(),
client,
@@ -726,7 +725,6 @@ pub fn rococo_parachain_build_import_queue(
Ok((timestamp, slot))
},
registry: config.prometheus_registry(),
can_author_with: sp_consensus::AlwaysCanAuthor,
spawner: &task_manager.spawn_essential_handle(),
telemetry,
})
@@ -1086,8 +1084,7 @@ where
let aura_verifier = move || {
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client2).unwrap();
Box::new(
cumulus_client_consensus_aura::build_verifier::<<AuraId as AppKey>::Pair, _, _, _>(
Box::new(cumulus_client_consensus_aura::build_verifier::<<AuraId as AppKey>::Pair, _, _>(
cumulus_client_consensus_aura::BuildVerifierParams {
client: client2.clone(),
create_inherent_data_providers: move |_, _| async move {
@@ -1101,11 +1098,9 @@ where
Ok((timestamp, slot))
},
can_author_with: sp_consensus::AlwaysCanAuthor,
telemetry: telemetry_handle,
},
),
) as Box<_>
)) as Box<_>
};
let relay_chain_verifier =
@@ -1530,7 +1525,6 @@ pub fn contracts_rococo_build_import_queue(
_,
_,
_,
_,
>(cumulus_client_consensus_aura::ImportQueueParams {
block_import: client.clone(),
client,
@@ -1546,7 +1540,6 @@ pub fn contracts_rococo_build_import_queue(
Ok((timestamp, slot))
},
registry: config.prometheus_registry(),
can_author_with: sp_consensus::AlwaysCanAuthor,
spawner: &task_manager.spawn_essential_handle(),
telemetry,
})
+4 -2
View File
@@ -45,11 +45,13 @@ use sp_version::RuntimeVersion;
// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, parameter_types,
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::Randomness,
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
ConstantMultiplier, DispatchClass, IdentityFee, Weight,
ConstantMultiplier, IdentityFee, Weight,
},
StorageValue,
};
+1 -1
View File
@@ -608,7 +608,7 @@ pub fn node_config(
is_collator: bool,
) -> Result<Configuration, ServiceError> {
let base_path = BasePath::new_temp_dir()?;
let root = base_path.path().to_path_buf();
let root = base_path.path().join(format!("cumulus_test_service_{}", key.to_string()));
let role = if is_collator { Role::Authority } else { Role::Full };
let key_seed = key.to_seed();
let mut spec = Box::new(chain_spec::get_chain_spec(para_id));