Skip to content

Commit

Permalink
chore: return nodes details
Browse files Browse the repository at this point in the history
  • Loading branch information
shanithkk committed Nov 14, 2023
1 parent a3ca208 commit 1541ba9
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 13 deletions.
2 changes: 1 addition & 1 deletion local.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"chain-type": "testnet",
"relaychain": {
"name": "polkadot",
"name": "rococo",
"nodes": [
{
"name": "alice",
Expand Down
9 changes: 6 additions & 3 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ def run(plan, args):
parachain.start_nodes(plan, args, relay_chain_details["relay_service_alice"].ip_address)

else:
# relay_chain.start_relay_chain(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
for paras in args["para"]:
parachain.run_testnet_mainnet(plan, args, paras)
parachain_info = parachain.run_testnet_mainnet(plan, args, paras)
plan.print(parachain_info)
service_details["parachains"] = parachain_info

return service_details
10 changes: 6 additions & 4 deletions parachain/node_setup.star
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def run_testnet_node_with_entrypoint(plan, args, image, chain_name, execute_command):
def run_testnet_node_with_entrypoint(plan, image, chain_name, execute_command):
service_config = ServiceConfig(
image = image,
ports = {
Expand All @@ -9,10 +9,11 @@ def run_testnet_node_with_entrypoint(plan, args, image, chain_name, execute_comm
},
entrypoint = execute_command,
)
parachain = plan.add_service(name = "{0}".format(chain_name), config = service_config)

plan.add_service(name = "{0}".format(chain_name), config = service_config)
return parachain

def run_testnet_node_with_command(plan, args, image, chain_name, execute_command):
def run_testnet_node_with_command(plan, image, chain_name, execute_command):
service_config = ServiceConfig(
image = image,
ports = {
Expand All @@ -23,5 +24,6 @@ def run_testnet_node_with_command(plan, args, image, chain_name, execute_command
},
cmd = execute_command,
)
parachain = plan.add_service(name = "{0}".format(chain_name), config = service_config)

plan.add_service(name = "{0}".format(chain_name), config = service_config)
return parachain
10 changes: 7 additions & 3 deletions parachain/parachain.star
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def run_testnet_mainnet(plan, args, parachain):
"--unsafe-rpc-external",
"--unsafe-ws-external",
]

parachain_info = {parachain: {}}
para_nodes = args["para"][parachain]["nodes"]
for node in para_nodes:
command = common_command
Expand All @@ -105,7 +105,11 @@ def run_testnet_mainnet(plan, args, parachain):
binary = parachain_details["entrypoint"]
command = [binary] + command

node_setup.run_testnet_node_with_entrypoint(plan, args, image, "{0}-{1}".format(parachain, node["name"]), command)
node_details = node_setup.run_testnet_node_with_entrypoint(plan, image, "{0}-{1}".format(parachain, node["name"]), command)
parachain_info[parachain]["parachain_" + node["name"]] = node_details

else:
node_setup.run_testnet_node_with_command(plan, args, image, "{0}-{1}".format(parachain, node["name"]), command)
node_details = node_setup.run_testnet_node_with_command(plan, image, "{0}-{1}".format(parachain, node["name"]), command)
parachain_info[parachain]["parachain_" + node["name"]] = node_details

return parachain_info
21 changes: 19 additions & 2 deletions relaychain/relay-chain.star
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
def start_relay_chain(plan, args):
name = args["chain-type"]
chain = args["relaychain"]["name"]
relay_node_details = {}
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".format(chain, relay_node["name"])]
plan.add_service(
name = "{0}-{1}".format(name, relay_node["name"]),
relay_node_detail = plan.add_service(
name = "{0}-{1}-{2}".format(name, chain, relay_node["name"]),
config = ServiceConfig(
image = "parity/polkadot:latest",
ports = {
Expand All @@ -17,6 +18,22 @@ def start_relay_chain(plan, args):
entrypoint = exec_command,
),
)
relay_node_details["relay_service_" + relay_node["name"]] = relay_node_detail

return relay_node_details

def start_test_main_net_relay_nodes(plan, args):
name = args["chain-type"]
chain = args["relaychain"]["name"]
if name == "testnet":
if chain != "rococo" and chain != "westend":
fail("Please provide rococo or westent as relaychain for testnet")
elif name == "mainnet":
if chain != "polkadot" and chain != "kusama":
fail("Please provide polkadot or kusama as relaychain for mainnet")
relay_node_details = start_relay_chain(plan, args)

return relay_node_details

def spawn_multiple_relay(plan, count):
list = ["alice", "bob", "dave", "charlie"]
Expand Down

0 comments on commit 1541ba9

Please sign in to comment.