mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 14:01:02 +00:00
Update futures and tokio for browser light client (#673)
* Make availability-store compile for WASM * Use --manifest-path instead * Make validation work on wasm! * Switch to Spawn trait * Migrate validation to std futures * Migrate network to std futures * Final changes to validation * Tidy up network * Tidy up validation * Switch branch * Migrate service * Get polkadot to compile via wasm! * Add browser-demo * Add initial browser file * Add browser-demo * Tidy * Temp switch back to substrate/master * tidy * Fix wasm build * Re-add release flag * Switch to polkadot-master * Revert cli tokio version to avoid libp2p panic * Update tokio version * Fix availability store tests * Fix validation tests * Remove futures01 from availability-store * Fix network tests * Small changes * Fix collator * Fix typo * Revert removal of tokio_executor that causes tokio version mismatch panic * Fix adder test parachain * Revert "Revert removal of tokio_executor that causes tokio version mismatch panic" This reverts commit cfeb50c01d8df5e209483406a711e64761b44ae9. * Update availability-store/src/worker.rs Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com> * Update network/src/lib.rs Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com> * Update network/src/lib.rs Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com> * Box pin changes * Asyncify network functions * Clean up browser validation worker error * Fix av store test * Nits * Fix validation test * Switch favicon * Fix validation test again * Revert "Asyncify network functions" This reverts commit f20ae6548dc482cb1e75bc80641cfe55c6131a53. * Add async blocks back in
This commit is contained in:
+31
-15
@@ -18,7 +18,8 @@
|
||||
|
||||
pub mod chain_spec;
|
||||
|
||||
use futures::sync::mpsc;
|
||||
use futures01::sync::mpsc;
|
||||
use futures::{FutureExt, TryFutureExt, task::{Spawn, SpawnError, FutureObj}};
|
||||
use client::LongestChain;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
@@ -44,8 +45,21 @@ pub use primitives::Blake2Hasher;
|
||||
pub use sp_runtime::traits::ProvideRuntimeApi;
|
||||
pub use sc_network::specialization::NetworkSpecialization;
|
||||
pub use chain_spec::ChainSpec;
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
pub use consensus::run_validation_worker;
|
||||
|
||||
/// Wrap a futures01 executor as a futures03 spawn.
|
||||
#[derive(Clone)]
|
||||
pub struct WrappedExecutor<T>(pub T);
|
||||
|
||||
impl<T> Spawn for WrappedExecutor<T>
|
||||
where T: futures01::future::Executor<Box<dyn futures01::Future<Item=(),Error=()> + Send + 'static>>
|
||||
{
|
||||
fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError> {
|
||||
self.0.execute(Box::new(future.map(Ok).compat()))
|
||||
.map_err(|_| SpawnError::shutdown())
|
||||
}
|
||||
}
|
||||
/// Polkadot-specific configuration.
|
||||
pub struct CustomConfiguration {
|
||||
/// Set to `Some` with a collator `CollatorId` and desired parachain
|
||||
@@ -151,11 +165,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
>, ServiceError>
|
||||
{
|
||||
use sc_network::DhtEvent;
|
||||
use futures03::{
|
||||
compat::Stream01CompatExt,
|
||||
stream::StreamExt,
|
||||
future::{FutureExt, TryFutureExt},
|
||||
};
|
||||
use futures::{compat::Stream01CompatExt, stream::StreamExt};
|
||||
|
||||
let is_collator = config.custom.collating_for.is_some();
|
||||
let is_authority = config.roles.is_authority() && !is_collator;
|
||||
@@ -237,12 +247,18 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
let mut path = PathBuf::from(db_path);
|
||||
path.push("availability");
|
||||
|
||||
av_store::Store::new(::av_store::Config {
|
||||
cache_size: None,
|
||||
path,
|
||||
},
|
||||
polkadot_network::AvailabilityNetworkShim(service.network()),
|
||||
)?
|
||||
let gossip = polkadot_network::AvailabilityNetworkShim(service.network());
|
||||
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
{
|
||||
av_store::Store::new(::av_store::Config {
|
||||
cache_size: None,
|
||||
path,
|
||||
}, gossip)?
|
||||
}
|
||||
|
||||
#[cfg(target_os = "unknown")]
|
||||
av_store::Store::new_in_memory(gossip)
|
||||
};
|
||||
|
||||
{
|
||||
@@ -263,7 +279,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
service.on_exit(),
|
||||
gossip_validator,
|
||||
service.client(),
|
||||
polkadot_network::validation::WrappedExecutor(service.spawn_task_handle()),
|
||||
WrappedExecutor(service.spawn_task_handle()),
|
||||
);
|
||||
let proposer = consensus::ProposerFactory::new(
|
||||
client.clone(),
|
||||
@@ -271,7 +287,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
validation_network.clone(),
|
||||
validation_network,
|
||||
service.transaction_pool(),
|
||||
Arc::new(service.spawn_task_handle()),
|
||||
Arc::new(WrappedExecutor(service.spawn_task_handle())),
|
||||
service.keystore(),
|
||||
availability_store.clone(),
|
||||
polkadot_runtime::constants::time::SLOT_DURATION,
|
||||
@@ -287,7 +303,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
let block_import = availability_store.block_import(
|
||||
block_import,
|
||||
client.clone(),
|
||||
Arc::new(service.spawn_task_handle()),
|
||||
Arc::new(WrappedExecutor(service.spawn_task_handle())),
|
||||
service.keystore(),
|
||||
)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user