From 25eea7ca9f1400722d071e94466189edf23c3358 Mon Sep 17 00:00:00 2001 From: riyasng12 Date: Thu, 23 Nov 2023 13:12:51 +0530 Subject: [PATCH 1/4] refactor: service details refactored for dive --- local.json | 2 +- main.star | 10 ++++------ parachain/parachain.star | 26 +++++++++++++++----------- relaychain/relay-chain.star | 9 ++++++--- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/local.json b/local.json index 5c18bdd..8c7e0a1 100644 --- a/local.json +++ b/local.json @@ -1,5 +1,5 @@ { - "chain-type": "testnet", + "chain-type": "local", "relaychain": { "name": "kusama", "nodes": [ diff --git a/main.star b/main.star index 75cc843..bcf70f0 100644 --- a/main.star +++ b/main.star @@ -5,13 +5,11 @@ package = import_module("./package_io/build-spec.star") def run(plan, args): plan.upload_files(src = "./parachain/static_files/configs", name = "configs") service_details = {"relaychains": {}, "parachains": {}, "prometheus": {}} - if args["chain-type"] == "local": relay_chain_details = relay_chain.start_relay_chains_local(plan, args) service_details["relaychains"] = relay_chain_details - - parchain_details = parachain.start_nodes(plan, args, relay_chain_details["relay_service_alice"].ip_address) - service_details["parachains"] = parchain_details + parachain_details = parachain.start_nodes(plan, args, relay_chain_details[0]["service_details"].ip_address) + service_details["parachains"] = parachain_details else: if len(args["relaychain"]) != 0: @@ -21,8 +19,8 @@ def run(plan, args): parachain_info = parachain.run_testnet_mainnet(plan, args, paras) service_details["parachains"] = parachain_info - ip = "{0}:{1}".format(relay_chain_details["relay_service_alice"].ip_address, relay_chain_details["relay_service_alice"].ports["prometheus"].number) + ip = "{0}:{1}".format(relay_chain_details[0]["service_details"].ip_address, relay_chain_details[0]["service_details"].ports["prometheus"].number) prometheus = package.prometheus(plan, args, ip) service_details["prometheus"] = prometheus - + plan.print(service_details["relaychains"]) return service_details diff --git a/parachain/parachain.star b/parachain/parachain.star index fa9a200..ecd2c08 100644 --- a/parachain/parachain.star +++ b/parachain/parachain.star @@ -38,24 +38,28 @@ def start_local_parachain_node(plan, args, parachain, para_id): "-c", "{0} --chain=/build/{1}-raw.json --ws-external --rpc-external --rpc-cors=all --name={1} --collator --rpc-methods=unsafe --force-authoring --execution=wasm --alice -- --chain=/app/raw-polkadot.json --execution=wasm".format(binary, chain_name), ] - parachain_details = {} + parachain_final = [] + parachain_detail = {} for node in args["para"][parachain]["nodes"]: - parachain_detail = spawn_parachain(plan, "{}-{}".format(chain_name, node["name"]), image, exec_comexec_commandmand, build_file = raw_service.name) - parachain_details[node["name"]] = parachain_detail - - plan.print(parachain_details) - return parachain_details + parachain_detail = {} + parachain_spawn_detail = spawn_parachain(plan, "{}-{}".format(chain_name, node["name"]), image, exec_comexec_commandmand, build_file = raw_service.name) + parachain_detail["node_details"]=parachain_spawn_detail + parachain_detail["nodename"]=node["name"] + parachain_final.append(parachain_detail) + return parachain_final def start_nodes(plan, args, relay_chain_ip): parachains = args["para"] - parachain_details = {} + final_parachain_details=[] for parachain in parachains: - parachain_details[parachain] = {} + parachain_details = {} para_id = register_para_slot.register_para_id(plan, relay_chain_ip) - parachain_details[parachain] = start_local_parachain_node(plan, args, parachain, para_id) + parachain_details["nodes"] = start_local_parachain_node(plan, args, parachain, para_id) + parachain_details["service_name"] = "parachain_service_" + parachain + parachain_details["parachain_name"] = parachain register_para_slot.onboard_genesis_state_and_wasm(plan, para_id, parachain, relay_chain_ip) - - return parachain_details + final_parachain_details.append(parachain_details) + return final_parachain_details def run_testnet_mainnet(plan, args, parachain): if args["chain-type"] == "testnet": diff --git a/relaychain/relay-chain.star b/relaychain/relay-chain.star index 28833e1..ada7aec 100644 --- a/relaychain/relay-chain.star +++ b/relaychain/relay-chain.star @@ -44,13 +44,16 @@ def spawn_multiple_relay(plan, count): def start_relay_chains_local(plan, args): relay_nodes = args["relaychain"]["nodes"] - relay_detail = {} + final_details=[] prometheus_port = 9615 for node in relay_nodes: + relay_detail = {} service_details = start_relay_chain_local(plan, node["name"], node["port"], prometheus_port) - relay_detail["relay_service_" + node["name"]] = service_details + relay_detail["service_details"] = service_details + relay_detail["service_name"] = "relay_service_" + node["name"] + final_details.append(relay_detail) prometheus_port = prometheus_port + 1 - return relay_detail + return final_details def start_relay_chain_local(plan, name, port, prometheus_port): exec_command = ["bin/sh", "-c", "polkadot --base-path=/data --chain=/app/raw-polkadot.json --validator --rpc-external --rpc-cors=all --name=alice --{0} --rpc-methods=unsafe --execution=wasm --prometheus-external".format(name)] From ebd23d92fc6fea439d21edbcc0a1170fbae8251d Mon Sep 17 00:00:00 2001 From: riyasng12 Date: Thu, 23 Nov 2023 14:33:00 +0530 Subject: [PATCH 2/4] refactor: removed print statement --- main.star | 1 - 1 file changed, 1 deletion(-) diff --git a/main.star b/main.star index bcf70f0..f4642c5 100644 --- a/main.star +++ b/main.star @@ -22,5 +22,4 @@ def run(plan, args): ip = "{0}:{1}".format(relay_chain_details[0]["service_details"].ip_address, relay_chain_details[0]["service_details"].ports["prometheus"].number) prometheus = package.prometheus(plan, args, ip) service_details["prometheus"] = prometheus - plan.print(service_details["relaychains"]) return service_details From 40e13661cd00e1b9f2d56981f0995414859dedfd Mon Sep 17 00:00:00 2001 From: riyasng12 Date: Mon, 27 Nov 2023 10:51:34 +0530 Subject: [PATCH 3/4] merge: resolved merge conflict --- main.star | 1 + 1 file changed, 1 insertion(+) diff --git a/main.star b/main.star index f4642c5..f007e31 100644 --- a/main.star +++ b/main.star @@ -23,3 +23,4 @@ def run(plan, args): prometheus = package.prometheus(plan, args, ip) service_details["prometheus"] = prometheus return service_details + \ No newline at end of file From fc33653e05683d5e55f3442b95e4c4f33e3c3f76 Mon Sep 17 00:00:00 2001 From: riyasng12 Date: Mon, 27 Nov 2023 14:42:33 +0530 Subject: [PATCH 4/4] refactor: service details access in prometheus --- local.json | 16 ++++++++++------ package_io/promethues.star | 8 ++++---- parachain/static_files/images.star | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/local.json b/local.json index 8c7e0a1..085dd39 100644 --- a/local.json +++ b/local.json @@ -1,17 +1,19 @@ { "chain-type": "local", "relaychain": { - "name": "kusama", + "name": "rococo", "nodes": [ { "name": "alice", "node-type": "validator", - "port": 9944 + "port": 9944, + "prometheus": false }, { "name": "bob", "node-type": "full", - "port": 9945 + "port": 9945, + "prometheus": true } ] }, @@ -21,13 +23,15 @@ "nodes": [ { "name": "alice", - "node-type": "collator" + "node-type": "collator", + "prometheus": true }, { "name": "bob", - "node-type": "full" + "node-type": "full", + "prometheus": false } ] } } -} +} \ No newline at end of file diff --git a/package_io/promethues.star b/package_io/promethues.star index b98bd50..2e35acc 100644 --- a/package_io/promethues.star +++ b/package_io/promethues.star @@ -75,11 +75,11 @@ 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"]["relay_service_{}".format(node["name"])].ip_address, service_details["relaychains"]["relay_service_{}".format(node["name"])].ports["prometheus"].number) + 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 = "relay_service_{}".format(node["name"]), + job_name = service_details["relaychains"][0]["service_name"], endpoint = endpoint, scrape_interval = "5s", ), @@ -89,11 +89,11 @@ def new_config_template_data(plan, args, service_details): for parachain in args["para"]: for node in args["para"][parachain]["nodes"]: if node["prometheus"] == True: - endpoint = "{0}:{1}".format(service_details["parachains"][parachain.lower()]["parachain_{}".format(node["name"])].ip_address, service_details["parachains"][parachain.lower()]["parachain_{}".format(node["name"])].ports["prometheus"].number) + 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 = "parachain_{}_{}".format(parachain, node["name"]), + job_name = service_details["parachains"][0]["parachain_name"], endpoint = endpoint, scrape_interval = "5s", ), diff --git a/parachain/static_files/images.star b/parachain/static_files/images.star index f887c87..6cd1736 100644 --- a/parachain/static_files/images.star +++ b/parachain/static_files/images.star @@ -116,7 +116,7 @@ parachain_images = { "base": ["altair-local", "catalyst", "centrifuge"], }, "bajun": { - "image": "ajuna/parachain-bajun:0.1.28", + "image": "ajuna/parachain-bajun:latest", "entrypoint": "/usr/local/bin/ajuna", "base": ["local", "/bajun/rococo/bajun-raw.json", "/bajun/bajun-raw.json"], },