From b7ed461e8ecb6628e2ce62db77acc9bc7a907ea6 Mon Sep 17 00:00:00 2001 From: Roland Sherwin Date: Thu, 29 Aug 2024 12:26:21 +0530 Subject: [PATCH] feat!: move network version string to sn_protocol --- Cargo.lock | 4 +++- sn_networking/src/driver.rs | 8 ++++---- sn_networking/src/event/swarm.rs | 10 +++------- sn_networking/src/lib.rs | 1 - sn_peers_acquisition/Cargo.toml | 4 ++-- sn_peers_acquisition/src/lib.rs | 2 +- sn_protocol/Cargo.toml | 2 ++ sn_protocol/src/lib.rs | 2 ++ {sn_networking => sn_protocol}/src/version.rs | 0 9 files changed, 17 insertions(+), 16 deletions(-) rename {sn_networking => sn_protocol}/src/version.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 1e98b13765..ee457dce8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7350,7 +7350,7 @@ dependencies = [ "libp2p", "rand 0.8.5", "reqwest 0.12.5", - "sn_networking", + "sn_protocol", "thiserror", "tokio", "tracing", @@ -7368,12 +7368,14 @@ dependencies = [ "custom_debug", "dirs-next", "hex 0.4.3", + "lazy_static", "libp2p", "prost 0.9.0", "rmp-serde", "serde", "serde_json", "sha2 0.10.8", + "sn_build_info", "sn_registers", "sn_transfers", "thiserror", diff --git a/sn_networking/src/driver.rs b/sn_networking/src/driver.rs index b47d4fba59..b0fc96753d 100644 --- a/sn_networking/src/driver.rs +++ b/sn_networking/src/driver.rs @@ -25,10 +25,6 @@ use crate::{ relay_manager::RelayManager, replication_fetcher::ReplicationFetcher, target_arch::{interval, spawn, Instant}, - version::{ - IDENTIFY_CLIENT_VERSION_STR, IDENTIFY_NODE_VERSION_STR, IDENTIFY_PROTOCOL_STR, - REQ_RESPONSE_VERSION_STR, - }, GetRecordError, Network, CLOSE_GROUP_SIZE, }; use crate::{transport, NodeIssue}; @@ -54,6 +50,10 @@ use prometheus_client::{metrics::info::Info, registry::Registry}; use sn_protocol::{ messages::{ChunkProof, Nonce, Request, Response}, storage::RetryStrategy, + version::{ + IDENTIFY_CLIENT_VERSION_STR, IDENTIFY_NODE_VERSION_STR, IDENTIFY_PROTOCOL_STR, + REQ_RESPONSE_VERSION_STR, + }, NetworkAddress, PrettyPrintKBucketKey, PrettyPrintRecordKey, }; use sn_transfers::PaymentQuote; diff --git a/sn_networking/src/event/swarm.rs b/sn_networking/src/event/swarm.rs index 7d2532f663..e0ae2ea687 100644 --- a/sn_networking/src/event/swarm.rs +++ b/sn_networking/src/event/swarm.rs @@ -7,13 +7,8 @@ // permissions and limitations relating to use of the SAFE Network Software. use crate::{ - cmd::LocalSwarmCmd, - event::NodeEvent, - multiaddr_is_global, multiaddr_strip_p2p, - relay_manager::is_a_relayed_peer, - target_arch::Instant, - version::{IDENTIFY_NODE_VERSION_STR, IDENTIFY_PROTOCOL_STR}, - NetworkEvent, Result, SwarmDriver, + cmd::LocalSwarmCmd, event::NodeEvent, multiaddr_is_global, multiaddr_strip_p2p, + relay_manager::is_a_relayed_peer, target_arch::Instant, NetworkEvent, Result, SwarmDriver, }; #[cfg(feature = "local-discovery")] use libp2p::mdns; @@ -28,6 +23,7 @@ use libp2p::{ }, Multiaddr, PeerId, TransportError, }; +use sn_protocol::version::{IDENTIFY_NODE_VERSION_STR, IDENTIFY_PROTOCOL_STR}; use std::collections::HashSet; use tokio::time::Duration; diff --git a/sn_networking/src/lib.rs b/sn_networking/src/lib.rs index 817436b519..8bc53b4377 100644 --- a/sn_networking/src/lib.rs +++ b/sn_networking/src/lib.rs @@ -30,7 +30,6 @@ mod spends; pub mod target_arch; mod transfers; mod transport; -pub mod version; use cmd::LocalSwarmCmd; use xor_name::XorName; diff --git a/sn_peers_acquisition/Cargo.toml b/sn_peers_acquisition/Cargo.toml index 0036835a3f..79c03be459 100644 --- a/sn_peers_acquisition/Cargo.toml +++ b/sn_peers_acquisition/Cargo.toml @@ -12,7 +12,7 @@ version = "0.4.2" [features] local-discovery = [] -network-contacts = ["sn_networking"] +network-contacts = ["sn_protocol"] websockets = [] [dependencies] @@ -21,7 +21,7 @@ lazy_static = "~1.4.0" libp2p = { version="0.53", features = [] } rand = "0.8.5" reqwest = { version="0.12.2", default-features=false, features = ["rustls-tls"] } -sn_networking = { path = "../sn_networking", version = "0.17.2", optional = true} +sn_protocol = { path = "../sn_protocol", version = "0.17.7", optional = true} thiserror = "1.0.23" tokio = { version = "1.32.0", default-features = false} tracing = { version = "~0.1.26" } diff --git a/sn_peers_acquisition/src/lib.rs b/sn_peers_acquisition/src/lib.rs index bd013c4485..f5abb10c2d 100644 --- a/sn_peers_acquisition/src/lib.rs +++ b/sn_peers_acquisition/src/lib.rs @@ -16,7 +16,7 @@ use libp2p::{multiaddr::Protocol, Multiaddr}; use rand::{seq::SliceRandom, thread_rng}; use reqwest::Client; #[cfg(feature = "network-contacts")] -use sn_networking::version::get_network_version; +use sn_protocol::version::get_network_version; use std::time::Duration; use tracing::*; use url::Url; diff --git a/sn_protocol/Cargo.toml b/sn_protocol/Cargo.toml index 93ffa24797..ad3785876f 100644 --- a/sn_protocol/Cargo.toml +++ b/sn_protocol/Cargo.toml @@ -22,11 +22,13 @@ crdts = { version = "7.3", default-features = false, features = ["merkle"] } custom_debug = "~0.6.1" dirs-next = "~2.0.0" hex = "~0.4.3" +lazy_static = "1.4.0" libp2p = { version="0.53", features = ["identify", "kad"] } rmp-serde = "1.1.1" serde = { version = "1.0.133", features = [ "derive", "rc" ]} serde_json = "1.0" sha2 = "0.10.7" +sn_build_info = { path = "../sn_build_info", version = "0.1.11" } sn_transfers = { path = "../sn_transfers", version = "0.18.10" } sn_registers = { path = "../sn_registers", version = "0.3.17" } thiserror = "1.0.23" diff --git a/sn_protocol/src/lib.rs b/sn_protocol/src/lib.rs index f0a67d0984..486d8690fe 100644 --- a/sn_protocol/src/lib.rs +++ b/sn_protocol/src/lib.rs @@ -19,6 +19,8 @@ pub mod node; pub mod node_rpc; /// Storage types for spends, chunks and registers. pub mod storage; +/// Network versioning +pub mod version; // this includes code generated from .proto files #[allow(clippy::unwrap_used, clippy::clone_on_ref_ptr)] diff --git a/sn_networking/src/version.rs b/sn_protocol/src/version.rs similarity index 100% rename from sn_networking/src/version.rs rename to sn_protocol/src/version.rs