mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
Update Substrate & Polkadot (#557)
* Update Substrate & Polkadot * Format * Update again
This commit is contained in:
@@ -18,33 +18,38 @@ use cumulus_client_consensus_aura::{
|
||||
build_aura_consensus, BuildAuraConsensusParams, SlotProportion,
|
||||
};
|
||||
use cumulus_client_consensus_common::{
|
||||
ParachainConsensus, ParachainCandidate, ParachainBlockImport,
|
||||
ParachainBlockImport, ParachainCandidate, ParachainConsensus,
|
||||
};
|
||||
use cumulus_client_network::build_block_announce_validator;
|
||||
use cumulus_client_service::{
|
||||
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
|
||||
};
|
||||
use cumulus_primitives_core::{
|
||||
ParaId, relay_chain::v1::{Hash as PHash, PersistedValidationData},
|
||||
relay_chain::v1::{Hash as PHash, PersistedValidationData},
|
||||
ParaId,
|
||||
};
|
||||
|
||||
use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier;
|
||||
use futures::lock::Mutex;
|
||||
use sc_client_api::ExecutorProvider;
|
||||
use sc_consensus::{
|
||||
import_queue::{BasicQueue, Verifier as VerifierT},
|
||||
BlockImportParams,
|
||||
};
|
||||
use sc_executor::native_executor_instance;
|
||||
use sc_network::NetworkService;
|
||||
use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager};
|
||||
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
|
||||
use sp_api::{ConstructRuntimeApi, ApiExt};
|
||||
use sp_consensus::{
|
||||
BlockImportParams, BlockOrigin, SlotData,
|
||||
import_queue::{BasicQueue, CacheKeyId, Verifier as VerifierT},
|
||||
};
|
||||
use sp_api::{ApiExt, ConstructRuntimeApi};
|
||||
use sp_consensus::{CacheKeyId, SlotData};
|
||||
use sp_consensus_aura::{sr25519::AuthorityId as AuraId, AuraApi};
|
||||
use sp_keystore::SyncCryptoStorePtr;
|
||||
use sp_runtime::{traits::{BlakeTwo256, Header as HeaderT}, generic::BlockId};
|
||||
use sp_runtime::{
|
||||
generic::BlockId,
|
||||
traits::{BlakeTwo256, Header as HeaderT},
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use substrate_prometheus_endpoint::Registry;
|
||||
use futures::lock::Mutex;
|
||||
use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier;
|
||||
|
||||
pub use sc_executor::NativeExecutor;
|
||||
|
||||
@@ -103,7 +108,7 @@ pub fn new_partial<RuntimeApi, Executor, BIQ>(
|
||||
TFullClient<Block, RuntimeApi, Executor>,
|
||||
TFullBackend<Block>,
|
||||
(),
|
||||
sp_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>,
|
||||
sc_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>,
|
||||
sc_transaction_pool::FullPool<Block, TFullClient<Block, RuntimeApi, Executor>>,
|
||||
(Option<Telemetry>, Option<TelemetryWorkerHandle>),
|
||||
>,
|
||||
@@ -130,7 +135,7 @@ where
|
||||
Option<TelemetryHandle>,
|
||||
&TaskManager,
|
||||
) -> Result<
|
||||
sp_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>,
|
||||
sc_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>,
|
||||
sc_service::Error,
|
||||
>,
|
||||
{
|
||||
@@ -227,7 +232,7 @@ where
|
||||
Option<TelemetryHandle>,
|
||||
&TaskManager,
|
||||
) -> Result<
|
||||
sp_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>,
|
||||
sc_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>,
|
||||
sc_service::Error,
|
||||
>,
|
||||
BIC: FnOnce(
|
||||
@@ -251,14 +256,12 @@ where
|
||||
let params = new_partial::<RuntimeApi, Executor, BIQ>(¶chain_config, build_import_queue)?;
|
||||
let (mut telemetry, telemetry_worker_handle) = params.other;
|
||||
|
||||
let relay_chain_full_node = cumulus_client_service::build_polkadot_full_node(
|
||||
polkadot_config,
|
||||
telemetry_worker_handle,
|
||||
)
|
||||
.map_err(|e| match e {
|
||||
polkadot_service::Error::Sub(x) => x,
|
||||
s => format!("{}", s).into(),
|
||||
})?;
|
||||
let relay_chain_full_node =
|
||||
cumulus_client_service::build_polkadot_full_node(polkadot_config, telemetry_worker_handle)
|
||||
.map_err(|e| match e {
|
||||
polkadot_service::Error::Sub(x) => x,
|
||||
s => format!("{}", s).into(),
|
||||
})?;
|
||||
|
||||
let client = params.client.clone();
|
||||
let backend = params.backend.clone();
|
||||
@@ -284,6 +287,7 @@ where
|
||||
import_queue: import_queue.clone(),
|
||||
on_demand: None,
|
||||
block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)),
|
||||
warp_sync: None,
|
||||
})?;
|
||||
|
||||
let rpc_client = client.clone();
|
||||
@@ -363,7 +367,7 @@ pub fn rococo_parachain_build_import_queue(
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
task_manager: &TaskManager,
|
||||
) -> Result<
|
||||
sp_consensus::DefaultImportQueue<
|
||||
sc_consensus::DefaultImportQueue<
|
||||
Block,
|
||||
TFullClient<Block, rococo_parachain_runtime::RuntimeApi, RococoParachainRuntimeExecutor>,
|
||||
>,
|
||||
@@ -371,29 +375,33 @@ pub fn rococo_parachain_build_import_queue(
|
||||
> {
|
||||
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
|
||||
|
||||
cumulus_client_consensus_aura::import_queue::<sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _>(
|
||||
cumulus_client_consensus_aura::ImportQueueParams {
|
||||
block_import: client.clone(),
|
||||
client: client.clone(),
|
||||
create_inherent_data_providers: move |_, _| async move {
|
||||
let time = sp_timestamp::InherentDataProvider::from_system_time();
|
||||
cumulus_client_consensus_aura::import_queue::<
|
||||
sp_consensus_aura::sr25519::AuthorityPair,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
>(cumulus_client_consensus_aura::ImportQueueParams {
|
||||
block_import: client.clone(),
|
||||
client: client.clone(),
|
||||
create_inherent_data_providers: move |_, _| async move {
|
||||
let time = sp_timestamp::InherentDataProvider::from_system_time();
|
||||
|
||||
let slot =
|
||||
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
|
||||
*time,
|
||||
slot_duration.slot_duration(),
|
||||
);
|
||||
let slot =
|
||||
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
|
||||
*time,
|
||||
slot_duration.slot_duration(),
|
||||
);
|
||||
|
||||
Ok((time, slot))
|
||||
},
|
||||
registry: config.prometheus_registry().clone(),
|
||||
can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(
|
||||
client.executor().clone(),
|
||||
),
|
||||
spawner: &task_manager.spawn_essential_handle(),
|
||||
telemetry,
|
||||
Ok((time, slot))
|
||||
},
|
||||
)
|
||||
registry: config.prometheus_registry().clone(),
|
||||
can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),
|
||||
spawner: &task_manager.spawn_essential_handle(),
|
||||
telemetry,
|
||||
})
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
@@ -499,7 +507,7 @@ pub fn shell_build_import_queue(
|
||||
_: Option<TelemetryHandle>,
|
||||
task_manager: &TaskManager,
|
||||
) -> Result<
|
||||
sp_consensus::DefaultImportQueue<
|
||||
sc_consensus::DefaultImportQueue<
|
||||
Block,
|
||||
TFullClient<Block, shell_runtime::RuntimeApi, ShellRuntimeExecutor>,
|
||||
>,
|
||||
@@ -671,10 +679,7 @@ where
|
||||
{
|
||||
async fn verify(
|
||||
&mut self,
|
||||
origin: BlockOrigin,
|
||||
header: Header,
|
||||
justifications: Option<sp_runtime::Justifications>,
|
||||
body: Option<Vec<<Block as sp_runtime::traits::Block>::Extrinsic>>,
|
||||
block_import: BlockImportParams<Block, ()>,
|
||||
) -> Result<
|
||||
(
|
||||
BlockImportParams<Block, ()>,
|
||||
@@ -682,7 +687,7 @@ where
|
||||
),
|
||||
String,
|
||||
> {
|
||||
let block_id = BlockId::hash(*header.parent_hash());
|
||||
let block_id = BlockId::hash(*block_import.header.parent_hash());
|
||||
|
||||
if self
|
||||
.client
|
||||
@@ -690,14 +695,9 @@ where
|
||||
.has_api::<dyn AuraApi<Block, AuraId>>(&block_id)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
self.aura_verifier
|
||||
.get_mut()
|
||||
.verify(origin, header, justifications, body)
|
||||
.await
|
||||
self.aura_verifier.get_mut().verify(block_import).await
|
||||
} else {
|
||||
self.relay_chain_verifier
|
||||
.verify(origin, header, justifications, body)
|
||||
.await
|
||||
self.relay_chain_verifier.verify(block_import).await
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -709,7 +709,7 @@ pub fn statemint_build_import_queue<RuntimeApi, Executor>(
|
||||
telemetry_handle: Option<TelemetryHandle>,
|
||||
task_manager: &TaskManager,
|
||||
) -> Result<
|
||||
sp_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>,
|
||||
sc_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>,
|
||||
sc_service::Error,
|
||||
>
|
||||
where
|
||||
@@ -786,10 +786,7 @@ pub async fn start_statemint_node<RuntimeApi, Executor>(
|
||||
parachain_config: Configuration,
|
||||
polkadot_config: Configuration,
|
||||
id: ParaId,
|
||||
) -> sc_service::error::Result<(
|
||||
TaskManager,
|
||||
Arc<TFullClient<Block, RuntimeApi, Executor>>,
|
||||
)>
|
||||
) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)>
|
||||
where
|
||||
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>>
|
||||
+ Send
|
||||
@@ -831,39 +828,36 @@ where
|
||||
let telemetry2 = telemetry.clone();
|
||||
let prometheus_registry2 = prometheus_registry.map(|r| (*r).clone());
|
||||
|
||||
let aura_consensus = BuildOnAccess::Uninitialized(Some(
|
||||
Box::new(move || {
|
||||
let slot_duration =
|
||||
cumulus_client_consensus_aura::slot_duration(&*client2).unwrap();
|
||||
let aura_consensus = BuildOnAccess::Uninitialized(Some(Box::new(move || {
|
||||
let slot_duration =
|
||||
cumulus_client_consensus_aura::slot_duration(&*client2).unwrap();
|
||||
|
||||
let proposer_factory =
|
||||
sc_basic_authorship::ProposerFactory::with_proof_recording(
|
||||
spawn_handle,
|
||||
client2.clone(),
|
||||
transaction_pool2,
|
||||
prometheus_registry2.as_ref(),
|
||||
telemetry2.clone(),
|
||||
);
|
||||
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
|
||||
spawn_handle,
|
||||
client2.clone(),
|
||||
transaction_pool2,
|
||||
prometheus_registry2.as_ref(),
|
||||
telemetry2.clone(),
|
||||
);
|
||||
|
||||
let relay_chain_backend2 = relay_chain_backend.clone();
|
||||
let relay_chain_client2 = relay_chain_client.clone();
|
||||
let relay_chain_backend2 = relay_chain_backend.clone();
|
||||
let relay_chain_client2 = relay_chain_client.clone();
|
||||
|
||||
build_aura_consensus::<
|
||||
sp_consensus_aura::sr25519::AuthorityPair,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
>(BuildAuraConsensusParams {
|
||||
proposer_factory,
|
||||
create_inherent_data_providers:
|
||||
move |_, (relay_parent, validation_data)| {
|
||||
let parachain_inherent =
|
||||
build_aura_consensus::<
|
||||
sp_consensus_aura::sr25519::AuthorityPair,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
>(BuildAuraConsensusParams {
|
||||
proposer_factory,
|
||||
create_inherent_data_providers: move |_, (relay_parent, validation_data)| {
|
||||
let parachain_inherent =
|
||||
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at_with_client(
|
||||
relay_parent,
|
||||
&relay_chain_client,
|
||||
@@ -871,42 +865,39 @@ where
|
||||
&validation_data,
|
||||
id,
|
||||
);
|
||||
async move {
|
||||
let time =
|
||||
sp_timestamp::InherentDataProvider::from_system_time();
|
||||
async move {
|
||||
let time = sp_timestamp::InherentDataProvider::from_system_time();
|
||||
|
||||
let slot =
|
||||
let slot =
|
||||
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
|
||||
*time,
|
||||
slot_duration.slot_duration(),
|
||||
);
|
||||
|
||||
let parachain_inherent =
|
||||
parachain_inherent.ok_or_else(|| {
|
||||
Box::<dyn std::error::Error + Send + Sync>::from(
|
||||
"Failed to create parachain inherent",
|
||||
)
|
||||
})?;
|
||||
Ok((time, slot, parachain_inherent))
|
||||
}
|
||||
},
|
||||
block_import: client2.clone(),
|
||||
relay_chain_client: relay_chain_client2,
|
||||
relay_chain_backend: relay_chain_backend2,
|
||||
para_client: client2.clone(),
|
||||
backoff_authoring_blocks: Option::<()>::None,
|
||||
sync_oracle,
|
||||
keystore,
|
||||
force_authoring,
|
||||
slot_duration,
|
||||
// We got around 500ms for proposing
|
||||
block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),
|
||||
// And a maximum of 750ms if slots are skipped
|
||||
max_block_proposal_slot_portion: Some(SlotProportion::new(1f32 / 16f32)),
|
||||
telemetry: telemetry2,
|
||||
})
|
||||
}),
|
||||
));
|
||||
let parachain_inherent = parachain_inherent.ok_or_else(|| {
|
||||
Box::<dyn std::error::Error + Send + Sync>::from(
|
||||
"Failed to create parachain inherent",
|
||||
)
|
||||
})?;
|
||||
Ok((time, slot, parachain_inherent))
|
||||
}
|
||||
},
|
||||
block_import: client2.clone(),
|
||||
relay_chain_client: relay_chain_client2,
|
||||
relay_chain_backend: relay_chain_backend2,
|
||||
para_client: client2.clone(),
|
||||
backoff_authoring_blocks: Option::<()>::None,
|
||||
sync_oracle,
|
||||
keystore,
|
||||
force_authoring,
|
||||
slot_duration,
|
||||
// We got around 500ms for proposing
|
||||
block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),
|
||||
// And a maximum of 750ms if slots are skipped
|
||||
max_block_proposal_slot_portion: Some(SlotProportion::new(1f32 / 16f32)),
|
||||
telemetry: telemetry2,
|
||||
})
|
||||
})));
|
||||
|
||||
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
|
||||
task_manager.spawn_handle(),
|
||||
|
||||
Reference in New Issue
Block a user