From 4dc17497f37e7b0d49d4e9865186841f2f5bd7c8 Mon Sep 17 00:00:00 2001 From: 0xFugue <119708655+0xFugue@users.noreply.github.com> Date: Tue, 14 Mar 2023 23:08:12 +0530 Subject: [PATCH 1/3] nomos graph & minor fixes (#96) * nomos node & minor fixes * nomos node & minor fixes --- config/config.json | 5 +- gennet-module/gennet.py | 110 ++++++++++++++++++++++++++-------------- 2 files changed, 76 insertions(+), 39 deletions(-) diff --git a/config/config.json b/config/config.json index 4c84733..992ab84 100644 --- a/config/config.json +++ b/config/config.json @@ -10,18 +10,19 @@ }, "gennet": { "num_nodes": 3, + "fanout": 3, "num_topics": 1, "num_partitions": 1, "num_subnets": 1, "container_size": "1", - "node_type_distribution": { "nwaku":100, "gowaku":0, "nomos":0 }, + "node_type_distribution": { "nwaku":100, "gowaku":0 }, "node_type": "desktop", "network_type": "newmanwattsstrogatz", "output_dir": "network_data", "benchmark": "False" }, "wls": { - "simulation_time": 60, + "simulation_time": 6, "message_rate": 10, "min_packet_size": 2, "max_packet_size": 1024, diff --git a/gennet-module/gennet.py b/gennet-module/gennet.py index c55a6ca..975bec1 100755 --- a/gennet-module/gennet.py +++ b/gennet-module/gennet.py @@ -19,9 +19,8 @@ from enum import Enum # To add a new node type, add appropriate entries to the nodeType and nodeTypeSwitch class nodeType(Enum): - NWAKU = "nwaku" # waku desktop config - GOWAKU = "gowaku" # waku mobile config - NOMOS = "nomos" + NWAKU = "nwaku" # waku desktop config + GOWAKU = "gowaku" # waku mobile config nodeTypeToToml = { @@ -31,8 +30,7 @@ nodeTypeToToml = { nodeTypeToDocker = { nodeType.NWAKU: "nim-waku", - nodeType.GOWAKU: "go-waku", - nodeType.NOMOS: "nomos" + nodeType.GOWAKU: "go-waku" } # To add a new network type, add appropriate entries to the networkType and networkTypeSwitch @@ -43,6 +41,7 @@ class networkType(Enum): NEWMANWATTSSTROGATZ = "newmanwattsstrogatz" # mesh, smallworld BARBELL = "barbell" # partition BALANCEDTREE = "balancedtree" # committees? + NOMOSTREE = "nomostree" # balanced binary tree with even # of leaves STAR = "star" # spof @@ -66,7 +65,7 @@ def write_toml(dirname, node_name, toml): # Draw the network and output the image to a file; does not account for subnets yet -def draw(dirname, H): +def draw_network(dirname, H): nx.draw(H, pos=nx.kamada_kawai_layout(H), with_labels=True) fname = os.path.join(dirname, NW_DATA_FNAME) plt.savefig(f"{os.path.splitext(fname)[0]}.png", format="png") @@ -121,34 +120,65 @@ def get_random_sublist(topics): ### network processing related fns ################################################# # Network Types -def generate_config_model(n): + +# |G| = n +def generate_config_model(ctx): + n = ctx.params["num_nodes"] # degrees = nx.random_powerlaw_tree_sequence(n, tries=10000) degrees = [random.randint(1, n) for i in range(n)] if (sum(degrees)) % 2 != 0: # adjust the degree to be even degrees[-1] += 1 return nx.configuration_model(degrees) # generate the graph - -def generate_scalefree_graph(n): +# |G| = n +def generate_scalefree_graph(ctx): + n = ctx.params["num_nodes"] return nx.scale_free_graph(n) +# |G| = n; n must be larger than k=D=3 +def generate_newmanwattsstrogatz_graph(ctx): + n = ctx.params["num_nodes"] + fanout = ctx.params["fanout"] + return nx.newman_watts_strogatz_graph(n, fanout, 0.5) -# n must be larger than k=D=3 -def generate_newmanwattsstrogatz_graph(n): - return nx.newman_watts_strogatz_graph(n, 3, 0.5) - - -def generate_barbell_graph(n): +# |G| = n (if odd); n+1 (if even) +def generate_barbell_graph(ctx): + n = ctx.params["num_nodes"] return nx.barbell_graph(int(n / 2), 1) - -def generate_balanced_tree(n, fanout=3): +# |G| > fanout^{\floor{log_n} + 1} +def generate_balanced_tree(ctx): + n = ctx.params["num_nodes"] + fanout = ctx.params["fanout"] height = int(math.log(n) / math.log(fanout)) return nx.balanced_tree(fanout, height) +# nomostree is a balanced binary tree with even number of leaves +# |G| = n (if odd); n+1 (if even) +def generate_nomos_tree(ctx): + n = ctx.params["num_nodes"] + fanout = ctx.params["fanout"] + # nomos currently insists on binary trees + assert(fanout == 2) + height = int(math.log(n) / math.log(fanout)) + G = nx.balanced_tree(fanout, height) + i, diff = 0, G.number_of_nodes() - n + leaves = [x for x in G.nodes() if G.degree(x) == 1] + nleaves = len(leaves) + if (nleaves - diff) % 2 != 0 : + diff -= 1 + for node in leaves : + if i == diff: + break + G.remove_node(node) + i += 1 + G = nx.convert_node_labels_to_integers(G) + return G -def generate_star_graph(n): - return nx.star_graph(n) +# |G| = n +def generate_star_graph(ctx): + n = ctx.params["num_nodes"] + return nx.star_graph(n-1) networkTypeSwitch = { @@ -157,13 +187,15 @@ networkTypeSwitch = { networkType.NEWMANWATTSSTROGATZ: generate_newmanwattsstrogatz_graph, networkType.BARBELL: generate_barbell_graph, networkType.BALANCEDTREE: generate_balanced_tree, + networkType.NOMOSTREE: generate_nomos_tree, networkType.STAR: generate_star_graph } # Generate the network from nw type -def generate_network(n, network_type): - return postprocess_network(networkTypeSwitch.get(network_type)(n)) +def generate_network(ctx): + network_type = networkType(ctx.params["network_type"]) + return postprocess_network(networkTypeSwitch.get(network_type)(ctx)) # Label the generated network with prefix @@ -333,17 +365,19 @@ def _num_subnets_callback(ctx: typer, Context, num_subnets: int): def main(ctx: typer.Context, - benchmark: bool = False, - container_size: int = 1, # TODO: reduce container packer memory consumption - output_dir: str = "network_data", - prng_seed: int = 3, - num_nodes: int = 4, - num_topics: int = 1, - node_type_distribution: str = typer.Argument("{\"nwaku\" : 100 }" ,callback=ast.literal_eval), - network_type: networkType = networkType.NEWMANWATTSSTROGATZ.value, - num_subnets: int = typer.Option(1, callback=_num_subnets_callback), - num_partitions: int = typer.Option(1, callback=_num_partitions_callback), - config_file: str = typer.Option("", callback=conf_callback, is_eager=True)): + benchmark: bool = typer.Option(False, help="Measure CPU/Mem usage of Gennet"), + draw: bool = typer.Option(False, help="Draw the generated network"), + container_size: int = typer.Option(1, help="Set the number of nodes per container"), # TODO: reduce container packer memory consumption + output_dir: str = typer.Option("network_data", help="Set the output directory for Gennet generated files"), + prng_seed: int = typer.Option(41, help="Set the random seed"), + num_nodes: int = typer.Option(4, help="Set the number of nodes"), + num_topics: int = typer.Option(1, help="Set the number of topics"), + fanout: int = typer.Option(3, help="Set the arity for trees & newmanwattsstrogatz"), + node_type_distribution: str = typer.Argument("{\"nwaku\" : 100 }" ,callback=ast.literal_eval, help="Set the node type distribution"), + network_type: networkType = typer.Option(networkType.NEWMANWATTSSTROGATZ.value, help="Set the node type"), + num_subnets: int = typer.Option(1, callback=_num_subnets_callback, help="Set the number of subnets"), + num_partitions: int = typer.Option(1, callback=_num_partitions_callback, help="Set the number of network partitions"), + config_file: str = typer.Option("", callback=conf_callback, is_eager=True, help="Set the input config file (JSON)")): # Benchmarking: record start time and start tracing mallocs if benchmark : @@ -372,18 +406,20 @@ def main(ctx: typer.Context, # Generate the network - G = generate_network(num_nodes, networkType(network_type)) + # G = generate_network(num_nodes, networkType(network_type), tree_arity) + G = generate_network(ctx) - # Do not complain if folder exists already + # Do not complain if the folder already exists os.makedirs(output_dir, exist_ok=True) # Generate file format specific data structs and write the files generate_and_write_files(ctx, G) - #generate_and_write_files(output_dir, num_topics, num_subnets, node_type_distribution, G) - #draw(G, outpur_dir) + if draw : + draw_network(output_dir, G) + end = time.time() time_took = end - start - print(f"For {num_nodes} nodes, network generation took {time_took} secs.\nThe generated network is under ./{output_dir}") + print(f"For {G.number_of_nodes()}/{num_nodes} nodes, network generation took {time_took} secs.\nThe generated network is under ./{output_dir}") # Benchmarking. Record finish time and stop the malloc tracing if benchmark : From 11b817a4bd48eacf60afe8ca0639716e316255a2 Mon Sep 17 00:00:00 2001 From: Alberto Soutullo Date: Wed, 15 Mar 2023 12:51:49 +0100 Subject: [PATCH 2/3] Added node configuration in gennet.py --- config/config.json | 5 ++++- gennet-module/gennet.py | 45 ++++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/config/config.json b/config/config.json index 992ab84..0425fe3 100644 --- a/config/config.json +++ b/config/config.json @@ -16,7 +16,10 @@ "num_subnets": 1, "container_size": "1", "node_type_distribution": { "nwaku":100, "gowaku":0 }, - "node_type": "desktop", + "node_config": { + "nwaku": "rpc-admin = true\nkeep-alive = true\nmetrics-server = true\ndiscv5-discovery = true\n", + "gowaku": "rpc-admin = true\nmetrics-server = true\nrpc = true\n" + }, "network_type": "newmanwattsstrogatz", "output_dir": "network_data", "benchmark": "False" diff --git a/gennet-module/gennet.py b/gennet-module/gennet.py index 975bec1..6ef0ccb 100755 --- a/gennet-module/gennet.py +++ b/gennet-module/gennet.py @@ -23,7 +23,7 @@ class nodeType(Enum): GOWAKU = "gowaku" # waku mobile config -nodeTypeToToml = { +nodeTypeToTomlDefault = { nodeType.NWAKU: "rpc-admin = true\nkeep-alive = true\nmetrics-server = true\n", nodeType.GOWAKU: "rpc-admin = true\nmetrics-server = true\nrpc = true\n" } @@ -159,14 +159,14 @@ def generate_nomos_tree(ctx): n = ctx.params["num_nodes"] fanout = ctx.params["fanout"] # nomos currently insists on binary trees - assert(fanout == 2) + assert(fanout == 2) height = int(math.log(n) / math.log(fanout)) G = nx.balanced_tree(fanout, height) i, diff = 0, G.number_of_nodes() - n leaves = [x for x in G.nodes() if G.degree(x) == 1] nleaves = len(leaves) if (nleaves - diff) % 2 != 0 : - diff -= 1 + diff -= 1 for node in leaves : if i == diff: break @@ -229,15 +229,22 @@ def generate_subnets(G, num_subnets): ### file format related fns ########################################################### # Generate per node toml configs -def generate_toml(topics, node_type=nodeType.NWAKU): +def generate_toml(topics, configuration, node_type=nodeType.NWAKU): topics = get_random_sublist(topics) if node_type == nodeType.GOWAKU: # comma separated list of quoted topics topic_str = ", ".join(f"\"{t}\"" for t in topics) topic_str = f"[{topic_str}]" else: # space separated topics - topic_str = " ".join(topics) + topic_str = " ".join(topics) topic_str = f"\"{topic_str}\"" - return f"{nodeTypeToToml.get(node_type)}topics = {topic_str}\n" + + if configuration is None: + config = nodeTypeToTomlDefault.get(node_type) + return f"{config}topics = {topic_str}\n" + + return f"{configuration}topics = {topic_str}\n" + + # Convert a dict to pair of arrays @@ -258,12 +265,12 @@ def generate_node_types(node_type_distribution, G): # Inverts a dictionary of lists def invert_dict_of_list(d): - inv = {} - for key, val in d.items(): - if val not in inv: - inv[val] = [key] - else: - inv[val].append(key) + inv = {} + for key, val in d.items(): + if val not in inv: + inv[val] = [key] + else: + inv[val].append(key) return inv @@ -292,11 +299,11 @@ def generate_and_write_files(ctx: typer, G): json_dump = {} json_dump[CONTAINER_PREFIX] = {} json_dump[EXTERNAL_NODES_PREFIX] = {} - inv = {} - for key, val in node2container.items(): - if val[1] not in inv: + inv = {} + for key, val in node2container.items(): + if val[1] not in inv: inv[val[1]] = [key] - else: + else: inv[val[1]].append(key) for container, nodes in inv.items(): json_dump[CONTAINER_PREFIX][container] = nodes @@ -307,7 +314,8 @@ def generate_and_write_files(ctx: typer, G): # write the per node toml for the i^ith node of appropriate type node_type, i = node_types_enum[i], i+1 - write_toml(ctx.params["output_dir"], node, generate_toml(topics, node_type)) + configuration = ctx.params.get("node_config", {}).get(node_type.value) + write_toml(ctx.params["output_dir"], node, generate_toml(topics, configuration, node_type)) json_dump[EXTERNAL_NODES_PREFIX][node] = {} json_dump[EXTERNAL_NODES_PREFIX][node]["static_nodes"] = [] for edge in G.edges(node): @@ -374,6 +382,7 @@ def main(ctx: typer.Context, num_topics: int = typer.Option(1, help="Set the number of topics"), fanout: int = typer.Option(3, help="Set the arity for trees & newmanwattsstrogatz"), node_type_distribution: str = typer.Argument("{\"nwaku\" : 100 }" ,callback=ast.literal_eval, help="Set the node type distribution"), + node_config: str = typer.Argument("{}" ,callback=ast.literal_eval, help="Set the node configuration"), network_type: networkType = typer.Option(networkType.NEWMANWATTSSTROGATZ.value, help="Set the node type"), num_subnets: int = typer.Option(1, callback=_num_subnets_callback, help="Set the number of subnets"), num_partitions: int = typer.Option(1, callback=_num_partitions_callback, help="Set the number of network partitions"), @@ -395,7 +404,7 @@ def main(ctx: typer.Context, print("Setting the random seed to", prng_seed) random.seed(prng_seed) np.random.seed(prng_seed) - + # leaving it for now should any json parsing issues pops up # Extract the node type distribution from config.json or use the default # no cli equivalent for node type distribution (NTD) From b9c60e248089fd691f040d47cfd35bca13a170d3 Mon Sep 17 00:00:00 2001 From: "guillaume.bouvignies" Date: Wed, 15 Mar 2023 13:56:43 +0100 Subject: [PATCH 3/3] Small changes to be k8s compatible --- gennet-module/gennet.py | 7 ++++--- src/file_helpers.star | 2 +- src/node_builders/node_builders.star | 2 +- src/node_builders/types/nomos_builder.star | 12 ++++++------ src/node_builders/types/waku_builder.star | 12 ++++++------ src/nomos.star | 2 +- src/system_variables.star | 7 +++++-- src/waku.star | 4 ++-- 8 files changed, 26 insertions(+), 22 deletions(-) diff --git a/gennet-module/gennet.py b/gennet-module/gennet.py index 975bec1..bac6f36 100755 --- a/gennet-module/gennet.py +++ b/gennet-module/gennet.py @@ -48,6 +48,7 @@ class networkType(Enum): NW_DATA_FNAME = "network_data.json" EXTERNAL_NODES_PREFIX, NODE_PREFIX, SUBNET_PREFIX, CONTAINER_PREFIX = \ "nodes", "node", "subnetwork", "containers" +ID_STR_SEPARATOR = "-" ### I/O related fns ############################################################## @@ -202,14 +203,14 @@ def generate_network(ctx): def postprocess_network(G): G = nx.Graph(G) # prune out parallel/multi edges G.remove_edges_from(nx.selfloop_edges(G)) # remove the self-loops - mapping = {i: f"{NODE_PREFIX}_{i}" for i in range(len(G))} + mapping = {i: f"{NODE_PREFIX}{ID_STR_SEPARATOR}{i}" for i in range(len(G))} return nx.relabel_nodes(G, mapping) # label the nodes def generate_subnets(G, num_subnets): n = len(G.nodes) if num_subnets == n: # if num_subnets == size of the network - return {f"{NODE_PREFIX}_{i}": f"{SUBNET_PREFIX}_{i}" for i in range(n)} + return {f"{NODE_PREFIX}{ID_STR_SEPARATOR}{i}": f"{SUBNET_PREFIX}_{i}" for i in range(n)} lst = list(range(n)) random.shuffle(lst) @@ -220,7 +221,7 @@ def generate_subnets(G, num_subnets): for end in offsets: l = [] for i in range(start, end + 1): - node2subnet[f"{NODE_PREFIX}_{lst[i]}"] = f"{SUBNET_PREFIX}_{subnet_id}" + node2subnet[f"{NODE_PREFIX}{ID_STR_SEPARATOR}{lst[i]}"] = f"{SUBNET_PREFIX}_{subnet_id}" #node2subnet[lst[i]] = subnet_id start = end subnet_id += 1 diff --git a/src/file_helpers.star b/src/file_helpers.star index de0d01f..c7f7f42 100644 --- a/src/file_helpers.star +++ b/src/file_helpers.star @@ -26,7 +26,7 @@ def generate_template_node_targets(services, port_id, key_value): service_info = services[vars.GENNET_NODES_KEY][service_name] service_ip = service_info[vars.IP_KEY] - service_port_number = str(service_info[vars.PORTS_KEY][port_id+"_"+service_name][0]) + service_port_number = str(service_info[vars.PORTS_KEY][port_id + vars.ID_STR_SEPARATOR + service_name][0]) targets_data.append('"' + service_ip + ":" + service_port_number + '"') data_as_string = ",".join(targets_data) diff --git a/src/node_builders/node_builders.star b/src/node_builders/node_builders.star index 207ed48..db82864 100644 --- a/src/node_builders/node_builders.star +++ b/src/node_builders/node_builders.star @@ -111,7 +111,7 @@ def interconnect_nodes(plan, topology_information, interconnection_batch): def _add_service_info_to_topology(plan, all_services_information, network_topology): for node_id, node_info in network_topology[vars.GENNET_NODES_KEY].items(): - node_rpc_port_id = vars.RPC_PORT_ID + "_" + node_id + node_rpc_port_id = vars.RPC_PORT_ID + vars.ID_STR_SEPARATOR + node_id image = network_topology[vars.GENNET_NODES_KEY][node_id][vars.GENNET_IMAGE_KEY] peer_id_getter = service_info_dispatcher[image] diff --git a/src/node_builders/types/nomos_builder.star b/src/node_builders/types/nomos_builder.star index fc2ac3f..bea0690 100644 --- a/src/node_builders/types/nomos_builder.star +++ b/src/node_builders/types/nomos_builder.star @@ -33,15 +33,15 @@ def _prepare_nomos_cmd_in_service(nomos_names, config_files): def _prepare_nomos_ports_in_service(node_names): prepared_ports = {} for i in range(len(node_names)): - prepared_ports[vars.RPC_PORT_ID + "_" + node_names[i]] = \ + prepared_ports[vars.RPC_PORT_ID + vars.ID_STR_SEPARATOR + node_names[i]] = \ PortSpec(number=vars.NOMOS_RPC_PORT_NUMBER + i, transport_protocol=vars.NOMOS_RPC_PORT_PROTOCOL) - prepared_ports[vars.PROMETHEUS_PORT_ID + "_" + node_names[i]] = \ + prepared_ports[vars.PROMETHEUS_PORT_ID + vars.ID_STR_SEPARATOR + node_names[i]] = \ PortSpec(number=vars.PROMETHEUS_PORT_NUMBER + i, transport_protocol=vars.PROMETHEUS_PORT_PROTOCOL) - prepared_ports[vars.NOMOS_LIBP2P_PORT_ID + "_" + node_names[i]] = \ + prepared_ports[vars.NOMOS_LIBP2P_PORT_ID + vars.ID_STR_SEPARATOR + node_names[i]] = \ PortSpec(number=vars.NOMOS_LIBP2P_PORT + i, transport_protocol=vars.NOMOS_LIBP2P_PORT_PROTOCOL) @@ -58,9 +58,9 @@ def _prepare_nomos_config_files_in_service(node_names, artifact_ids): def _add_nomos_ports_info_to_topology(network_topology, all_services_information, node_info, node_id): - nomos_rpc_port_id = vars.RPC_PORT_ID + "_" + node_id - libp2p_port_id = vars.NOMOS_LIBP2P_PORT_ID + "_" + node_id - prometheus_port_id = vars.PROMETHEUS_PORT_ID + "_" + node_id + nomos_rpc_port_id = vars.RPC_PORT_ID + vars.ID_STR_SEPARATOR + node_id + libp2p_port_id = vars.NOMOS_LIBP2P_PORT_ID + vars.ID_STR_SEPARATOR + node_id + prometheus_port_id = vars.PROMETHEUS_PORT_ID + vars.ID_STR_SEPARATOR + node_id network_topology[vars.GENNET_NODES_KEY][node_id][vars.PORTS_KEY] = {} _add_nomos_port(network_topology, all_services_information, node_id, node_info, nomos_rpc_port_id) diff --git a/src/node_builders/types/waku_builder.star b/src/node_builders/types/waku_builder.star index 6e256c4..bd0a0c8 100644 --- a/src/node_builders/types/waku_builder.star +++ b/src/node_builders/types/waku_builder.star @@ -5,15 +5,15 @@ vars = import_module("github.com/logos-co/wakurtosis/src/system_variables.star") def prepare_waku_ports_in_service(wakunode_names): prepared_ports = {} for i in range(len(wakunode_names)): - prepared_ports[vars.RPC_PORT_ID + "_" + wakunode_names[i]] = \ + prepared_ports[vars.RPC_PORT_ID + vars.ID_STR_SEPARATOR + wakunode_names[i]] = \ PortSpec(number=vars.WAKU_RPC_PORT_NUMBER + i, transport_protocol=vars.WAKU_RPC_PORT_PROTOCOL) - prepared_ports[vars.PROMETHEUS_PORT_ID + "_" + wakunode_names[i]] = \ + prepared_ports[vars.PROMETHEUS_PORT_ID + vars.ID_STR_SEPARATOR + wakunode_names[i]] = \ PortSpec(number=vars.PROMETHEUS_PORT_NUMBER + i, transport_protocol=vars.PROMETHEUS_PORT_PROTOCOL) - prepared_ports[vars.WAKU_LIBP2P_PORT_ID + "_" + wakunode_names[i]] = \ + prepared_ports[vars.WAKU_LIBP2P_PORT_ID + vars.ID_STR_SEPARATOR + wakunode_names[i]] = \ PortSpec(number=vars.WAKU_LIBP2P_PORT + i, transport_protocol=vars.WAKU_LIBP2P_PORT_PROTOCOL) @@ -29,9 +29,9 @@ def prepare_waku_config_files_in_service(node_names, artifact_ids): def _add_waku_ports_info_to_topology(network_topology, all_services_information, node_info, node_id): - waku_rpc_port_id = vars.RPC_PORT_ID + "_" + node_id - libp2p_port_id = vars.WAKU_LIBP2P_PORT_ID + "_" + node_id - prometheus_port_id = vars.PROMETHEUS_PORT_ID + "_" + node_id + waku_rpc_port_id = vars.RPC_PORT_ID + vars.ID_STR_SEPARATOR + node_id + libp2p_port_id = vars.WAKU_LIBP2P_PORT_ID + vars.ID_STR_SEPARATOR + node_id + prometheus_port_id = vars.PROMETHEUS_PORT_ID + vars.ID_STR_SEPARATOR + node_id network_topology[vars.GENNET_NODES_KEY][node_id][vars.PORTS_KEY] = {} _add_waku_port(network_topology, all_services_information, node_id, node_info, waku_rpc_port_id) diff --git a/src/nomos.star b/src/nomos.star index 17c3281..b17e169 100644 --- a/src/nomos.star +++ b/src/nomos.star @@ -30,7 +30,7 @@ def _merge_peer_ids(peer_ids): def connect_nomos_to_peers(plan, service_name, node_id, port_id, peer_ids): body = _merge_peer_ids(peer_ids) - port_id = port_id + "_" + node_id + port_id = port_id + vars.ID_STR_SEPARATOR + node_id response = call_protocols.send_http_post_req(plan, service_name, port_id, vars.NOMOS_NET_CONN_URL, body) diff --git a/src/system_variables.star b/src/system_variables.star index 22c1af2..1fd42e6 100644 --- a/src/system_variables.star +++ b/src/system_variables.star @@ -2,6 +2,9 @@ NWAKU_IMAGE = "statusteam/nim-waku:019f357d" GOWAKU_IMAGE = "gowaku" +# If changing this, you'll likely need to change it as well in gennet +ID_STR_SEPARATOR = "-" + RPC_PORT_ID = "rpc" NODE_CONFIG_FILE_LOCATION = "github.com/logos-co/wakurtosis/config/topology_generated/" @@ -42,7 +45,7 @@ NOMOS_NET_CONN_URL = "/network/conn" # Prometheus Configuration PROMETHEUS_IMAGE = "prom/prometheus:latest" PROMETHEUS_SERVICE_NAME = "prometheus" -PROMETHEUS_PORT_ID = "prometheus" +PROMETHEUS_PORT_ID = "prom" PROMETHEUS_PORT_PROTOCOL = "TCP" PROMETHEUS_PORT_NUMBER = 8008 PROMETHEUS_CONFIGURATION_PATH = "github.com/logos-co/wakurtosis/monitoring/prometheus.yml" @@ -62,7 +65,7 @@ GRAFANA_CUSTOMIZATION_PATH = "github.com/logos-co/wakurtosis/monitoring/configur GRAFANA_DASHBOARD_PATH = "github.com/logos-co/wakurtosis/monitoring/configuration/dashboards/" GRAFANA_SERVICE_NAME = "grafana" -GRAFANA_PORT_ID = "grafana_tcp" +GRAFANA_PORT_ID = "grafana" + ID_STR_SEPARATOR + "tcp" GRAFANA_TCP_PORT = 3000 CONTAINER_CONFIGURATION_GRAFANA = "/etc/grafana/" diff --git a/src/waku.star b/src/waku.star index 79f598e..936a900 100644 --- a/src/waku.star +++ b/src/waku.star @@ -19,7 +19,7 @@ def get_wakunode_peer_id(plan, service_name, port_id): def create_node_multiaddress(node_id, node_information): ip = node_information[vars.IP_KEY] - port = node_information[vars.PORTS_KEY][vars.WAKU_LIBP2P_PORT_ID + "_" + node_id][0] + port = node_information[vars.PORTS_KEY][vars.WAKU_LIBP2P_PORT_ID + vars.ID_STR_SEPARATOR + node_id][0] waku_node_id = node_information[vars.PEER_ID_KEY] return '"/ip4/' + str(ip) + '/tcp/' + str(port) + '/p2p/' + waku_node_id + '"' @@ -32,7 +32,7 @@ def _merge_peer_ids(peer_ids): def connect_wakunode_to_peers(plan, service_name, node_id, port_id, peer_ids): method = vars.CONNECT_TO_PEER_METHOD params = _merge_peer_ids(peer_ids) - port_id = port_id + "_" + node_id + port_id = port_id + vars.ID_STR_SEPARATOR + node_id response = call_protocols.send_json_rpc(plan, service_name, port_id, method, params)