Merge pull request #5914 from nymtech/feature/nym-node-gw-reset

nym-node debug command to reset providers db
This commit is contained in:
benedetta davico
2025-08-05 12:05:44 +02:00
committed by GitHub
5 changed files with 65 additions and 3 deletions
+4
View File
@@ -0,0 +1,4 @@
// Copyright 2025 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
pub(crate) mod reset_providers_dbs;
@@ -0,0 +1,36 @@
// Copyright 2025 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
use crate::cli::helpers::ConfigArgs;
use crate::config::upgrade_helpers::try_load_current_config;
use crate::node::helpers::load_ed25519_identity_public_key;
use crate::node::ServiceProvidersData;
use nym_network_requester::{CustomGatewayDetails, GatewayDetails, GatewayRegistration};
use std::fs;
#[derive(Debug, clap::Args)]
pub struct Args {
#[clap(flatten)]
pub(crate) config: ConfigArgs,
}
pub async fn execute(args: Args) -> anyhow::Result<()> {
let config = try_load_current_config(args.config.config_path()).await?;
let public_key = load_ed25519_identity_public_key(
&config.storage_paths.keys.public_ed25519_identity_key_file,
)?;
let storage_paths = &config.service_providers.storage_paths;
for db_path in [
&storage_paths.authenticator.gateway_registrations,
&storage_paths.ip_packet_router.gateway_registrations,
&storage_paths.network_requester.gateway_registrations,
] {
fs::remove_file(db_path)?;
let gateway_details: GatewayRegistration =
GatewayDetails::Custom(CustomGatewayDetails::new(public_key)).into();
ServiceProvidersData::initialise_client_gateway_storage(db_path, &gateway_details).await?;
}
Ok(())
}
+1
View File
@@ -3,6 +3,7 @@
pub(crate) mod bonding_information;
pub(super) mod build_info;
pub(super) mod debug;
pub(super) mod migrate;
pub(crate) mod node_details;
pub(crate) mod reset_sphinx_keys;
+23 -2
View File
@@ -2,12 +2,12 @@
// SPDX-License-Identifier: GPL-3.0-only
use crate::cli::commands::{
bonding_information, build_info, migrate, node_details, reset_sphinx_keys, run, sign,
bonding_information, build_info, debug, migrate, node_details, reset_sphinx_keys, run, sign,
test_throughput,
};
use crate::env::vars::{NYMNODE_CONFIG_ENV_FILE_ARG, NYMNODE_NO_BANNER_ARG};
use crate::logging::setup_tracing_logger;
use clap::{Parser, Subcommand};
use clap::{Args, Parser, Subcommand};
use nym_bin_common::bin_info;
use std::future::Future;
use std::sync::OnceLock;
@@ -72,6 +72,11 @@ impl Cli {
Commands::UnsafeResetSphinxKeys(args) => {
{ Self::execute_async(reset_sphinx_keys::execute(args))? }?
}
Commands::Debug(debug) => match debug.command {
DebugCommands::ResetProvidersGatewayDbs(args) => {
{ Self::execute_async(debug::reset_providers_dbs::execute(args))? }?
}
},
}
Ok(())
}
@@ -100,12 +105,28 @@ pub(crate) enum Commands {
/// UNSAFE: reset existing sphinx keys and attempt to generate fresh one for the current network state
UnsafeResetSphinxKeys(reset_sphinx_keys::Args),
/// Commands exposed for debug purposes, usually not meant to be used by operators
#[clap(hide = true)]
Debug(Debug),
/// Attempt to approximate the maximum mixnet throughput if nym-node
/// was running on this machine in mixnet mode
#[clap(hide = true)]
TestThroughput(test_throughput::Args),
}
#[derive(Debug, Args)]
pub(crate) struct Debug {
#[clap(subcommand)]
pub(crate) command: DebugCommands,
}
#[derive(Subcommand, Debug)]
pub(crate) enum DebugCommands {
/// Reset the internal GatewaysDetailsStores of all service providers in case they got corrupted
ResetProvidersGatewayDbs(debug::reset_providers_dbs::Args),
}
#[cfg(test)]
mod tests {
use super::*;
+1 -1
View File
@@ -164,7 +164,7 @@ impl ServiceProvidersData {
Ok(())
}
async fn initialise_client_gateway_storage(
pub(crate) async fn initialise_client_gateway_storage(
storage_path: &Path,
registration: &GatewayRegistration,
) -> Result<(), ServiceProvidersError> {