Skip to content

Commit

Permalink
fix: fixed service details for mainnet and testnet (#132)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Shanith K K <[email protected]>
  • Loading branch information
3 people authored Dec 1, 2023
1 parent edf37a8 commit 0708b62
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 49 deletions.
8 changes: 7 additions & 1 deletion main.star
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions package_io/constant.star
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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"]
49 changes: 29 additions & 20 deletions package_io/promethues.star
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions parachain/node_setup.star
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
29 changes: 19 additions & 10 deletions parachain/parachain.star
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"])]
Expand All @@ -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
8 changes: 4 additions & 4 deletions parachain/static_files/images.star
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
22 changes: 13 additions & 9 deletions relaychain/relay-chain.star
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down Expand Up @@ -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
Expand All @@ -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,
),
Expand Down

0 comments on commit 0708b62

Please sign in to comment.