From 0708b62b40cc5f4872bac4a21189fa07e05969b2 Mon Sep 17 00:00:00 2001 From: Riya Singh Date: Fri, 1 Dec 2023 12:24:55 +0530 Subject: [PATCH] fix: fixed service details for mainnet and testnet (#132) * refactor: refactor config file, change para from dict to list * fix: typo and encointer mainnet * refactor: prometheus port name * fix: fixed service details for mainnet and testnet * fix: fixed prometheus issue for parachains * fix: removed print statement * fix: subzero and calamari * fix: pendulum localnet * fix: robonomics * fix: robonomics relay chain * fix: fix issue running kilt testnet --------- Co-authored-by: abhiyana Co-authored-by: Shanith K K --- main.star | 8 ++++- package_io/constant.star | 6 ++-- package_io/promethues.star | 49 ++++++++++++++++++------------ parachain/node_setup.star | 4 +-- parachain/parachain.star | 29 ++++++++++++------ parachain/static_files/images.star | 8 ++--- relaychain/relay-chain.star | 22 ++++++++------ 7 files changed, 77 insertions(+), 49 deletions(-) diff --git a/main.star b/main.star index 0395a7a..34b12de 100644 --- a/main.star +++ b/main.star @@ -19,9 +19,15 @@ def run(plan, args): if len(args["relaychain"]) != 0: relay_node_detals = relay_chain.start_test_main_net_relay_nodes(plan, args) service_details["relaychains"] = relay_node_detals + final_parachain_detail = [] for paras in args["para"]: + parachain_details={} + parachain_details["service_name"] = "parachain_service_" + paras["name"] + parachain_details["parachain_name"] = paras["name"] parachain_info = parachain.run_testnet_mainnet(plan, paras, args) - service_details["parachains"] = parachain_info + parachain_details["nodes"] = parachain_info + final_parachain_detail.append(parachain_details) + service_details["parachains"] = final_parachain_detail prometheus_address = promethues.launch_prometheus(plan, args, service_details, prometheus_template) service_details["prometheus"] = prometheus_address diff --git a/package_io/constant.star b/package_io/constant.star index ba8ed60..f3c7d34 100644 --- a/package_io/constant.star +++ b/package_io/constant.star @@ -2,9 +2,9 @@ PLAIN_BUILD_SPEC = "plain-build-spec" RAW_BUILD_SPEC = "raw-build-spec" EDIT_BUILD_SPEC = "edit-build-spec" CURL_JQ_IMAGE = "badouralix/curl-jq" -NODE_IMAGE = "node:21.1" +NODE_IMAGE = "hugobyte/parachain-node-modules" PARA_SLOT_REGISTER_SERVICE_NAME = "para-slot-registration" -BINARY_COMMAND_CHAINS = ["manta", "khala", "phala", "clover"] +BINARY_COMMAND_CHAINS = ["manta", "khala", "phala", "clover", "calamari", "subzero", "robonomics"] NO_WS_PORT = ["acala", "frequency", "moonbeam", "karura", "ajuna", "bajun", "centrifuge", "moonsama", "encointer", "moonriver", "altair"] DIFFERENT_IMAGES_FOR_MAINNET = { @@ -22,4 +22,4 @@ DIFFERENT_IMAGES_FOR_TESTNET = { "altair": "centrifugeio/centrifuge-chain:main-latest", } -CHAIN_COMMAND = ["manta", "moonsama", "interlay", "kintsugi-btc", "polkadex", "centrifuge", "altair"] +CHAIN_COMMAND = ["manta", "moonsama", "interlay", "kintsugi-btc", "polkadex", "centrifuge", "altair", "robonomics", "kilt"] diff --git a/package_io/promethues.star b/package_io/promethues.star index 3b947df..0815f23 100644 --- a/package_io/promethues.star +++ b/package_io/promethues.star @@ -76,29 +76,38 @@ def new_config_template_data(plan, args, service_details): relay_nodes = args["relaychain"]["nodes"] for node in relay_nodes: if node["prometheus"] == True: - endpoint = "{0}:{1}".format(service_details["relaychains"][0]["service_details"].ip_address, service_details["relaychains"][0]["service_details"].ports["prometheus"].number) - - metrics_jobs.append( - new_metrics_job( - job_name = service_details["relaychains"][0]["service_name"], - endpoint = endpoint, - scrape_interval = "5s", - ), - ) - plan.print(node["prometheus"]) - + for relay_chain in service_details["relaychains"]: + node_name = relay_chain["service_details"].name + if node_name.endswith(node["name"]): + ip = relay_chain["service_details"].ip_address + port_number = relay_chain["service_details"].ports["metrics"].number + endpoint = "{0}:{1}".format(ip, port_number) + metrics_jobs.append( + new_metrics_job( + job_name = "relay_service_{}".format(node["name"]), + endpoint = endpoint, + scrape_interval = "5s", + ), + ) + for parachain in args["para"]: for node in parachain["nodes"]: if node["prometheus"] == True: - endpoint = "{0}:{1}".format(service_details["parachains"][0]["nodes"][0]["node_details"].ip_address, service_details["parachains"][0]["nodes"][0]["node_details"].ports["prometheus"].number) - - metrics_jobs.append( - new_metrics_job( - job_name = service_details["parachains"][0]["parachain_name"], - endpoint = endpoint, - scrape_interval = "5s", - ), - ) + for para_chain in service_details["parachains"]: + for para_chain_node in para_chain["nodes"]: + service_name = para_chain_node["node_details"].name + string = "{}-{}-{}".format(parachain["name"],node["name"],args["chain-type"]) + if string == service_name: + ip = para_chain_node["node_details"].ip_address + port_number = para_chain_node["node_details"].ports["metrics"].number + endpoint = "{0}:{1}".format(ip, port_number) + metrics_jobs.append( + new_metrics_job( + job_name = "parachain_{}_service_{}".format(parachain["name"],node["name"]), + endpoint = endpoint, + scrape_interval = "5s", + ), + ) return { "MetricsJobs": metrics_jobs, diff --git a/parachain/node_setup.star b/parachain/node_setup.star index c029549..93a61b8 100644 --- a/parachain/node_setup.star +++ b/parachain/node_setup.star @@ -3,7 +3,7 @@ def run_testnet_node_with_entrypoint(plan, image, chain_name, execute_command): image = image, ports = { "ws": PortSpec(9944, transport_protocol = "TCP"), - "prometheus": PortSpec(9615, transport_protocol = "TCP", application_protocol = "http"), + "metrics": PortSpec(9615, transport_protocol = "TCP", application_protocol = "http"), }, files = { "/app": "configs", @@ -19,7 +19,7 @@ def run_testnet_node_with_command(plan, image, chain_name, execute_command): image = image, ports = { "ws": PortSpec(9944, transport_protocol = "TCP"), - "prometheus": PortSpec(9615, transport_protocol = "TCP", application_protocol = "http"), + "metrics": PortSpec(9615, transport_protocol = "TCP", application_protocol = "http"), }, files = { "/app": "configs", diff --git a/parachain/parachain.star b/parachain/parachain.star index e4adbf6..6c3db7c 100644 --- a/parachain/parachain.star +++ b/parachain/parachain.star @@ -18,7 +18,7 @@ def spawn_parachain(plan, chain_name, image, command, build_file): files = files, ports = { "ws": PortSpec(9944, transport_protocol = "TCP"), - "prometheus": PortSpec(9615, transport_protocol = "TCP"), + "metrics": PortSpec(9615, transport_protocol = "TCP"), }, entrypoint = command, ), @@ -80,23 +80,22 @@ def run_testnet_mainnet(plan, parachain, args): base = parachain_details["base"][1] if parachain["name"] in constant.DIFFERENT_IMAGES_FOR_TESTNET: - image = constant.DIFFERENT_IMAGES_FOR_TESTNET[parachain["name"]] + image = constant.DIFFERENT_IMAGES_FOR_TESTNET[parachain["name"].lower()] else: main_chain = "polkadot" - parachain_details = parachain_list.parachain_images[parachain["name"]] + parachain_details = parachain_list.parachain_images[parachain["name"].lower()] image = parachain_details["image"] base = parachain_details["base"][2] if parachain["name"] in constant.DIFFERENT_IMAGES_FOR_MAINNET: - image = constant.DIFFERENT_IMAGES_FOR_MAINNET[parachain["name"]] - + image = constant.DIFFERENT_IMAGES_FOR_MAINNET[parachain["name"].lower()] if base == None: fail("Tesnet is not there for {}".format(parachain["name"])) if parachain["name"] in constant.NO_WS_PORT: - common_command = [ + common_command = [ "--chain={0}".format(base), "--port=30333", "--rpc-port=9944", @@ -125,6 +124,11 @@ def run_testnet_mainnet(plan, parachain, args): if parachain == "altair" or "centrifuge": common_command = common_command + ["--database=auto"] + if parachain["name"] == "subzero" and args["chain-type"] == "mainnet": + common_command = [x for x in common_command if x != "--chain="] + common_command = [x for x in common_command if x != "--port=30333"] + + final_parachain_info = [] for node in parachain["nodes"]: command = common_command command = command + ["--name={0}".format(node["name"])] @@ -143,12 +147,17 @@ def run_testnet_mainnet(plan, parachain, args): if parachain["name"] in constant.BINARY_COMMAND_CHAINS: binary = parachain_details["entrypoint"] command = [binary] + command - + node_info = {} node_details = node_setup.run_testnet_node_with_entrypoint(plan, image, "{0}-{1}-{2}".format(parachain["name"], node["name"], args["chain-type"]), command) - parachain_info[parachain["name"]]["parachain_" + node["name"]] = node_details + node_info["nodename"] = node["name"] + node_info["node_details"] = node_details + final_parachain_info.append(node_info) else: + node_info = {} node_details = node_setup.run_testnet_node_with_command(plan, image, "{0}-{1}-{2}".format(parachain["name"], node["name"], args["chain-type"]), command) - parachain_info[parachain["name"]]["parachain_" + node["name"]] = node_details + node_info["nodename"] = node["name"] + node_info["node_details"] = node_details + final_parachain_info.append(node_info) - return parachain_info + return final_parachain_info diff --git a/parachain/static_files/images.star b/parachain/static_files/images.star index 2f97466..3bfe5d7 100644 --- a/parachain/static_files/images.star +++ b/parachain/static_files/images.star @@ -83,12 +83,12 @@ parachain_images = { "pendulum": { "image": "pendulumchain/pendulum-collator:latest", "entrypoint": "/usr/local/bin/pendulum-collator", - "base": ["litentry-dev", "foucoco", "pendulum"], + "base": ["dev", "foucoco", "pendulum"], }, "phala": { "image": "phalanetwork/phala-node:latest", "entrypoint": "/usr/local/bin/khala-node", - "base": ["dev", "rhala", "phala"], + "base": ["phala-dev-2035", "rhala", "phala"], }, "polkadex": { "image": "polkadex/parachain:latest", @@ -158,12 +158,12 @@ parachain_images = { "robonomics": { "image": "robonomics/robonomics:latest", "entrypoint": "/usr/local/bin/robonomics", - "base": ["dev", "ipci-dev", "ipci"], + "base": ["alpha-dev", "ipci-dev", "ipci"], }, "subzero": { "image": "playzero/subzero:latest", "entrypoint": "/usr/local/bin/subzero", - "base": ["dev", "testnet", None], + "base": ["dev", None, ""], }, "turing": { "image": "oaknetwork/turing:latest", diff --git a/relaychain/relay-chain.star b/relaychain/relay-chain.star index 4e50f69..e63d491 100644 --- a/relaychain/relay-chain.star +++ b/relaychain/relay-chain.star @@ -1,30 +1,34 @@ def start_relay_chain(plan, args): name = args["chain-type"] chain = args["relaychain"]["name"] - relay_node_details = {} + final_details=[] + prometheus = 9615 for relay_node in args["relaychain"]["nodes"]: port = relay_node["port"] exec_command = ["bin/sh", "-c", "polkadot --rpc-external --rpc-cors=all --rpc-methods=unsafe --chain {0} --name={1} --execution=wasm --prometheus-external".format(chain, relay_node["name"])] - relay_node_detail = plan.add_service( + service_details = plan.add_service( name = "{0}-{1}-{2}".format(name, chain, relay_node["name"]), config = ServiceConfig( image = "parity/polkadot:latest", ports = { "ws": PortSpec(9944, transport_protocol = "TCP"), - "prometheus": PortSpec(9615, transport_protocol = "TCP"), + "metrics": PortSpec(9615, transport_protocol = "TCP"), }, public_ports = { "ws": PortSpec(port, transport_protocol = "TCP"), - "prometheus": PortSpec(prometheus, transport_protocol = "TCP"), + "metrics": PortSpec(prometheus, transport_protocol = "TCP"), }, entrypoint = exec_command, ), ) prometheus += 1 - relay_node_details["relay_service_" + relay_node["name"]] = relay_node_detail + relay_node_details = {} + relay_node_details["service_details"] = service_details + relay_node_details["service_name"] = service_details.name + final_details.append(relay_node_details) - return relay_node_details + return final_details def start_test_main_net_relay_nodes(plan, args): name = args["chain-type"] @@ -54,7 +58,7 @@ def start_relay_chains_local(plan, args): relay_detail = {} service_details = start_relay_chain_local(plan, node["name"], node["port"], prometheus_port) relay_detail["service_details"] = service_details - relay_detail["service_name"] = "relay_service_" + node["name"] + relay_detail["service_name"] = service_details.name final_details.append(relay_detail) prometheus_port = prometheus_port + 1 return final_details @@ -70,11 +74,11 @@ def start_relay_chain_local(plan, name, port, prometheus_port): }, ports = { "ws": PortSpec(9944, transport_protocol = "TCP"), - "prometheus": PortSpec(9615, transport_protocol = "TCP"), + "metrics": PortSpec(9615, transport_protocol = "TCP"), }, public_ports = { "ws": PortSpec(port, transport_protocol = "TCP"), - "prometheus": PortSpec(prometheus_port, transport_protocol = "TCP"), + "metrics": PortSpec(prometheus_port, transport_protocol = "TCP"), }, entrypoint = exec_command, ),