Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
086c666
serde for ReconstructedMessage
durch Jun 7, 2024
bad775f
AsyncRead for MixnetClient
durch Jun 7, 2024
227ff43
Switch to PollSender
durch Jun 12, 2024
0feb783
temp
mfahampshire Jun 18, 2025
d1253f5
Use Sink always
durch Jun 12, 2024
4b75998
minor changes with new files / fixes
mfahampshire Jun 18, 2025
16c2808
InputMessageCodec, Serde for MixPacket
durch Jun 12, 2024
429d72d
ReconstructedMessageCodec
durch Jun 13, 2024
9031ecb
Use tokio AsyncRead
durch Jun 13, 2024
5fdb4e4
remove double asyncwrite
mfahampshire Jun 18, 2025
adc92b2
AsyncWrite
durch Jun 13, 2024
0cc56d9
WASM changes
durch Jun 14, 2024
ab06967
tweaks to tcpproxy example
mfahampshire Jun 18, 2025
64793ed
Update IPR sig
durch Jun 18, 2024
b472161
Cleanup prints
durch Jun 18, 2024
df27450
Log decoding error
durch Jun 19, 2024
755d06e
fmt
durch Jun 19, 2024
4c2a8d3
Address part of PR comments
durch Jun 25, 2024
cc03e35
initial pass streamwrapper
mfahampshire Jun 17, 2025
ec37431
temp
mfahampshire Jun 20, 2025
632d4b5
first full pass @ stream + split wrappers
mfahampshire Jun 24, 2025
dbe731a
make inputmessage anonymous type over simple
mfahampshire Jun 25, 2025
5ac6e43
adding surbs + anon reply functionality
mfahampshire Jun 26, 2025
b5cd5e9
added surbs to split r/w + some streamlining + comments + tests
mfahampshire Jun 26, 2025
0ab0fa1
reorg
mfahampshire Jul 1, 2025
0b98666
commit before messing with reexport stuff
mfahampshire Jul 3, 2025
5e94eb3
temp commit: got gateway dir dependency working, moving on to vpn-api…
mfahampshire Jul 4, 2025
5190a42
before directory modification
mfahampshire Jul 4, 2025
c300a45
removed circular dep from gateway-directory
mfahampshire Jul 4, 2025
47bae45
out of dependency hell
mfahampshire Jul 7, 2025
bc82c55
mod ip_packet_client
mfahampshire Jul 9, 2025
e12f018
got ipr wrapper connected
mfahampshire Jul 9, 2025
a0062f8
* pulled in helpers from various files
mfahampshire Jul 14, 2025
b3a139c
pull in + mod nym-gateway
mfahampshire Jul 14, 2025
3b9ebb4
* got ipr pings working with stream_wrapper_ipr
mfahampshire Jul 14, 2025
37f095a
comment out logging in test
mfahampshire Jul 21, 2025
fcfc126
commenting format change + comment out logging in test
mfahampshire Jul 21, 2025
127a7bc
commenting
mfahampshire Jul 21, 2025
f1df277
more comments
mfahampshire Jul 21, 2025
49beebf
Remove unnecessary MixnetClient from IpSocket: streamlining
mfahampshire Jul 21, 2025
941040a
removed IpMixSocket; was a bit unnecessary given connection logic
mfahampshire Jul 22, 2025
1808fc3
err handling on surb send between split
mfahampshire Jul 22, 2025
9c6df40
split ipmixstream + tests
mfahampshire Jul 22, 2025
4f9c7bd
export extra types from ipmixstream
mfahampshire Jul 22, 2025
c54014b
commenting
mfahampshire Jul 24, 2025
c17b9ad
smolmix device + example
mfahampshire Jul 24, 2025
9f0d107
remove old note
mfahampshire Jul 24, 2025
8f7018b
change logging for nym provider
mfahampshire Jul 24, 2025
3b74462
update readme with new logging
mfahampshire Jul 24, 2025
bdb2410
TLS first version
mfahampshire Sep 26, 2025
0ec10ad
remove clunky old examples in place of unit tests
mfahampshire Sep 26, 2025
a901bfd
rough first reqwest client poc
mfahampshire Sep 29, 2025
a5262ac
Tests + getting reuable client in new() for speedup
mfahampshire Sep 30, 2025
8df89f4
Fix inverted buffer slice logic
mfahampshire Oct 3, 2025
44528cc
framing > byte buffer
mfahampshire Oct 7, 2025
b47c4b2
Fix logging in tests
mfahampshire Oct 7, 2025
362475d
Made explicit error types
mfahampshire Oct 7, 2025
3de7842
add missed stuff from rebase
mfahampshire Oct 16, 2025
76b4ab1
linting
mfahampshire Oct 16, 2025
4b52f91
almost sorted new version gw dir
mfahampshire Oct 16, 2025
830d631
Fix gw directory api change in ipr wrapper
mfahampshire Oct 17, 2025
ec6291e
Clean up unused imports
mfahampshire Oct 17, 2025
9a486e0
deprecate notice for tcpproxy module
mfahampshire Oct 17, 2025
344caaf
remove unwraps in place of error types
mfahampshire Oct 17, 2025
937c7d1
remove comments and unused imports
mfahampshire Oct 17, 2025
9239a72
Remove unused imports
mfahampshire Oct 17, 2025
5b34f7b
Move files to examples + split examples apart
mfahampshire Oct 17, 2025
790a90c
info -> debug logging for serialised bytes written by stream_wrapper
mfahampshire Oct 17, 2025
1afcfa5
strip down commenting that is triggering compiler err
mfahampshire Oct 17, 2025
d345cf6
rename smolmix - mixtcp
mfahampshire Oct 17, 2025
05ea281
smol mixtcp readme
mfahampshire Oct 17, 2025
5a4eb42
lint
mfahampshire Oct 20, 2025
9a7fd15
reintroduce import
mfahampshire Oct 20, 2025
3e82dae
remove accidental import from merge
mfahampshire Oct 20, 2025
aa99c2f
Add RwLock to wasm client helper
mfahampshire Oct 20, 2025
0b4e8cc
Mod to mixnet client mutability from traits elsewhere
mfahampshire Oct 20, 2025
10bfb78
Fix FFI shared lib
mfahampshire Oct 20, 2025
0a7f4d4
clippy warnings: remove
mfahampshire Oct 20, 2025
c8d9ec0
clippy
mfahampshire Oct 20, 2025
707c91d
clippy
mfahampshire Oct 21, 2025
61782e8
temp get rid of logging for ci
mfahampshire Oct 21, 2025
672a4cf
temp get rid of logging for ci again
mfahampshire Oct 21, 2025
9fe7d69
remove old commented out imports
mfahampshire Oct 21, 2025
e17d009
clippy
mfahampshire Oct 21, 2025
8e8738b
remove accidental double import
mfahampshire Oct 21, 2025
3d31be2
lock
mfahampshire Oct 21, 2025
40c111f
lint
mfahampshire Oct 21, 2025
352c4cc
remove external dep on nymvpn repo in sdk
mfahampshire Oct 21, 2025
0166bb1
added stream module to mixnet readme
mfahampshire Oct 21, 2025
362a293
remove unused
mfahampshire Oct 22, 2025
0e39dbb
cont removing unnecessary types
mfahampshire Oct 22, 2025
6c591d7
temp before big mod
mfahampshire Oct 22, 2025
592997b
remove nymvpnapi - always use http fallback
mfahampshire Oct 22, 2025
2bc68ae
remove last nym vpn api deps
mfahampshire Oct 22, 2025
d48bcc0
clippy
mfahampshire Oct 23, 2025
b2f7424
edition matches workspace
mfahampshire Oct 23, 2025
c7153ff
add license to mixtcp cargo
mfahampshire Oct 23, 2025
89d3adc
remove external patch
mfahampshire Oct 23, 2025
937a400
removed dependency on nym-gateway-directory
jstuczyn Oct 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,001 changes: 1,043 additions & 958 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ members = [
"common/wireguard-private-metadata/tests",
"common/wireguard-types",
"common/zulip-client",
"documentation/autodoc",
"gateway",
"nym-api",
"nym-api/nym-api-requests",
Expand All @@ -124,7 +123,6 @@ members = [
"nym-credential-proxy/nym-credential-proxy",
"nym-credential-proxy/nym-credential-proxy-requests",
"nym-credential-proxy/vpn-api-lib-wasm",
"nym-ip-packet-client",
"nym-network-monitor",
"nym-node",
"nym-node-status-api/nym-node-status-agent",
Expand All @@ -142,6 +140,8 @@ members = [
"sdk/ffi/go",
"sdk/ffi/shared",
"sdk/rust/nym-sdk",
"mixtcp",
# "service-providers/authenticator",
"service-providers/common",
"service-providers/ip-packet-router",
"service-providers/network-requester",
Expand All @@ -154,6 +154,7 @@ members = [
"tools/internal/ssl-inject",
"tools/internal/testnet-manager",
"tools/internal/testnet-manager/dkg-bypass-contract",
"tools/internal/testnet-manager/dkg-bypass-contract",
"tools/internal/validator-status-check",
"tools/nym-cli",
"tools/nym-id-cli",
Expand Down
4 changes: 3 additions & 1 deletion common/client-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ license.workspace = true

[dependencies]
async-trait = { workspace = true }
base64 = { workspace = true }
bincode = { workspace = true }
base64 = "0.21.2"
bs58 = { workspace = true }
clap = { workspace = true, optional = true }
cfg-if = { workspace = true }
Expand All @@ -25,6 +26,7 @@ sha2 = { workspace = true }
si-scale = { workspace = true }
thiserror = { workspace = true }
url = { workspace = true, features = ["serde"] }
tokio-util = { workspace = true, features = ["codec"] }
time = { workspace = true }
tokio = { workspace = true, features = ["sync", "macros"] }
tracing = { workspace = true }
Expand Down
14 changes: 6 additions & 8 deletions common/client-core/src/client/base_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use crate::init::{
types::{GatewaySetup, InitialisationResult},
};
use futures::channel::mpsc;
use futures::SinkExt;
use nym_bandwidth_controller::BandwidthController;
use nym_client_core_config_types::{ForgetMe, RememberMe};
use nym_client_core_gateways_storage::{GatewayDetails, GatewaysDetailsStore};
Expand Down Expand Up @@ -66,7 +67,7 @@ use std::os::raw::c_int as RawFd;
use std::path::Path;
use std::sync::Arc;
use time::OffsetDateTime;
use tokio::sync::mpsc::Sender;
use tokio_util::sync::{PollSendError, PollSender};
use url::Url;

#[cfg(target_arch = "wasm32")]
Expand Down Expand Up @@ -108,10 +109,7 @@ pub struct ClientInput {
}

impl ClientInput {
pub async fn send(
&self,
message: InputMessage,
) -> Result<(), tokio::sync::mpsc::error::SendError<InputMessage>> {
pub async fn send(&mut self, message: InputMessage) -> Result<(), PollSendError<InputMessage>> {
self.input_sender.send(message).await
}
}
Expand Down Expand Up @@ -756,7 +754,7 @@ where
config: &Config,
user_agent: Option<UserAgent>,
client_stats_id: String,
input_sender: Sender<InputMessage>,
input_sender: PollSender<InputMessage>,
shutdown_tracker: &ShutdownTracker,
) -> ClientStatsSender {
tracing::info!("Starting statistics control...");
Expand Down Expand Up @@ -975,7 +973,7 @@ where
&self.config,
self.user_agent.clone(),
generate_client_stats_id(*self_address.identity()),
input_sender.clone(),
tokio_util::sync::PollSender::new(input_sender.clone()),
&shutdown_tracker.child_tracker(),
);

Expand Down Expand Up @@ -1102,7 +1100,7 @@ where
client_input: ClientInputStatus::AwaitingProducer {
client_input: ClientInput {
connection_command_sender: client_connection_tx,
input_sender,
input_sender: PollSender::new(input_sender),
client_request_sender,
},
},
Expand Down
87 changes: 84 additions & 3 deletions common/client-core/src/client/inbound_messages.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
// Copyright 2020-2023 - Nym Technologies SA <[email protected]>
// SPDX-License-Identifier: Apache-2.0

use nym_sphinx::addressing::clients::Recipient;
use nym_sphinx::anonymous_replies::requests::AnonymousSenderTag;
use nym_sphinx::forwarding::packet::MixPacket;
use nym_sphinx::params::PacketType;
use nym_task::connections::TransmissionLane;
use serde::{Deserialize, Serialize};
use std::convert::TryInto;
use tokio_util::{
bytes::Buf,
bytes::BytesMut,
codec::{Decoder, Encoder},
};

use crate::error::ClientCoreError;

pub type InputMessageSender = tokio::sync::mpsc::Sender<InputMessage>;
pub type InputMessageSender = tokio_util::sync::PollSender<InputMessage>;
pub type InputMessageReceiver = tokio::sync::mpsc::Receiver<InputMessage>;

#[derive(Debug)]
const LENGHT_ENCODING_PREFIX_SIZE: usize = 4;

#[derive(Serialize, Deserialize, Debug)]
pub enum InputMessage {
/// Fire an already prepared mix packets into the network.
/// No guarantees are made about it. For example no retransmssion
Expand Down Expand Up @@ -65,6 +75,10 @@ pub enum InputMessage {
}

impl InputMessage {
pub fn simple(data: &[u8], recipient: Recipient) -> Self {
InputMessage::new_regular(recipient, data.to_vec(), TransmissionLane::General, None)
}

pub fn new_premade(
msgs: Vec<MixPacket>,
lane: TransmissionLane,
Expand Down Expand Up @@ -185,4 +199,71 @@ impl InputMessage {
self.set_max_retransmissions(max_retransmissions);
self
}
#[allow(clippy::expect_used)]
pub fn serialized_size(&self) -> u64 {
bincode::serialized_size(self).expect("failed to get serialized InputMessage size")
+ LENGHT_ENCODING_PREFIX_SIZE as u64
}
}

// TODO: Tests
pub struct AdressedInputMessageCodec(pub Recipient);

impl Encoder<&[u8]> for AdressedInputMessageCodec {
type Error = ClientCoreError;

fn encode(&mut self, item: &[u8], buf: &mut BytesMut) -> Result<(), Self::Error> {
let mut codec = InputMessageCodec;
let input_message = InputMessage::simple(item, self.0);
codec.encode(input_message, buf)?;
Ok(())
}
}

pub struct InputMessageCodec;

impl Encoder<InputMessage> for InputMessageCodec {
type Error = ClientCoreError;

fn encode(&mut self, item: InputMessage, buf: &mut BytesMut) -> Result<(), Self::Error> {
#[allow(clippy::expect_used)]
let encoded = bincode::serialize(&item).expect("failed to serialize InputMessage");
let encoded_len = encoded.len() as u32;
let mut encoded_with_len = encoded_len.to_le_bytes().to_vec();
encoded_with_len.extend(encoded);
buf.reserve(encoded_with_len.len());
buf.extend_from_slice(&encoded_with_len);
Ok(())
}
}

impl Decoder for InputMessageCodec {
type Item = InputMessage;
type Error = ClientCoreError;

fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
if buf.len() < LENGHT_ENCODING_PREFIX_SIZE {
return Ok(None);
}
#[allow(clippy::expect_used)]
let len = u32::from_le_bytes(
buf[0..LENGHT_ENCODING_PREFIX_SIZE]
.try_into()
.expect("Could not coarce to array"),
) as usize;
if buf.len() < len + LENGHT_ENCODING_PREFIX_SIZE {
return Ok(None);
}

let decoded = match bincode::deserialize(
&buf[LENGHT_ENCODING_PREFIX_SIZE..len + LENGHT_ENCODING_PREFIX_SIZE],
) {
Ok(decoded) => decoded,
Err(_) => return Ok(None),
};

buf.advance(len + LENGHT_ENCODING_PREFIX_SIZE);

Ok(Some(decoded))
}
}
2 changes: 1 addition & 1 deletion common/client-core/src/client/mix_traffic/transceiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use nym_validator_client::nyxd::contract_traits::DkgQueryClient;
use std::fmt::Debug;
use std::os::raw::c_int as RawFd;
use thiserror::Error;
use tracing::{debug, error};
use tracing::debug;

#[cfg(not(target_arch = "wasm32"))]
use futures::channel::oneshot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use nym_sphinx::anonymous_replies::requests::AnonymousSenderTag;
use nym_sphinx::anonymous_replies::ReplySurbWithKeyRotation;
use nym_task::connections::{ConnectionId, TransmissionLane};
use std::sync::Weak;
use tracing::error;

pub(crate) fn new_control_channels() -> (ReplyControllerSender, ReplyControllerReceiver) {
let (tx, rx) = mpsc::unbounded();
Expand Down
2 changes: 1 addition & 1 deletion common/client-core/src/client/statistics_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#![warn(clippy::dbg_macro)]

use crate::client::inbound_messages::{InputMessage, InputMessageSender};
use futures::StreamExt;
use futures::{SinkExt, StreamExt};
use nym_client_core_config_types::StatsReporting;
use nym_sphinx::addressing::Recipient;
use nym_statistics_common::clients::{
Expand Down
2 changes: 1 addition & 1 deletion common/client-core/src/init/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ mod tests {

#[test]
fn test_multiple_urls_prepared_for_retries() {
let urls = vec![
let urls = [
Url::parse("https://api1.nym.com").unwrap(),
Url::parse("https://api2.nym.com").unwrap(),
Url::parse("https://api3.nym.com").unwrap(),
Expand Down
1 change: 1 addition & 0 deletions common/client-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(deprecated)]
use std::future::Future;

#[cfg(all(
Expand Down
1 change: 1 addition & 0 deletions common/client-core/surb-storage/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2022 - Nym Technologies SA <[email protected]>
// SPDX-License-Identifier: Apache-2.0

#![allow(deprecated)]
pub use backend::*;
pub use combined::CombinedReplyStorage;
pub use key_storage::SentReplyKeys;
Expand Down
84 changes: 84 additions & 0 deletions common/client-libs/validator-client/src/nym_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,49 @@ pub trait NymApiClientExt: ApiClient {
Ok(SkimmedNodesWithMetadata::new(nodes, metadata))
}

async fn get_all_basic_exit_assigned_nodes_with_metadata(
&self,
) -> Result<SkimmedNodesWithMetadata, NymAPIError> {
// Get all nodes that can act as exit gateways
let mut page = 0;
let res = self
.get_basic_exit_assigned_nodes_v2(false, Some(page), None, false)
.await?;

let metadata = res.metadata;
let mut nodes = res.nodes.data;

if res.nodes.pagination.total == nodes.len() {
return Ok(SkimmedNodesWithMetadata::new(nodes, metadata));
}

page += 1;

loop {
let res = self
.get_basic_exit_assigned_nodes_v2(false, Some(page), None, false)
.await?;

if !metadata.consistency_check(&res.metadata) {
return Err(NymAPIError::InternalResponseInconsistency {
url: self.api_url().clone(),
details: "Inconsistent paged metadata".to_string(),
});
}

nodes.append(&mut res.nodes.data.clone());

// Check if we've got all nodes
if nodes.len() >= res.nodes.pagination.total {
break;
} else {
page += 1;
}
}

Ok(SkimmedNodesWithMetadata::new(nodes, metadata))
}

async fn get_all_described_nodes(&self) -> Result<Vec<NymNodeDescription>, NymAPIError> {
// TODO: deal with paging in macro or some helper function or something, because it's the same pattern everywhere
let mut page = 0;
Expand Down Expand Up @@ -467,6 +510,47 @@ pub trait NymApiClientExt: ApiClient {
.await
}

/// retrieve basic information for nodes are capable of operating as an exit gateway
/// this includes legacy gateways and nym-nodes
#[instrument(level = "debug", skip(self))]
async fn get_basic_exit_assigned_nodes_v2(
&self,
no_legacy: bool,
page: Option<u32>,
per_page: Option<u32>,
use_bincode: bool,
) -> Result<PaginatedCachedNodesResponseV2<SkimmedNode>, NymAPIError> {
let mut params = Vec::new();

if no_legacy {
params.push(("no_legacy", "true".to_string()))
}

if let Some(page) = page {
params.push(("page", page.to_string()))
}

if let Some(per_page) = per_page {
params.push(("per_page", per_page.to_string()))
}

if use_bincode {
params.push(("output", "bincode".to_string()))
}

self.get_response(
&[
routes::V2_API_VERSION,
"unstable",
routes::NYM_NODES_ROUTES,
"skimmed",
"exit-gateways",
],
&params,
)
.await
}

/// retrieve basic information for nodes that got assigned 'mixing' node in this epoch
/// this includes legacy mixnodes and nym-nodes
#[deprecated(note = "use get_basic_active_mixing_assigned_nodes_v2")]
Expand Down
2 changes: 2 additions & 0 deletions common/cosmwasm-smart-contracts/coconut-dkg/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2022-2023 - Nym Technologies SA <[email protected]>
// SPDX-License-Identifier: Apache-2.0

#![allow(clippy::derivable_impls)]
// MAX: surpressing warning for the moment, will be dealt with in a different PR (TODO)
use cosmwasm_schema::cw_serde;
use std::fmt::{Display, Formatter};
use std::str::FromStr;
Expand Down
4 changes: 2 additions & 2 deletions common/credential-storage/src/ephemeral_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ mod tests {
let _exp_date_sigs = generate_expiration_date_signatures(
sig_req.expiration_date.ecash_unix_timestamp(),
&[signing_keys.secret_key()],
&vec![signing_keys.verification_key()],
&[signing_keys.verification_key()],
&signing_keys.verification_key(),
&[1],
)?;
Expand All @@ -263,7 +263,7 @@ mod tests {

let wallet = issuance.aggregate_signature_shares(
&signing_keys.verification_key(),
&vec![partial_wallet],
&[partial_wallet],
sig_req,
)?;

Expand Down
Loading
Loading