Feature Noise XKpsk3 : Fix localnet (#4465)

* add custom mixnet option for gateways

* add custom mixnet option for mixnode

* change topology construction as to not miss described_nodes

* adapt localnet scripts to new topology

* add snake_case alias to described_nodes
This commit is contained in:
Simon Wicky
2024-03-19 15:49:29 +01:00
committed by GitHub
parent 5a9c391ba2
commit 4b3dcb6eca
12 changed files with 275 additions and 35 deletions
+137 -1
View File
@@ -14,6 +14,18 @@ def add_mixnode(base_network, base_dir, mix_id):
base_network["mixnodes"][str(mix_id)][0]["layer"] = mix_id
base_network["mixnodes"][str(mix_id)][0]["mix_id"] = mix_id
base_network["mixnodes"][str(mix_id)][0]["owner"] = "whatever"
#described_node
template = mixnode_template()
template["Mixnode"]["bond"]["mix_node"]["identity_key"] = mix_data["identity_key"]
template["Mixnode"]["bond"]["mix_node"]["sphinx_key"] = mix_data["sphinx_key"]
template["Mixnode"]["bond"]["mix_node"]["mix_port"] = mix_data["mix_port"]
template["Mixnode"]["bond"]["mix_node"]["host"] = mix_data["bind_address"]
template["Mixnode"]["bond"]["layer"] = mix_id
template["Mixnode"]["bond"]["mix_id"] = mix_id
template["Mixnode"]["self_described"]["host_information"]["keys"]["ed25519"] = mix_data["identity_key"]
template["Mixnode"]["self_described"]["host_information"]["keys"]["x25519"] = mix_data["sphinx_key"]
base_network["described_nodes"][mix_id] = template
return base_network
@@ -27,6 +39,17 @@ def add_gateway(base_network, base_dir):
# base_network["gateways"][0]["version"] = gateway_data["version"]
base_network["gateways"][0]["host"] = gateway_data["bind_address"]
base_network["gateways"][0]["owner"] = "whatever"
#described_node
template = gateway_template()
template["Gateway"]["bond"]["gateway"]["identity_key"] = gateway_data["identity_key"]
template["Gateway"]["bond"]["gateway"]["sphinx_key"] = gateway_data["sphinx_key"]
template["Gateway"]["bond"]["gateway"]["mix_port"] = gateway_data["mix_port"]
template["Gateway"]["bond"]["gateway"]["clients_port"] = gateway_data["clients_port"]
template["Gateway"]["bond"]["gateway"]["host"] = gateway_data["bind_address"]
template["Gateway"]["self_described"]["host_information"]["keys"]["ed25519"] = gateway_data["identity_key"]
template["Gateway"]["self_described"]["host_information"]["keys"]["x25519"] = gateway_data["sphinx_key"]
base_network["described_nodes"][0] = template
return base_network
@@ -37,7 +60,8 @@ def main(args):
"2": [{}],
"3": [{}],
},
"gateways": [{}]
"gateways": [{}],
"described_nodes":[{}, {}, {}, {}]
}
base_dir = args[0]
@@ -50,5 +74,117 @@ def main(args):
json.dump(base_network, out, indent=2)
def gateway_template():
return {"Gateway": {
"bond": {
"pledge_amount": {
"denom": "unym",
"amount": "0"
},
"owner": "whatever",
"block_height": 0,
"gateway": {
"host": "TO_BE_FILLED",
"mix_port": "TO_BE_FILLED",
"clients_port": "TO_BE_FILLED",
"location": "whatever",
"sphinx_key": "TO_BE_FILLED",
"identity_key": "TO_BE_FILLED",
"version": "whatever",
},
"proxy": None,
},
"self_described": {
"host_information": {
"ip_address": [
"0.0.0.0"
],
"hostname": None,
"keys": {
"ed25519": "TO_BE_FILLED",
"x25519": "TO_BE_FILLED"
}
},
"build_information": {
"binary_name": "whatever",
"build_timestamp": "whatever",
"build_version": "whatever",
"commit_sha": "whatever",
"commit_timestamp": "whatever",
"commit_branch": "whatever",
"rustc_version": "whatever",
"rustc_channel": "whatever",
"cargo_profile": "whatever"
},
"network_requester": {
"address": "none",
"uses_exit_policy": True
},
"mixnet_websockets": {
"ws_port": 9000,
"wss_port": None
},
"noise_information": {
"supported": True
}
}
}}
def mixnode_template():
return {
"Mixnode": {
"bond": {
"mix_id": "TO_BE_FILLED",
"owner": "whatever",
"original_pledge": {
"denom": "unym",
"amount": "0"
},
"layer": "TO_BE_FILLED",
"mix_node": {
"host": "TO_BE_FILLED",
"mix_port": "TO_BE_FILLED",
"verloc_port": 1790,
"http_api_port": 8000,
"sphinx_key": "TO_BE_FILLED",
"identity_key": "TO_BE_FILLED",
"version": "whatever"
},
"proxy": None,
"bonding_height": 0,
"is_unbonding": False
},
"self_described": {
"host_information": {
"ip_address": [
"0.0.0.0"
],
"hostname": None,
"keys": {
"ed25519": "TO_BE_FILLED",
"x25519": "TO_BE_FILLED"
}
},
"build_information": {
"binary_name": "whatever",
"build_timestamp": "whatever",
"build_version": "whatever",
"commit_sha": "whatever",
"commit_timestamp": "whatever",
"commit_branch": "whatever",
"rustc_version": "whatever",
"rustc_channel": "whatever",
"cargo_profile": "whatever"
},
"network_requester": None,
"ip_packet_router": None,
"mixnet_websockets": None,
"noise_information": {
"supported": True
}
}
}
}
if __name__ == '__main__':
main(sys.argv[1:])
+4 -4
View File
@@ -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-mixnode -- run --id mix1-$suffix --custom-mixnet \"$networkfile\" \""
tmux split-window -t localnet:0 "/usr/bin/env sh -c \" cargo run --release --bin nym-mixnode -- run --id mix2-$suffix --custom-mixnet \"$networkfile\" \""
tmux split-window -t localnet:0 "/usr/bin/env sh -c \" cargo run --release --bin nym-mixnode -- run --id mix3-$suffix --custom-mixnet \"$networkfile\" \""
tmux split-window -t localnet:0 "/usr/bin/env sh -c \" cargo run --release --bin nym-gateway -- run --id gateway-$suffix --local --custom-mixnet \"$networkfile\" \""
while ! nc -z localhost 9000; do
echo "waiting for nym-gateway to launch on port 9000..."