Skip to content

Commit

Permalink
Remove web RTC due to memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
aterentic-ethernal committed Dec 20, 2024
1 parent b06d05c commit 4df8f58
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 696 deletions.
668 changes: 16 additions & 652 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ rand = { version = "0.8.5", default-features = false }
# TODO: Replace with released libp2p version once webrtc-websys compilation issue is resolved
libp2p = { git = "https://github.com/libp2p/rust-libp2p", rev = "aa9317fbdd88cc4c9a39ea608fa1d57e022297fc", features = ["kad", "identify", "ping", "mdns", "autonat", "relay", "dcutr", "upnp", "noise", "yamux", "dns", "metrics", "tokio", "macros", "tcp", "quic", "serde", "websocket"] }
libp2p-allow-block-list = { git = "https://github.com/libp2p/rust-libp2p", rev = "aa9317fbdd88cc4c9a39ea608fa1d57e022297fc" }
libp2p-webrtc = { git = "https://github.com/libp2p/rust-libp2p", rev = "aa9317fbdd88cc4c9a39ea608fa1d57e022297fc" }
libp2p-webrtc-websys = { git = "https://github.com/libp2p/rust-libp2p", rev = "aa9317fbdd88cc4c9a39ea608fa1d57e022297fc" }
multihash = { version = "0.14.0", default-features = false, features = ["blake3", "sha3"] }
semver = "1.0.23"
Expand Down
4 changes: 4 additions & 0 deletions bootstrap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.4.2](https://github.com/availproject/avail-light/releases/tag/avail-light-bootstrap-v0.4.2) - 2024-12-20

- Temporary remove WebRTC support to reduce memory usage

## [0.4.1](https://github.com/availproject/avail-light/releases/tag/avail-light-bootstrap-v0.4.1) - 2024-11-29

- Update opentelemetry sdk version
Expand Down
5 changes: 2 additions & 3 deletions bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "avail-light-bootstrap"
version = "0.4.1"
version = "0.4.2"
build = "../build.rs"
edition = "2021"
description = "Avail network Bootstrap Node for p2p Light Client"
Expand All @@ -14,12 +14,11 @@ confy = { workspace = true }
hex = { workspace = true }
libp2p = { workspace = true }
libp2p-allow-block-list = { workspace = true }
libp2p-webrtc = { workspace = true, features = ["tokio"] }
multihash = { workspace = true }
rand = { workspace = true }
semver = { workspace = true }
serde = { workspace = true }
tokio = { workspace = true }
tokio = { workspace = true, features = ["signal"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
void = { workspace = true }
Expand Down
11 changes: 0 additions & 11 deletions bootstrap/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ async fn run() -> Result<()> {

info!("TCP listener started on port {}.", cfg.port);

network_client
.start_listening(webrtc_multiaddress(cfg.webrtc_port))
.await
.context("Unable to create WebRTC P2P listener.")?;

info!("WebRTC listening on port {}.", cfg.webrtc_port);

info!("Bootstrap node starting ...");
Expand Down Expand Up @@ -178,9 +173,3 @@ fn construct_multiaddress(is_websocket: bool, port: u16) -> Multiaddr {

tcp_multiaddress
}

fn webrtc_multiaddress(webrtc_port: u16) -> Multiaddr {
Multiaddr::from(Ipv4Addr::UNSPECIFIED)
.with(Protocol::Udp(webrtc_port))
.with(Protocol::WebRTCDirect)
}
7 changes: 0 additions & 7 deletions bootstrap/src/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use libp2p::{
swarm::NetworkBehaviour,
tcp, yamux, PeerId, SwarmBuilder,
};
use libp2p_webrtc as webrtc;
use multihash::Hasher;
use rand::thread_rng;
use tokio::sync::mpsc;

mod client;
Expand Down Expand Up @@ -105,11 +103,6 @@ pub async fn init(
noise::Config::new,
yamux::Config::default,
)?
.with_other_transport(|keypair| {
use webrtc::tokio::{Certificate, Transport};
let certificate = Certificate::generate(&mut thread_rng());
Ok(Transport::new(keypair.clone(), certificate?))
})?
.with_dns()?
.with_behaviour(behaviour)?
.with_swarm_config(|c| generate_config(c, cfg))
Expand Down
2 changes: 1 addition & 1 deletion client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## 1.12.4
## [1.12.4](https://github.com/availproject/avail-light/releases/tag/avail-light-client-v1.12.4) - 2024-12-20

- Update `avail-light-core` to 1.1.0

Expand Down
10 changes: 2 additions & 8 deletions client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,14 @@ async fn run(

spawn_in_span(shutdown.with_cancel(p2p_event_loop.run()));

let addrs = vec![
cfg.libp2p.tcp_multiaddress(),
cfg.libp2p.webrtc_multiaddress(),
];
let addrs = vec![cfg.libp2p.tcp_multiaddress()];

// Start the TCP and WebRTC listeners
p2p_client
.start_listening(addrs)
.await
.wrap_err("Error starting listener.")?;
info!(
"TCP listener started on port {}. WebRTC listening on port {}.",
cfg.libp2p.port, cfg.libp2p.webrtc_port
);
info!("TCP listener started on port {}", cfg.libp2p.port);

let p2p_clone = p2p_client.to_owned();
let cfg_clone = cfg.to_owned();
Expand Down
3 changes: 2 additions & 1 deletion core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog

## 1.1.0
## [1.1.0](https://github.com/availproject/avail-light/tree/avail-light-core-v1.1.0) - 2024-12-20

- Temporary remove WebRTC support to reduce memory usage
- Update opentelemetry sdk version to 0.27.1
- Enable WASM compilation of the network, light_client and related mods

Expand Down
4 changes: 2 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ smallvec = "1.6.1"
strip-ansi-escapes = "0.2.0"
strum = { version = "0.26.3", features = ["derive"] }
sysinfo = "0.30.12"
tokio = { workspace = true }
tokio-retry = "0.3"
tokio-stream = { workspace = true }
tracing = { workspace = true }
Expand All @@ -50,7 +49,6 @@ hyper = { version = "0.14.23", features = ["full", "http1"] }
jsonrpsee-core = { version = "0.21.0", features = ["client"] }
libc = "0.2.150"
libp2p = { workspace = true }
libp2p-webrtc = { workspace = true, features = ["tokio"] }
multihash = { workspace = true }
num = "0.4.0"
num_cpus = "1.13.0"
Expand All @@ -61,6 +59,7 @@ rocksdb = { version = "0.21.0", features = ["snappy", "multi-threaded-cf"], opti
strip-ansi-escapes = "0.2.0"
thiserror = "1.0.64"
threadpool = "1.8.1"
tokio = { workspace = true, features = ["signal"] }
tokio-util = "0.7.10"
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
Expand All @@ -82,6 +81,7 @@ libp2p = { workspace = true, features = ["wasm-bindgen"] }
libp2p-webrtc-websys = { workspace = true }
rand = { workspace = true, features = ["std_rng"] }
thiserror-no-std = "2.0.2"
tokio = { workspace = true }
tokio_with_wasm = { version = "0.7.1", default-features = false, features = ["sync", "macros", "rt", "time"] }
wasm-bindgen = "0.2.90"
web-time = "1.1.0"
Expand Down
9 changes: 0 additions & 9 deletions core/src/network/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ use libp2p::{
#[cfg(not(target_arch = "wasm32"))]
use libp2p::{mdns, tcp, upnp};
#[cfg(not(target_arch = "wasm32"))]
use libp2p_webrtc as webrtc;
#[cfg(not(target_arch = "wasm32"))]
use multihash::{self, Hasher};
#[cfg(not(target_arch = "wasm32"))]
use rand::thread_rng;
use semver::Version;
use serde::{Deserialize, Serialize};
#[cfg(not(target_arch = "wasm32"))]
Expand Down Expand Up @@ -340,11 +336,6 @@ async fn build_swarm(
noise::Config::new,
yamux::Config::default,
)?
.with_other_transport(|keypair| {
use webrtc::tokio::{Certificate, Transport};
let certificate = Certificate::generate(&mut thread_rng());
Ok(Transport::new(keypair.clone(), certificate?))
})?
.with_dns()?
.with_relay_client(noise::Config::new, yamux::Config::default)?
.with_behaviour(behaviour)?
Expand Down
2 changes: 1 addition & 1 deletion fat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## 1.12.3
## [1.12.3](https://github.com/availproject/avail-light/releases/tag/avail-light-fat-v1.12.3) - 2024-12-20

- Update `avail-light-core` to 1.1.0

Expand Down

0 comments on commit 4df8f58

Please sign in to comment.