Support mnemonic in the NS agent

This commit is contained in:
benedettadavico
2025-07-02 17:29:59 +02:00
committed by Bogdan-Ștefan Neacşu
parent 8d2cd48da5
commit 0867bafdbd
7 changed files with 19 additions and 2 deletions
@@ -57,5 +57,5 @@ jobs:
- name: BuildAndPushImageOnHarbor
run: |
docker build --build-arg GIT_REF=${{ github.event.inputs.gateway_probe_git_ref }} -f ${{ env.WORKING_DIRECTORY }}/Dockerfile . -t harbor.nymte.ch/nym/${{ env.CONTAINER_NAME }}:${{ steps.get_version.outputs.result }}-${{ steps.cleanup_gateway_probe_ref.outputs.git_ref }}
docker build --build-arg GIT_REF=${{ github.event.inputs.gateway_probe_git_ref }} --build-arg MNEMONIC="${{ secrets.CANARY_PROBE_MNEMONIC }}" -f ${{ env.WORKING_DIRECTORY }}/Dockerfile . -t harbor.nymte.ch/nym/${{ env.CONTAINER_NAME }}:${{ steps.get_version.outputs.result }}-${{ steps.cleanup_gateway_probe_ref.outputs.git_ref }}
docker push harbor.nymte.ch/nym/${{ env.CONTAINER_NAME }} --all-tags
@@ -306,6 +306,7 @@ export RUST_LOG="info"
export NODE_STATUS_AGENT_SERVER_ADDRESS="http://127.0.0.1"
export NODE_STATUS_AGENT_SERVER_PORT="8000"
export NODE_STATUS_AGENT_AUTH_KEY=<NS_AGENT_PRIVATE_KEY>
export NODE_STATUS_AGENT_PROBE_MNEMONIC=<NS_AGENT_MNEMONIC>
export NODE_STATUS_AGENT_PROBE_EXTRA_ARGS="netstack-download-timeout-sec=30,netstack-num-ping=2,netstack-send-timeout-sec=1,netstack-recv-timeout-sec=1"
workers=${1:-1}
@@ -2,6 +2,7 @@
FROM harbor.nymte.ch/dockerhub/rust:latest AS builder
ARG GIT_REF=main
ARG MNEMONIC
RUN apt update && apt install -yy libdbus-1-dev pkg-config libclang-dev
@@ -38,4 +39,5 @@ COPY --from=builder /usr/src/nym/target/release/nym-node-status-agent ./
COPY --from=builder /usr/src/nym-vpn-client/nym-vpn-core/target/release/nym-gateway-probe ./
ENV NODE_STATUS_AGENT_PROBE_PATH=/nym/nym-gateway-probe
ENV NODE_STATUS_AGENT_PROBE_MNEMONIC="$MNEMONIC"
ENTRYPOINT [ "/nym/nym-node-status-agent", "run-probe" ]
@@ -21,6 +21,7 @@ export NODE_STATUS_AGENT_SERVER_ADDRESS="http://127.0.0.1"
export NODE_STATUS_AGENT_SERVER_PORT="8000"
export NODE_STATUS_AGENT_PROBE_PATH="$crate_root/nym-gateway-probe"
export NODE_STATUS_AGENT_AUTH_KEY="BjyC9SsHAZUzPRkQR4sPTvVrp4GgaquTh5YfSJksvvWT"
export NODE_STATUS_AGENT_PROBE_MNEMONIC="$MNEMONIC"
export NODE_STATUS_AGENT_PROBE_EXTRA_ARGS="netstack-download-timeout-sec=30,netstack-num-ping=2,netstack-send-timeout-sec=1,netstack-recv-timeout-sec=1"
workers=${1:-1}
@@ -36,6 +36,10 @@ pub(crate) enum Command {
#[arg(long, env = "NODE_STATUS_AGENT_PROBE_PATH")]
probe_path: String,
/// mnemonic for acquiring zk-nyms
#[arg(long, env = "NODE_STATUS_AGENT_PROBE_MNEMONIC")]
mnemonic: String,
#[arg(
long,
env = "NODE_STATUS_AGENT_PROBE_EXTRA_ARGS",
@@ -58,12 +62,14 @@ impl Args {
server_port,
ns_api_auth_key,
probe_path,
mnemonic,
probe_extra_args,
} => run_probe::run_probe(
server_address,
server_port.to_owned(),
ns_api_auth_key,
probe_path,
mnemonic,
probe_extra_args,
)
.await
@@ -7,6 +7,7 @@ pub(crate) async fn run_probe(
server_port: u16,
ns_api_auth_key: &str,
probe_path: &str,
mnemonic: &str,
probe_extra_args: &Vec<String>,
) -> anyhow::Result<()> {
let auth_key = PrivateKey::from_base58_string(ns_api_auth_key)
@@ -20,7 +21,11 @@ pub(crate) async fn run_probe(
tracing::info!("Probe version:\n{}", version);
if let Some(testrun) = ns_api_client.request_testrun().await? {
let log = probe.run_and_get_log(&Some(testrun.gateway_identity_key), probe_extra_args);
let log = probe.run_and_get_log(
&Some(testrun.gateway_identity_key),
mnemonic,
probe_extra_args,
);
ns_api_client
.submit_results(testrun.testrun_id, log, testrun.assigned_at_utc)
@@ -73,6 +73,7 @@ impl GwProbe {
pub(crate) fn run_and_get_log(
&self,
gateway_key: &Option<String>,
mnemonic: &str,
probe_extra_args: &Vec<String>,
) -> String {
let mut command = std::process::Command::new(&self.path);
@@ -81,6 +82,7 @@ impl GwProbe {
if let Some(gateway_id) = gateway_key {
command.arg("--gateway").arg(gateway_id);
}
command.arg("--mnemonic").arg(mnemonic);
tracing::info!("Extra args for the probe:");
for arg in probe_extra_args {