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 1 commit
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
9 changes: 9 additions & 0 deletions README.md
Expand Up @@ -163,6 +163,9 @@ Make sure you store the yml files shown below in your repository under `.github/
env:
# optional: will be passed to docker srtool run cmd
BUILD_OPTS: "--features on-chain-release-build"
# optional: will override the parachain pallet and call IDs, see below
PARACHAIN_PALLET_ID: 0x1e
AUTHORIZE_UPGRADE_PREFIX: 0x02
with:
chain: ${{ matrix.chain }}
runtime_dir: polkadot-parachains/${{ matrix.chain }}-runtime
Expand All @@ -172,6 +175,12 @@ Make sure you store the yml files shown below in your repository under `.github/
cat ${{ matrix.chain }}-srtool-digest.json
echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}"

Similar to [subwasm](https://github.com/chevdor/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`

## Dev notes

Due to a [bug in act](https://github.com/nektos/act/issues/655), the defaults defined in the action are not applied. That means **must** pass all the inputs while testing with `act`.
Expand Down
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