Update Substrate & Polkadot (#84)

This commit is contained in:
Bastian Köcher
2020-04-29 14:23:18 +02:00
committed by GitHub
parent 06a36a6650
commit 5f008af15f
15 changed files with 398 additions and 406 deletions
-1
View File
@@ -11,7 +11,6 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-b
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
+18 -26
View File
@@ -18,17 +18,18 @@
use cumulus_runtime::ParachainBlockData;
use sc_client::Client;
use sp_consensus::{
BlockImport, BlockImportParams, BlockOrigin, Environment, Error as ConsensusError,
ForkChoiceStrategy, Proposal, Proposer, RecordProof,
};
use sp_inherents::InherentDataProviders;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, HashFor};
use sp_api::{ApiExt, ProvideRuntimeApi};
use sc_client_api::{StateBackend, UsageProvider, Finalizer, BlockchainEvents};
use polkadot_collator::{
BuildParachainContext, InvalidHead, Network as CollatorNetwork, ParachainContext,
PolkadotClient,
RuntimeApiCollection,
};
use polkadot_primitives::{
parachain::{self, BlockData, GlobalValidationSchedule, LocalValidationData, Id as ParaId},
@@ -234,17 +235,17 @@ where
}
/// Implements `BuildParachainContext` to build a collator instance.
pub struct CollatorBuilder<Block: BlockT, PF, BI, Backend, Executor, Runtime> {
pub struct CollatorBuilder<Block: BlockT, PF, BI, Backend, Client> {
proposer_factory: PF,
inherent_data_providers: InherentDataProviders,
block_import: BI,
para_id: ParaId,
client: Arc<Client<Backend, Executor, Block, Runtime>>,
_marker: PhantomData<Block>,
client: Arc<Client>,
_marker: PhantomData<(Block, Backend)>,
}
impl<Block: BlockT, PF, BI, Backend, Executor, Runtime>
CollatorBuilder<Block, PF, BI, Backend, Executor, Runtime>
impl<Block: BlockT, PF, BI, Backend, Client>
CollatorBuilder<Block, PF, BI, Backend, Client>
{
/// Create a new instance of self.
pub fn new(
@@ -252,7 +253,7 @@ impl<Block: BlockT, PF, BI, Backend, Executor, Runtime>
inherent_data_providers: InherentDataProviders,
block_import: BI,
para_id: ParaId,
client: Arc<Client<Backend, Executor, Block, Runtime>>,
client: Arc<Client>,
) -> Self {
Self {
proposer_factory,
@@ -268,8 +269,8 @@ impl<Block: BlockT, PF, BI, Backend, Executor, Runtime>
type TransactionFor<E, Block> =
<<E as Environment<Block>>::Proposer as Proposer<Block>>::Transaction;
impl<Block: BlockT, PF, BI, Backend, Executor, Runtime> BuildParachainContext
for CollatorBuilder<Block, PF, BI, Backend, Executor, Runtime>
impl<Block: BlockT, PF, BI, Backend, Client> BuildParachainContext
for CollatorBuilder<Block, PF, BI, Backend, Client>
where
PF: Environment<Block> + Send + 'static,
BI: BlockImport<Block, Error = sp_consensus::Error, Transaction = TransactionFor<PF, Block>>
@@ -277,31 +278,22 @@ where
+ Sync
+ 'static,
Backend: sc_client_api::Backend<Block> + 'static,
Executor: sc_client_api::CallExecutor<Block> + Send + Sync + 'static,
Runtime: Send + Sync + 'static,
Client: Finalizer<Block, Backend> + UsageProvider<Block> + Send + Sync + 'static,
{
type ParachainContext = Collator<Block, PF, BI>;
fn build<B, E, R, Spawner, Extrinsic>(
fn build<PClient, Spawner, Extrinsic>(
self,
polkadot_client: Arc<PolkadotClient<B, E, R>>,
polkadot_client: Arc<PClient>,
spawner: Spawner,
network: impl CollatorNetwork + Clone + 'static,
) -> Result<Self::ParachainContext, ()>
where
PolkadotClient<B, E, R>: sp_api::ProvideRuntimeApi<PBlock>,
<PolkadotClient<B, E, R> as sp_api::ProvideRuntimeApi<PBlock>>::Api:
polkadot_service::RuntimeApiCollection<Extrinsic>,
E: sc_client::CallExecutor<PBlock> + Clone + Send + Sync + 'static,
PClient: ProvideRuntimeApi<PBlock> + Send + Sync + BlockchainEvents<PBlock> + 'static,
PClient::Api: RuntimeApiCollection<Extrinsic>,
<PClient::Api as ApiExt<PBlock>>::StateBackend: StateBackend<HashFor<PBlock>>,
Spawner: Spawn + Clone + Send + Sync + 'static,
Extrinsic: codec::Codec + Send + Sync + 'static,
<<PolkadotClient<B, E, R> as sp_api::ProvideRuntimeApi<PBlock>>::Api as sp_api::ApiExt<
PBlock,
>>::StateBackend: sp_api::StateBackend<sp_runtime::traits::BlakeTwo256>,
R: Send + Sync + 'static,
B: sc_client_api::Backend<PBlock> + 'static,
// Rust bug: https://github.com/rust-lang/rust/issues/24159
B::State: sp_api::StateBackend<sp_runtime::traits::BlakeTwo256>,
{
let follow =
match cumulus_consensus::follow_polkadot(self.para_id, self.client, polkadot_client) {