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 function to create build spec for parachain #36

Merged
merged 5 commits into from
Nov 3, 2023
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
1 change: 0 additions & 1 deletion local.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

"para": {
"acala": {
"id": 2000,
"nodes": [
{
"name": "alice",
Expand Down
12 changes: 7 additions & 5 deletions main.star
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
parachain = import_module("./parachain/parachain.star")
relay_chain = import_module("./relaychain/relay-chain.star")
litentry = import_module("./parachain/litentry.star")
clover = import_module("./parachain/clover.star")

def run(plan, args):
plan.upload_files(src = "./parachain/static_files/configs", name = "configs")
service_details = {"relaychains": {}, "parachains": {}}
if args["chain-type"] == "local":
service_details["relaychains"] = relay_chain.start_relay_chains_local(plan, args)
service_details["parachains"] = clover.run_clover(plan)


image = "bifrostnetwork/bifrost:bifrost-v0.9.66"
binary = "/usr/local/bin/bifrost"
chain_name = "bifrost-local"
parachain.create_parachain_build_spec_with_para_id(plan, image, binary, chain_name, para_id = 200)

else:
relay_chain.start_relay_chain(plan, args)

return service_details
24 changes: 24 additions & 0 deletions package_io/build-spec.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def create_service_for_build_spec(plan, service_name, image, build_file):
files = {
"/app": "configs",
}
if build_file != None:
files["/build"] = build_file

plan.add_service(
name = service_name,
config = ServiceConfig(
image = image,
files = files,
entrypoint = ["bin/sh"],
),
)

def create_edit_and_build_spec(plan, service_name, image, chain_name, command, build_file):
create_service_for_build_spec(plan, service_name, image, build_file)

plan.exec(service_name = service_name, recipe = command)

plan.store_service_files(service_name = service_name, src = "/tmp/{0}.json".format(chain_name), name = service_name)

plan.stop_service(service_name)
4 changes: 4 additions & 0 deletions package_io/constant.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PLAIN_BUILD_SPEC = "plain-build-spec"
RAW_BUILD_SPEC = "raw-build-spec"
EDIT_BUILD_SPEC = "edit-build-spec"
CURL_JQ_IMAGE = "badouralix/curl-jq"
18 changes: 16 additions & 2 deletions parachain/parachain.star
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
def run(plan, args):
plan.print("hello")
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, para_id):
command = ExecRecipe(command = [
"bin/sh",
"-c",
"{0} build-spec --chain={1} --disable-default-bootnode > /tmp/{1}.json".format(binary, 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",
"-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),
])
build_spec.create_edit_and_build_spec(plan, constant.EDIT_BUILD_SPEC, constant.CURL_JQ_IMAGE, chain_name, command, constant.PLAIN_BUILD_SPEC)
shanithkk marked this conversation as resolved.
Show resolved Hide resolved
164 changes: 164 additions & 0 deletions parachain/static_files/configs/raw-rococo-local.json

Large diffs are not rendered by default.