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

Allow override of parachain pallet ID and authorize_upgrade call ID #12

Merged
merged 3 commits into from Jul 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README_src.adoc
Expand Up @@ -45,5 +45,5 @@ If your project uses standard values (such as your runtime package being named `
== Sample workflows

include::examples/index.adoc[leveloffset=+1]

include::doc/parachain-overrides.adoc[]
include::doc/dev-notes.adoc[]
9 changes: 8 additions & 1 deletion action.yml
Expand Up @@ -117,6 +117,11 @@ runs:

echo "BUILD_OPTS=${{ env.BUILD_OPTS }}" >> $GITHUB_ENV

PARACHAIN_PALLET_ID=${${{ env.PARACHAIN_PALLET_ID }}:-0x01}
AUTHORIZE_UPGRADE_PREFIX=${${{ env.AUTHORIZE_UPGRADE_PREFIX }}:-0x03}
echo "PARACHAIN_PALLET_ID=$PARACHAIN_PALLET_ID" >> $GITHUB_ENV
echo "AUTHORIZE_UPGRADE_PREFIX=$AUTHORIZE_UPGRADE_PREFIX" >> $GITHUB_ENV

echo ::endgroup

- id: env_check
Expand All @@ -132,6 +137,8 @@ runs:
echo ℹ️ workdir: ${{ env.WORKDIR }}
echo ℹ️ runtime_dir: ${{ env.RUNTIME_DIR }}
echo ℹ️ build_opts: ${{ env.BUILD_OPTS }}
echo ℹ️ parachain_pallet_id: ${{ env.PARACHAIN_PALLET_ID }}
echo ℹ️ authorize_upgrade_prefix: ${{ env.AUTHORIZE_UPGRADE_PREFIX }}
echo ℹ️ .git folder: `ls -ald ${{ env.WORKDIR }}/.git`
echo ℹ️ Cargo.toml: `ls -al ${{ env.WORKDIR }}/Cargo.toml`

Expand Down Expand Up @@ -170,7 +177,7 @@ runs:
shell: bash
run: |
echo ::group::Srtool build of chain ${{ inputs.chain }}
CMD="docker run -i --rm -e PACKAGE=${{ env.PACKAGE }} -e RUNTIME_DIR=${{ env.RUNTIME_DIR }} -e BUILD_OPTS -v ${{ env.WORKDIR }}:/build ${{ env.SRTOOL_IMAGE }} build --app --json -cM"
CMD="docker run -i --rm -e PACKAGE=${{ env.PACKAGE }} -e RUNTIME_DIR=${{ env.RUNTIME_DIR }} -e BUILD_OPTS -e PARACHAIN_PALLET_ID -e AUTHORIZE_UPGRADE_PREFIX -v ${{ env.WORKDIR }}:/build ${{ env.SRTOOL_IMAGE }} build --app --json -cM"
echo ::debug::build::docker_run $CMD

# here we keep streaming the progress and fetch the last line for the json result
Expand Down
6 changes: 6 additions & 0 deletions doc/parachain-overrides.adoc
@@ -0,0 +1,6 @@

Similar to https://github.com/chevdor/subwasm[subwasm], the parachain pallet ID and the `authorize_upgrade` call ID can be overriden by `PARACHAIN_PALLET_ID` and `AUTHORIZE_UPGRADE_PREFIX` environmental variables, respectively. It will affect the generated proposal hash `parachain_authorize_upgrade_hash`.

If unset, the two envs will have the following default values:
- `PARACHAIN_PALLET_ID`: `0x01`
- `AUTHORIZE_UPGRADE_PREFIX`: `0x03`
28 changes: 28 additions & 0 deletions examples/06_parachain_overrides.yml
@@ -0,0 +1,28 @@
name: Srtool build

on: push

jobs:
srtool:
runs-on: ubuntu-latest
strategy:
matrix:
chain: ["statemine", "westmint"]
steps:
- uses: actions/checkout@v3
- name: Srtool build
id: srtool_build
uses: chevdor/srtool-actions@v0.4.0
env:
# optional: will override the parachain pallet ID and authorize_upgrade call ID,
# which will result in a different parachain_authorize_upgrade_hash
PARACHAIN_PALLET_ID: 0x1e
AUTHORIZE_UPGRADE_PREFIX: 0x02
with:
chain: ${{ matrix.chain }}
runtime_dir: polkadot-parachains/${{ matrix.chain }}-runtime
- name: Summary
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq . > ${{ matrix.chain }}-srtool-digest.json
cat ${{ matrix.chain }}-srtool-digest.json
echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}"
6 changes: 6 additions & 0 deletions examples/index.adoc
Expand Up @@ -32,3 +32,9 @@ include::03_artifacts.yml[]
----
include::05_build_opts.yml[]
----

== Environmental variables and parachain overrides
[source,yaml]
----
include::06_parachain_overrides.yml[]
----