Skip to content

Commit

Permalink
Merge pull request #162 from HugoByte/refactor-service-config-develop…
Browse files Browse the repository at this point in the history
…ment

fix: fix issue when the node type is anything which is not valid the still node in getting started as full node
  • Loading branch information
Mr-Nobody21 authored Dec 14, 2023
2 parents 60ceed9 + 01e0f81 commit f0bdb36
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
4 changes: 4 additions & 0 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package = import_module("./package_io/build-spec.star")
promethues = import_module("./package_io/promethues.star")
grafana = import_module("./package_io/grafana.star")
explorer = import_module("./package_io/polkadot_js_app.star")
utils = import_module("./package_io/utils.star")

def run(plan, args):
"""
Expand Down Expand Up @@ -31,6 +32,9 @@ def run_polkadot_setup(plan, args):
Returns:
dict: Service details containing information about relay chains, parachains, and Prometheus.
"""

utils.check_config_validity(plan, args)

plan.upload_files(src = "./parachain/static_files/configs", name = "configs")
plan.upload_files(src = "./parachain/static_files/javascript", name = "javascript")

Expand Down
2 changes: 1 addition & 1 deletion package_io/constant.star
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CURL_JQ_IMAGE = "badouralix/curl-jq"
NODE_IMAGE = "hugobyte/parachain-node-modules"
PARA_SLOT_REGISTER_SERVICE_NAME = "para-slot-registration"
BINARY_COMMAND_CHAINS = ["manta", "khala", "phala", "clover", "calamari", "subzero", "robonomics"]
NO_WS_PORT = ["acala", "frequency", "moonbeam", "karura", "ajuna", "bajun", "centrifuge", "moonsama", "encointer", "moonriver", "altair", "mangata"]
NO_WS_PORT = ["acala", "frequency", "moonbeam", "karura", "ajuna", "bajun", "centrifuge", "moonsama", "encointer", "moonriver", "altair", "mangata", "khala", "phala", "turing"]

DIFFERENT_IMAGES_FOR_MAINNET = {
"centrifuge": "centrifugeio/centrifuge-chain:main-latest",
Expand Down
19 changes: 19 additions & 0 deletions package_io/utils.star
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,22 @@ def get_service_url(protocol ,ip_address, ports):
url = "{0}://{1}:{2}".format(protocol, ip_address, ports)
return url


def check_config_validity(plan, args):
if len(args["relaychain"]) != 0:
for node in args["relaychain"]["nodes"]:
if len(node) != 0:
if node["node-type"] in ["validator", "full"]:
plan.print("config for relaynodes is valid")
else:
return fail("relaychain node-type can be only validator/full")

if len(args["para"]) != 0:
for para in args["para"]:
if len(para["nodes"]) != 0:
for node in para["nodes"]:
if node["node-type"] in ["validator", "full", "collator"]:
plan.print("config for parachain is valid")
else:
return fail("parachain node-type can be only validator/full/collator")

6 changes: 3 additions & 3 deletions parachain/parachain.star
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def start_local_parachain_node(plan, args, parachain_config, para_id):
parachain_detail["prometheus_port"] = parachain_spawn_detail.ports["metrics"].number
parachain_detail["ip_address"] = parachain_spawn_detail.ip_address
parachain_detail["prometheus"] = node["prometheus"]
parachain_detail["node"] = node["node-type"]
parachain_detail["node-type"] = node["node-type"]
parachain_final[parachain_spawn_detail.name] = parachain_detail
return parachain_final

Expand Down Expand Up @@ -202,7 +202,7 @@ def run_testnet_mainnet(plan, parachain, args):
node_info["ip_address"] = node_details.ip_address
node_info["prometheus_port"] = node_details.ports["metrics"].number
node_info["prometheus"] = node["prometheus"]
node_info["node"] = node["node-type"]
node_info["node-type"] = node["node-type"]
final_parachain_info[node_details.name] = node_info

else:
Expand All @@ -215,6 +215,6 @@ def run_testnet_mainnet(plan, parachain, args):
node_info["ip_address"] = node_details.ip_address
node_info["prometheus_port"] = node_details.ports["metrics"].number
node_info["prometheus"] = node["prometheus"]
node_info["node"] = node["node-type"]
node_info["node-type"] = node["node-type"]
final_parachain_info[node_details.name] = node_info
return final_parachain_info
2 changes: 2 additions & 0 deletions relaychain/relay-chain.star
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def start_relay_chain(plan, args):
relay_node_details["prometheus_port"] = service_details.ports["metrics"].number
relay_node_details["prometheus"] = relay_node["prometheus"]
relay_node_details["ip_address"] = service_details.ip_address
relay_node_details["node-type"] = relay_node["node-type"]
final_details[service_details.name] = relay_node_details

return final_details
Expand Down Expand Up @@ -116,6 +117,7 @@ def start_relay_chains_local(plan, args):
relay_detail["prometheus_port"] = service_details.ports["metrics"].number
relay_detail["prometheus"] = node["prometheus"]
relay_detail["ip_address"] = service_details.ip_address
relay_detail["node-type"] = node["node-type"]
final_details[service_details.name] = relay_detail
prometheus_port = prometheus_port + 1

Expand Down

0 comments on commit f0bdb36

Please sign in to comment.