deploy: chain spec from a repo path, with a sha256 check
The mainnet package arrives as files (spec, bootnodes, genesis, checksum file, readme) with the node staying on 0.11.1, so the spec is committed under asset/chainspec/ after verification and the deploy takes a repo path as well as a URL. CHAINSPEC_SHA256 / chainspec_sha256 re-verifies the file in fetch. The fetch job now checks the repo out. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CBgs2nSi4H2mdh8kD8vMX5
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
5ad19ccb2a
commit
f515c8057b
@@ -39,7 +39,10 @@ on:
|
||||
description: quantus-node version (overrides the pin)
|
||||
required: false
|
||||
chainspec_url:
|
||||
description: "chain spec JSON to run from (overrides CHAINSPEC_URL); empty = the built-in CHAIN name"
|
||||
description: "chain spec JSON to run from (overrides CHAINSPEC_URL): an https URL, or a path in this repo such as asset/chainspec/mainnet.json; empty = the built-in CHAIN name"
|
||||
required: false
|
||||
chainspec_sha256:
|
||||
description: "sha256 the chain spec file must have (overrides CHAINSPEC_SHA256); from the publisher's checksum file"
|
||||
required: false
|
||||
expected_genesis:
|
||||
description: "0x genesis hash the started node must report (overrides EXPECTED_GENESIS); required with a chain spec"
|
||||
@@ -74,6 +77,7 @@ env:
|
||||
# override each of these for the cutover; commit the values afterwards so
|
||||
# push-triggered deploys keep them.
|
||||
CHAINSPEC_URL: ""
|
||||
CHAINSPEC_SHA256: ""
|
||||
EXPECTED_GENESIS: ""
|
||||
BOOTNODES: ""
|
||||
# The miner is deployed by quantus/miner's own workflow, following its main
|
||||
@@ -112,10 +116,12 @@ jobs:
|
||||
outputs:
|
||||
node_version: ${{ steps.v.outputs.node }}
|
||||
chainspec_url: ${{ steps.v.outputs.chainspec_url }}
|
||||
chainspec_sha256: ${{ steps.v.outputs.chainspec_sha256 }}
|
||||
expected_genesis: ${{ steps.v.outputs.expected_genesis }}
|
||||
bootnodes: ${{ steps.v.outputs.bootnodes }}
|
||||
chain_id: ${{ steps.cs.outputs.chain_id }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- id: v
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -124,6 +130,7 @@ jobs:
|
||||
echo "quantus-node ${n}"
|
||||
cs="${{ github.event.inputs.chainspec_url || env.CHAINSPEC_URL }}"
|
||||
eg="${{ github.event.inputs.expected_genesis || env.EXPECTED_GENESIS }}"
|
||||
sha="${{ github.event.inputs.chainspec_sha256 || env.CHAINSPEC_SHA256 }}"
|
||||
bn="${{ github.event.inputs.bootnodes || env.BOOTNODES }}"
|
||||
if [ -n "$cs" ] && [ -z "$eg" ]; then
|
||||
echo "a chain spec needs expected_genesis: without it a look-alike spec would pass validation" >&2
|
||||
@@ -134,6 +141,7 @@ jobs:
|
||||
case "$b" in /*/p2p/*) ;; *) echo "bootnode '$b' is not a multiaddr ending in /p2p/<peer id>" >&2; exit 1 ;; esac
|
||||
done
|
||||
echo "chainspec_url=${cs}" >> "$GITHUB_OUTPUT"
|
||||
echo "chainspec_sha256=${sha}" >> "$GITHUB_OUTPUT"
|
||||
echo "expected_genesis=${eg}" >> "$GITHUB_OUTPUT"
|
||||
echo "bootnodes=${bn}" >> "$GITHUB_OUTPUT"
|
||||
echo "chain spec: ${cs:-built-in ${{ env.CHAIN }}}; expected genesis: ${eg:-not asserted}; bootnodes: ${bn:-none}"
|
||||
@@ -148,8 +156,22 @@ jobs:
|
||||
exit 0
|
||||
fi
|
||||
mkdir -p _bin
|
||||
curl -fSL --retry 5 --retry-delay 5 --retry-all-errors --connect-timeout 15 \
|
||||
-o _bin/chainspec.json "$cs"
|
||||
case "$cs" in
|
||||
http://*|https://*)
|
||||
curl -fSL --retry 5 --retry-delay 5 --retry-all-errors --connect-timeout 15 \
|
||||
-o _bin/chainspec.json "$cs" ;;
|
||||
*)
|
||||
# A file committed to this repo (verified against the publisher's
|
||||
# checksum before it was committed, and again below).
|
||||
test -s "$cs" || { echo "chain spec '$cs' is neither a URL nor a file in this repo" >&2; exit 1; }
|
||||
cp "$cs" _bin/chainspec.json ;;
|
||||
esac
|
||||
sha="${{ steps.v.outputs.chainspec_sha256 }}"
|
||||
if [ -n "$sha" ]; then
|
||||
got=$(sha256sum _bin/chainspec.json | cut -d' ' -f1)
|
||||
[ "$got" = "$sha" ] || { echo "chain spec sha256 ${got} is not the expected ${sha}" >&2; exit 1; }
|
||||
echo "chain spec sha256 matches"
|
||||
fi
|
||||
# The spec must parse, and its id is the directory the node keeps
|
||||
# this chain's state and miner credentials under.
|
||||
id=$(python3 -c "
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
Chain spec files the node deploy can run from (`CHAINSPEC_URL` / the
|
||||
`chainspec_url` input as a repo path, e.g. `asset/chainspec/mainnet.json`).
|
||||
Commit only a file verified against the publisher's checksum, and record that
|
||||
checksum in `CHAINSPEC_SHA256` so the deploy re-verifies it; the started node's
|
||||
genesis hash is asserted separately against `EXPECTED_GENESIS`.
|
||||
Reference in New Issue
Block a user