From 1237e038d1e5381ca307300b5692a3d3e6d0c34e Mon Sep 17 00:00:00 2001 From: Chris O'Neil Date: Fri, 6 Dec 2024 16:35:29 +0000 Subject: [PATCH] chore: remove the `websockets` feature We will no longer use websocket connections with libp2p. --- .github/workflows/cross-platform.yml | 16 --- .github/workflows/merge_websocket.yml | 162 -------------------------- Justfile | 8 +- README.md | 7 -- ant-cli/Cargo.toml | 1 - ant-networking/Cargo.toml | 1 - ant-networking/src/driver.rs | 11 -- ant-networking/src/transport/other.rs | 26 ----- ant-node/Cargo.toml | 1 - ant-protocol/Cargo.toml | 1 - autonomi/Cargo.toml | 1 - 11 files changed, 4 insertions(+), 231 deletions(-) delete mode 100644 .github/workflows/merge_websocket.yml diff --git a/.github/workflows/cross-platform.yml b/.github/workflows/cross-platform.yml index 103b9af8fd..7b268cba02 100644 --- a/.github/workflows/cross-platform.yml +++ b/.github/workflows/cross-platform.yml @@ -38,19 +38,3 @@ jobs: # Allow clippy lints (these can be pedantic on WASM), but deny regular Rust warnings run: cargo clippy --target=wasm32-unknown-unknown --package=autonomi --lib --tests -- --allow=clippy::all --deny=warnings timeout-minutes: 30 - - websocket: - if: "!startsWith(github.event.head_commit.message, 'chore(release):')" - name: Standard Websocket builds - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - - name: Build all for `websockets` - run: cargo build --features="websockets" - timeout-minutes: 30 diff --git a/.github/workflows/merge_websocket.yml b/.github/workflows/merge_websocket.yml deleted file mode 100644 index ca2c17c435..0000000000 --- a/.github/workflows/merge_websocket.yml +++ /dev/null @@ -1,162 +0,0 @@ -name: Check before merge (websockets) - -on: - # tests must run for a PR to be valid and pass merge queue muster - # on main, we want to know that all commits are passing at a glance, any deviation should help bisecting errors - # the merge run checks should show on master and enable this clear test/passing history - merge_group: - branches: [main, alpha*, beta*, rc*] - pull_request: - branches: ["*"] - -env: - CARGO_INCREMENTAL: 0 # bookkeeping for incremental builds has overhead, not useful in CI. - WINSW_URL: https://github.com/winsw/winsw/releases/download/v3.0.0-alpha.11/WinSW-x64.exe - GENESIS_PK: 9377ab39708a59d02d09bfd3c9bc7548faab9e0c2a2700b9ac7d5c14f0842f0b4bb0df411b6abd3f1a92b9aa1ebf5c3d - GENESIS_SK: 5ec88891c1098a0fede5b98b07f8abc931d7247b7aa310d21ab430cc957f9f02 - -jobs: - large_file_upload_test_with_ws: - if: "!startsWith(github.event.head_commit.message, 'chore(release):')" - name: Large file upload (websockets) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - - name: install ripgrep - shell: bash - run: sudo apt-get install -y ripgrep - - - name: Check the available space - run: | - df - echo "Home dir:" - du -sh /home/runner/ - echo "Home subdirs:" - du -sh /home/runner/*/ - echo "PWD:" - du -sh . - echo "PWD subdirs:" - du -sh */ - - - name: Download material (135MB) - shell: bash - run: | - mkdir test_data_1 - cd test_data_1 - wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/Qi930/safe-qiWithListeners-x86_64.tar.gz - wget https://sn-node.s3.eu-west-2.amazonaws.com/joshuef/Qi930/safenode-qiWithListeners-x86_64.tar.gz - ls -l - cd .. - tar -cvzf test_data_1.tar.gz test_data_1 - ls -l - - - name: Build binaries - run: cargo build --release --features local,websockets --bin antnode --bin ant - timeout-minutes: 30 - - - name: Start a local network - uses: maidsafe/ant-local-testnet-action@main - with: - action: start - enable-evm-testnet: true - node-path: target/release/antnode - platform: ubuntu-latest - build: true - sn-log: "" - - - name: Check if ANT_PEERS and EVM_NETWORK are set - shell: bash - run: | - if [[ -z "$ANT_PEERS" ]]; then - echo "The ANT_PEERS variable has not been set" - exit 1 - elif [[ -z "$EVM_NETWORK" ]]; then - echo "The EVM_NETWORK variable has not been set" - exit 1 - else - echo "ANT_PEERS has been set to $ANT_PEERS" - echo "EVM_NETWORK has been set to $EVM_NETWORK" - fi - - - name: Check the available space post download - run: | - df - echo "Home dir:" - du -sh /home/runner/ - echo "Home subdirs:" - du -sh /home/runner/*/ - echo "PWD:" - du -sh . - echo "PWD subdirs:" - du -sh */ - - - name: export default secret key - run: echo "SECRET_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" >> $GITHUB_ENV - shell: bash - - - name: File upload - run: ./target/release/ant --log-output-dest=data-dir file upload "./test_data_1.tar.gz" > ./upload_output 2>&1 - env: - ANT_LOG: "v" - timeout-minutes: 5 - - - name: showing the upload terminal output - run: cat upload_output - shell: bash - if: always() - - - name: parse address - run: | - UPLOAD_ADDRESS=$(rg "At address: ([0-9a-f]*)" -o -r '$1' ./upload_output) - echo "UPLOAD_ADDRESS=$UPLOAD_ADDRESS" >> $GITHUB_ENV - shell: bash - - - name: File Download - run: ./target/release/ant --log-output-dest=data-dir file download ${{ env.UPLOAD_ADDRESS }} ./downloaded_resources > ./download_output 2>&1 - env: - ANT_LOG: "v" - timeout-minutes: 5 - - - name: showing the download terminal output - run: | - cat download_output - ls -l - cd downloaded_resources - ls -l - shell: bash - if: always() - - - name: Confirming connection errors - shell: bash - timeout-minutes: 1 - env: - NODE_DATA_PATH: /home/runner/.local/share/autonomi/node - run: | - incoming_connection_errors=$(rg "IncomingConnectionError" $NODE_DATA_PATH -c --stats | \ - rg "(\d+) matches" | rg "\d+" -o) || { echo "Failed to find IncomingConnectionError error"; exit 0; } - if [ -z "$incoming_connection_errors" ]; then - echo "Doesn't find any IncomingConnectionError error !" - else - echo "Found $incoming_connection_errors IncomingConnectionError errors." - fi - unexpected_eof_errors=$(rg "UnexpectedEof" $NODE_DATA_PATH -c --stats | \ - rg "(\d+) matches" | rg "\d+" -o) || { echo "Failed to find UnexpectedEof error"; exit 0; } - if [ -z "$unexpected_eof_errors" ]; then - echo "Doesn't find any UnexpectedEof error !" - else - echo "Found $unexpected_eof_errors UnexpectedEof errors." - fi - - - name: Stop the local network and upload logs - if: always() - uses: maidsafe/ant-local-testnet-action@main - with: - action: stop - platform: ubuntu-latest - log_file_prefix: safe_test_logs_large_file_upload_with_ws - build: true diff --git a/Justfile b/Justfile index 2eb3768d03..f18f083c63 100644 --- a/Justfile +++ b/Justfile @@ -68,16 +68,16 @@ build-release-artifacts arch nightly="false": cargo binstall --no-confirm cross cross build --release --target $arch --bin nat-detection $nightly_feature cross build --release --target $arch --bin node-launchpad $nightly_feature - cross build --release --features websockets --target $arch --bin ant $nightly_feature - cross build --release --features websockets --target $arch --bin antnode $nightly_feature + cross build --release --target $arch --bin ant $nightly_feature + cross build --release --target $arch --bin antnode $nightly_feature cross build --release --target $arch --bin antctl $nightly_feature cross build --release --target $arch --bin antctld $nightly_feature cross build --release --target $arch --bin antnode_rpc_client $nightly_feature else cargo build --release --target $arch --bin nat-detection $nightly_feature cargo build --release --target $arch --bin node-launchpad $nightly_feature - cargo build --release --features websockets --target $arch --bin ant $nightly_feature - cargo build --release --features websockets --target $arch --bin antnode $nightly_feature + cargo build --release --target $arch --bin ant $nightly_feature + cargo build --release --target $arch --bin antnode $nightly_feature cargo build --release --target $arch --bin antctl $nightly_feature cargo build --release --target $arch --bin antctld $nightly_feature cargo build --release --target $arch --bin antnode_rpc_client $nightly_feature diff --git a/README.md b/README.md index bac5d08181..f9cb70f106 100644 --- a/README.md +++ b/README.md @@ -63,13 +63,6 @@ More options about EVM Network below. The Autonomi network uses `quic` as the default transport protocol. -The `websockets` feature is available for the `ant-networking` crate, and above, and will allow for -tcp over websockets. - -If building for `wasm32` then `websockets` are enabled by default as this is the only method -available to communicate with a network as things stand. (And that network must have `websockets` -enabled.) - #### Building for wasm32 WASM support for the autonomi API is currently under active development. More docs coming soon. diff --git a/ant-cli/Cargo.toml b/ant-cli/Cargo.toml index 77c9343190..c6eecb42f6 100644 --- a/ant-cli/Cargo.toml +++ b/ant-cli/Cargo.toml @@ -17,7 +17,6 @@ path = "src/main.rs" default = ["metrics"] local = ["ant-bootstrap/local", "autonomi/local"] metrics = ["ant-logging/process-metrics"] -websockets = ["autonomi/websockets"] [[bench]] name = "files" diff --git a/ant-networking/Cargo.toml b/ant-networking/Cargo.toml index 7867e7d7ec..717b251ac9 100644 --- a/ant-networking/Cargo.toml +++ b/ant-networking/Cargo.toml @@ -17,7 +17,6 @@ loud = [] open-metrics = ["libp2p/metrics", "prometheus-client", "hyper", "sysinfo"] # tcp is automatically enabled when compiling for wasm32 upnp = ["libp2p/upnp"] -websockets = ["libp2p/tcp"] [dependencies] aes-gcm-siv = "0.11.1" diff --git a/ant-networking/src/driver.rs b/ant-networking/src/driver.rs index eb34b13e2a..f259b82dab 100644 --- a/ant-networking/src/driver.rs +++ b/ant-networking/src/driver.rs @@ -446,17 +446,6 @@ impl NetworkBuilder { .listen_on(addr_quic) .expect("Multiaddr should be supported by our configured transports"); - // Listen on WebSocket - #[cfg(any(feature = "websockets", target_arch = "wasm32"))] - { - let addr_ws = Multiaddr::from(listen_socket_addr.ip()) - .with(Protocol::Tcp(listen_socket_addr.port())) - .with(Protocol::Ws("/".into())); - swarm_driver - .listen_on(addr_ws) - .expect("Multiaddr should be supported by our configured transports"); - } - Ok((network, events_receiver, swarm_driver)) } diff --git a/ant-networking/src/transport/other.rs b/ant-networking/src/transport/other.rs index 9143c27e63..75bca5ed27 100644 --- a/ant-networking/src/transport/other.rs +++ b/ant-networking/src/transport/other.rs @@ -1,9 +1,5 @@ #[cfg(feature = "open-metrics")] use crate::MetricsRegistries; -#[cfg(feature = "websockets")] -use futures::future::Either; -#[cfg(feature = "websockets")] -use libp2p::{core::upgrade, noise, yamux}; use libp2p::{ core::{muxing::StreamMuxerBox, transport}, identity::Keypair, @@ -18,28 +14,6 @@ pub(crate) fn build_transport( #[cfg(feature = "open-metrics")] let trans = libp2p::metrics::BandwidthTransport::new(trans, &mut registries.standard_metrics); - #[cfg(feature = "websockets")] - // Using a closure here due to the complex return type - let generate_ws_transport = || { - let tcp = libp2p::tcp::tokio::Transport::new(libp2p::tcp::Config::default()); - libp2p::websocket::WsConfig::new(tcp) - .upgrade(upgrade::Version::V1) - .authenticate( - noise::Config::new(keypair) - .expect("Signing libp2p-noise static DH keypair failed."), - ) - .multiplex(yamux::Config::default()) - }; - - // With the `websockets` feature enabled, we add it as a fallback transport. - #[cfg(feature = "websockets")] - let trans = trans - .or_transport(generate_ws_transport()) - .map(|either_output, _| match either_output { - Either::Left((peer_id, muxer)) => (peer_id, StreamMuxerBox::new(muxer)), - Either::Right((peer_id, muxer)) => (peer_id, StreamMuxerBox::new(muxer)), - }); - #[cfg(not(feature = "websockets"))] let trans = trans.map(|(peer_id, muxer), _| (peer_id, StreamMuxerBox::new(muxer))); trans.boxed() diff --git a/ant-node/Cargo.toml b/ant-node/Cargo.toml index 21b5ac2863..a3c5681bfe 100644 --- a/ant-node/Cargo.toml +++ b/ant-node/Cargo.toml @@ -24,7 +24,6 @@ nightly = [] open-metrics = ["ant-networking/open-metrics", "prometheus-client"] otlp = ["ant-logging/otlp"] upnp = ["ant-networking/upnp"] -websockets = ["ant-networking/websockets"] [dependencies] ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.0" } diff --git a/ant-protocol/Cargo.toml b/ant-protocol/Cargo.toml index ee5a001cd4..f7c1bf4659 100644 --- a/ant-protocol/Cargo.toml +++ b/ant-protocol/Cargo.toml @@ -12,7 +12,6 @@ version = "0.17.15" [features] default = [] rpc=["tonic", "prost"] -websockets=[] [dependencies] ant-build-info = { path = "../ant-build-info", version = "0.1.19" } diff --git a/autonomi/Cargo.toml b/autonomi/Cargo.toml index 2f58cf7f23..941cc9748e 100644 --- a/autonomi/Cargo.toml +++ b/autonomi/Cargo.toml @@ -23,7 +23,6 @@ local = ["ant-networking/local", "ant-evm/local"] loud = [] registers = [] vault = ["registers"] -websockets = ["ant-networking/websockets"] [dependencies] ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.0" }