mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51:02 +00:00
* Companion for #6726 * Spaces * 'Update substrate' Co-authored-by: parity-processbot <>
This commit is contained in:
Generated
+168
-138
File diff suppressed because it is too large
Load Diff
@@ -30,25 +30,12 @@ use av_store::{Store as AvailabilityStore, ErasureNetworking};
|
|||||||
use sc_network_gossip::TopicNotification;
|
use sc_network_gossip::TopicNotification;
|
||||||
use sp_api::{ApiRef, ProvideRuntimeApi};
|
use sp_api::{ApiRef, ProvideRuntimeApi};
|
||||||
use sp_runtime::traits::Block as BlockT;
|
use sp_runtime::traits::Block as BlockT;
|
||||||
use sp_core::{crypto::Pair, traits::SpawnNamed};
|
use sp_core::{crypto::Pair, testing::TaskExecutor};
|
||||||
use sp_keyring::Sr25519Keyring;
|
use sp_keyring::Sr25519Keyring;
|
||||||
|
|
||||||
use futures::executor::{LocalPool, LocalSpawner};
|
use futures::executor::LocalPool;
|
||||||
use futures::task::{LocalSpawnExt, SpawnExt};
|
use futures::task::{LocalSpawnExt, SpawnExt};
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct Executor(LocalSpawner);
|
|
||||||
|
|
||||||
impl SpawnNamed for Executor {
|
|
||||||
fn spawn(&self, _: &'static str, future: futures::future::BoxFuture<'static, ()>) {
|
|
||||||
self.0.spawn_local(future).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn spawn_blocking(&self, name: &'static str, future: futures::future::BoxFuture<'static, ()>) {
|
|
||||||
self.spawn(name, future);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct MockNetworkOps {
|
pub struct MockNetworkOps {
|
||||||
recorded: Mutex<Recorded>,
|
recorded: Mutex<Recorded>,
|
||||||
@@ -256,7 +243,7 @@ fn test_setup(config: Config) -> (
|
|||||||
mock_gossip.clone(),
|
mock_gossip.clone(),
|
||||||
api.clone(),
|
api.clone(),
|
||||||
worker_rx,
|
worker_rx,
|
||||||
Executor(pool.spawner()),
|
TaskExecutor::new(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let service = Service {
|
let service = Service {
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ fn import_single_good_block_without_header_fails() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn async_import_queue_drops() {
|
fn async_import_queue_drops() {
|
||||||
let executor = sp_core::testing::SpawnBlockingExecutor::new();
|
let executor = sp_core::testing::TaskExecutor::new();
|
||||||
// Perform this test multiple times since it exhibits non-deterministic behavior.
|
// Perform this test multiple times since it exhibits non-deterministic behavior.
|
||||||
for _ in 0..100 {
|
for _ in 0..100 {
|
||||||
let verifier = PassThroughVerifier::new(true);
|
let verifier = PassThroughVerifier::new(true);
|
||||||
|
|||||||
@@ -573,7 +573,7 @@ pub trait TestNetFactory: Sized {
|
|||||||
Box::new(block_import.clone()),
|
Box::new(block_import.clone()),
|
||||||
justification_import,
|
justification_import,
|
||||||
finality_proof_import,
|
finality_proof_import,
|
||||||
&sp_core::testing::SpawnBlockingExecutor::new(),
|
&sp_core::testing::TaskExecutor::new(),
|
||||||
None,
|
None,
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -650,7 +650,7 @@ pub trait TestNetFactory: Sized {
|
|||||||
Box::new(block_import.clone()),
|
Box::new(block_import.clone()),
|
||||||
justification_import,
|
justification_import,
|
||||||
finality_proof_import,
|
finality_proof_import,
|
||||||
&sp_core::testing::SpawnBlockingExecutor::new(),
|
&sp_core::testing::TaskExecutor::new(),
|
||||||
None,
|
None,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
@@ -903,7 +903,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_harness<T: Future<Output=()>>(keystore: KeyStorePtr, test: impl FnOnce(TestHarness) -> T) {
|
fn test_harness<T: Future<Output=()>>(keystore: KeyStorePtr, test: impl FnOnce(TestHarness) -> T) {
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
|
|
||||||
let (context, virtual_overseer) = polkadot_subsystem::test_helpers::make_subsystem_context(pool.clone());
|
let (context, virtual_overseer) = polkadot_subsystem::test_helpers::make_subsystem_context(pool.clone());
|
||||||
|
|
||||||
|
|||||||
@@ -706,7 +706,7 @@ mod test {
|
|||||||
signed_availability: signed.clone(),
|
signed_availability: signed.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) =
|
let (mut ctx, mut handle) =
|
||||||
make_subsystem_context::<BitfieldDistributionMessage, _>(pool);
|
make_subsystem_context::<BitfieldDistributionMessage, _>(pool);
|
||||||
|
|
||||||
@@ -766,7 +766,7 @@ mod test {
|
|||||||
signed_availability: signed.clone(),
|
signed_availability: signed.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) =
|
let (mut ctx, mut handle) =
|
||||||
make_subsystem_context::<BitfieldDistributionMessage, _>(pool);
|
make_subsystem_context::<BitfieldDistributionMessage, _>(pool);
|
||||||
|
|
||||||
@@ -818,7 +818,7 @@ mod test {
|
|||||||
signed_availability: signed_bitfield.clone(),
|
signed_availability: signed_bitfield.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) =
|
let (mut ctx, mut handle) =
|
||||||
make_subsystem_context::<BitfieldDistributionMessage, _>(pool);
|
make_subsystem_context::<BitfieldDistributionMessage, _>(pool);
|
||||||
|
|
||||||
@@ -915,7 +915,7 @@ mod test {
|
|||||||
signed_availability: signed_bitfield.clone(),
|
signed_availability: signed_bitfield.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) =
|
let (mut ctx, mut handle) =
|
||||||
make_subsystem_context::<BitfieldDistributionMessage, _>(pool);
|
make_subsystem_context::<BitfieldDistributionMessage, _>(pool);
|
||||||
|
|
||||||
@@ -1052,7 +1052,7 @@ mod test {
|
|||||||
// validator 0 key pair
|
// validator 0 key pair
|
||||||
let (mut state, _signing_context, _validator_pair) = state_with_view(view![], hash_a.clone());
|
let (mut state, _signing_context, _validator_pair) = state_with_view(view![], hash_a.clone());
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) =
|
let (mut ctx, mut handle) =
|
||||||
make_subsystem_context::<BitfieldDistributionMessage, _>(pool);
|
make_subsystem_context::<BitfieldDistributionMessage, _>(pool);
|
||||||
|
|
||||||
|
|||||||
@@ -635,7 +635,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_harness<T: Future<Output=()>>(test: impl FnOnce(TestHarness) -> T) {
|
fn test_harness<T: Future<Output=()>>(test: impl FnOnce(TestHarness) -> T) {
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (network, network_handle) = new_test_network();
|
let (network, network_handle) = new_test_network();
|
||||||
let (context, virtual_overseer) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (context, virtual_overseer) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
|
|||||||
@@ -619,7 +619,7 @@ mod tests {
|
|||||||
our_view: View(vec![hash_a, hash_b]),
|
our_view: View(vec![hash_a, hash_b]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
let mut descriptor = CandidateDescriptor::default();
|
let mut descriptor = CandidateDescriptor::default();
|
||||||
descriptor.pov_hash = pov_hash;
|
descriptor.pov_hash = pov_hash;
|
||||||
@@ -699,7 +699,7 @@ mod tests {
|
|||||||
our_view: View(vec![hash_a]),
|
our_view: View(vec![hash_a]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
let mut descriptor = CandidateDescriptor::default();
|
let mut descriptor = CandidateDescriptor::default();
|
||||||
descriptor.pov_hash = pov_hash;
|
descriptor.pov_hash = pov_hash;
|
||||||
@@ -777,7 +777,7 @@ mod tests {
|
|||||||
our_view: View(vec![hash_a]),
|
our_view: View(vec![hash_a]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
@@ -849,7 +849,7 @@ mod tests {
|
|||||||
our_view: View(vec![hash_a]),
|
our_view: View(vec![hash_a]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
@@ -937,7 +937,7 @@ mod tests {
|
|||||||
our_view: View(vec![hash_a]),
|
our_view: View(vec![hash_a]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
@@ -1000,7 +1000,7 @@ mod tests {
|
|||||||
our_view: View(vec![hash_a]),
|
our_view: View(vec![hash_a]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
@@ -1061,7 +1061,7 @@ mod tests {
|
|||||||
our_view: View(vec![hash_a]),
|
our_view: View(vec![hash_a]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
@@ -1119,7 +1119,7 @@ mod tests {
|
|||||||
our_view: View(vec![hash_a]),
|
our_view: View(vec![hash_a]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
@@ -1204,7 +1204,7 @@ mod tests {
|
|||||||
our_view: View(vec![hash_a, hash_b]),
|
our_view: View(vec![hash_a, hash_b]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
@@ -1266,7 +1266,7 @@ mod tests {
|
|||||||
our_view: View(vec![hash_a]),
|
our_view: View(vec![hash_a]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
@@ -1343,7 +1343,7 @@ mod tests {
|
|||||||
our_view: View(vec![hash_a]),
|
our_view: View(vec![hash_a]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
@@ -1426,7 +1426,7 @@ mod tests {
|
|||||||
our_view: View(vec![hash_a]),
|
our_view: View(vec![hash_a]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
|
|||||||
@@ -1212,7 +1212,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
let peer = PeerId::random();
|
let peer = PeerId::random();
|
||||||
|
|
||||||
@@ -1304,7 +1304,7 @@ mod tests {
|
|||||||
(peer_c.clone(), peer_data_from_view(peer_c_view)),
|
(peer_c.clone(), peer_data_from_view(peer_c_view)),
|
||||||
].into_iter().collect();
|
].into_iter().collect();
|
||||||
|
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ impl<C> Subsystem<C> for Subsystem2
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
femme::with_level(femme::LevelFilter::Trace);
|
femme::with_level(femme::LevelFilter::Trace);
|
||||||
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
|
let spawner = sp_core::testing::TaskExecutor::new();
|
||||||
futures::executor::block_on(async {
|
futures::executor::block_on(async {
|
||||||
let timer_stream = stream::repeat(()).then(|_| async {
|
let timer_stream = stream::repeat(()).then(|_| async {
|
||||||
Delay::new(Duration::from_secs(1)).await;
|
Delay::new(Duration::from_secs(1)).await;
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ where
|
|||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// # fn main() { executor::block_on(async move {
|
/// # fn main() { executor::block_on(async move {
|
||||||
/// let spawner = sp_core::testing::SpawnBlockingExecutor::new();
|
/// let spawner = sp_core::testing::TaskExecutor::new();
|
||||||
/// let all_subsystems = AllSubsystems {
|
/// let all_subsystems = AllSubsystems {
|
||||||
/// candidate_validation: ValidationSubsystem,
|
/// candidate_validation: ValidationSubsystem,
|
||||||
/// candidate_backing: DummySubsystem,
|
/// candidate_backing: DummySubsystem,
|
||||||
@@ -1058,7 +1058,7 @@ mod tests {
|
|||||||
// Checks that a minimal configuration of two jobs can run and exchange messages.
|
// Checks that a minimal configuration of two jobs can run and exchange messages.
|
||||||
#[test]
|
#[test]
|
||||||
fn overseer_works() {
|
fn overseer_works() {
|
||||||
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
|
let spawner = sp_core::testing::TaskExecutor::new();
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
let (s1_tx, mut s1_rx) = mpsc::channel(64);
|
let (s1_tx, mut s1_rx) = mpsc::channel(64);
|
||||||
@@ -1123,7 +1123,7 @@ mod tests {
|
|||||||
// Should immediately conclude the overseer itself with an error.
|
// Should immediately conclude the overseer itself with an error.
|
||||||
#[test]
|
#[test]
|
||||||
fn overseer_panics_on_subsystem_exit() {
|
fn overseer_panics_on_subsystem_exit() {
|
||||||
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
|
let spawner = sp_core::testing::TaskExecutor::new();
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
let (s1_tx, _) = mpsc::channel(64);
|
let (s1_tx, _) = mpsc::channel(64);
|
||||||
@@ -1218,7 +1218,7 @@ mod tests {
|
|||||||
// notifications on imported blocks triggers expected `StartWork` and `StopWork` heartbeats.
|
// notifications on imported blocks triggers expected `StartWork` and `StopWork` heartbeats.
|
||||||
#[test]
|
#[test]
|
||||||
fn overseer_start_stop_works() {
|
fn overseer_start_stop_works() {
|
||||||
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
|
let spawner = sp_core::testing::TaskExecutor::new();
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
let first_block_hash = [1; 32].into();
|
let first_block_hash = [1; 32].into();
|
||||||
@@ -1314,7 +1314,7 @@ mod tests {
|
|||||||
// notifications on imported blocks triggers expected `StartWork` and `StopWork` heartbeats.
|
// notifications on imported blocks triggers expected `StartWork` and `StopWork` heartbeats.
|
||||||
#[test]
|
#[test]
|
||||||
fn overseer_finalize_works() {
|
fn overseer_finalize_works() {
|
||||||
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
|
let spawner = sp_core::testing::TaskExecutor::new();
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
let first_block_hash = [1; 32].into();
|
let first_block_hash = [1; 32].into();
|
||||||
|
|||||||
@@ -891,7 +891,7 @@ mod tests {
|
|||||||
type OverseerHandle = test_helpers::TestSubsystemContextHandle<CandidateSelectionMessage>;
|
type OverseerHandle = test_helpers::TestSubsystemContextHandle<CandidateSelectionMessage>;
|
||||||
|
|
||||||
fn test_harness<T: Future<Output=()>>(run_args: HashMap<Hash, Vec<FromJob>>, test: impl FnOnce(OverseerHandle, mpsc::Receiver<(Option<Hash>, JobsError<Error>)>) -> T) {
|
fn test_harness<T: Future<Output=()>>(run_args: HashMap<Hash, Vec<FromJob>>, test: impl FnOnce(OverseerHandle, mpsc::Receiver<(Option<Hash>, JobsError<Error>)>) -> T) {
|
||||||
let pool = sp_core::testing::SpawnBlockingExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (context, overseer_handle) = make_subsystem_context(pool.clone());
|
let (context, overseer_handle) = make_subsystem_context(pool.clone());
|
||||||
let (err_tx, err_rx) = mpsc::channel(16);
|
let (err_tx, err_rx) = mpsc::channel(16);
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ sc-executor = { git = "https://github.com/paritytech/substrate", branch = "maste
|
|||||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
|
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
|
||||||
parking_lot = { version = "0.10.0", optional = true }
|
parking_lot = { version = "0.10.0", optional = true }
|
||||||
log = { version = "0.4.8", optional = true }
|
log = { version = "0.4.8", optional = true }
|
||||||
|
futures = { version = "0.3.4", optional = true }
|
||||||
|
|
||||||
[target.'cfg(not(any(target_os = "android", target_os = "unknown")))'.dependencies]
|
[target.'cfg(not(any(target_os = "android", target_os = "unknown")))'.dependencies]
|
||||||
shared_memory = { version = "0.10.0", optional = true }
|
shared_memory = { version = "0.10.0", optional = true }
|
||||||
@@ -43,4 +44,5 @@ std = [
|
|||||||
"sc-executor",
|
"sc-executor",
|
||||||
"sp-io",
|
"sp-io",
|
||||||
"polkadot-core-primitives/std",
|
"polkadot-core-primitives/std",
|
||||||
|
"futures",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
use std::any::{TypeId, Any};
|
use std::any::{TypeId, Any};
|
||||||
use crate::primitives::{ValidationParams, ValidationResult};
|
use crate::primitives::{ValidationParams, ValidationResult};
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use sp_core::storage::ChildInfo;
|
use sp_core::{storage::ChildInfo, traits::{CallInWasm, SpawnNamed}};
|
||||||
use sp_core::traits::CallInWasm;
|
|
||||||
use sp_externalities::Extensions;
|
use sp_externalities::Extensions;
|
||||||
use sp_wasm_interface::HostFunctions as _;
|
use sp_wasm_interface::HostFunctions as _;
|
||||||
|
|
||||||
@@ -119,10 +118,11 @@ pub fn validate_candidate(
|
|||||||
validation_code: &[u8],
|
validation_code: &[u8],
|
||||||
params: ValidationParams,
|
params: ValidationParams,
|
||||||
options: ExecutionMode<'_>,
|
options: ExecutionMode<'_>,
|
||||||
|
spawner: impl SpawnNamed + 'static,
|
||||||
) -> Result<ValidationResult, Error> {
|
) -> Result<ValidationResult, Error> {
|
||||||
match options {
|
match options {
|
||||||
ExecutionMode::Local => {
|
ExecutionMode::Local => {
|
||||||
validate_candidate_internal(validation_code, ¶ms.encode())
|
validate_candidate_internal(validation_code, ¶ms.encode(), spawner)
|
||||||
},
|
},
|
||||||
#[cfg(not(any(target_os = "android", target_os = "unknown")))]
|
#[cfg(not(any(target_os = "android", target_os = "unknown")))]
|
||||||
ExecutionMode::Remote(pool) => {
|
ExecutionMode::Remote(pool) => {
|
||||||
@@ -154,9 +154,10 @@ type HostFunctions = sp_io::SubstrateHostFunctions;
|
|||||||
pub fn validate_candidate_internal(
|
pub fn validate_candidate_internal(
|
||||||
validation_code: &[u8],
|
validation_code: &[u8],
|
||||||
encoded_call_data: &[u8],
|
encoded_call_data: &[u8],
|
||||||
|
spawner: impl SpawnNamed + 'static,
|
||||||
) -> Result<ValidationResult, Error> {
|
) -> Result<ValidationResult, Error> {
|
||||||
let mut extensions = Extensions::new();
|
let mut extensions = Extensions::new();
|
||||||
extensions.register(sp_core::traits::TaskExecutorExt(sp_core::tasks::executor()));
|
extensions.register(sp_core::traits::TaskExecutorExt::new(spawner));
|
||||||
|
|
||||||
let mut ext = ValidationExternalities(extensions);
|
let mut ext = ValidationExternalities(extensions);
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,12 @@
|
|||||||
use std::{process, env, sync::Arc, sync::atomic};
|
use std::{process, env, sync::Arc, sync::atomic};
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use crate::primitives::{ValidationParams, ValidationResult};
|
use crate::primitives::{ValidationParams, ValidationResult};
|
||||||
use super::{validate_candidate_internal, Error};
|
use super::{validate_candidate_internal, Error, MAX_CODE_MEM, MAX_RUNTIME_MEM};
|
||||||
use super::{MAX_CODE_MEM, MAX_RUNTIME_MEM};
|
|
||||||
use shared_memory::{SharedMem, SharedMemConf, EventState, WriteLockable, EventWait, EventSet};
|
use shared_memory::{SharedMem, SharedMemConf, EventState, WriteLockable, EventWait, EventSet};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use log::{debug, trace};
|
use log::{debug, trace};
|
||||||
|
use futures::executor::ThreadPool;
|
||||||
|
use sp_core::traits::SpawnNamed;
|
||||||
|
|
||||||
const WORKER_ARGS_TEST: &[&'static str] = &["--nocapture", "validation_worker"];
|
const WORKER_ARGS_TEST: &[&'static str] = &["--nocapture", "validation_worker"];
|
||||||
/// CLI Argument to start in validation worker mode.
|
/// CLI Argument to start in validation worker mode.
|
||||||
@@ -43,6 +44,25 @@ enum Event {
|
|||||||
WorkerReady = 2,
|
WorkerReady = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
struct TaskExecutor(ThreadPool);
|
||||||
|
|
||||||
|
impl TaskExecutor {
|
||||||
|
fn new() -> Result<Self, String> {
|
||||||
|
ThreadPool::new().map_err(|e| e.to_string()).map(Self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SpawnNamed for TaskExecutor {
|
||||||
|
fn spawn_blocking(&self, _: &'static str, future: futures::future::BoxFuture<'static, ()>) {
|
||||||
|
self.0.spawn_ok(future);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn spawn(&self, _: &'static str, future: futures::future::BoxFuture<'static, ()>) {
|
||||||
|
self.0.spawn_ok(future);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A pool of hosts.
|
/// A pool of hosts.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ValidationPool {
|
pub struct ValidationPool {
|
||||||
@@ -92,6 +112,7 @@ pub fn run_worker(mem_id: &str) -> Result<(), String> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let exit = Arc::new(atomic::AtomicBool::new(false));
|
let exit = Arc::new(atomic::AtomicBool::new(false));
|
||||||
|
let task_executor = TaskExecutor::new()?;
|
||||||
// spawn parent monitor thread
|
// spawn parent monitor thread
|
||||||
let watch_exit = exit.clone();
|
let watch_exit = exit.clone();
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
@@ -139,7 +160,7 @@ pub fn run_worker(mem_id: &str) -> Result<(), String> {
|
|||||||
let (call_data, _) = rest.split_at_mut(MAX_RUNTIME_MEM);
|
let (call_data, _) = rest.split_at_mut(MAX_RUNTIME_MEM);
|
||||||
let (call_data, _) = call_data.split_at_mut(header.params_size as usize);
|
let (call_data, _) = call_data.split_at_mut(header.params_size as usize);
|
||||||
|
|
||||||
let result = validate_candidate_internal(code, call_data);
|
let result = validate_candidate_internal(code, call_data, task_executor.clone());
|
||||||
debug!("{} Candidate validated: {:?}", process::id(), result);
|
debug!("{} Candidate validated: {:?}", process::id(), result);
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ adder = { package = "test-parachain-adder", path = "adder" }
|
|||||||
halt = { package = "test-parachain-halt", path = "halt" }
|
halt = { package = "test-parachain-halt", path = "halt" }
|
||||||
code-upgrader = { package = "test-parachain-code-upgrader", path = "code-upgrader" }
|
code-upgrader = { package = "test-parachain-code-upgrader", path = "code-upgrader" }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [ "std" ]
|
default = [ "std" ]
|
||||||
std = [
|
std = [
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ pub fn execute_good_on_parent() {
|
|||||||
code_upgrade_allowed: None,
|
code_upgrade_allowed: None,
|
||||||
},
|
},
|
||||||
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
||||||
|
sp_core::testing::TaskExecutor::new(),
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
let new_head = HeadData::decode(&mut &ret.head_data.0[..]).unwrap();
|
let new_head = HeadData::decode(&mut &ret.head_data.0[..]).unwrap();
|
||||||
@@ -117,6 +118,7 @@ fn execute_good_chain_on_parent() {
|
|||||||
code_upgrade_allowed: None,
|
code_upgrade_allowed: None,
|
||||||
},
|
},
|
||||||
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
||||||
|
sp_core::testing::TaskExecutor::new(),
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
let new_head = HeadData::decode(&mut &ret.head_data.0[..]).unwrap();
|
let new_head = HeadData::decode(&mut &ret.head_data.0[..]).unwrap();
|
||||||
@@ -157,5 +159,6 @@ fn execute_bad_on_parent() {
|
|||||||
code_upgrade_allowed: None,
|
code_upgrade_allowed: None,
|
||||||
},
|
},
|
||||||
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
||||||
|
sp_core::testing::TaskExecutor::new(),
|
||||||
).unwrap_err();
|
).unwrap_err();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ pub fn execute_good_no_upgrade() {
|
|||||||
code_upgrade_allowed: None,
|
code_upgrade_allowed: None,
|
||||||
},
|
},
|
||||||
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
||||||
|
sp_core::testing::TaskExecutor::new(),
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
let new_head = HeadData::decode(&mut &ret.head_data.0[..]).unwrap();
|
let new_head = HeadData::decode(&mut &ret.head_data.0[..]).unwrap();
|
||||||
@@ -86,6 +87,7 @@ pub fn execute_good_with_upgrade() {
|
|||||||
code_upgrade_allowed: Some(20),
|
code_upgrade_allowed: Some(20),
|
||||||
},
|
},
|
||||||
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
||||||
|
sp_core::testing::TaskExecutor::new(),
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
let new_head = HeadData::decode(&mut &ret.head_data.0[..]).unwrap();
|
let new_head = HeadData::decode(&mut &ret.head_data.0[..]).unwrap();
|
||||||
@@ -129,6 +131,7 @@ pub fn code_upgrade_not_allowed() {
|
|||||||
code_upgrade_allowed: None,
|
code_upgrade_allowed: None,
|
||||||
},
|
},
|
||||||
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
||||||
|
sp_core::testing::TaskExecutor::new(),
|
||||||
).unwrap();
|
).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +162,7 @@ pub fn applies_code_upgrade_after_delay() {
|
|||||||
code_upgrade_allowed: Some(2),
|
code_upgrade_allowed: Some(2),
|
||||||
},
|
},
|
||||||
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
||||||
|
sp_core::testing::TaskExecutor::new(),
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
let new_head = HeadData::decode(&mut &ret.head_data.0[..]).unwrap();
|
let new_head = HeadData::decode(&mut &ret.head_data.0[..]).unwrap();
|
||||||
@@ -194,6 +198,7 @@ pub fn applies_code_upgrade_after_delay() {
|
|||||||
code_upgrade_allowed: None,
|
code_upgrade_allowed: None,
|
||||||
},
|
},
|
||||||
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
||||||
|
sp_core::testing::TaskExecutor::new(),
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
let new_head = HeadData::decode(&mut &ret.head_data.0[..]).unwrap();
|
let new_head = HeadData::decode(&mut &ret.head_data.0[..]).unwrap();
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ fn terminates_on_timeout() {
|
|||||||
code_upgrade_allowed: None,
|
code_upgrade_allowed: None,
|
||||||
},
|
},
|
||||||
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
||||||
|
sp_core::testing::TaskExecutor::new(),
|
||||||
);
|
);
|
||||||
match result {
|
match result {
|
||||||
Err(parachain::wasm_executor::Error::Timeout) => {},
|
Err(parachain::wasm_executor::Error::Timeout) => {},
|
||||||
@@ -66,6 +67,7 @@ fn parallel_execution() {
|
|||||||
code_upgrade_allowed: None,
|
code_upgrade_allowed: None,
|
||||||
},
|
},
|
||||||
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool2),
|
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool2),
|
||||||
|
sp_core::testing::TaskExecutor::new(),
|
||||||
).ok());
|
).ok());
|
||||||
let _ = parachain::wasm_executor::validate_candidate(
|
let _ = parachain::wasm_executor::validate_candidate(
|
||||||
halt::wasm_binary_unwrap(),
|
halt::wasm_binary_unwrap(),
|
||||||
@@ -78,6 +80,7 @@ fn parallel_execution() {
|
|||||||
code_upgrade_allowed: None,
|
code_upgrade_allowed: None,
|
||||||
},
|
},
|
||||||
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
parachain::wasm_executor::ExecutionMode::RemoteTest(&pool),
|
||||||
|
sp_core::testing::TaskExecutor::new(),
|
||||||
);
|
);
|
||||||
thread.join().unwrap();
|
thread.join().unwrap();
|
||||||
// total time should be < 2 x EXECUTION_TIMEOUT_SEC
|
// total time should be < 2 x EXECUTION_TIMEOUT_SEC
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ pub fn new_light() -> (
|
|||||||
let local_call_executor = LocalCallExecutor::new(
|
let local_call_executor = LocalCallExecutor::new(
|
||||||
backend.clone(),
|
backend.clone(),
|
||||||
executor,
|
executor,
|
||||||
sp_core::tasks::executor(),
|
Box::new(sp_core::testing::TaskExecutor::new()),
|
||||||
Default::default()
|
Default::default()
|
||||||
);
|
);
|
||||||
let call_executor = LightExecutor::new(
|
let call_executor = LightExecutor::new(
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ use polkadot_erasure_coding as erasure;
|
|||||||
use sp_api::ProvideRuntimeApi;
|
use sp_api::ProvideRuntimeApi;
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
use primitives::traits::SpawnNamed;
|
||||||
|
|
||||||
/// Encapsulates connections to collators and allows collation on any parachain.
|
/// Encapsulates connections to collators and allows collation on any parachain.
|
||||||
///
|
///
|
||||||
@@ -64,6 +65,7 @@ pub async fn collation_fetch<C: Collators, P>(
|
|||||||
client: Arc<P>,
|
client: Arc<P>,
|
||||||
max_block_data_size: Option<u64>,
|
max_block_data_size: Option<u64>,
|
||||||
n_validators: usize,
|
n_validators: usize,
|
||||||
|
spawner: impl SpawnNamed + Clone + 'static,
|
||||||
) -> Result<(CollationInfo, crate::pipeline::FullOutput), C::Error>
|
) -> Result<(CollationInfo, crate::pipeline::FullOutput), C::Error>
|
||||||
where
|
where
|
||||||
P::Api: ParachainHost<Block, Error = sp_blockchain::Error>,
|
P::Api: ParachainHost<Block, Error = sp_blockchain::Error>,
|
||||||
@@ -82,6 +84,7 @@ pub async fn collation_fetch<C: Collators, P>(
|
|||||||
&relay_parent,
|
&relay_parent,
|
||||||
max_block_data_size,
|
max_block_data_size,
|
||||||
n_validators,
|
n_validators,
|
||||||
|
spawner.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
match res {
|
match res {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ use parachain::{
|
|||||||
use runtime_primitives::traits::{BlakeTwo256, Hash as HashT};
|
use runtime_primitives::traits::{BlakeTwo256, Hash as HashT};
|
||||||
use sp_api::ProvideRuntimeApi;
|
use sp_api::ProvideRuntimeApi;
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
use primitives::traits::SpawnNamed;
|
||||||
|
|
||||||
pub use parachain::wasm_executor::ValidationPool;
|
pub use parachain::wasm_executor::ValidationPool;
|
||||||
|
|
||||||
@@ -191,6 +192,7 @@ pub fn validate<'a>(
|
|||||||
local_validation: &'a LocalValidationData,
|
local_validation: &'a LocalValidationData,
|
||||||
global_validation: &'a GlobalValidationData,
|
global_validation: &'a GlobalValidationData,
|
||||||
validation_code: &ValidationCode,
|
validation_code: &ValidationCode,
|
||||||
|
spawner: impl SpawnNamed + 'static,
|
||||||
) -> Result<ValidatedCandidate<'a>, Error> {
|
) -> Result<ValidatedCandidate<'a>, Error> {
|
||||||
if collation.head_data.0.len() > global_validation.max_head_data_size as _ {
|
if collation.head_data.0.len() > global_validation.max_head_data_size as _ {
|
||||||
return Err(Error::HeadDataTooLarge(
|
return Err(Error::HeadDataTooLarge(
|
||||||
@@ -222,6 +224,7 @@ pub fn validate<'a>(
|
|||||||
&validation_code.0,
|
&validation_code.0,
|
||||||
params,
|
params,
|
||||||
execution_mode,
|
execution_mode,
|
||||||
|
spawner,
|
||||||
) {
|
) {
|
||||||
Ok(result) => {
|
Ok(result) => {
|
||||||
if result.head_data == collation.head_data {
|
if result.head_data == collation.head_data {
|
||||||
@@ -277,6 +280,7 @@ pub fn full_output_validation_with_api<P>(
|
|||||||
expected_relay_parent: &Hash,
|
expected_relay_parent: &Hash,
|
||||||
max_block_data_size: Option<u64>,
|
max_block_data_size: Option<u64>,
|
||||||
n_validators: usize,
|
n_validators: usize,
|
||||||
|
spawner: impl SpawnNamed + 'static,
|
||||||
) -> Result<FullOutput, Error> where
|
) -> Result<FullOutput, Error> where
|
||||||
P: ProvideRuntimeApi<Block>,
|
P: ProvideRuntimeApi<Block>,
|
||||||
P::Api: ParachainHost<Block, Error = sp_blockchain::Error>,
|
P::Api: ParachainHost<Block, Error = sp_blockchain::Error>,
|
||||||
@@ -302,6 +306,7 @@ pub fn full_output_validation_with_api<P>(
|
|||||||
&local_validation,
|
&local_validation,
|
||||||
&global_validation,
|
&global_validation,
|
||||||
&validation_code,
|
&validation_code,
|
||||||
|
spawner,
|
||||||
);
|
);
|
||||||
|
|
||||||
match res {
|
match res {
|
||||||
|
|||||||
@@ -312,6 +312,7 @@ impl<Fetch: Future + Unpin> ParachainWork<Fetch> {
|
|||||||
&expected_relay_parent,
|
&expected_relay_parent,
|
||||||
max_block_data_size,
|
max_block_data_size,
|
||||||
n_validators,
|
n_validators,
|
||||||
|
primitives::testing::TaskExecutor::new(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
full_output.check_consistency(candidate)?;
|
full_output.check_consistency(candidate)?;
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ impl<C, N, P, SC, SP> ServiceBuilder<C, N, P, SC, SP> where
|
|||||||
N::BuildTableRouter: Send + Unpin + 'static,
|
N::BuildTableRouter: Send + Unpin + 'static,
|
||||||
<N::TableRouter as TableRouter>::SendLocalCollation: Send,
|
<N::TableRouter as TableRouter>::SendLocalCollation: Send,
|
||||||
SC: SelectChain<Block> + 'static,
|
SC: SelectChain<Block> + 'static,
|
||||||
SP: SpawnNamed + Send + 'static,
|
SP: SpawnNamed + Clone + 'static,
|
||||||
// Rust bug: https://github.com/rust-lang/rust/issues/24159
|
// Rust bug: https://github.com/rust-lang/rust/issues/24159
|
||||||
sp_api::StateBackendFor<P, Block>: sp_api::StateBackend<HashFor<Block>>,
|
sp_api::StateBackendFor<P, Block>: sp_api::StateBackend<HashFor<Block>>,
|
||||||
{
|
{
|
||||||
@@ -167,11 +167,15 @@ impl<C, N, P, SC, SP> ServiceBuilder<C, N, P, SC, SP> where
|
|||||||
let mut parachain_validation = ParachainValidationInstances {
|
let mut parachain_validation = ParachainValidationInstances {
|
||||||
client: self.client.clone(),
|
client: self.client.clone(),
|
||||||
network: self.network,
|
network: self.network,
|
||||||
spawner: self.spawner,
|
spawner: self.spawner.clone(),
|
||||||
availability_store: self.availability_store,
|
availability_store: self.availability_store,
|
||||||
live_instances: HashMap::new(),
|
live_instances: HashMap::new(),
|
||||||
validation_pool: validation_pool.clone(),
|
validation_pool: validation_pool.clone(),
|
||||||
collation_fetch: DefaultCollationFetch(self.collators, validation_pool),
|
collation_fetch: DefaultCollationFetch {
|
||||||
|
collators: self.collators,
|
||||||
|
validation_pool,
|
||||||
|
spawner: self.spawner,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let client = self.client;
|
let client = self.client;
|
||||||
@@ -253,11 +257,17 @@ pub(crate) trait CollationFetch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct DefaultCollationFetch<C>(C, Option<ValidationPool>);
|
struct DefaultCollationFetch<C, S> {
|
||||||
impl<C> CollationFetch for DefaultCollationFetch<C>
|
collators: C,
|
||||||
|
validation_pool: Option<ValidationPool>,
|
||||||
|
spawner: S,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C, S> CollationFetch for DefaultCollationFetch<C, S>
|
||||||
where
|
where
|
||||||
C: Collators + Send + Sync + Unpin + 'static,
|
C: Collators + Send + Sync + Unpin + 'static,
|
||||||
C::Collation: Send + Unpin + 'static,
|
C::Collation: Send + Unpin + 'static,
|
||||||
|
S: SpawnNamed + Clone + 'static,
|
||||||
{
|
{
|
||||||
type Error = C::Error;
|
type Error = C::Error;
|
||||||
|
|
||||||
@@ -273,15 +283,15 @@ impl<C> CollationFetch for DefaultCollationFetch<C>
|
|||||||
P::Api: ParachainHost<Block, Error = sp_blockchain::Error>,
|
P::Api: ParachainHost<Block, Error = sp_blockchain::Error>,
|
||||||
P: ProvideRuntimeApi<Block> + Send + Sync + 'static,
|
P: ProvideRuntimeApi<Block> + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
let DefaultCollationFetch(collators, validation_pool) = self;
|
|
||||||
crate::collation::collation_fetch(
|
crate::collation::collation_fetch(
|
||||||
validation_pool,
|
self.validation_pool,
|
||||||
parachain,
|
parachain,
|
||||||
relay_parent,
|
relay_parent,
|
||||||
collators,
|
self.collators,
|
||||||
client,
|
client,
|
||||||
max_block_data_size,
|
max_block_data_size,
|
||||||
n_validators,
|
n_validators,
|
||||||
|
self.spawner,
|
||||||
).boxed()
|
).boxed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -553,7 +563,7 @@ mod tests {
|
|||||||
use runtime_primitives::traits::Block as BlockT;
|
use runtime_primitives::traits::Block as BlockT;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use sp_keyring::sr25519::Keyring;
|
use sp_keyring::sr25519::Keyring;
|
||||||
use primitives::testing::SpawnBlockingExecutor;
|
use primitives::testing::TaskExecutor;
|
||||||
|
|
||||||
/// Events fired while running mock implementations to follow execution.
|
/// Events fired while running mock implementations to follow execution.
|
||||||
enum Events {
|
enum Events {
|
||||||
@@ -714,7 +724,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn launch_work_is_executed_properly() {
|
fn launch_work_is_executed_properly() {
|
||||||
let executor = SpawnBlockingExecutor::new();
|
let executor = TaskExecutor::new();
|
||||||
let keystore = keystore::Store::new_in_memory();
|
let keystore = keystore::Store::new_in_memory();
|
||||||
|
|
||||||
// Make sure `Bob` key is in the keystore, so this mocked node will be a parachain validator.
|
// Make sure `Bob` key is in the keystore, so this mocked node will be a parachain validator.
|
||||||
@@ -754,7 +764,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn router_is_built_on_relay_chain_validator() {
|
fn router_is_built_on_relay_chain_validator() {
|
||||||
let executor = SpawnBlockingExecutor::new();
|
let executor = TaskExecutor::new();
|
||||||
let keystore = keystore::Store::new_in_memory();
|
let keystore = keystore::Store::new_in_memory();
|
||||||
|
|
||||||
// Make sure `Alice` key is in the keystore, so this mocked node will be a relay-chain validator.
|
// Make sure `Alice` key is in the keystore, so this mocked node will be a relay-chain validator.
|
||||||
|
|||||||
Reference in New Issue
Block a user