[bugfix] make sure localnet script works in post nym-node era
This commit is contained in:
@@ -18,6 +18,7 @@ pub(crate) async fn execute(mut args: Args) -> Result<(), NymNodeError> {
|
||||
let config_path = args.config.config_path();
|
||||
let output = args.output;
|
||||
let bonding_info_path = args.bonding_information_output.clone();
|
||||
let init_only = args.init_only;
|
||||
|
||||
let config = if !config_path.exists() {
|
||||
debug!("no configuration file found at '{}'", config_path.display());
|
||||
@@ -25,16 +26,11 @@ pub(crate) async fn execute(mut args: Args) -> Result<(), NymNodeError> {
|
||||
if args.deny_init {
|
||||
return Err(NymNodeError::ForbiddenInitialisation { config_path });
|
||||
}
|
||||
let init_only = args.init_only;
|
||||
|
||||
let maybe_custom_mnemonic = args.take_mnemonic();
|
||||
|
||||
let config = args.build_config()?;
|
||||
NymNode::initialise(&config, maybe_custom_mnemonic).await?;
|
||||
if init_only {
|
||||
debug!("returning due to the 'init-only' flag");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
config
|
||||
} else {
|
||||
@@ -73,5 +69,10 @@ pub(crate) async fn execute(mut args: Args) -> Result<(), NymNodeError> {
|
||||
})?;
|
||||
}
|
||||
|
||||
if init_only {
|
||||
debug!("returning due to the 'init-only' flag");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
nym_node.run().await
|
||||
}
|
||||
|
||||
+15
-14
@@ -3,30 +3,31 @@ import os.path
|
||||
import sys
|
||||
|
||||
|
||||
def add_mixnode(base_network, base_dir, mix_id):
|
||||
def add_mixnode(base_network, base_dir, mix_id, port_delta):
|
||||
with open(os.path.join(base_dir, "mix" + str(mix_id) + ".json"), "r") as json_blob:
|
||||
mix_data = json.load(json_blob)
|
||||
|
||||
base_network["mixnodes"][str(mix_id)][0]["identity_key"] = mix_data["identity_key"]
|
||||
base_network["mixnodes"][str(mix_id)][0]["sphinx_key"] = mix_data["sphinx_key"]
|
||||
base_network["mixnodes"][str(mix_id)][0]["mix_port"] = mix_data["mix_port"]
|
||||
base_network["mixnodes"][str(mix_id)][0]["mix_port"] = 10000 + port_delta
|
||||
base_network["mixnodes"][str(mix_id)][0]["version"] = mix_data["version"]
|
||||
base_network["mixnodes"][str(mix_id)][0]["host"] = mix_data["bind_address"]
|
||||
base_network["mixnodes"][str(mix_id)][0]["layer"] = mix_id
|
||||
base_network["mixnodes"][str(mix_id)][0]["host"] = "127.0.0.1"
|
||||
base_network["mixnodes"][str(mix_id)][0]["layer"] = mix_id % 3 + 1
|
||||
base_network["mixnodes"][str(mix_id)][0]["mix_id"] = mix_id
|
||||
base_network["mixnodes"][str(mix_id)][0]["owner"] = "whatever"
|
||||
base_network["mixnodes"][str(mix_id)][0]["owner"] = "n1jw6mp7d5xqc7w6xm79lha27glmd0vdt3l9artf"
|
||||
return base_network
|
||||
|
||||
|
||||
def add_gateway(base_network, base_dir):
|
||||
def add_gateway(base_network, base_dir, port_delta):
|
||||
with open(os.path.join(base_dir, "gateway.json"), "r") as json_blob:
|
||||
gateway_data = json.load(json_blob)
|
||||
base_network["gateways"][0]["identity_key"] = gateway_data["identity_key"]
|
||||
base_network["gateways"][0]["sphinx_key"] = gateway_data["sphinx_key"]
|
||||
base_network["gateways"][0]["mix_port"] = gateway_data["mix_port"]
|
||||
base_network["gateways"][0]["clients_port"] = gateway_data["clients_port"]
|
||||
base_network["gateways"][0]["mix_port"] = 10000 + port_delta
|
||||
base_network["gateways"][0]["clients_port"] = 9000
|
||||
# base_network["gateways"][0]["version"] = gateway_data["version"]
|
||||
base_network["gateways"][0]["host"] = gateway_data["bind_address"]
|
||||
base_network["gateways"][0]["owner"] = "whatever"
|
||||
base_network["gateways"][0]["host"] = "127.0.0.1"
|
||||
base_network["gateways"][0]["owner"] = "n1jw6mp7d5xqc7w6xm79lha27glmd0vdt3l9artf"
|
||||
return base_network
|
||||
|
||||
|
||||
@@ -41,10 +42,10 @@ def main(args):
|
||||
}
|
||||
|
||||
base_dir = args[0]
|
||||
base_network = add_mixnode(base_network, base_dir, 1)
|
||||
base_network = add_mixnode(base_network, base_dir, 2)
|
||||
base_network = add_mixnode(base_network, base_dir, 3)
|
||||
base_network = add_gateway(base_network, base_dir)
|
||||
base_network = add_mixnode(base_network, base_dir, 1, 1)
|
||||
base_network = add_mixnode(base_network, base_dir, 2, 2)
|
||||
base_network = add_mixnode(base_network, base_dir, 3, 3)
|
||||
base_network = add_gateway(base_network, base_dir, 4)
|
||||
|
||||
with open(os.path.join(base_dir, "network.json"), "w") as out:
|
||||
json.dump(base_network, out, indent=2)
|
||||
|
||||
@@ -20,16 +20,16 @@ echo "Using $localnetdir for the localnet"
|
||||
|
||||
# initialise mixnet
|
||||
echo "initialising mixnode1..."
|
||||
cargo run --release --bin nym-mixnode -- init --id "mix1-$suffix" --host 127.0.0.1 --mix-port 10001 --verloc-port 20001 --http-api-port 30001 --metrics-key=lala --output=json >>"$localnetdir/mix1.json"
|
||||
cargo run --release --bin nym-node -- run --id "mix1-$suffix" --init-only --mixnet-bind-address=127.0.0.1:10001 --verloc-bind-address 127.0.0.1:20001 --http-bind-address 127.0.0.1:30001 --http-access-token=lala --output=json --bonding-information-output "$localnetdir/mix1.json"
|
||||
|
||||
echo "initialising mixnode2..."
|
||||
cargo run --release --bin nym-mixnode -- init --id "mix2-$suffix" --host 127.0.0.1 --mix-port 10002 --verloc-port 20002 --http-api-port 30002 --metrics-key=lala --output=json >>"$localnetdir/mix2.json"
|
||||
cargo run --release --bin nym-node -- run --id "mix2-$suffix" --init-only --mixnet-bind-address=127.0.0.1:10002 --verloc-bind-address 127.0.0.1:20002 --http-bind-address 127.0.0.1:30002 --http-access-token=lala --output=json --bonding-information-output "$localnetdir/mix2.json"
|
||||
|
||||
echo "initialising mixnode3..."
|
||||
cargo run --release --bin nym-mixnode -- init --id "mix3-$suffix" --host 127.0.0.1 --mix-port 10003 --verloc-port 20003 --http-api-port 30003 --metrics-key=lala --output=json >>"$localnetdir/mix3.json"
|
||||
cargo run --release --bin nym-node -- run --id "mix3-$suffix" --init-only --mixnet-bind-address=127.0.0.1:10003 --verloc-bind-address 127.0.0.1:20003 --http-bind-address 127.0.0.1:30003 --http-access-token=lala --output=json --bonding-information-output "$localnetdir/mix3.json"
|
||||
|
||||
echo "initialising gateway..."
|
||||
cargo run --release --bin nym-gateway -- init --id "gateway-$suffix" --host 127.0.0.1 --mix-port 10004 --clients-port 9000 --output=json >>"$localnetdir/gateway.json"
|
||||
cargo run --release --bin nym-node -- run --id "gateway-$suffix" --init-only --mode entry --mixnet-bind-address=127.0.0.1:10004 --entry-bind-address 127.0.0.1:9000 --verloc-bind-address 127.0.0.1:20004 --http-bind-address 127.0.0.1:30004 --http-access-token=lala --output=json --bonding-information-output "$localnetdir/gateway.json"
|
||||
|
||||
# build the topology
|
||||
echo "combining json files..."
|
||||
@@ -42,10 +42,10 @@ echo "the full network file is located at $networkfile"
|
||||
echo "starting the mixnet..."
|
||||
tmux start-server
|
||||
|
||||
tmux new-session -d -s localnet -n Mixnet -d "/usr/bin/env sh -c \" cargo run --release --bin nym-mixnode -- run --id mix1-$suffix \""
|
||||
tmux split-window -t localnet:0 "/usr/bin/env sh -c \" cargo run --release --bin nym-mixnode -- run --id mix2-$suffix \""
|
||||
tmux split-window -t localnet:0 "/usr/bin/env sh -c \" cargo run --release --bin nym-mixnode -- run --id mix3-$suffix \""
|
||||
tmux split-window -t localnet:0 "/usr/bin/env sh -c \" cargo run --release --bin nym-gateway -- run --id gateway-$suffix --local \""
|
||||
tmux new-session -d -s localnet -n Mixnet -d "/usr/bin/env sh -c \" cargo run --release --bin nym-node -- run --id mix1-$suffix \""
|
||||
tmux split-window -t localnet:0 "/usr/bin/env sh -c \" cargo run --release --bin nym-node -- run --id mix2-$suffix \""
|
||||
tmux split-window -t localnet:0 "/usr/bin/env sh -c \" cargo run --release --bin nym-node -- run --id mix3-$suffix \""
|
||||
tmux split-window -t localnet:0 "/usr/bin/env sh -c \" cargo run --release --bin nym-node -- run --id gateway-$suffix \""
|
||||
|
||||
while ! nc -z localhost 9000; do
|
||||
echo "waiting for nym-gateway to launch on port 9000..."
|
||||
|
||||
Reference in New Issue
Block a user