Skip to content

Commit 983cba2

Browse files
authored
Bridge proto client params in Self-Described (#6035)
1 parent eeb0278 commit 983cba2

File tree

9 files changed

+51
-1
lines changed

9 files changed

+51
-1
lines changed

nym-node/nym-node-requests/src/api/v1/gateway/models.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,9 @@ pub struct WebSockets {
4646

4747
pub wss_port: Option<u16>,
4848
}
49+
50+
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
51+
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
52+
pub struct Bridges {
53+
pub client_params_path: String,
54+
}

nym-node/nym-node-requests/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub mod routes {
4141
pub const GATEWAY: &str = "/gateway";
4242
pub const MIXNODE: &str = "/mixnode";
4343
pub const METRICS: &str = "/metrics";
44+
pub const BRIDGES: &str = "/bridges";
4445
pub const NETWORK_REQUESTER: &str = "/network-requester";
4546
pub const IP_PACKET_ROUTER: &str = "/ip-packet-router";
4647
pub const AUTHENTICATOR: &str = "/authenticator";

nym-node/src/config/old_configs/old_config_v10.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,9 @@ pub struct GatewayTasksPathsV10 {
979979

980980
/// Path to file containing cosmos account mnemonic used for zk-nym redemption.
981981
pub cosmos_mnemonic: PathBuf,
982+
983+
/// Path to file containing bridge client params to be served in the node self-described.
984+
pub bridge_client_params: Option<PathBuf>,
982985
}
983986

984987
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
@@ -1469,6 +1472,7 @@ pub async fn try_upgrade_config_v10<P: AsRef<Path>>(
14691472
clients_storage: old_cfg.gateway_tasks.storage_paths.clients_storage,
14701473
stats_storage: old_cfg.gateway_tasks.storage_paths.stats_storage,
14711474
cosmos_mnemonic: old_cfg.gateway_tasks.storage_paths.cosmos_mnemonic,
1475+
bridge_client_params: old_cfg.gateway_tasks.storage_paths.bridge_client_params,
14721476
},
14731477
enforce_zk_nyms: old_cfg.gateway_tasks.enforce_zk_nyms,
14741478
ws_bind_address: old_cfg.gateway_tasks.ws_bind_address,

nym-node/src/config/old_configs/old_config_v9.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,7 @@ pub async fn try_upgrade_config_v9<P: AsRef<Path>>(
14861486
clients_storage: old_cfg.gateway_tasks.storage_paths.clients_storage,
14871487
stats_storage: old_cfg.gateway_tasks.storage_paths.stats_storage,
14881488
cosmos_mnemonic: old_cfg.gateway_tasks.storage_paths.cosmos_mnemonic,
1489+
bridge_client_params: None,
14891490
},
14901491
enforce_zk_nyms: old_cfg.gateway_tasks.enforce_zk_nyms,
14911492
ws_bind_address: old_cfg.gateway_tasks.ws_bind_address,

nym-node/src/config/persistence.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ pub struct GatewayTasksPaths {
146146

147147
/// Path to file containing cosmos account mnemonic used for zk-nym redemption.
148148
pub cosmos_mnemonic: PathBuf,
149+
150+
/// Path to file containing bridge client params to be served in the node self-described.
151+
pub bridge_client_params: Option<PathBuf>,
149152
}
150153

151154
impl GatewayTasksPaths {
@@ -154,6 +157,7 @@ impl GatewayTasksPaths {
154157
clients_storage: data_dir.as_ref().join(DEFAULT_CLIENTS_STORAGE_FILENAME),
155158
stats_storage: data_dir.as_ref().join(DEFAULT_STATS_STORAGE_FILENAME),
156159
cosmos_mnemonic: data_dir.as_ref().join(DEFAULT_MNEMONIC_FILENAME),
160+
bridge_client_params: None,
157161
}
158162
}
159163

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
2+
// SPDX-License-Identifier: GPL-3.0-only
3+
4+
use axum::Router;
5+
use nym_node_requests::api::v1::gateway::models;
6+
use tower_http::services::ServeFile;
7+
8+
#[derive(Debug, Clone, Default)]
9+
pub struct Config {
10+
pub details: Option<models::Bridges>,
11+
}
12+
13+
pub(crate) fn routes<S: Send + Sync + 'static + Clone>(config: Config) -> Router<S> {
14+
if let Some(cfg) = config.details {
15+
Router::new().route_service("/client-params", ServeFile::new(cfg.client_params_path))
16+
} else {
17+
Router::new()
18+
}
19+
}

nym-node/src/node/http/router/api/v1/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use axum::Router;
77
use nym_node_requests::routes::api::v1;
88

99
pub mod authenticator;
10+
pub mod bridges;
1011
pub mod gateway;
1112
pub mod health;
1213
pub mod ip_packet_router;
@@ -23,6 +24,7 @@ pub struct Config {
2324
pub metrics: metrics::Config,
2425
pub gateway: gateway::Config,
2526
pub mixnode: mixnode::Config,
27+
pub bridges: bridges::Config,
2628
pub network_requester: network_requester::Config,
2729
pub ip_packet_router: ip_packet_router::Config,
2830
pub authenticator: authenticator::Config,
@@ -33,6 +35,7 @@ pub(super) fn routes(config: Config) -> Router<AppState> {
3335
.route(v1::HEALTH, get(health::root_health))
3436
.route(v1::LOAD, get(load::root_load))
3537
.nest(v1::METRICS, metrics::routes(config.metrics))
38+
.nest(v1::BRIDGES, bridges::routes(config.bridges))
3639
.nest(v1::GATEWAY, gateway::routes(config.gateway))
3740
.nest(v1::MIXNODE, mixnode::routes(config.mixnode))
3841
.nest(

nym-node/src/node/http/router/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use axum::Router;
1010
use nym_bin_common::bin_info_owned;
1111
use nym_http_api_common::middleware::logging;
1212
use nym_node_requests::api::v1::authenticator::models::Authenticator;
13-
use nym_node_requests::api::v1::gateway::models::Gateway;
13+
use nym_node_requests::api::v1::gateway::models::{Bridges, Gateway};
1414
use nym_node_requests::api::v1::ip_packet_router::models::IpPacketRouter;
1515
use nym_node_requests::api::v1::mixnode::models::Mixnode;
1616
use nym_node_requests::api::v1::network_requester::exit_policy::models::UsedExitPolicy;
@@ -48,6 +48,7 @@ impl HttpServerConfig {
4848
metrics: Default::default(),
4949
gateway: Default::default(),
5050
mixnode: Default::default(),
51+
bridges: Default::default(),
5152
network_requester: Default::default(),
5253
ip_packet_router: Default::default(),
5354
authenticator: Default::default(),
@@ -121,6 +122,13 @@ impl HttpServerConfig {
121122
self.api.v1_config.metrics.bearer_token = bearer_token.map(|b| Arc::new(Zeroizing::new(b)));
122123
self
123124
}
125+
126+
pub fn with_bridge_client_params_file(mut self, path: &Path) -> Self {
127+
self.api.v1_config.bridges.details = Some(Bridges {
128+
client_params_path: path.to_string_lossy().to_string(),
129+
});
130+
self
131+
}
124132
}
125133

126134
pub struct NymNodeRouter {

nym-node/src/node/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,10 @@ impl NymNode {
811811
config.api.v1_config.node.roles.ip_packet_router_enabled = true;
812812
}
813813

814+
if let Some(path) = &self.config.gateway_tasks.storage_paths.bridge_client_params {
815+
config = config.with_bridge_client_params_file(path);
816+
}
817+
814818
let x25519_versioned_noise_key = if self.config.mixnet.debug.unsafe_disable_noise {
815819
None
816820
} else {

0 commit comments

Comments
 (0)