Remove substrate-in-the-browser (#9541)

* Comment out browser stuff

* Remove browser stuff

* Remove more wasm transport code

* Remove ExtTransport and rework how telemetry initialises.

* Change (most) wasm-timer using code to use std::time

* Rename CI-job

* Aura does not compile for wasm

* Remove testing in the browser on CI

* Update README

* Leave `StreamSink` be

* fmt
This commit is contained in:
David
2021-08-17 20:06:23 +02:00
committed by GitHub
parent 598c6676ae
commit 2de7e51c2a
61 changed files with 57 additions and 921 deletions
+3 -15
View File
@@ -29,7 +29,7 @@ pub use crate::{
},
warp_request_handler::WarpSyncProvider,
};
pub use libp2p::{build_multiaddr, core::PublicKey, identity, wasm_ext::ExtTransport};
pub use libp2p::{build_multiaddr, core::PublicKey, identity};
// Note: this re-export shouldn't be part of the public API of the crate and will be removed in
// the future.
@@ -42,7 +42,7 @@ use core::{fmt, iter};
use futures::future;
use libp2p::{
identity::{ed25519, Keypair},
multiaddr, wasm_ext, Multiaddr, PeerId,
multiaddr, Multiaddr, PeerId,
};
use prometheus_endpoint::Registry;
use sc_consensus::ImportQueue;
@@ -490,11 +490,7 @@ impl NetworkConfiguration {
extra_sets: Vec::new(),
client_version: client_version.into(),
node_name: node_name.into(),
transport: TransportConfig::Normal {
enable_mdns: false,
allow_private_ipv4: true,
wasm_external_transport: None,
},
transport: TransportConfig::Normal { enable_mdns: false, allow_private_ipv4: true },
max_parallel_downloads: 5,
sync_mode: SyncMode::Full,
enable_dht_random_walk: true,
@@ -628,14 +624,6 @@ pub enum TransportConfig {
/// [RFC1918](https://tools.ietf.org/html/rfc1918)). Irrelevant for addresses that have
/// been passed in [`NetworkConfiguration::boot_nodes`].
allow_private_ipv4: bool,
/// Optional external implementation of a libp2p transport. Used in WASM contexts where we
/// need some binding between the networking provided by the operating system or
/// environment and libp2p.
///
/// This parameter exists whatever the target platform is, but it is expected to be set to
/// `Some` only when compiling for WASM.
wasm_external_transport: Option<wasm_ext::ExtTransport>,
},
/// Only allow connections within the same process.
+1 -2
View File
@@ -40,9 +40,8 @@ use std::{
error, io,
pin::Pin,
task::{Context, Poll},
time::Duration,
time::{Duration, Instant},
};
use wasm_timer::Instant;
/// Time after we disconnect from a node before we purge its information from the cache.
const CACHE_EXPIRE: Duration = Duration::from_secs(10 * 60);
@@ -42,9 +42,8 @@ use std::{
str,
sync::Arc,
task::{Context, Poll},
time::Duration,
time::{Duration, Instant},
};
use wasm_timer::Instant;
/// Network behaviour that handles opening substreams for custom protocols with other peers.
///
@@ -88,9 +88,8 @@ use std::{
str,
sync::Arc,
task::{Context, Poll},
time::Duration,
time::{Duration, Instant},
};
use wasm_timer::Instant;
/// Number of pending notifications in asynchronous contexts.
/// See [`NotificationsSink::reserve_notification`] for context.
@@ -24,9 +24,8 @@ use sp_blockchain::Error as ClientError;
use sp_runtime::traits::{Block as BlockT, NumberFor, Zero};
use std::{
collections::{HashMap, HashSet, VecDeque},
time::Duration,
time::{Duration, Instant},
};
use wasm_timer::Instant;
// Time to wait before trying to get the same extra data from the same peer.
const EXTRA_RETRY_WAIT: Duration = Duration::from_secs(10);
@@ -60,9 +60,8 @@ use std::{
io, iter,
pin::Pin,
task::{Context, Poll},
time::Duration,
time::{Duration, Instant},
};
use wasm_timer::Instant;
pub use libp2p::request_response::{InboundFailure, OutboundFailure, RequestId};
+3 -5
View File
@@ -291,10 +291,9 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkWorker<B, H> {
};
let (transport, bandwidth) = {
let (config_mem, config_wasm) = match params.network_config.transport {
TransportConfig::MemoryOnly => (true, None),
TransportConfig::Normal { wasm_external_transport, .. } =>
(false, wasm_external_transport),
let config_mem = match params.network_config.transport {
TransportConfig::MemoryOnly => true,
TransportConfig::Normal { .. } => false,
};
// The yamux buffer size limit is configured to be equal to the maximum frame size
@@ -337,7 +336,6 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkWorker<B, H> {
transport::build_transport(
local_identity,
config_mem,
config_wasm,
params.network_config.yamux_window_size,
yamux_maximum_buffer_size,
)
+4 -11
View File
@@ -25,7 +25,7 @@ use libp2p::{
transport::{Boxed, OptionalTransport},
upgrade,
},
identity, mplex, noise, wasm_ext, PeerId, Transport,
identity, mplex, noise, PeerId, Transport,
};
#[cfg(not(target_os = "unknown"))]
use libp2p::{dns, tcp, websocket};
@@ -51,18 +51,11 @@ pub use self::bandwidth::BandwidthSinks;
pub fn build_transport(
keypair: identity::Keypair,
memory_only: bool,
wasm_external_transport: Option<wasm_ext::ExtTransport>,
yamux_window_size: Option<u32>,
yamux_maximum_buffer_size: usize,
) -> (Boxed<(PeerId, StreamMuxerBox)>, Arc<BandwidthSinks>) {
// Build the base layer of the transport.
let transport = if let Some(t) = wasm_external_transport {
OptionalTransport::some(t)
} else {
OptionalTransport::none()
};
#[cfg(not(target_os = "unknown"))]
let transport = transport.or_transport(if !memory_only {
let transport = if !memory_only {
let desktop_trans = tcp::TcpConfig::new().nodelay(true);
let desktop_trans =
websocket::WsConfig::new(desktop_trans.clone()).or_transport(desktop_trans);
@@ -73,9 +66,9 @@ pub fn build_transport(
EitherTransport::Right(desktop_trans.map_err(dns::DnsErr::Transport))
})
} else {
// For the in-memory case we set up the transport with an `.or_transport` below.
OptionalTransport::none()
});
};
let transport = transport.or_transport(if memory_only {
OptionalTransport::some(libp2p::core::transport::MemoryTransport::default())
} else {