From 30d73b24444cff33e21c648da4e456bf9189f79c Mon Sep 17 00:00:00 2001 From: Benno Zeeman Date: Tue, 29 Oct 2024 20:44:31 +0100 Subject: [PATCH 1/2] fix(autonomi): fix wasm warnings from cargo check --- .github/workflows/cross-platform.yml | 5 +++++ sn_networking/src/lib.rs | 18 +++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cross-platform.yml b/.github/workflows/cross-platform.yml index 6beeac321d..e82110b67e 100644 --- a/.github/workflows/cross-platform.yml +++ b/.github/workflows/cross-platform.yml @@ -34,6 +34,11 @@ jobs: run: wasm-pack build --dev --target=web autonomi timeout-minutes: 30 + - name: Cargo check for WASM + # Allow clippy lints (these can be pedantic on WASM), but deny regular Rust warnings + run: cargo clippy --target=wasm32-unknown-unknown --package=autonomi --all-targets -- --allow=clippy::all --deny=warnings + timeout-minutes: 30 + websocket: if: "!startsWith(github.event.head_commit.message, 'chore(release):')" name: Standard Websocket builds diff --git a/sn_networking/src/lib.rs b/sn_networking/src/lib.rs index 06699f7fe1..0910f865cc 100644 --- a/sn_networking/src/lib.rs +++ b/sn_networking/src/lib.rs @@ -30,7 +30,6 @@ mod transfers; mod transport; use cmd::LocalSwarmCmd; -use sn_registers::SignedRegister; use xor_name::XorName; // re-export arch dependent deps for use in the crate, or above @@ -62,15 +61,11 @@ use sn_evm::{AttoTokens, PaymentQuote, QuotingMetrics, RewardsAddress}; use sn_protocol::{ error::Error as ProtocolError, messages::{ChunkProof, Cmd, Nonce, Query, QueryResponse, Request, Response}, - storage::{ - try_deserialize_record, try_serialize_record, RecordHeader, RecordKind, RecordType, - RetryStrategy, - }, + storage::{RecordType, RetryStrategy}, NetworkAddress, PrettyPrintKBucketKey, PrettyPrintRecordKey, CLOSE_GROUP_SIZE, }; -use sn_transfers::SignedSpend; use std::{ - collections::{BTreeMap, HashMap, HashSet}, + collections::{BTreeMap, HashMap}, net::IpAddr, sync::Arc, }; @@ -79,6 +74,15 @@ use tokio::sync::{ oneshot, }; use tokio::time::Duration; +#[cfg(not(target_arch = "wasm32"))] +use { + sn_protocol::storage::{ + try_deserialize_record, try_serialize_record, RecordHeader, RecordKind, + }, + sn_registers::SignedRegister, + sn_transfers::SignedSpend, + std::collections::HashSet, +}; /// The type of quote for a selected payee. pub type PayeeQuote = (PeerId, RewardsAddress, PaymentQuote); From 387759ec05b3a188ffc10f0aa19c2c6602bd33ed Mon Sep 17 00:00:00 2001 From: Benno Zeeman Date: Wed, 6 Nov 2024 16:47:58 +0100 Subject: [PATCH 2/2] style(sn_networking): fix warning for wasm --- sn_networking/src/bootstrap.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/sn_networking/src/bootstrap.rs b/sn_networking/src/bootstrap.rs index f8b7cf1e59..d3c693dec7 100644 --- a/sn_networking/src/bootstrap.rs +++ b/sn_networking/src/bootstrap.rs @@ -107,6 +107,7 @@ impl ContinuousBootstrap { /// Returns `true` if we should carry out the Kademlia Bootstrap process immediately. /// Also optionally returns the new interval to re-bootstrap. + #[cfg_attr(target_arch = "wasm32", allow(clippy::unused_async))] pub(crate) async fn should_we_bootstrap( &self, peers_in_rt: u32,