Skip to content

Commit

Permalink
fixed testnet-manager tool to work with the updated binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
jstuczyn committed Oct 14, 2024
1 parent d04331a commit 8e38da8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 67 deletions.
6 changes: 0 additions & 6 deletions tools/internal/testnet-manager/src/manager/dkg_skip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ impl<'a> PemStorableKey for FakeDkgKey<'a> {
}
}

impl EcashSignerWithPaths {
pub(crate) fn api_port(&self) -> u16 {
self.data.endpoint.port().unwrap()
}
}

struct DkgSkipCtx<'a> {
progress: ProgressTracker,
network: &'a LoadedNetwork,
Expand Down
5 changes: 3 additions & 2 deletions tools/internal/testnet-manager/src/manager/local_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ impl NetworkManager {
"--enable-zk-nym",
"--announce-address",
info.data.endpoint.as_ref(),
"--bind-address",
&format!("0.0.0.0:{}", info.data.endpoint.port().unwrap()),
])
.stdin(Stdio::null())
.stderr(Stdio::null())
Expand Down Expand Up @@ -163,11 +165,10 @@ impl NetworkManager {

let mut cmds = Vec::new();
for signer in &ctx.signers {
let port = signer.api_port();
let id = ctx.signer_id(signer);

cmds.push(format!(
"ROCKET_PORT={port} {bin_canon_display} -c {env_canon_display} run --id {id}"
"{bin_canon_display} -c {env_canon_display} run --id {id}"
));
}
Ok(RunCommands(cmds))
Expand Down
53 changes: 28 additions & 25 deletions tools/internal/testnet-manager/src/manager/local_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ impl NetworkManager {
&format!("127.0.0.1:{verloc_port}"),
"--entry-bind-address",
&format!("127.0.0.1:{clients_port}"),
"--mixnet-announce-port",
&mix_port.to_string(),
"--verloc-announce-port",
&verloc_port.to_string(),
"--mnemonic",
&Zeroizing::new(node.owner.mnemonic.to_string()),
"--local",
Expand Down Expand Up @@ -203,11 +207,7 @@ impl NetworkManager {

ctx.set_pb_message(format!("generating bonding signature for node {id}..."));

let msg = if is_gateway {
node.gateway_bonding_payload()
} else {
node.mixnode_bonding_payload()
};
let msg = node.bonding_payload();

let child = Command::new(&ctx.nym_node_binary)
.args([
Expand Down Expand Up @@ -318,28 +318,20 @@ impl NetworkManager {

let owner = ctx.signing_node_owner(node)?;

let (bonding_fut, typ) = if is_gateway {
(
owner.bond_gateway(
node.gateway(),
node.bonding_signature(),
node.pledge().into(),
None,
),
"gateway",
)
let typ = if is_gateway {
"gateway [as nym-node]"
} else {
(
owner.bond_mixnode(
node.mixnode(),
node.cost_params(),
node.bonding_signature(),
node.pledge().into(),
None,
),
"mixnode",
)
"mixnode [as nym-node]"
};

let bonding_fut = owner.bond_nymnode(
node.bonding_nym_node(),
node.cost_params(),
node.bonding_signature(),
node.pledge().into(),
None,
);

let res = ctx.async_with_progress(bonding_fut).await?;
ctx.println(format!(
"\t{id} ({typ}) bonded in transaction: {}",
Expand Down Expand Up @@ -376,6 +368,7 @@ impl NetworkManager {
style("[4/5]").bold().dim()
));

// this could be batched in a single tx, but that's too much effort for now
let rewarder = ctx.signing_rewarder()?;

ctx.set_pb_message("starting epoch transition...");
Expand All @@ -386,6 +379,16 @@ impl NetworkManager {
let fut = rewarder.reconcile_epoch_events(None, None);
ctx.async_with_progress(fut).await?;

ctx.set_pb_message("finally assigning the active set... exit...");
let fut = rewarder.assign_roles(
RoleAssignment {
role: Role::ExitGateway,
nodes: vec![],
},
None,
);
ctx.async_with_progress(fut).await?;

ctx.set_pb_message("finally assigning the active set... entry...");
let fut = rewarder.assign_roles(
RoleAssignment {
Expand Down
42 changes: 8 additions & 34 deletions tools/internal/testnet-manager/src/manager/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use nym_coconut_dkg_common::types::Addr;
use nym_contracts_common::signing::MessageSignature;
use nym_contracts_common::Percent;
use nym_mixnet_contract_common::{
construct_gateway_bonding_sign_payload, construct_mixnode_bonding_sign_payload, Gateway,
MixNode, NodeCostParams,
construct_gateway_bonding_sign_payload, construct_mixnode_bonding_sign_payload,
construct_nym_node_bonding_sign_payload, Gateway, MixNode, NodeCostParams,
};
use nym_validator_client::nyxd::CosmWasmCoin;

Expand Down Expand Up @@ -44,27 +44,11 @@ impl NymNode {
CosmWasmCoin::new(100_000000, "unym")
}

pub(crate) fn gateway(&self) -> Gateway {
Gateway {
pub(crate) fn bonding_nym_node(&self) -> nym_mixnet_contract_common::NymNode {
nym_mixnet_contract_common::NymNode {
host: "127.0.0.1".to_string(),
mix_port: self.mix_port,
clients_port: self.clients_port,
location: "foomp".to_string(),
sphinx_key: self.sphinx_key.clone(),
custom_http_port: Some(self.http_port),
identity_key: self.identity_key.clone(),
version: self.version.clone(),
}
}

pub(crate) fn mixnode(&self) -> MixNode {
MixNode {
host: "127.0.0.1".to_string(),
mix_port: self.mix_port,
verloc_port: self.verloc_port,
http_api_port: self.http_port,
sphinx_key: self.sphinx_key.clone(),
identity_key: self.identity_key.clone(),
version: self.version.clone(),
}
}

Expand All @@ -80,24 +64,14 @@ impl NymNode {
self.bonding_signature.parse().unwrap()
}

pub(crate) fn mixnode_bonding_payload(&self) -> String {
let payload = construct_mixnode_bonding_sign_payload(
pub(crate) fn bonding_payload(&self) -> String {
let payload = construct_nym_node_bonding_sign_payload(
0,
Addr::unchecked(self.owner.address.to_string()),
self.pledge(),
self.mixnode(),
self.bonding_nym_node(),
self.cost_params(),
);
payload.to_base58_string().unwrap()
}

pub(crate) fn gateway_bonding_payload(&self) -> String {
let payload = construct_gateway_bonding_sign_payload(
0,
Addr::unchecked(self.owner.address.to_string()),
self.pledge(),
self.gateway(),
);
payload.to_base58_string().unwrap()
}
}

0 comments on commit 8e38da8

Please sign in to comment.