From dba369c70242c36a3b6f18dda88a1eda4d5b985e Mon Sep 17 00:00:00 2001 From: abhiyana Date: Tue, 21 Nov 2023 17:23:45 +0530 Subject: [PATCH] feat: implement the kurtosis package for deployment of chopstick network --- chopsticks/chopsticks.star | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 chopsticks/chopsticks.star diff --git a/chopsticks/chopsticks.star b/chopsticks/chopsticks.star new file mode 100644 index 0000000..b51da9e --- /dev/null +++ b/chopsticks/chopsticks.star @@ -0,0 +1,58 @@ +""" +This package contains code for spawning the chopstick network. +""" + +def run_chopsticks_parachain(plan, para_chain): + """ + Set up a service for the chopstick network for given parachain. + + Args: + plan: The Kurtosis plan. + para_chain (str): The parachain to configure for the chopstick network. + """ + + service_config = ServiceConfig( + image="node:latest", + ports={ + "TCP": PortSpec(number=8000) + }, + public_ports={ + "TCP": PortSpec(number=8000) + }, + entrypoint=["/bin/sh", "-c", "yarn add @acala-network/chopsticks@latest && npx @acala-network/chopsticks --config=%s --port=8000" % (para_chain)] + ) + + plan.add_service(name="chopstick-", config=service_config) + + +def run_chopsticks_xcm(plan, relay_chain, para_chains): + """ + Set up a service for the chopstick network with cross-chain messaging (xcm) support with give relachain and parachains. + + Args: + plan: The Kurtosis plan. + relay_chain (str): The relay chain for cross-chain messaging. + para_chains (list): List of parachains to include in the network. + """ + + exec_cmd = "npx @acala-network/chopsticks xcm" + exec_cmd = exec_cmd + " -r " + relay_chain + + for para in para_chains: + exec_cmd = exec_cmd + " -p " + para + + ports = {} + public_ports = {} + + for i in range(0, len(para_chains) + 1): + ports["TCP" + str(i)] = PortSpec(number=8000 + i) + public_ports["TCP" + str(i)] = PortSpec(number=8000 + i) + + service_config = ServiceConfig( + image="node:latest", + ports=ports, + public_ports=public_ports, + entrypoint=["/bin/sh", "-c", "yarn add @acala-network/chopsticks@latest && %s" % (exec_cmd)] + ) + + plan.add_service(name="chopstick-", config=service_config)