Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Update futures and tokio for browser light client (#673)
Browse files Browse the repository at this point in the history
* 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 cfeb50c.

* 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 f20ae65.

* Add async blocks back in
  • Loading branch information
expenses authored Dec 10, 2019
1 parent 4782840 commit 5b4ffee
Show file tree
Hide file tree
Showing 34 changed files with 827 additions and 445 deletions.
69 changes: 35 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions availability-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ polkadot-runtime = { path = "../runtime" }
parking_lot = "0.9.0"
derive_more = "0.99"
log = "0.4.8"
futures01 = "0.1.17"
futures = { package = "futures", version = "0.3.1", features = ["compat"] }
tokio = "0.1.7"
futures = "0.3.1"
tokio = { version = "0.2.4", features = ["rt-core"] }
exit-future = "0.2.0"
codec = { package = "parity-scale-codec", version = "1.1.0", default-features = false, features = ["derive"] }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
Expand Down
12 changes: 5 additions & 7 deletions availability-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#![warn(missing_docs)]

use futures::prelude::*;
use futures::channel::{mpsc, oneshot};
use futures::{channel::{mpsc, oneshot}, task::Spawn};
use keystore::KeyStorePtr;
use polkadot_primitives::{
Hash, Block,
Expand All @@ -38,7 +38,7 @@ use client::{
BlockchainEvents, BlockBody,
};
use sp_api::ApiExt;

use std::pin::Pin;
use log::warn;

use std::sync::Arc;
Expand All @@ -58,10 +58,7 @@ use worker::{
use store::{Store as InnerStore};

/// Abstraction over an executor that lets you spawn tasks in the background.
pub(crate) type TaskExecutor =
Arc<dyn futures01::future::Executor<
Box<dyn futures01::Future<Item = (), Error = ()> + Send>
> + Send + Sync>;
pub(crate) type TaskExecutor = Arc<dyn Spawn + Send + Sync>;

const LOG_TARGET: &str = "availability";

Expand Down Expand Up @@ -110,7 +107,7 @@ pub trait ProvideGossipMessages {
fn gossip_messages_for(
&self,
topic: Hash,
) -> Box<dyn Stream<Item = (Hash, Hash, ErasureChunk)> + Send + Unpin>;
) -> Pin<Box<dyn Stream<Item = (Hash, Hash, ErasureChunk)> + Send>>;

/// Gossip an erasure chunk message.
fn gossip_erasure_chunk(
Expand Down Expand Up @@ -155,6 +152,7 @@ impl Store {
///
/// Creating a store among other things starts a background worker thread which
/// handles most of the write operations to the storage.
#[cfg(not(target_os = "unknown"))]
pub fn new<PGM>(config: Config, gossip: PGM) -> io::Result<Self>
where PGM: ProvideGossipMessages + Send + Sync + Clone + 'static
{
Expand Down
2 changes: 2 additions & 0 deletions availability-store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

#[cfg(not(target_os = "unknown"))]
use kvdb_rocksdb::{Database, DatabaseConfig};
use kvdb::{KeyValueDB, DBTransaction};
use codec::{Encode, Decode};
Expand Down Expand Up @@ -82,6 +83,7 @@ fn erasure_roots_in_relay_chain_block_key(relay_block: &Hash) -> Vec<u8> {

impl Store {
/// Create a new `Store` with given condig on disk.
#[cfg(not(target_os = "unknown"))]
pub(super) fn new(config: Config) -> io::Result<Self> {
let mut db_config = DatabaseConfig::with_columns(Some(columns::NUM_COLUMNS));

Expand Down
Loading

0 comments on commit 5b4ffee

Please sign in to comment.