Update Substrate & Polkadot (#557)

* Update Substrate & Polkadot

* Format

* Update again
This commit is contained in:
Bastian Köcher
2021-08-03 11:59:37 +02:00
committed by GitHub
parent eda565a052
commit 6c0abc6f7d
19 changed files with 560 additions and 539 deletions
+381 -351
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -21,6 +21,7 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "mas
sc-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }
# Polkadot dependencies # Polkadot dependencies
@@ -18,15 +18,14 @@
use codec::Codec; use codec::Codec;
use sc_client_api::{backend::AuxStore, BlockOf, UsageProvider}; use sc_client_api::{backend::AuxStore, BlockOf, UsageProvider};
use sc_consensus::{import_queue::DefaultImportQueue, BlockImport};
use sc_consensus_aura::AuraVerifier; use sc_consensus_aura::AuraVerifier;
use sc_consensus_slots::InherentDataProviderExt; use sc_consensus_slots::InherentDataProviderExt;
use sc_telemetry::TelemetryHandle; use sc_telemetry::TelemetryHandle;
use sp_api::{ApiExt, ProvideRuntimeApi}; use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder as BlockBuilderApi; use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::{HeaderBackend, ProvideCache}; use sp_blockchain::{HeaderBackend, ProvideCache};
use sp_consensus::{ use sp_consensus::{CanAuthorWith, Error as ConsensusError};
import_queue::DefaultImportQueue, BlockImport, CanAuthorWith, Error as ConsensusError,
};
use sp_consensus_aura::{digests::CompatibleDigestItem, AuraApi}; use sp_consensus_aura::{digests::CompatibleDigestItem, AuraApi};
use sp_core::crypto::Pair; use sp_core::crypto::Pair;
use sp_inherents::CreateInherentDataProviders; use sp_inherents::CreateInherentDataProviders;
+7 -6
View File
@@ -33,13 +33,14 @@ use cumulus_primitives_core::{
use futures::lock::Mutex; use futures::lock::Mutex;
use polkadot_client::ClientHandle; use polkadot_client::ClientHandle;
use sc_client_api::{backend::AuxStore, Backend, BlockOf}; use sc_client_api::{backend::AuxStore, Backend, BlockOf};
use sc_consensus::BlockImport;
use sc_consensus_slots::{BackoffAuthoringBlocksStrategy, SlotInfo}; use sc_consensus_slots::{BackoffAuthoringBlocksStrategy, SlotInfo};
use sc_telemetry::TelemetryHandle; use sc_telemetry::TelemetryHandle;
use sp_api::ProvideRuntimeApi; use sp_api::ProvideRuntimeApi;
use sp_application_crypto::AppPublic; use sp_application_crypto::AppPublic;
use sp_blockchain::{HeaderBackend, ProvideCache}; use sp_blockchain::{HeaderBackend, ProvideCache};
use sp_consensus::{ use sp_consensus::{
BlockImport, EnableProofRecording, Environment, ProofRecording, Proposer, SlotData, SyncOracle, EnableProofRecording, Environment, ProofRecording, Proposer, SlotData, SyncOracle,
}; };
use sp_consensus_aura::AuraApi; use sp_consensus_aura::AuraApi;
use sp_core::crypto::Pair; use sp_core::crypto::Pair;
@@ -52,8 +53,7 @@ mod import_queue;
pub use import_queue::{build_verifier, import_queue, BuildVerifierParams, ImportQueueParams}; pub use import_queue::{build_verifier, import_queue, BuildVerifierParams, ImportQueueParams};
pub use sc_consensus_aura::{ pub use sc_consensus_aura::{
slot_duration, AuraVerifier, BuildAuraWorkerParams, SlotDuration, slot_duration, AuraVerifier, BuildAuraWorkerParams, SlotDuration, SlotProportion,
SlotProportion,
}; };
pub use sc_consensus_slots::InherentDataProviderExt; pub use sc_consensus_slots::InherentDataProviderExt;
@@ -138,8 +138,8 @@ where
P::Public: AppPublic + Hash + Member + Encode + Decode, P::Public: AppPublic + Hash + Member + Encode + Decode,
P::Signature: TryFrom<Vec<u8>> + Hash + Member + Encode + Decode, P::Signature: TryFrom<Vec<u8>> + Hash + Member + Encode + Decode,
{ {
let worker = let worker = sc_consensus_aura::build_aura_worker::<P, _, _, _, _, _, _, _, _>(
sc_consensus_aura::build_aura_worker::<P, _, _, _, _, _, _, _, _>(BuildAuraWorkerParams { BuildAuraWorkerParams {
client: para_client, client: para_client,
block_import: ParachainBlockImport::new(block_import), block_import: ParachainBlockImport::new(block_import),
justification_sync_link: (), justification_sync_link: (),
@@ -151,7 +151,8 @@ where
telemetry, telemetry,
block_proposal_slot_portion, block_proposal_slot_portion,
max_block_proposal_slot_portion, max_block_proposal_slot_portion,
}); },
);
Self { Self {
create_inherent_data_providers: Arc::new(create_inherent_data_providers), create_inherent_data_providers: Arc::new(create_inherent_data_providers),
@@ -7,6 +7,7 @@ edition = "2018"
[dependencies] [dependencies]
# Substrate deps # Substrate deps
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
+7 -7
View File
@@ -15,7 +15,7 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. // along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use polkadot_primitives::v1::{Hash as PHash, PersistedValidationData}; use polkadot_primitives::v1::{Hash as PHash, PersistedValidationData};
use sp_consensus::BlockImport; use sc_consensus::BlockImport;
use sp_runtime::traits::Block as BlockT; use sp_runtime::traits::Block as BlockT;
mod parachain_consensus; mod parachain_consensus;
@@ -96,19 +96,19 @@ where
async fn check_block( async fn check_block(
&mut self, &mut self,
block: sp_consensus::BlockCheckParams<Block>, block: sc_consensus::BlockCheckParams<Block>,
) -> Result<sp_consensus::ImportResult, Self::Error> { ) -> Result<sc_consensus::ImportResult, Self::Error> {
self.0.check_block(block).await self.0.check_block(block).await
} }
async fn import_block( async fn import_block(
&mut self, &mut self,
mut block_import_params: sp_consensus::BlockImportParams<Block, Self::Transaction>, mut block_import_params: sc_consensus::BlockImportParams<Block, Self::Transaction>,
cache: std::collections::HashMap<sp_consensus::import_queue::CacheKeyId, Vec<u8>>, cache: std::collections::HashMap<sp_consensus::CacheKeyId, Vec<u8>>,
) -> Result<sp_consensus::ImportResult, Self::Error> { ) -> Result<sc_consensus::ImportResult, Self::Error> {
// Best block is determined by the relay chain, or if we are doing the intial sync // Best block is determined by the relay chain, or if we are doing the intial sync
// we import all blocks as new best. // we import all blocks as new best.
block_import_params.fork_choice = Some(sp_consensus::ForkChoiceStrategy::Custom( block_import_params.fork_choice = Some(sc_consensus::ForkChoiceStrategy::Custom(
block_import_params.origin == sp_consensus::BlockOrigin::NetworkInitialSync, block_import_params.origin == sp_consensus::BlockOrigin::NetworkInitialSync,
)); ));
self.0.import_block(block_import_params, cache).await self.0.import_block(block_import_params, cache).await
@@ -17,9 +17,10 @@
use sc_client_api::{ use sc_client_api::{
Backend, BlockBackend, BlockImportNotification, BlockchainEvents, Finalizer, UsageProvider, Backend, BlockBackend, BlockImportNotification, BlockchainEvents, Finalizer, UsageProvider,
}; };
use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy};
use sp_api::ProvideRuntimeApi; use sp_api::ProvideRuntimeApi;
use sp_blockchain::{Error as ClientError, Result as ClientResult}; use sp_blockchain::{Error as ClientError, Result as ClientResult};
use sp_consensus::{BlockImport, BlockImportParams, BlockOrigin, BlockStatus, ForkChoiceStrategy}; use sp_consensus::{BlockOrigin, BlockStatus};
use sp_runtime::{ use sp_runtime::{
generic::BlockId, generic::BlockId,
traits::{Block as BlockT, Header as HeaderT}, traits::{Block as BlockT, Header as HeaderT},
+2 -1
View File
@@ -25,8 +25,9 @@ use futures::{channel::mpsc, executor::block_on, select, FutureExt, Stream, Stre
use futures_timer::Delay; use futures_timer::Delay;
use polkadot_primitives::v1::{Block as PBlock, Id as ParaId}; use polkadot_primitives::v1::{Block as PBlock, Id as ParaId};
use sc_client_api::UsageProvider; use sc_client_api::UsageProvider;
use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy};
use sp_blockchain::{Error as ClientError, Result as ClientResult}; use sp_blockchain::{Error as ClientError, Result as ClientResult};
use sp_consensus::{BlockImport, BlockImportParams, BlockOrigin, ForkChoiceStrategy}; use sp_consensus::BlockOrigin;
use sp_runtime::generic::BlockId; use sp_runtime::generic::BlockId;
use std::{ use std::{
sync::{Arc, Mutex}, sync::{Arc, Mutex},
@@ -15,6 +15,7 @@ sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "mas
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }
# Polkadot dependencies # Polkadot dependencies
@@ -16,19 +16,18 @@
use std::{marker::PhantomData, sync::Arc}; use std::{marker::PhantomData, sync::Arc};
use sc_consensus::{
import_queue::{BasicQueue, Verifier as VerifierT},
BlockImport, BlockImportParams,
};
use sp_api::ProvideRuntimeApi; use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder as BlockBuilderApi; use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::Result as ClientResult; use sp_blockchain::Result as ClientResult;
use sp_consensus::{ use sp_consensus::{error::Error as ConsensusError, CacheKeyId};
error::Error as ConsensusError,
import_queue::{BasicQueue, CacheKeyId, Verifier as VerifierT},
BlockImport, BlockImportParams, BlockOrigin,
};
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider}; use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
use sp_runtime::{ use sp_runtime::{
generic::BlockId, generic::BlockId,
traits::{Block as BlockT, Header as HeaderT}, traits::{Block as BlockT, Header as HeaderT},
Justifications,
}; };
/// A verifier that just checks the inherents. /// A verifier that just checks the inherents.
@@ -59,10 +58,7 @@ where
{ {
async fn verify( async fn verify(
&mut self, &mut self,
origin: BlockOrigin, mut block_params: BlockImportParams<Block, ()>,
header: Block::Header,
justifications: Option<Justifications>,
mut body: Option<Vec<Block::Extrinsic>>,
) -> Result< ) -> Result<
( (
BlockImportParams<Block, ()>, BlockImportParams<Block, ()>,
@@ -70,10 +66,10 @@ where
), ),
String, String,
> { > {
if let Some(inner_body) = body.take() { if let Some(inner_body) = block_params.body.take() {
let inherent_data_providers = self let inherent_data_providers = self
.create_inherent_data_providers .create_inherent_data_providers
.create_inherent_data_providers(*header.parent_hash(), ()) .create_inherent_data_providers(*block_params.header.parent_hash(), ())
.await .await
.map_err(|e| e.to_string())?; .map_err(|e| e.to_string())?;
@@ -81,13 +77,13 @@ where
.create_inherent_data() .create_inherent_data()
.map_err(|e| format!("{:?}", e))?; .map_err(|e| format!("{:?}", e))?;
let block = Block::new(header.clone(), inner_body); let block = Block::new(block_params.header.clone(), inner_body);
let inherent_res = self let inherent_res = self
.client .client
.runtime_api() .runtime_api()
.check_inherents( .check_inherents(
&BlockId::Hash(*header.parent_hash()), &BlockId::Hash(*block.header().parent_hash()),
block.clone(), block.clone(),
inherent_data, inherent_data,
) )
@@ -106,17 +102,12 @@ where
} }
let (_, inner_body) = block.deconstruct(); let (_, inner_body) = block.deconstruct();
body = Some(inner_body); block_params.body = Some(inner_body);
} }
let post_hash = Some(header.hash()); block_params.post_hash = Some(block_params.header.hash());
let mut block_import_params = BlockImportParams::new(origin, header);
block_import_params.body = body;
block_import_params.justifications = justifications;
block_import_params.post_hash = post_hash; Ok((block_params, None))
Ok((block_import_params, None))
} }
} }
@@ -43,10 +43,10 @@ use cumulus_primitives_core::{
use parking_lot::Mutex; use parking_lot::Mutex;
use polkadot_client::ClientHandle; use polkadot_client::ClientHandle;
use sc_client_api::Backend; use sc_client_api::Backend;
use sc_consensus::{BlockImport, BlockImportParams};
use sp_api::ProvideRuntimeApi; use sp_api::ProvideRuntimeApi;
use sp_consensus::{ use sp_consensus::{
BlockImport, BlockImportParams, BlockOrigin, EnableProofRecording, Environment, ProofRecording, BlockOrigin, EnableProofRecording, Environment, ProofRecording, Proposal, Proposer,
Proposal, Proposer,
}; };
use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider}; use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider};
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT}; use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT};
@@ -208,8 +208,8 @@ where
let mut block_import_params = BlockImportParams::new(BlockOrigin::Own, header); let mut block_import_params = BlockImportParams::new(BlockOrigin::Own, header);
block_import_params.body = Some(extrinsics); block_import_params.body = Some(extrinsics);
block_import_params.state_action = sp_consensus::StateAction::ApplyChanges( block_import_params.state_action = sc_consensus::StateAction::ApplyChanges(
sp_consensus::StorageChanges::Changes(storage_changes) sc_consensus::StorageChanges::Changes(storage_changes),
); );
if let Err(err) = self if let Err(err) = self
+1 -1
View File
@@ -13,6 +13,7 @@ sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
# Polkadot deps # Polkadot deps
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
@@ -44,7 +45,6 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "mas
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" }
+2 -4
View File
@@ -43,11 +43,9 @@
//! make sure that the blocks are imported in the correct order. //! make sure that the blocks are imported in the correct order.
use sc_client_api::{BlockBackend, BlockchainEvents, UsageProvider}; use sc_client_api::{BlockBackend, BlockchainEvents, UsageProvider};
use sc_consensus::import_queue::{ImportQueue, IncomingBlock};
use sp_api::ProvideRuntimeApi; use sp_api::ProvideRuntimeApi;
use sp_consensus::{ use sp_consensus::{BlockOrigin, BlockStatus};
import_queue::{ImportQueue, IncomingBlock},
BlockOrigin, BlockStatus,
};
use sp_runtime::{ use sp_runtime::{
generic::BlockId, generic::BlockId,
traits::{Block as BlockT, Header as HeaderT, NumberFor}, traits::{Block as BlockT, Header as HeaderT, NumberFor},
+1
View File
@@ -18,6 +18,7 @@ sc-service = { git = "https://github.com/paritytech/substrate", branch = "master
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
+15 -14
View File
@@ -26,14 +26,15 @@ use polkadot_service::{AbstractClient, Client as PClient, ClientHandle, RuntimeA
use sc_client_api::{ use sc_client_api::{
Backend as BackendT, BlockBackend, BlockchainEvents, Finalizer, UsageProvider, Backend as BackendT, BlockBackend, BlockchainEvents, Finalizer, UsageProvider,
}; };
use sc_consensus::{
import_queue::{ImportQueue, IncomingBlock, Link, Origin},
BlockImport,
};
use sc_service::{Configuration, Role, TaskManager}; use sc_service::{Configuration, Role, TaskManager};
use sc_telemetry::TelemetryWorkerHandle; use sc_telemetry::TelemetryWorkerHandle;
use sp_api::ProvideRuntimeApi; use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend; use sp_blockchain::HeaderBackend;
use sp_consensus::{ use sp_consensus::BlockOrigin;
import_queue::{ImportQueue, IncomingBlock, Link, Origin},
BlockImport, BlockOrigin,
};
use sp_core::{traits::SpawnNamed, Pair}; use sp_core::{traits::SpawnNamed, Pair};
use sp_runtime::{ use sp_runtime::{
traits::{BlakeTwo256, Block as BlockT, NumberFor}, traits::{BlakeTwo256, Block as BlockT, NumberFor},
@@ -118,18 +119,18 @@ where
}); });
relay_chain_full_node relay_chain_full_node
.client .client
.execute_with(StartPoVRecovery { .execute_with(StartPoVRecovery {
para_id, para_id,
client: client.clone(), client: client.clone(),
import_queue, import_queue,
task_manager, task_manager,
overseer_handle: relay_chain_full_node overseer_handle: relay_chain_full_node
.overseer_handle .overseer_handle
.clone() .clone()
.ok_or_else(|| "Polkadot full node did not provide an `OverseerHandle`!")?, .ok_or_else(|| "Polkadot full node did not provide an `OverseerHandle`!")?,
_phantom: PhantomData, _phantom: PhantomData,
})?; })?;
cumulus_client_collator::start_collator(cumulus_client_collator::StartCollatorParams { cumulus_client_collator::start_collator(cumulus_client_collator::StartCollatorParams {
runtime_api: client.clone(), runtime_api: client.clone(),
+111 -120
View File
@@ -18,33 +18,38 @@ use cumulus_client_consensus_aura::{
build_aura_consensus, BuildAuraConsensusParams, SlotProportion, build_aura_consensus, BuildAuraConsensusParams, SlotProportion,
}; };
use cumulus_client_consensus_common::{ use cumulus_client_consensus_common::{
ParachainConsensus, ParachainCandidate, ParachainBlockImport, ParachainBlockImport, ParachainCandidate, ParachainConsensus,
}; };
use cumulus_client_network::build_block_announce_validator; use cumulus_client_network::build_block_announce_validator;
use cumulus_client_service::{ use cumulus_client_service::{
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams, prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
}; };
use cumulus_primitives_core::{ 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_client_api::ExecutorProvider;
use sc_consensus::{
import_queue::{BasicQueue, Verifier as VerifierT},
BlockImportParams,
};
use sc_executor::native_executor_instance; use sc_executor::native_executor_instance;
use sc_network::NetworkService; use sc_network::NetworkService;
use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager}; use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
use sp_api::{ConstructRuntimeApi, ApiExt}; use sp_api::{ApiExt, ConstructRuntimeApi};
use sp_consensus::{ use sp_consensus::{CacheKeyId, SlotData};
BlockImportParams, BlockOrigin, SlotData,
import_queue::{BasicQueue, CacheKeyId, Verifier as VerifierT},
};
use sp_consensus_aura::{sr25519::AuthorityId as AuraId, AuraApi}; use sp_consensus_aura::{sr25519::AuthorityId as AuraId, AuraApi};
use sp_keystore::SyncCryptoStorePtr; 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 std::sync::Arc;
use substrate_prometheus_endpoint::Registry; use substrate_prometheus_endpoint::Registry;
use futures::lock::Mutex;
use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier;
pub use sc_executor::NativeExecutor; pub use sc_executor::NativeExecutor;
@@ -103,7 +108,7 @@ pub fn new_partial<RuntimeApi, Executor, BIQ>(
TFullClient<Block, RuntimeApi, Executor>, TFullClient<Block, RuntimeApi, Executor>,
TFullBackend<Block>, 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>>, sc_transaction_pool::FullPool<Block, TFullClient<Block, RuntimeApi, Executor>>,
(Option<Telemetry>, Option<TelemetryWorkerHandle>), (Option<Telemetry>, Option<TelemetryWorkerHandle>),
>, >,
@@ -130,7 +135,7 @@ where
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
) -> Result< ) -> Result<
sp_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>, sc_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>,
sc_service::Error, sc_service::Error,
>, >,
{ {
@@ -227,7 +232,7 @@ where
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
) -> Result< ) -> Result<
sp_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>, sc_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>,
sc_service::Error, sc_service::Error,
>, >,
BIC: FnOnce( BIC: FnOnce(
@@ -251,14 +256,12 @@ where
let params = new_partial::<RuntimeApi, Executor, BIQ>(&parachain_config, build_import_queue)?; let params = new_partial::<RuntimeApi, Executor, BIQ>(&parachain_config, build_import_queue)?;
let (mut telemetry, telemetry_worker_handle) = params.other; let (mut telemetry, telemetry_worker_handle) = params.other;
let relay_chain_full_node = cumulus_client_service::build_polkadot_full_node( let relay_chain_full_node =
polkadot_config, cumulus_client_service::build_polkadot_full_node(polkadot_config, telemetry_worker_handle)
telemetry_worker_handle, .map_err(|e| match e {
) polkadot_service::Error::Sub(x) => x,
.map_err(|e| match e { s => format!("{}", s).into(),
polkadot_service::Error::Sub(x) => x, })?;
s => format!("{}", s).into(),
})?;
let client = params.client.clone(); let client = params.client.clone();
let backend = params.backend.clone(); let backend = params.backend.clone();
@@ -284,6 +287,7 @@ where
import_queue: import_queue.clone(), import_queue: import_queue.clone(),
on_demand: None, on_demand: None,
block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)), block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)),
warp_sync: None,
})?; })?;
let rpc_client = client.clone(); let rpc_client = client.clone();
@@ -363,7 +367,7 @@ pub fn rococo_parachain_build_import_queue(
telemetry: Option<TelemetryHandle>, telemetry: Option<TelemetryHandle>,
task_manager: &TaskManager, task_manager: &TaskManager,
) -> Result< ) -> Result<
sp_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<
Block, Block,
TFullClient<Block, rococo_parachain_runtime::RuntimeApi, RococoParachainRuntimeExecutor>, 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)?; 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::import_queue::<
cumulus_client_consensus_aura::ImportQueueParams { sp_consensus_aura::sr25519::AuthorityPair,
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::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 = let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
*time, *time,
slot_duration.slot_duration(), slot_duration.slot_duration(),
); );
Ok((time, slot)) 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,
}, },
) 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) .map_err(Into::into)
} }
@@ -499,7 +507,7 @@ pub fn shell_build_import_queue(
_: Option<TelemetryHandle>, _: Option<TelemetryHandle>,
task_manager: &TaskManager, task_manager: &TaskManager,
) -> Result< ) -> Result<
sp_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<
Block, Block,
TFullClient<Block, shell_runtime::RuntimeApi, ShellRuntimeExecutor>, TFullClient<Block, shell_runtime::RuntimeApi, ShellRuntimeExecutor>,
>, >,
@@ -671,10 +679,7 @@ where
{ {
async fn verify( async fn verify(
&mut self, &mut self,
origin: BlockOrigin, block_import: BlockImportParams<Block, ()>,
header: Header,
justifications: Option<sp_runtime::Justifications>,
body: Option<Vec<<Block as sp_runtime::traits::Block>::Extrinsic>>,
) -> Result< ) -> Result<
( (
BlockImportParams<Block, ()>, BlockImportParams<Block, ()>,
@@ -682,7 +687,7 @@ where
), ),
String, String,
> { > {
let block_id = BlockId::hash(*header.parent_hash()); let block_id = BlockId::hash(*block_import.header.parent_hash());
if self if self
.client .client
@@ -690,14 +695,9 @@ where
.has_api::<dyn AuraApi<Block, AuraId>>(&block_id) .has_api::<dyn AuraApi<Block, AuraId>>(&block_id)
.unwrap_or(false) .unwrap_or(false)
{ {
self.aura_verifier self.aura_verifier.get_mut().verify(block_import).await
.get_mut()
.verify(origin, header, justifications, body)
.await
} else { } else {
self.relay_chain_verifier self.relay_chain_verifier.verify(block_import).await
.verify(origin, header, justifications, body)
.await
} }
} }
} }
@@ -709,7 +709,7 @@ pub fn statemint_build_import_queue<RuntimeApi, Executor>(
telemetry_handle: Option<TelemetryHandle>, telemetry_handle: Option<TelemetryHandle>,
task_manager: &TaskManager, task_manager: &TaskManager,
) -> Result< ) -> Result<
sp_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>, sc_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>,
sc_service::Error, sc_service::Error,
> >
where where
@@ -786,10 +786,7 @@ pub async fn start_statemint_node<RuntimeApi, Executor>(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
id: ParaId, id: ParaId,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)>
TaskManager,
Arc<TFullClient<Block, RuntimeApi, Executor>>,
)>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>>
+ Send + Send
@@ -831,39 +828,36 @@ where
let telemetry2 = telemetry.clone(); let telemetry2 = telemetry.clone();
let prometheus_registry2 = prometheus_registry.map(|r| (*r).clone()); let prometheus_registry2 = prometheus_registry.map(|r| (*r).clone());
let aura_consensus = BuildOnAccess::Uninitialized(Some( let aura_consensus = BuildOnAccess::Uninitialized(Some(Box::new(move || {
Box::new(move || { let slot_duration =
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client2).unwrap();
cumulus_client_consensus_aura::slot_duration(&*client2).unwrap();
let proposer_factory = let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
sc_basic_authorship::ProposerFactory::with_proof_recording( spawn_handle,
spawn_handle, client2.clone(),
client2.clone(), transaction_pool2,
transaction_pool2, prometheus_registry2.as_ref(),
prometheus_registry2.as_ref(), telemetry2.clone(),
telemetry2.clone(), );
);
let relay_chain_backend2 = relay_chain_backend.clone(); let relay_chain_backend2 = relay_chain_backend.clone();
let relay_chain_client2 = relay_chain_client.clone(); let relay_chain_client2 = relay_chain_client.clone();
build_aura_consensus::< build_aura_consensus::<
sp_consensus_aura::sr25519::AuthorityPair, sp_consensus_aura::sr25519::AuthorityPair,
_, _,
_, _,
_, _,
_, _,
_, _,
_, _,
_, _,
_, _,
_, _,
>(BuildAuraConsensusParams { >(BuildAuraConsensusParams {
proposer_factory, proposer_factory,
create_inherent_data_providers: create_inherent_data_providers: move |_, (relay_parent, validation_data)| {
move |_, (relay_parent, validation_data)| { let parachain_inherent =
let parachain_inherent =
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at_with_client( cumulus_primitives_parachain_inherent::ParachainInherentData::create_at_with_client(
relay_parent, relay_parent,
&relay_chain_client, &relay_chain_client,
@@ -871,42 +865,39 @@ where
&validation_data, &validation_data,
id, id,
); );
async move { async move {
let time = let time = sp_timestamp::InherentDataProvider::from_system_time();
sp_timestamp::InherentDataProvider::from_system_time();
let slot = let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
*time, *time,
slot_duration.slot_duration(), slot_duration.slot_duration(),
); );
let parachain_inherent = let parachain_inherent = parachain_inherent.ok_or_else(|| {
parachain_inherent.ok_or_else(|| { Box::<dyn std::error::Error + Send + Sync>::from(
Box::<dyn std::error::Error + Send + Sync>::from( "Failed to create parachain inherent",
"Failed to create parachain inherent", )
) })?;
})?; Ok((time, slot, parachain_inherent))
Ok((time, slot, parachain_inherent)) }
} },
}, block_import: client2.clone(),
block_import: client2.clone(), relay_chain_client: relay_chain_client2,
relay_chain_client: relay_chain_client2, relay_chain_backend: relay_chain_backend2,
relay_chain_backend: relay_chain_backend2, para_client: client2.clone(),
para_client: client2.clone(), backoff_authoring_blocks: Option::<()>::None,
backoff_authoring_blocks: Option::<()>::None, sync_oracle,
sync_oracle, keystore,
keystore, force_authoring,
force_authoring, slot_duration,
slot_duration, // We got around 500ms for proposing
// We got around 500ms for proposing block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),
block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32), // And a maximum of 750ms if slots are skipped
// And a maximum of 750ms if slots are skipped max_block_proposal_slot_portion: Some(SlotProportion::new(1f32 / 16f32)),
max_block_proposal_slot_portion: Some(SlotProportion::new(1f32 / 16f32)), telemetry: telemetry2,
telemetry: telemetry2, })
}) })));
}),
));
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
task_manager.spawn_handle(), task_manager.spawn_handle(),
@@ -26,7 +26,8 @@ const PROJECT_NAME: &str = "validation-worker";
const SKIP_ENV: &str = "SKIP_BUILD"; const SKIP_ENV: &str = "SKIP_BUILD";
fn main() { fn main() {
if env::var(SKIP_ENV).is_ok() { return if env::var(SKIP_ENV).is_ok() {
return;
} }
let out_dir = PathBuf::from(env::var("OUT_DIR").expect("`OUT_DIR` is set by cargo")); let out_dir = PathBuf::from(env::var("OUT_DIR").expect("`OUT_DIR` is set by cargo"));
@@ -42,11 +43,13 @@ fn main() {
} }
fn find_cargo_lock() -> PathBuf { fn find_cargo_lock() -> PathBuf {
let mut path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` is set by cargo")); let mut path = PathBuf::from(
env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` is set by cargo"),
);
loop { loop {
if path.join("Cargo.lock").exists() { if path.join("Cargo.lock").exists() {
return path.join("Cargo.lock") return path.join("Cargo.lock");
} }
if !path.pop() { if !path.pop() {
+1 -1
View File
@@ -17,6 +17,7 @@ sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -28,7 +29,6 @@ sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
+2 -1
View File
@@ -99,7 +99,7 @@ pub fn new_partial(
Client, Client,
TFullBackend<Block>, TFullBackend<Block>,
(), (),
sp_consensus::import_queue::BasicQueue<Block, PrefixedMemoryDB<BlakeTwo256>>, sc_consensus::import_queue::BasicQueue<Block, PrefixedMemoryDB<BlakeTwo256>>,
sc_transaction_pool::FullPool<Block, Client>, sc_transaction_pool::FullPool<Block, Client>,
(), (),
>, >,
@@ -213,6 +213,7 @@ where
import_queue: import_queue.clone(), import_queue: import_queue.clone(),
on_demand: None, on_demand: None,
block_announce_validator_builder: Some(Box::new(block_announce_validator_builder)), block_announce_validator_builder: Some(Box::new(block_announce_validator_builder)),
warp_sync: None,
})?; })?;
let rpc_extensions_builder = { let rpc_extensions_builder = {