Skip to content

Commit

Permalink
refactor: removed unused function for registration of parachain
Browse files Browse the repository at this point in the history
  • Loading branch information
shanithkk committed Jan 30, 2024
1 parent 6b4b3bf commit c2eb471
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 86 deletions.
49 changes: 0 additions & 49 deletions parachain/build-spec.star
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,6 @@ build_spec = import_module("../package_io/build-spec.star")
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",
"-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, chain_name + "plain", image, chain_name, command, build_file = None)
command = ExecRecipe(command = [
"/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},/' -e 's/\"parachain_id\": [0-9]*,/\"parachain_id\": {0},/' /build/{1}.json > /tmp/{1}.json".format(para_id, chain_name),
])
build_spec.create_edit_and_build_spec(plan, chain_name + "edit", constant.CURL_JQ_IMAGE, chain_name, command, chain_name + "plain")
raw_service = create_raw_build_spec_genisis_state_genisis_wasm(plan, binary, image, chain_name, chain_name + "edit")

return raw_service

def create_raw_build_spec_genisis_state_genisis_wasm(plan, binary, image, chain_name, build_file):
raw_service = build_spec.create_service_for_build_spec(plan, chain_name + "raw", image, build_file)

command = ExecRecipe(command = [
"/bin/sh",
"-c",
"{0} build-spec --chain=/build/{1}.json --raw --disable-default-bootnode > /tmp/{1}-raw.json".format(binary, chain_name),
])
result = plan.exec(service_name = chain_name + "raw", recipe = command)
plan.verify(result["code"], "==", 0)

command = ExecRecipe(command = [
"/bin/sh",
"-c",
"{0} export-genesis-wasm --chain=/tmp/{1}-raw.json > /tmp/{1}-genesis-wasm".format(binary, chain_name),
])
result = plan.exec(service_name = chain_name + "raw", recipe = command)
plan.verify(result["code"], "==", 0)

command = ExecRecipe(command = [
"/bin/sh",
"-c",
"{0} export-genesis-state --chain=/tmp/{1}-raw.json > /tmp/{1}-genesis-state".format(binary, chain_name),
])
result = plan.exec(service_name = chain_name + "raw", recipe = command)
plan.verify(result["code"], "==", 0)

plan.store_service_files(service_name = chain_name + "raw", src = "/tmp/*", name = chain_name + "raw")
plan.stop_service(chain_name + "raw")

return raw_service

def create_parachain_build_spec_with_para_ids(plan, image, binary, chain_name, chain_base, para_id):
files = {
"/app": "configs",
}
Expand Down
6 changes: 3 additions & 3 deletions parachain/parachain.star
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def start_local_parachain_node(plan, chain_type, parachain, para_id):
image = parachain_details["image"]
binary = parachain_details["entrypoint"]
chain_base = parachain_details["base"][0]
raw_service = build_spec.create_parachain_build_spec_with_para_ids(plan, image, binary, chain_name, chain_base, para_id)
raw_service = build_spec.create_parachain_build_spec_with_para_id(plan, image, binary, chain_name, chain_base, para_id)

parachain_final = {}

Expand Down Expand Up @@ -89,9 +89,9 @@ def start_nodes(plan, chain_type, parachains, relay_chain_ip):
final_parachain_details = {}

for parachain in parachains:
para_id = register_para_slot.register_para_ids(plan, relay_chain_ip)
para_id = register_para_slot.register_para_id(plan, relay_chain_ip)
parachain_details = start_local_parachain_node(plan, chain_type, parachain, para_id)
register_para_slot.run_onboard_genesis_state_and_wasm(plan, para_id, parachain["name"], relay_chain_ip)
register_para_slot.onboard_genesis_state_and_wasm(plan, para_id, parachain["name"], relay_chain_ip)
final_parachain_details.update(parachain_details)

return final_parachain_details
Expand Down
34 changes: 1 addition & 33 deletions parachain/register-para-id.star
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,6 @@ build_spec = import_module("../package_io/build-spec.star")
constant = import_module("../package_io/constant.star")

def register_para_id(plan, alice_ip):
test = build_spec.create_service_for_build_spec(plan, constant.PARA_SLOT_REGISTER_SERVICE_NAME, constant.NODE_IMAGE, "javascript")
result = plan.exec(service_name = test.name, recipe = ExecRecipe(command = ["/bin/sh", "-c", "cd /build && npm i "]))
plan.verify(result["code"], "==", 0)
result = plan.exec(service_name = test.name, recipe = ExecRecipe(command = ["/bin/sh", "-c", "cd /build && node register ws://{0}:9944 //Alice ".format(alice_ip)]))
plan.verify(result["code"], "==", 0)
para_id = plan.exec(service_name = test.name, recipe = ExecRecipe(command = ["/bin/sh", "-c", "cat /tmp/para.json | tr -d '\n\r'"]))
plan.verify(para_id["code"], "==", 0)
plan.remove_service(test.name)
return para_id["output"]

def onboard_genesis_state_and_wasm(plan, para_id, chain_name, alice_ip):
service = plan.add_service(
name = "upload-{}-genesis-file".format(chain_name),
config = ServiceConfig(
image = constant.NODE_IMAGE,
files = {
"/app": "configs",
"/build": chain_name + "raw",
"/javascript": "javascript",
},
entrypoint = ["/bin/sh"],
),
)

result = plan.exec(service_name = service.name, recipe = ExecRecipe(command = ["/bin/sh", "-c", "cd /javascript && npm i "]))
plan.verify(result["code"], "==", 0)
result = 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.verify(result["code"], "==", 0)

plan.remove_service(service.name)

def register_para_ids(plan, alice_ip):
files = {
"/app": "configs",
"/build": "javascript",
Expand All @@ -55,7 +23,7 @@ def register_para_ids(plan, alice_ip):
)
return id.output

def run_onboard_genesis_state_and_wasm(plan, para_id, chain_name, alice_ip):
def onboard_genesis_state_and_wasm(plan, para_id, chain_name, alice_ip):
files = {
"/app": "configs",
"/build": chain_name + "raw",
Expand Down
1 change: 0 additions & 1 deletion testdata/chain_value.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
acala,Polkadot
bifrost,Polkadot
clover,Polkadot
integritee,Polkadot
kilt,Polkadot
moonbeam,Polkadot
litentry,Polkadot
Expand Down

0 comments on commit c2eb471

Please sign in to comment.