From 9437da6b5322e13bd668a259a7145b16fff29f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Thu, 16 Jan 2025 11:31:17 +0000 Subject: [PATCH] changed behaviour of egress node validitiy --- common/client-core/config-types/src/lib.rs | 1 - .../mixnet-contract/src/nym_node.rs | 4 ++++ common/topology/src/lib.rs | 19 ++++++++----------- common/wasm/client-core/src/config/mod.rs | 1 - .../wasm/client-core/src/config/override.rs | 1 - 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/common/client-core/config-types/src/lib.rs b/common/client-core/config-types/src/lib.rs index 2031c5c34e8..ae9d5c06599 100644 --- a/common/client-core/config-types/src/lib.rs +++ b/common/client-core/config-types/src/lib.rs @@ -553,7 +553,6 @@ pub struct Topology { /// Specifies whether this client should attempt to retrieve all available network nodes /// as opposed to just active mixnodes/gateways. - /// Useless without `ignore_epoch_roles = true` pub use_extended_topology: bool, /// Specifies whether this client should ignore the current epoch role of the target egress node diff --git a/common/cosmwasm-smart-contracts/mixnet-contract/src/nym_node.rs b/common/cosmwasm-smart-contracts/mixnet-contract/src/nym_node.rs index 4087489cc36..85e28c7d757 100644 --- a/common/cosmwasm-smart-contracts/mixnet-contract/src/nym_node.rs +++ b/common/cosmwasm-smart-contracts/mixnet-contract/src/nym_node.rs @@ -113,6 +113,10 @@ impl Role { pub fn is_standby(&self) -> bool { matches!(self, Role::Standby) } + + pub fn is_mixnode(&self) -> bool { + matches!(self, Role::Layer1 | Role::Layer2 | Role::Layer3) + } } impl Display for Role { diff --git a/common/topology/src/lib.rs b/common/topology/src/lib.rs index c71ada3c2dc..1077d1ffe55 100644 --- a/common/topology/src/lib.rs +++ b/common/topology/src/lib.rs @@ -401,20 +401,17 @@ impl NymTopology { }); }; - // a 'valid' egress is one assigned to either entry role (i.e. entry for another client) - // or exit role (as a service provider) + // a 'valid' egress is one that is currently **not** acting as a mixnode if !ignore_epoch_roles { - let Some(role) = self.rewarded_set.role(node.node_id) else { - return Err(NymTopologyError::InvalidEgressRole { - node_identity: Box::new(node_identity), - }); - }; - if !matches!(role, Role::EntryGateway | Role::ExitGateway) { - return Err(NymTopologyError::InvalidEgressRole { - node_identity: Box::new(node_identity), - }); + if let Some(role) = self.rewarded_set.role(node.node_id) { + if role.is_mixnode() { + return Err(NymTopologyError::InvalidEgressRole { + node_identity: Box::new(node_identity), + }); + } } } + Ok(node) } diff --git a/common/wasm/client-core/src/config/mod.rs b/common/wasm/client-core/src/config/mod.rs index aab813f5daf..5c20f832d3e 100644 --- a/common/wasm/client-core/src/config/mod.rs +++ b/common/wasm/client-core/src/config/mod.rs @@ -390,7 +390,6 @@ pub struct TopologyWasm { /// Specifies whether this client should attempt to retrieve all available network nodes /// as opposed to just active mixnodes/gateways. - /// Useless without `ignore_epoch_roles = true` pub use_extended_topology: bool, /// Specifies whether this client should ignore the current epoch role of the target egress node diff --git a/common/wasm/client-core/src/config/override.rs b/common/wasm/client-core/src/config/override.rs index f85ad9d241c..a1a10769fad 100644 --- a/common/wasm/client-core/src/config/override.rs +++ b/common/wasm/client-core/src/config/override.rs @@ -274,7 +274,6 @@ pub struct TopologyWasmOverride { /// Specifies whether this client should attempt to retrieve all available network nodes /// as opposed to just active mixnodes/gateways. - /// Useless without `ignore_epoch_roles = true` #[tsify(optional)] pub use_extended_topology: Option,