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

feat: implement the kurtosis package for running the polkadot js App #122

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
10 changes: 6 additions & 4 deletions local.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion main.star
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions package_io/constant.star
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"]
22 changes: 11 additions & 11 deletions parachain/build-spec.star
Original file line number Diff line number Diff line change
Expand Up @@ -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),
])
Expand All @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions parachain/parachain.star
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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),
]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)]
Expand Down
3 changes: 3 additions & 0 deletions parachain/register-para-id.star
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
2 changes: 1 addition & 1 deletion parachain/static_files/configs/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ scrape_configs:
- job_name: "substrate_node"
scrape_interval: 5s
static_configs:
- targets: ["172.16.0.3:9615"]
- targets: ["172.16.0.3:9615"]
20 changes: 10 additions & 10 deletions parachain/static_files/images.star
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"],
Expand All @@ -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",
Expand All @@ -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"],
Expand All @@ -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"],
Expand All @@ -130,15 +130,15 @@ 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"],
},
"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",
Expand All @@ -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",
Expand Down
27 changes: 27 additions & 0 deletions parachain/testnet-setup/centrifuge.star
Original file line number Diff line number Diff line change
@@ -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)
25 changes: 25 additions & 0 deletions polkadot-js-app/polkadot_js_app.star
Original file line number Diff line number Diff line change
@@ -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)