Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
65895db
chore: update tokio-related dependencies
jstuczyn Oct 24, 2023
867e92c
'thiserror' implementation for verloc error
jstuczyn Oct 24, 2023
8f83fd7
module responsible for updating paths allowed for forward travel
jstuczyn Oct 26, 2023
b401123
starting the provider inside the mixnode
jstuczyn Oct 26, 2023
4fabb7a
creating correct filters based on whether node is a gateway or isnt b…
jstuczyn Oct 26, 2023
527fc5d
[mixnode] using the ingress filter for incoming connections
jstuczyn Oct 26, 2023
81548eb
setting initial provider values at construction
jstuczyn Oct 26, 2023
a72414e
using parking_lot::RwLock instead of tokio::RwLock
jstuczyn Oct 26, 2023
d9cfec1
[mixnode] using the egress filter for outgoing packets
jstuczyn Oct 26, 2023
e67e6a9
[gateway] using the ingress filter for incoming (mix) connections
jstuczyn Oct 26, 2023
7248054
[gateway] using the egress filter for outgoing packets
jstuczyn Oct 26, 2023
7659db9
clippy
jstuczyn Oct 26, 2023
e70303f
fixed mixnode config template
jstuczyn Oct 27, 2023
6b0a743
helper on TaskClient to sleep for specified amount of time
jstuczyn Oct 27, 2023
667d8d3
an option to set whether mixnode should enforce forward travel policy
jstuczyn Oct 27, 2023
d9f88ca
ibid. for the gateway
jstuczyn Oct 27, 2023
8883f64
added mixnode clap argument to set nyxd urls
jstuczyn Oct 27, 2023
06e7b95
build all binaries before starting localnet
jstuczyn Oct 27, 2023
66dadda
fixed gateway test
jstuczyn Oct 27, 2023
dfb7b70
post-rebase clippy
jstuczyn Oct 31, 2023
c21b015
changed filtering behaviour to always use ALL bonded mixnodes and gat…
jstuczyn Nov 21, 2023
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ serde_json = "1.0.91"
tap = "1.0.1"
time = "0.3.30"
thiserror = "1.0.48"
tokio = "1.24.1"
tokio = "1.33.0"
tokio-stream = "0.1.14"
tokio-tungstenite = "0.20.1"
tokio-util = "0.7.9"
tracing = "0.1.37"
tungstenite = { version = "0.20.1", default-features = false }
ts-rs = "7.0.0"
Expand Down
4 changes: 2 additions & 2 deletions common/client-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ nym-credential-storage = { path = "../credential-storage" }
nym-network-defaults = { path = "../network-defaults" }

[target."cfg(not(target_arch = \"wasm32\"))".dependencies.tokio-stream]
version = "0.1.11"
workspace = true
features = ["time"]

[target."cfg(not(target_arch = \"wasm32\"))".dependencies.tokio]
workspace = true
features = ["time"]

[target."cfg(not(target_arch = \"wasm32\"))".dependencies.tokio-tungstenite]
version = "0.20.1"
workspace = true

[target."cfg(not(target_arch = \"wasm32\"))".dependencies.sqlx]
version = "0.6.2"
Expand Down
2 changes: 1 addition & 1 deletion common/client-libs/gateway-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ workspace = true
features = ["macros", "rt", "net", "sync", "time"]

[target."cfg(not(target_arch = \"wasm32\"))".dependencies.tokio-stream]
version = "0.1.11"
workspace = true
features = ["net", "sync", "time"]

[target."cfg(not(target_arch = \"wasm32\"))".dependencies.tokio-tungstenite]
Expand Down
2 changes: 1 addition & 1 deletion common/client-libs/mixnet-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition = "2021"
futures = { workspace = true }
log = { workspace = true }
tokio = { version = "1.24.1", features = ["time", "net", "rt"] }
tokio-util = { version = "0.7.4", features = ["codec"] }
tokio-util = { workspace = true, features = ["codec"] }

# internal
nym-sphinx = { path = "../../nymsphinx" }
Expand Down
17 changes: 6 additions & 11 deletions common/client-libs/mixnet-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,10 @@ impl Client {
// We could have as well used conn.send_all(receiver.map(Ok)), but considering we don't care
// about neither receiver nor the connection, it doesn't matter which one gets consumed
if let Err(err) = receiver.map(Ok).forward(conn).await {
warn!("Failed to forward packets to {} - {err}", address);
warn!("Failed to forward packets to {address} - {err}");
}

debug!(
"connection manager to {} is finished. Either the connection failed or mixnet client got dropped",
address
);
debug!("connection manager to {address} is finished. Either the connection failed or mixnet client got dropped");
}

/// If we're trying to reconnect, determine how long we should wait.
Expand Down Expand Up @@ -207,18 +204,16 @@ impl SendWithoutResponse for Client {
if let Some(sender) = self.conn_new.get_mut(&address) {
if let Err(err) = sender.channel.try_send(framed_packet) {
if err.is_full() {
debug!("Connection to {} seems to not be able to handle all the traffic - dropping the current packet", address);
debug!("Connection to {address} seems to not be able to handle all the traffic - dropping the current packet");
// it's not a 'big' error, but we did not manage to send the packet
// if the queue is full, we can't really do anything but to drop the packet
Err(io::Error::new(
io::ErrorKind::WouldBlock,
"connection queue is full",
))
} else if err.is_disconnected() {
debug!(
"Connection to {} seems to be dead. attempting to re-establish it...",
address
);
debug!("Connection to {address} seems to be dead. attempting to re-establish it...");

// it's not a 'big' error, but we did not manage to send the packet, but queue
// it up to send it as soon as the connection is re-established
self.make_connection(address, err.into_inner());
Expand All @@ -238,7 +233,7 @@ impl SendWithoutResponse for Client {
}
} else {
// there was never a connection to begin with
debug!("establishing initial connection to {}", address);
debug!("establishing initial connection to {address}");
// it's not a 'big' error, but we did not manage to send the packet, but queue the packet
// for sending for as soon as the connection is created
self.make_connection(address, framed_packet);
Expand Down
3 changes: 3 additions & 0 deletions common/client-libs/validator-client/src/nyxd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ pub use tendermint_rpc::{
};
pub use tendermint_rpc::{Request, Response, SimpleRequest};

#[cfg(feature = "http-client")]
pub use tendermint_rpc::Url as RpcUrl;

#[cfg(feature = "http-client")]
use crate::http_client;
#[cfg(feature = "http-client")]
Expand Down
18 changes: 18 additions & 0 deletions common/cosmwasm-smart-contracts/mixnet-contract/src/mixnode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,24 @@ pub enum Layer {
Three = 3,
}

impl Layer {
pub fn try_next(&self) -> Option<Self> {
match self {
Layer::One => Some(Layer::Two),
Layer::Two => Some(Layer::Three),
Layer::Three => None,
}
}

pub fn try_previous(&self) -> Option<Self> {
match self {
Layer::One => None,
Layer::Two => Some(Layer::One),
Layer::Three => Some(Layer::Two),
}
}
}

impl From<Layer> for String {
fn from(layer: Layer) -> Self {
(layer as u8).to_string()
Expand Down
10 changes: 6 additions & 4 deletions common/mixnode-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ futures = { workspace = true }
humantime-serde = "1.0"
log = { workspace = true }
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.24.1", features = [
serde = { workspace = true, features = ["derive"] }
tokio = { workspace = true, features = [
"time",
"macros",
"rt",
"net",
"io-util",
] }
tokio-util = { version = "0.7.4", features = ["codec"] }
tokio-util = { workspace = true, features = ["codec"] }
url = { workspace = true }
thiserror = { workspace = true }
parking_lot = { workspace = true }

## tracing
tracing = { version = "0.1.37", optional = true }
tracing = { workspace = true, optional = true }

nym-crypto = { path = "../crypto" }
nym-network-defaults = { path = "../network-defaults" }
Expand All @@ -37,6 +38,7 @@ nym-sphinx-params = { path = "../nymsphinx/params" }
nym-sphinx-types = { path = "../nymsphinx/types" }
nym-task = { path = "../task" }
nym-validator-client = { path = "../client-libs/validator-client" }
nym-mixnet-contract-common = { path = "../cosmwasm-smart-contracts/mixnet-contract" }
nym-bin-common = { path = "../bin-common" }

cfg-if = "1.0.0"
Expand Down
27 changes: 27 additions & 0 deletions common/mixnode-common/src/forward_travel/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0

use nym_validator_client::nyxd::error::NyxdError;
use std::net::IpAddr;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum ForwardTravelError {
#[error("received a connection request from a forbidden address: '{address}'")]
DisallowedIngressAddress { address: IpAddr },

#[error("received a request to open connection to a forbidden address: '{address}'")]
DisallowedEgressAddress { address: IpAddr },

#[error("no valid nyxd urls are available for topology queries")]
NoNyxdUrlsAvailable,

#[error("nyxd interaction failure: {source}")]
NyxdFailure {
#[from]
source: NyxdError,
},

#[error("the current epoch appears to be stuck")]
StuckEpoch,
}
Loading