mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
Generated
+14
-14
@@ -2160,7 +2160,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "kusama-runtime"
|
name = "kusama-runtime"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"frame-executive 2.0.0 (git+https://github.com/paritytech/substrate?branch=cumulus-branch)",
|
"frame-executive 2.0.0 (git+https://github.com/paritytech/substrate?branch=cumulus-branch)",
|
||||||
@@ -3881,7 +3881,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "polkadot-availability-store"
|
name = "polkadot-availability-store"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"exit-future 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"exit-future 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -3909,7 +3909,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "polkadot-cli"
|
name = "polkadot-cli"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -3929,7 +3929,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "polkadot-collator"
|
name = "polkadot-collator"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -3955,7 +3955,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "polkadot-erasure-coding"
|
name = "polkadot-erasure-coding"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -3968,7 +3968,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "polkadot-network"
|
name = "polkadot-network"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
"arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -3996,7 +3996,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "polkadot-parachain"
|
name = "polkadot-parachain"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -4016,7 +4016,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "polkadot-primitives"
|
name = "polkadot-primitives"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pallet-babe 2.0.0 (git+https://github.com/paritytech/substrate?branch=cumulus-branch)",
|
"pallet-babe 2.0.0 (git+https://github.com/paritytech/substrate?branch=cumulus-branch)",
|
||||||
@@ -4036,7 +4036,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "polkadot-rpc"
|
name = "polkadot-rpc"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pallet-transaction-payment-rpc 2.0.0 (git+https://github.com/paritytech/substrate?branch=cumulus-branch)",
|
"pallet-transaction-payment-rpc 2.0.0 (git+https://github.com/paritytech/substrate?branch=cumulus-branch)",
|
||||||
@@ -4053,7 +4053,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "polkadot-runtime"
|
name = "polkadot-runtime"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"frame-executive 2.0.0 (git+https://github.com/paritytech/substrate?branch=cumulus-branch)",
|
"frame-executive 2.0.0 (git+https://github.com/paritytech/substrate?branch=cumulus-branch)",
|
||||||
@@ -4112,7 +4112,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "polkadot-runtime-common"
|
name = "polkadot-runtime-common"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"frame-support 2.0.0 (git+https://github.com/paritytech/substrate?branch=cumulus-branch)",
|
"frame-support 2.0.0 (git+https://github.com/paritytech/substrate?branch=cumulus-branch)",
|
||||||
@@ -4142,7 +4142,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "polkadot-service"
|
name = "polkadot-service"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"frame-system-rpc-runtime-api 2.0.0 (git+https://github.com/paritytech/substrate?branch=cumulus-branch)",
|
"frame-system-rpc-runtime-api 2.0.0 (git+https://github.com/paritytech/substrate?branch=cumulus-branch)",
|
||||||
"futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -4196,7 +4196,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "polkadot-statement-table"
|
name = "polkadot-statement-table"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"polkadot-primitives 0.7.21 (git+https://github.com/paritytech/polkadot?branch=cumulus-branch)",
|
"polkadot-primitives 0.7.21 (git+https://github.com/paritytech/polkadot?branch=cumulus-branch)",
|
||||||
@@ -4206,7 +4206,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "polkadot-validation"
|
name = "polkadot-validation"
|
||||||
version = "0.7.21"
|
version = "0.7.21"
|
||||||
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#b1f88ed21ec551c35ff2c2d776b214f2383a56d6"
|
source = "git+https://github.com/paritytech/polkadot?branch=cumulus-branch#5ed74bac90ac24a2abd9828e310caaccde26f15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|||||||
+68
-80
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
use cumulus_runtime::ParachainBlockData;
|
use cumulus_runtime::ParachainBlockData;
|
||||||
|
|
||||||
|
use sc_client::Client;
|
||||||
use sp_consensus::{
|
use sp_consensus::{
|
||||||
BlockImport, BlockImportParams, BlockOrigin, Environment, Error as ConsensusError,
|
BlockImport, BlockImportParams, BlockOrigin, Environment, Error as ConsensusError,
|
||||||
ForkChoiceStrategy, Proposal, Proposer, RecordProof,
|
ForkChoiceStrategy, Proposal, Proposer, RecordProof,
|
||||||
@@ -30,14 +31,15 @@ use polkadot_collator::{
|
|||||||
PolkadotClient,
|
PolkadotClient,
|
||||||
};
|
};
|
||||||
use polkadot_primitives::{
|
use polkadot_primitives::{
|
||||||
parachain::{self, BlockData, Status as ParachainStatus}, Block as PBlock, Hash as PHash,
|
parachain::{self, BlockData, Status as ParachainStatus, Id as ParaId}, Block as PBlock,
|
||||||
|
Hash as PHash,
|
||||||
};
|
};
|
||||||
|
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
|
|
||||||
use log::{error, trace};
|
use log::{error, trace};
|
||||||
|
|
||||||
use futures::{task::Spawn, Future, future};
|
use futures::{task::Spawn, Future, future, FutureExt};
|
||||||
|
|
||||||
use std::{fmt::Debug, marker::PhantomData, sync::Arc, time::Duration, pin::Pin};
|
use std::{fmt::Debug, marker::PhantomData, sync::Arc, time::Duration, pin::Pin};
|
||||||
|
|
||||||
@@ -231,30 +233,57 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Implements `BuildParachainContext` to build a collator instance.
|
/// Implements `BuildParachainContext` to build a collator instance.
|
||||||
pub struct CollatorBuilder<Block, SP> {
|
pub struct CollatorBuilder<Block: BlockT, PF, BI, Backend, Executor, Runtime> {
|
||||||
setup_parachain: SP,
|
proposer_factory: PF,
|
||||||
|
inherent_data_providers: InherentDataProviders,
|
||||||
|
block_import: BI,
|
||||||
|
para_id: ParaId,
|
||||||
|
client: Arc<Client<Backend, Executor, Block, Runtime>>,
|
||||||
_marker: PhantomData<Block>,
|
_marker: PhantomData<Block>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Block, SP> CollatorBuilder<Block, SP> {
|
impl<Block: BlockT, PF, BI, Backend, Executor, Runtime>
|
||||||
|
CollatorBuilder<Block, PF, BI, Backend, Executor, Runtime>
|
||||||
|
{
|
||||||
/// Create a new instance of self.
|
/// Create a new instance of self.
|
||||||
pub fn new(setup_parachain: SP) -> Self {
|
pub fn new(
|
||||||
|
proposer_factory: PF,
|
||||||
|
inherent_data_providers: InherentDataProviders,
|
||||||
|
block_import: BI,
|
||||||
|
para_id: ParaId,
|
||||||
|
client: Arc<Client<Backend, Executor, Block, Runtime>>,
|
||||||
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
setup_parachain,
|
proposer_factory,
|
||||||
|
inherent_data_providers,
|
||||||
|
block_import,
|
||||||
|
para_id,
|
||||||
|
client,
|
||||||
_marker: PhantomData,
|
_marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Block: BlockT, SP: SetupParachain<Block>> BuildParachainContext for CollatorBuilder<Block, SP>
|
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>
|
||||||
where
|
where
|
||||||
<SP::ProposerFactory as Environment<Block>>::Proposer: Send,
|
PF: Environment<Block> + Send + 'static,
|
||||||
|
BI: BlockImport<Block, Error = sp_consensus::Error, Transaction = TransactionFor<PF, Block>>
|
||||||
|
+ Send
|
||||||
|
+ Sync
|
||||||
|
+ 'static,
|
||||||
|
Backend: sc_client_api::Backend<Block> + 'static,
|
||||||
|
Executor: sc_client_api::CallExecutor<Block> + Send + Sync + 'static,
|
||||||
|
Runtime: Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
type ParachainContext = Collator<Block, SP::ProposerFactory, SP::BlockImport>;
|
type ParachainContext = Collator<Block, PF, BI>;
|
||||||
|
|
||||||
fn build<B, E, R, Spawner, Extrinsic>(
|
fn build<B, E, R, Spawner, Extrinsic>(
|
||||||
self,
|
self,
|
||||||
client: Arc<PolkadotClient<B, E, R>>,
|
polkadot_client: Arc<PolkadotClient<B, E, R>>,
|
||||||
spawner: Spawner,
|
spawner: Spawner,
|
||||||
network: Arc<dyn CollatorNetwork>,
|
network: Arc<dyn CollatorNetwork>,
|
||||||
) -> Result<Self::ParachainContext, ()>
|
) -> Result<Self::ParachainContext, ()>
|
||||||
@@ -273,53 +302,32 @@ where
|
|||||||
// Rust bug: https://github.com/rust-lang/rust/issues/24159
|
// Rust bug: https://github.com/rust-lang/rust/issues/24159
|
||||||
B::State: sp_api::StateBackend<sp_core::Blake2Hasher>,
|
B::State: sp_api::StateBackend<sp_core::Blake2Hasher>,
|
||||||
{
|
{
|
||||||
let (proposer_factory, block_import, inherent_data_providers) = self
|
let follow =
|
||||||
.setup_parachain
|
match cumulus_consensus::follow_polkadot(self.para_id, self.client, polkadot_client) {
|
||||||
.setup_parachain(client, spawner)
|
Ok(follow) => follow,
|
||||||
.map_err(|e| error!("Error setting up the parachain: {}", e))?;
|
Err(e) => {
|
||||||
|
return Err(error!("Could not start following polkadot: {:?}", e));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
spawner
|
||||||
|
.spawn_obj(
|
||||||
|
Box::new(
|
||||||
|
follow.map(|_| ()),
|
||||||
|
)
|
||||||
|
.into(),
|
||||||
|
)
|
||||||
|
.map_err(|_| error!("Could not spawn parachain server!"))?;
|
||||||
|
|
||||||
Ok(Collator::new(
|
Ok(Collator::new(
|
||||||
proposer_factory,
|
self.proposer_factory,
|
||||||
inherent_data_providers,
|
self.inherent_data_providers,
|
||||||
network,
|
network,
|
||||||
block_import,
|
self.block_import,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Something that can setup a parachain.
|
|
||||||
pub trait SetupParachain<Block: BlockT>: Send {
|
|
||||||
/// The proposer factory of the parachain to build blocks.
|
|
||||||
type ProposerFactory: Environment<Block> + Send + 'static;
|
|
||||||
/// The block import for importing the blocks build by the collator.
|
|
||||||
type BlockImport: BlockImport<
|
|
||||||
Block,
|
|
||||||
Error = ConsensusError,
|
|
||||||
Transaction = <<Self::ProposerFactory as Environment<Block>>::Proposer as Proposer<
|
|
||||||
Block,
|
|
||||||
>>::Transaction,
|
|
||||||
> + Send
|
|
||||||
+ Sync
|
|
||||||
+ 'static;
|
|
||||||
|
|
||||||
/// Setup the parachain.
|
|
||||||
fn setup_parachain<P, SP>(
|
|
||||||
self,
|
|
||||||
polkadot_client: P,
|
|
||||||
spawner: SP,
|
|
||||||
) -> Result<
|
|
||||||
(
|
|
||||||
Self::ProposerFactory,
|
|
||||||
Self::BlockImport,
|
|
||||||
InherentDataProviders,
|
|
||||||
),
|
|
||||||
String,
|
|
||||||
>
|
|
||||||
where
|
|
||||||
P: cumulus_consensus::PolkadotClient,
|
|
||||||
SP: Spawn + Clone + Send + Sync + 'static;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -339,7 +347,7 @@ mod tests {
|
|||||||
use substrate_test_client::{NativeExecutor, WasmExecutionMethod::Interpreted};
|
use substrate_test_client::{NativeExecutor, WasmExecutionMethod::Interpreted};
|
||||||
|
|
||||||
use test_client::{
|
use test_client::{
|
||||||
Client, DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt,
|
DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt,
|
||||||
};
|
};
|
||||||
use test_runtime::{Block, Header};
|
use test_runtime::{Block, Header};
|
||||||
|
|
||||||
@@ -433,38 +441,19 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DummySetup;
|
|
||||||
|
|
||||||
impl SetupParachain<Block> for DummySetup {
|
|
||||||
type ProposerFactory = DummyFactory;
|
|
||||||
type BlockImport = Client;
|
|
||||||
|
|
||||||
fn setup_parachain<P, SP>(
|
|
||||||
self,
|
|
||||||
_: P,
|
|
||||||
_: SP,
|
|
||||||
) -> Result<
|
|
||||||
(
|
|
||||||
Self::ProposerFactory,
|
|
||||||
Self::BlockImport,
|
|
||||||
InherentDataProviders,
|
|
||||||
),
|
|
||||||
String,
|
|
||||||
> {
|
|
||||||
Ok((
|
|
||||||
DummyFactory,
|
|
||||||
TestClientBuilder::new().build(),
|
|
||||||
InherentDataProviders::default(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn collates_produces_a_block() {
|
fn collates_produces_a_block() {
|
||||||
|
let id = ParaId::from(100);
|
||||||
let _ = env_logger::try_init();
|
let _ = env_logger::try_init();
|
||||||
let spawner = futures::executor::ThreadPool::new().unwrap();
|
let spawner = futures::executor::ThreadPool::new().unwrap();
|
||||||
|
|
||||||
let builder = CollatorBuilder::new(DummySetup);
|
let builder = CollatorBuilder::new(
|
||||||
|
DummyFactory,
|
||||||
|
InherentDataProviders::default(),
|
||||||
|
TestClientBuilder::new().build(),
|
||||||
|
id,
|
||||||
|
Arc::new(TestClientBuilder::new().build()),
|
||||||
|
);
|
||||||
let context = builder
|
let context = builder
|
||||||
.build::<_, _, polkadot_service::polkadot_runtime::RuntimeApi, _, _>(
|
.build::<_, _, polkadot_service::polkadot_runtime::RuntimeApi, _, _>(
|
||||||
Arc::new(
|
Arc::new(
|
||||||
@@ -479,7 +468,6 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.expect("Creates parachain context");
|
.expect("Creates parachain context");
|
||||||
|
|
||||||
let id = ParaId::from(100);
|
|
||||||
let header = Header::new(
|
let header = Header::new(
|
||||||
0,
|
0,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
|
|||||||
+19
-131
@@ -21,19 +21,12 @@ use parachain_runtime::{self, opaque::Block, GenesisConfig};
|
|||||||
use sc_executor::native_executor_instance;
|
use sc_executor::native_executor_instance;
|
||||||
use sc_network::construct_simple_protocol;
|
use sc_network::construct_simple_protocol;
|
||||||
use sc_service::{AbstractService, Configuration};
|
use sc_service::{AbstractService, Configuration};
|
||||||
use sp_consensus::{BlockImport, Environment, Proposer};
|
|
||||||
use sp_inherents::InherentDataProviders;
|
|
||||||
use sp_core::crypto::Pair;
|
|
||||||
|
|
||||||
use polkadot_collator::build_collator_service;
|
|
||||||
use polkadot_primitives::parachain::CollatorPair;
|
use polkadot_primitives::parachain::CollatorPair;
|
||||||
use polkadot_service::IsKusama;
|
|
||||||
|
|
||||||
use cumulus_collator::CollatorBuilder;
|
use cumulus_collator::CollatorBuilder;
|
||||||
|
|
||||||
use futures::{future, task::Spawn, FutureExt, TryFutureExt};
|
use futures::FutureExt;
|
||||||
|
|
||||||
use log::error;
|
|
||||||
|
|
||||||
pub use sc_executor::NativeExecutor;
|
pub use sc_executor::NativeExecutor;
|
||||||
|
|
||||||
@@ -86,15 +79,12 @@ macro_rules! new_full_start {
|
|||||||
///
|
///
|
||||||
/// This function blocks until done.
|
/// This function blocks until done.
|
||||||
pub fn run_collator<E: sc_service::ChainSpecExtension>(
|
pub fn run_collator<E: sc_service::ChainSpecExtension>(
|
||||||
mut parachain_config: Configuration<GenesisConfig, E>,
|
parachain_config: Configuration<GenesisConfig, E>,
|
||||||
key: Arc<CollatorPair>,
|
key: Arc<CollatorPair>,
|
||||||
polkadot_config: polkadot_collator::Configuration,
|
mut polkadot_config: polkadot_collator::Configuration,
|
||||||
) -> sc_cli::error::Result<()> {
|
) -> sc_cli::error::Result<()> {
|
||||||
let para_id = crate::PARA_ID;
|
sc_cli::run_service_until_exit(parachain_config, move |parachain_config| {
|
||||||
|
polkadot_config.task_executor = parachain_config.task_executor.clone();
|
||||||
if polkadot_config.expect_chain_spec().is_kusama() {
|
|
||||||
sc_cli::run_service_until_exit(polkadot_config, |polkadot_config| {
|
|
||||||
parachain_config.task_executor = polkadot_config.task_executor.clone();
|
|
||||||
|
|
||||||
let (builder, inherent_data_providers) = new_full_start!(parachain_config);
|
let (builder, inherent_data_providers) = new_full_start!(parachain_config);
|
||||||
inherent_data_providers
|
inherent_data_providers
|
||||||
@@ -104,132 +94,30 @@ pub fn run_collator<E: sc_service::ChainSpecExtension>(
|
|||||||
let service = builder
|
let service = builder
|
||||||
.with_network_protocol(|_| Ok(NodeProtocol::new()))?
|
.with_network_protocol(|_| Ok(NodeProtocol::new()))?
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let proposer_factory = sc_basic_authorship::ProposerFactory {
|
let proposer_factory = sc_basic_authorship::ProposerFactory {
|
||||||
client: service.client(),
|
client: service.client(),
|
||||||
transaction_pool: service.transaction_pool(),
|
transaction_pool: service.transaction_pool(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let block_import = service.client();
|
let block_import = service.client();
|
||||||
|
let client = service.client();
|
||||||
let setup_parachain = SetupParachain {
|
let builder = CollatorBuilder::new(
|
||||||
service,
|
|
||||||
inherent_data_providers,
|
|
||||||
proposer_factory,
|
proposer_factory,
|
||||||
block_import,
|
|
||||||
};
|
|
||||||
|
|
||||||
let builder = CollatorBuilder::new(setup_parachain);
|
|
||||||
|
|
||||||
build_collator_service(
|
|
||||||
polkadot_service::kusama_new_full(polkadot_config, Some((key.public(), para_id)), None, false, 6000)?,
|
|
||||||
para_id,
|
|
||||||
key,
|
|
||||||
builder,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
sc_cli::run_service_until_exit(polkadot_config, |polkadot_config| {
|
|
||||||
parachain_config.task_executor = polkadot_config.task_executor.clone();
|
|
||||||
|
|
||||||
let (builder, inherent_data_providers) = new_full_start!(parachain_config);
|
|
||||||
inherent_data_providers
|
|
||||||
.register_provider(sp_timestamp::InherentDataProvider)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let service = builder
|
|
||||||
.with_network_protocol(|_| Ok(NodeProtocol::new()))?
|
|
||||||
.build()?;
|
|
||||||
let proposer_factory = sc_basic_authorship::ProposerFactory {
|
|
||||||
client: service.client(),
|
|
||||||
transaction_pool: service.transaction_pool(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let block_import = service.client();
|
|
||||||
|
|
||||||
let setup_parachain = SetupParachain {
|
|
||||||
service,
|
|
||||||
inherent_data_providers,
|
inherent_data_providers,
|
||||||
proposer_factory,
|
|
||||||
block_import,
|
block_import,
|
||||||
};
|
crate::PARA_ID,
|
||||||
|
client,
|
||||||
|
);
|
||||||
|
|
||||||
let builder = CollatorBuilder::new(setup_parachain);
|
let polkadot_future = polkadot_collator::start_collator(
|
||||||
|
|
||||||
build_collator_service(
|
|
||||||
polkadot_service::polkadot_new_full(polkadot_config, Some((key.public(), para_id)), None, false, 6000)?,
|
|
||||||
para_id,
|
|
||||||
key,
|
|
||||||
builder,
|
builder,
|
||||||
)
|
crate::PARA_ID,
|
||||||
|
key,
|
||||||
|
polkadot_config,
|
||||||
|
).map(|_| ());
|
||||||
|
service.spawn_essential_task("polkadot", polkadot_future);
|
||||||
|
|
||||||
|
Ok(service)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
struct SetupParachain<S, PF, BI> {
|
|
||||||
service: S,
|
|
||||||
proposer_factory: PF,
|
|
||||||
inherent_data_providers: InherentDataProviders,
|
|
||||||
block_import: BI,
|
|
||||||
}
|
|
||||||
|
|
||||||
type TransactionFor<E, Block> =
|
|
||||||
<<E as Environment<Block>>::Proposer as Proposer<Block>>::Transaction;
|
|
||||||
|
|
||||||
impl<S, PF, BI> cumulus_collator::SetupParachain<Block> for SetupParachain<S, PF, BI>
|
|
||||||
where
|
|
||||||
S: AbstractService,
|
|
||||||
PF: Environment<Block> + Send + 'static,
|
|
||||||
BI: BlockImport<Block, Error = sp_consensus::Error, Transaction = TransactionFor<PF, Block>>
|
|
||||||
+ Send
|
|
||||||
+ Sync
|
|
||||||
+ 'static,
|
|
||||||
{
|
|
||||||
type ProposerFactory = PF;
|
|
||||||
type BlockImport = BI;
|
|
||||||
|
|
||||||
fn setup_parachain<P: cumulus_consensus::PolkadotClient, Spawner>(
|
|
||||||
self,
|
|
||||||
polkadot_client: P,
|
|
||||||
spawner: Spawner,
|
|
||||||
) -> Result<
|
|
||||||
(
|
|
||||||
Self::ProposerFactory,
|
|
||||||
Self::BlockImport,
|
|
||||||
InherentDataProviders,
|
|
||||||
),
|
|
||||||
String,
|
|
||||||
>
|
|
||||||
where
|
|
||||||
Spawner: Spawn + Clone + Send + Sync + 'static,
|
|
||||||
{
|
|
||||||
let client = self.service.client();
|
|
||||||
|
|
||||||
let follow =
|
|
||||||
match cumulus_consensus::follow_polkadot(crate::PARA_ID, client, polkadot_client) {
|
|
||||||
Ok(follow) => follow,
|
|
||||||
Err(e) => {
|
|
||||||
return Err(format!("Could not start following polkadot: {:?}", e));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
spawner
|
|
||||||
.spawn_obj(
|
|
||||||
Box::new(
|
|
||||||
future::select(
|
|
||||||
self.service
|
|
||||||
.map_err(|e| error!("Parachain service error: {:?}", e)),
|
|
||||||
follow,
|
|
||||||
)
|
|
||||||
.map(|_| ()),
|
|
||||||
)
|
|
||||||
.into(),
|
|
||||||
)
|
|
||||||
.map_err(|_| "Could not spawn parachain server!")?;
|
|
||||||
|
|
||||||
Ok((
|
|
||||||
self.proposer_factory,
|
|
||||||
self.block_import,
|
|
||||||
self.inherent_data_providers,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user