From fcbdd4691f5cfa981d569562466d1d2d176a5a58 Mon Sep 17 00:00:00 2001 From: Abhishek Harde <47945971+abhiyana@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:36:54 +0530 Subject: [PATCH] feat: implement the kurtosis package for running the polkadot js App (#122) * feat: implement the kurtosis package for deployment of chopstick network * chore: fix issues in ws port issues * fix: fix for moonriver, kilt * fix: fix clover testnet running issue * refactor: change node type for clover in local.json * fix: fix the issue bin/sh * feat: implement kurtosis package for running polkadot -js App * merge: merge to main * refactor: add the prometheus key in local.json * fix: change the base for interlay local --------- Co-authored-by: Shanith K K --- local.json | 10 ++++--- main.star | 1 - package_io/constant.star | 5 ++-- parachain/build-spec.star | 22 +++++++-------- parachain/parachain.star | 12 ++++++--- parachain/register-para-id.star | 3 +++ parachain/static_files/configs/prometheus.yml | 2 +- parachain/static_files/images.star | 20 +++++++------- parachain/testnet-setup/centrifuge.star | 27 +++++++++++++++++++ polkadot-js-app/polkadot_js_app.star | 25 +++++++++++++++++ 10 files changed, 95 insertions(+), 32 deletions(-) create mode 100644 parachain/testnet-setup/centrifuge.star create mode 100644 polkadot-js-app/polkadot_js_app.star diff --git a/local.json b/local.json index 085dd39..e32c51b 100644 --- a/local.json +++ b/local.json @@ -13,18 +13,20 @@ "name": "bob", "node-type": "full", "port": 9945, - "prometheus": true + "prometheus": false + } ] }, "para": { - "acala": { + "khala": { "nodes": [ { "name": "alice", - "node-type": "collator", - "prometheus": true + "node-type": "validator", + "prometheus": false + }, { "name": "bob", diff --git a/main.star b/main.star index b3ba64f..89395da 100644 --- a/main.star +++ b/main.star @@ -15,7 +15,6 @@ def run(plan, args): service_details["relaychains"] = relay_chain_details parachain_details = parachain.start_nodes(plan, args, relay_chain_details[0]["service_details"].ip_address) service_details["parachains"] = parachain_details - else: if len(args["relaychain"]) != 0: relay_node_detals = relay_chain.start_test_main_net_relay_nodes(plan, args) diff --git a/package_io/constant.star b/package_io/constant.star index 0b5365a..4f5ff58 100644 --- a/package_io/constant.star +++ b/package_io/constant.star @@ -4,8 +4,8 @@ EDIT_BUILD_SPEC = "edit-build-spec" CURL_JQ_IMAGE = "badouralix/curl-jq" NODE_IMAGE = "node:21.1" PARA_SLOT_REGISTER_SERVICE_NAME = "para-slot-registration" -BINARY_COMMAND_CHAINS = ["manta", "khala", "phala"] -NO_WS_PORT = ["acala", "frequency", "moonbeam", "karura", "ajuna", "bajun"] +BINARY_COMMAND_CHAINS = ["manta", "khala", "phala", "clover"] +NO_WS_PORT = ["acala", "frequency", "moonbeam", "karura", "ajuna", "bajun", "centrifuge", "moonsama", "encointer", "moonriver"] DIFFERENT_IMAGES_FOR_MAINNET = { "centrifuge": "centrifugeio/centrifuge-chain:main-latest", @@ -16,6 +16,7 @@ DIFFERENT_IMAGES_FOR_TESTNET = { "frequency": "frequencychain/parachain-node-rococo", "centrifuge": "centrifugeio/centrifuge-chain:main-latest", "karura": "acala/mandala-node:latest", + "clover": "cloverio/clover-iris:0.1.15" } CHAIN_COMMAND = ["manta", "moonsama", "interlay", "kintsugi-btc"] diff --git a/parachain/build-spec.star b/parachain/build-spec.star index 43f1882..54b14d6 100644 --- a/parachain/build-spec.star +++ b/parachain/build-spec.star @@ -3,13 +3,13 @@ constant = import_module("../package_io/constant.star") def create_parachain_build_spec_with_para_id(plan, image, binary, chain_name, chain_base, para_id): command = ExecRecipe(command = [ - "bin/sh", + "/bin/sh", "-c", "{0} build-spec --chain={1} --disable-default-bootnode > /tmp/{2}.json".format(binary, chain_base, chain_name), ]) build_spec.create_edit_and_build_spec(plan, constant.PLAIN_BUILD_SPEC, image, chain_name, command, build_file = None) command = ExecRecipe(command = [ - "bin/sh", + "/bin/sh", "-c", "sed -e 's/\"parachainId\": *[0-9]\\+/\"parachainId\": {0}/' -e 's/\"para_id\": [0-9]*,/\"para_id\": {0},/' -e 's/\"paraId\": [0-9]*,/\"paraId\": {0},/' /build/{1}.json > /tmp/{1}.json".format(para_id, chain_name), ]) @@ -22,32 +22,32 @@ def create_raw_build_spec_genisis_state_genisis_wasm(plan, binary, image, chain_ raw_service = build_spec.create_service_for_build_spec(plan, constant.RAW_BUILD_SPEC, image, build_file) command = ExecRecipe(command = [ - "bin/sh", + "/bin/sh", "-c", "{0} build-spec --chain=/build/{1}.json --raw --disable-default-bootnode > /tmp/{1}-raw.json".format(binary, chain_name), ]) plan.exec(service_name = constant.RAW_BUILD_SPEC, recipe = command) command = ExecRecipe(command = [ - "bin/sh", + "/bin/sh", "-c", "{0} export-genesis-wasm --chain=/tmp/{1}-raw.json > /tmp/{1}-genesis-wasm".format(binary, chain_name), ]) plan.exec(service_name = constant.RAW_BUILD_SPEC, recipe = command) command = ExecRecipe(command = [ - "bin/sh", + "/bin/sh", "-c", "{0} export-genesis-state --chain=/tmp/{1}-raw.json > /tmp/{1}-genesis-state".format(binary, chain_name), ]) plan.exec(service_name = constant.RAW_BUILD_SPEC, recipe = command) - command = ExecRecipe(command = [ - "bin/sh", - "-c", - "cp /build/{0}.json /tmp/{0}.json".format(chain_name), - ]) - plan.exec(service_name = constant.RAW_BUILD_SPEC, recipe = command) + # command = ExecRecipe(command = [ + # "/bin/sh", + # "-c", + # "cp /build/{0}.json /tmp/{0}.json".format(chain_name), + # ]) + # plan.exec(service_name = constant.RAW_BUILD_SPEC, recipe = command) plan.store_service_files(service_name = constant.RAW_BUILD_SPEC, src = "/tmp/*", name = constant.RAW_BUILD_SPEC) plan.stop_service(constant.RAW_BUILD_SPEC) diff --git a/parachain/parachain.star b/parachain/parachain.star index e7d42ba..ed520df 100644 --- a/parachain/parachain.star +++ b/parachain/parachain.star @@ -26,7 +26,8 @@ def spawn_parachain(plan, chain_name, image, command, build_file): return parachain_node -def start_local_parachain_node(plan, args, parachain, para_id): +def start_local_parachain_node(plan, args, parachain_name, para_id): + parachain = parachain_name.lower() parachain_details = parachain_list.parachain_images[parachain] image = parachain_details["image"] binary = parachain_details["entrypoint"] @@ -36,13 +37,13 @@ def start_local_parachain_node(plan, args, parachain, para_id): if parachain in constant.NO_WS_PORT: exec_comexec_commandmand = [ - "bin/bash", + "/bin/bash", "-c", "{0} --chain=/build/{1}-raw.json --rpc-port=9944 --rpc-external --rpc-cors=all --prometheus-external --name={1} --collator --rpc-methods=unsafe --force-authoring --execution=wasm -- --chain=/app/raw-polkadot.json --execution=wasm".format(binary, chain_name), ] else: exec_comexec_commandmand = [ - "bin/bash", + "/bin/bash", "-c", "{0} --chain=/build/{1}-raw.json --ws-port=9944 --rpc-port=9933 --ws-external --rpc-external --prometheus-external --rpc-cors=all --name={1} --collator --rpc-methods=unsafe --force-authoring --execution=wasm -- --chain=/app/raw-polkadot.json --execution=wasm".format(binary, chain_name), ] @@ -72,6 +73,8 @@ def start_nodes(plan, args, relay_chain_ip): def run_testnet_mainnet(plan, args, parachain): if args["chain-type"] == "testnet": main_chain = "rococo" + if parachain == "ajuna": + parachain = "bajun" parachain_details = parachain_list.parachain_images[parachain] image = parachain_details["image"] base = parachain_details["base"][1] @@ -120,6 +123,9 @@ def run_testnet_mainnet(plan, args, parachain): command = command + ["--name={0}".format(node["name"])] if node["node-type"] == "collator": command = command + ["--collator"] + + if node["node-type"] == "validator": + command = command + ["--validator"] if parachain in constant.CHAIN_COMMAND: command = command + ["--", "--chain={0}".format(main_chain)] diff --git a/parachain/register-para-id.star b/parachain/register-para-id.star index 2c8e8aa..b62e47a 100644 --- a/parachain/register-para-id.star +++ b/parachain/register-para-id.star @@ -8,6 +8,7 @@ def register_para_id(plan, alice_ip): plan.exec(service_name = test.name, recipe = ExecRecipe(command = ["/bin/sh", "-c", "cd /build && node register ws://{0}:9944 //Alice ".format(alice_ip)])) para_id = plan.exec(service_name = test.name, recipe = ExecRecipe(command = ["/bin/sh", "-c", "cat /tmp/para.json | tr -d '\n\r'"])) + plan.remove_service(test.name) return para_id["output"] def onboard_genesis_state_and_wasm(plan, para_id, chain_name, alice_ip): @@ -26,3 +27,5 @@ def onboard_genesis_state_and_wasm(plan, para_id, chain_name, alice_ip): plan.exec(service_name = service.name, recipe = ExecRecipe(command = ["/bin/sh", "-c", "cd /javascript && npm i "])) plan.exec(service_name = service.name, recipe = ExecRecipe(command = ["/bin/sh", "-c", "cd /javascript && node onboard ws://{0}:9944 //Alice {1} /build/{2}-genesis-state /build/{2}-genesis-wasm".format(alice_ip, para_id, chain_name)])) + + plan.remove_service(service.name) diff --git a/parachain/static_files/configs/prometheus.yml b/parachain/static_files/configs/prometheus.yml index e4616c1..3e172f3 100644 --- a/parachain/static_files/configs/prometheus.yml +++ b/parachain/static_files/configs/prometheus.yml @@ -11,4 +11,4 @@ scrape_configs: - job_name: "substrate_node" scrape_interval: 5s static_configs: - - targets: ["172.16.0.3:9615"] \ No newline at end of file + - targets: ["172.16.0.3:9615"] diff --git a/parachain/static_files/images.star b/parachain/static_files/images.star index 6cd1736..f0af891 100644 --- a/parachain/static_files/images.star +++ b/parachain/static_files/images.star @@ -23,7 +23,7 @@ parachain_images = { "clover": { "image": "cloverio/clover-para:v0.1.24", "entrypoint": "/opt/clover/bin/clover", - "base": ["dev", "testnet", "mainnet"], + "base": ["dev", "iris", "clover"], }, "frequency": { "image": "frequencychain/collator-node-local:latest", @@ -38,9 +38,9 @@ parachain_images = { "interlay": { "image": "interlayhq/interbtc:latest", "entrypoint": "/usr/local/bin/interbtc-parachain", - "base": ["dev", "interlay-testnet-latest", "interlay-latest"], + "base": ["interlay-dev", "interlay-testnet-latest", "interlay-latest"], }, - "kilt-spiritnet": { + "kilt": { "image": "kiltprotocol/kilt-node:latest", "entrypoint": "/usr/local/bin/node-executable", "base": ["dev", "/node/dev-specs/kilt-parachain/peregrine-kilt.json", "spiritnet"], @@ -63,7 +63,7 @@ parachain_images = { "moonbeam": { "image": "moonbeamfoundation/moonbeam:sha-32933811", "entrypoint": "/moonbeam/moonbeam", - "base": ["dev", "alphanet", "moonbeam"], + "base": ["moonbeam-dev", "alphanet", "moonbeam"], }, "moonsama": { "image": "moonsama/moonsama-node:latest", @@ -85,7 +85,7 @@ parachain_images = { "entrypoint": "/usr/local/bin/pendulum-collator", "base": ["litentry-dev", "foucoco", "pendulum"], }, - "phala-network": { + "phala": { "image": "litentry/litentry-parachain:latest", "entrypoint": "/usr/local/bin/litentry-collator", "base": ["dev", "rhala", "phala"], @@ -98,14 +98,14 @@ parachain_images = { "subsocial": { "image": "dappforce/subsocial-parachain:latest", "entrypoint": "/usr/local/bin/subsocial-collator", - "base": ["local-rococo", "--chain=/app/soonsocial.json", ""], + "base": ["local-rococo", "/app/soonsocial.json", ""], }, "zeitgeist": { "image": "zeitgeistpm/zeitgeist-node-parachain", "entrypoint": "/usr/local/bin/zeitgeist", "base": ["dev", "battery_station", "zeitgeist"], }, - "encointer-network": { + "encointer": { "image": "encointer/parachain:1.5.1", "entrypoint": "/usr/local/bin/encointer-collator", "base": ["encointer-rococo-local", "encointer-rococo", "mainnet"], @@ -130,7 +130,7 @@ parachain_images = { "entrypoint": "/usr/local/bin/acala", "base": ["dev", "mandala-latest", "karura"], }, - "khala network": { + "khala": { "image": "phalanetwork/khala-node:latest", "entrypoint": "/usr/local/bin/khala-node", "base": ["khala-dev-2004", "rhala", "khala"], @@ -138,7 +138,7 @@ parachain_images = { "kintsugi-btc": { "image": "interlayhq/interbtc:latest", "entrypoint": "tini -- /usr/local/bin/interbtc-parachain", - "base": ["dev", "kintsugi-testnet-latest", "kintsugi"], + "base": ["kintsugi-dev", "kintsugi-testnet-latest", "kintsugi"], }, "litmus": { "image": "litentry/litentry-parachain:latest", @@ -153,7 +153,7 @@ parachain_images = { "moonriver": { "image": "moonbeamfoundation/moonbeam:sha-519bd694", "entrypoint": "/moonbeam/moonbeam", - "base": ["dev", "alphanet", "moonriver"], + "base": ["moonriver-dev", "alphanet", "moonriver"], }, "robonomics": { "image": "robonomics/robonomics:latest", diff --git a/parachain/testnet-setup/centrifuge.star b/parachain/testnet-setup/centrifuge.star new file mode 100644 index 0000000..f598ad3 --- /dev/null +++ b/parachain/testnet-setup/centrifuge.star @@ -0,0 +1,27 @@ +def run_centrifuge(plan): + exec_command = [ + "--chain=catalyst", + "--rpc-port=9944", + "--rpc-external", + "--rpc-cors=all", + "--rpc-methods=unsafe", + "--execution=wasm", + "--tmp", + "--", + "--chain=rococo" + ] + altair_service_config = ServiceConfig( + image = "centrifugeio/centrifuge-chain:main-latest", + files = { + "/app": "configs", + }, + ports = { + "ws": PortSpec(9944, transport_protocol = "TCP"), + }, + public_ports = { + "ws": PortSpec(9432, transport_protocol = "TCP"), + }, + cmd = exec_command, + entrypoint = ["/usr/local/bin/centrifuge-chain"] + ) + plan.add_service(name = "centrifuge-node", config = altair_service_config) diff --git a/polkadot-js-app/polkadot_js_app.star b/polkadot-js-app/polkadot_js_app.star new file mode 100644 index 0000000..265c26f --- /dev/null +++ b/polkadot-js-app/polkadot_js_app.star @@ -0,0 +1,25 @@ +""" +This file contain code for running the polkadot-js App +""" +def run_pokadot_js_app(plan, ws_url): + """ + This function will run the service for polkadot Js App + Args: + plan (object): kurtosis plan object1 + ws_url (str): connect to a Polkadot node of given web socket URL + """ + service_config = ServiceConfig( + image = "jacogr/polkadot-js-apps:latest", + + ports = { + "TCP" : PortSpec(80) + }, + public_ports = { + "TCP" : PortSpec(80) + }, + env_vars = { + "WS_URL": ws_url, + } + ) + plan.add_service(name="polkadot-js", config=service_config) + \ No newline at end of file