Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: refactor config file, change para from dict to list #128

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions local.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
]
},

"para": {
"khala": {
"para": [
{
"name":"acala",
"nodes": [
{
"name": "alice",
Expand All @@ -35,5 +36,5 @@
}
]
}
}
]
}
2 changes: 1 addition & 1 deletion main.star
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def run(plan, args):
relay_node_detals = relay_chain.start_test_main_net_relay_nodes(plan, args)
service_details["relaychains"] = relay_node_detals
for paras in args["para"]:
parachain_info = parachain.run_testnet_mainnet(plan, args, paras)
parachain_info = parachain.run_testnet_mainnet(plan, paras, args)
service_details["parachains"] = parachain_info

prometheus_address = promethues.launch_prometheus(plan, args, service_details, prometheus_template)
Expand Down
2 changes: 1 addition & 1 deletion package_io/promethues.star
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def new_config_template_data(plan, args, service_details):
plan.print(node["prometheus"])

for parachain in args["para"]:
for node in args["para"][parachain]["nodes"]:
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)

Expand Down
58 changes: 29 additions & 29 deletions parachain/parachain.star
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def spawn_parachain(plan, chain_name, image, command, build_file):

return parachain_node

def start_local_parachain_node(plan, args, parachain_name, para_id):
parachain = parachain_name.lower()
def start_local_parachain_node(plan, args, parachain_config, para_id):
parachain = parachain_config["name"].lower()
parachain_details = parachain_list.parachain_images[parachain]
image = parachain_details["image"]
binary = parachain_details["entrypoint"]
Expand All @@ -49,7 +49,7 @@ def start_local_parachain_node(plan, args, parachain_name, para_id):
]
parachain_final = []
parachain_detail = {}
for node in args["para"][parachain]["nodes"]:
for node in parachain_config["nodes"]:
parachain_detail = {}
parachain_spawn_detail = spawn_parachain(plan, "{0}-{1}-{2}".format(parachain, node["name"], args["chain-type"]), image, exec_comexec_commandmand, build_file = raw_service.name)
parachain_detail["node_details"] = parachain_spawn_detail
Expand All @@ -64,39 +64,39 @@ def start_nodes(plan, args, relay_chain_ip):
parachain_details = {}
para_id = register_para_slot.register_para_id(plan, relay_chain_ip)
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)
parachain_details["service_name"] = "parachain_service_" + parachain["name"]
parachain_details["parachain_name"] = parachain["name"]
register_para_slot.onboard_genesis_state_and_wasm(plan, para_id, parachain["name"], relay_chain_ip)
final_parachain_details.append(parachain_details)
return final_parachain_details

def run_testnet_mainnet(plan, args, parachain):
parachain_config = parachain
def run_testnet_mainnet(plan, parachain, args):
if args["chain-type"] == "testnet":
main_chain = "rococo"
if parachain == "ajuna":
parachain = "bajun"
parachain_details = parachain_list.parachain_images[parachain]
if parachain["name"] == "ajuna":
parachain["name"] = "bajun"
parachain_details = parachain_list.parachain_images[parachain["name"]]
image = parachain_details["image"]
base = parachain_details["base"][1]

if parachain in constant.DIFFERENT_IMAGES_FOR_TESTNET:
image = constant.DIFFERENT_IMAGES_FOR_TESTNET[parachain]
if parachain["name"] in constant.DIFFERENT_IMAGES_FOR_TESTNET:
image = constant.DIFFERENT_IMAGES_FOR_TESTNET[parachain["name"]]

else:
main_chain = "polkadot"
parachain_details = parachain_list.parachain_images[parachain]
parachain_details = parachain_list.parachain_images[parachain["name"]]
image = parachain_details["image"]
base = parachain_details["base"][2]

if parachain in constant.DIFFERENT_IMAGES_FOR_MAINNET:
image = constant.DIFFERENT_IMAGES_FOR_MAINNET[parachain]
if parachain["name"] in constant.DIFFERENT_IMAGES_FOR_MAINNET:
image = constant.DIFFERENT_IMAGES_FOR_MAINNET[parachain["name"]]


if base == None:
fail("Tesnet is not there for {}".format(parachain))
fail("Tesnet is not there for {}".format(parachain["name"]))

if parachain in constant.NO_WS_PORT:
common_command = [
if parachain["name"] in constant.NO_WS_PORT:
common_command = [
"--chain={0}".format(base),
"--port=30333",
"--rpc-port=9944",
Expand All @@ -121,11 +121,11 @@ def run_testnet_mainnet(plan, args, parachain):
"--unsafe-ws-external",
]

parachain_info = {parachain["name"]: {}}
if parachain == "altair" or "centrifuge":
common_command = common_command + ["--database=auto"]
parachain_info = {parachain: {}}
para_nodes = args["para"][parachain_config]["nodes"]
for node in para_nodes:

for node in parachain["nodes"]:
command = common_command
command = command + ["--name={0}".format(node["name"])]
if node["node-type"] == "collator":
Expand All @@ -134,21 +134,21 @@ def run_testnet_mainnet(plan, args, parachain):
if node["node-type"] == "validator":
command = command + ["--validator"]

if parachain in constant.CHAIN_COMMAND:
if parachain["name"] in constant.CHAIN_COMMAND:
command = command + ["--", "--chain={0}".format(main_chain)]

if parachain == "kilt-spiritnet" and args["chain-type"] == "testnet":
if parachain["name"] == "kilt-spiritnet" and args["chain-type"] == "testnet":
command = command + ["--", "--chain=/node/dev-specs/kilt-parachain/peregrine-relay.json"]

if parachain in constant.BINARY_COMMAND_CHAINS:
if parachain["name"] in constant.BINARY_COMMAND_CHAINS:
binary = parachain_details["entrypoint"]
command = [binary] + command

node_details = node_setup.run_testnet_node_with_entrypoint(plan, image, "{0}-{1}-{2}".format(parachain, node["name"], args["chain-type"]), command)
parachain_info[parachain]["parachain_" + node["name"]] = node_details
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

else:
node_details = node_setup.run_testnet_node_with_command(plan, image, "{0}-{1}-{2}".format(parachain, node["name"], args["chain-type"]), command)
parachain_info[parachain]["parachain_" + node["name"]] = node_details
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

return parachain_info
2 changes: 1 addition & 1 deletion parachain/static_files/images.star
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ parachain_images = {
"encointer": {
"image": "encointer/parachain:1.5.1",
"entrypoint": "/usr/local/bin/encointer-collator",
"base": ["encointer-rococo-local", "encointer-rococo", "mainnet"],
"base": ["encointer-rococo-local", "encointer-rococo", "encointer-kusama"],
},
"altair": {
"image": "centrifugeio/centrifuge-chain:test-PR1628-354d76c-23-11-28",
Expand Down
2 changes: 1 addition & 1 deletion relaychain/relay-chain.star
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def start_test_main_net_relay_nodes(plan, args):
chain = args["relaychain"]["name"]
if name == "testnet":
if chain != "rococo" and chain != "westend":
fail("Please provide rococo or westent as relaychain for testnet")
fail("Please provide rococo or westend as relaychain for testnet")
elif name == "mainnet":
if chain != "polkadot" and chain != "kusama":
fail("Please provide polkadot or kusama as relaychain for mainnet")
Expand Down