Skip to content
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
138 changes: 112 additions & 26 deletions .github/workflows/platform-sync.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,54 @@
name: Platform consensus check

# The packages of one Release run on Linux, Windows and macOS (Apple Silicon) each restore the
# published pruned snapshot with --download-snapshot and sync mainnet up to its head, with the
# executor running as the packages ship it. Every node logs its state digest each 1000 blocks: the
# three systems must log the same digests for the same blocks. The Windows and macOS packages are
# published only after this check has passed (PUBLISH_PLATFORMS in release.yml).
# The packages for Linux, Windows and macOS (Apple Silicon) each restore the published pruned
# snapshot with --download-snapshot and sync mainnet up to its head, with the executor running as the
# packages ship it. Every node logs its state digest each 1000 blocks: the three systems must log the
# same digests for the same blocks, reach the head at a speed in line with Linux, and stop cleanly
# (Linux and macOS exit with status 0, macOS leaves no crash report).
#
# Where the packages come from:
# - release.yml calls this workflow on the packages of its own run (release_run = its run id), and
# publishes the Windows and macOS packages only if it passes;
# - a scheduled run (weekly) and a manual run without inputs take the latest published community
# release, so that what users download is what is checked;
# - a manual run with release_run takes the packages of that Release run (a pull request's too).
on:
# a platform-sync-* tag checks the latest successful Release run (a manual run needs the workflow
# on the default branch)
schedule:
- cron: '0 5 * * 0' # Sunday 05:00 UTC
# a platform-sync-* tag checks the latest published release (a manual run needs the workflow on
# the default branch)
push:
tags: ['platform-sync-*']
workflow_dispatch:
inputs:
release_run:
description: 'Id of a Release workflow run whose artifacts hold the Linux, Windows and macOS packages (empty = the latest successful one)'
description: 'Id of a Release workflow run whose artifacts hold the Linux, Windows and macOS packages (empty = the latest published community release)'
default: ''
tag:
description: 'A published release to check, e.g. community-v4.2.532-community.14 (empty = the latest)'
default: ''
timeout_min:
description: 'Minutes each node has to reach the head (Linux needs about 5)'
default: '30'
min_common:
description: 'Blocks with a digest from all three systems needed to pass'
default: '5'
workflow_call:
inputs:
release_run:
description: 'Id of the Release run whose artifacts hold the packages: the calling run itself'
type: string
default: ''
current_run:
description: 'release_run is the calling run, still running: it is not checked for success'
type: boolean
default: false
timeout_min:
type: string
default: '30'
min_common:
type: string
default: '5'

permissions:
contents: read
Expand All @@ -30,29 +58,40 @@ jobs:
resolve:
runs-on: ubuntu-24.04
outputs:
run: ${{ steps.run.outputs.run }}
mode: ${{ steps.src.outputs.mode }}
run: ${{ steps.src.outputs.run }}
tag: ${{ steps.src.outputs.tag }}
steps:
- name: Release run
id: run
- name: Where the packages come from
id: src
env:
GH_TOKEN: ${{ github.token }}
IN_RUN: ${{ inputs.release_run }}
IN_TAG: ${{ inputs.tag }}
CURRENT_RUN: ${{ inputs.current_run }}
run: |
# only runs of code from this repository: a pull request from a fork builds packages too,
# and those binaries are not run here
trusted='[.workflow_runs[] | select(.conclusion == "success" and .head_repository.full_name == $repo)]'
run="$IN_RUN"
if [ -z "$run" ]; then
run=$(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/release.yml/runs?per_page=50" \
| jq -r --arg repo "$GITHUB_REPOSITORY" "$trusted | .[0].id // empty")
if [ -n "$IN_RUN" ]; then
echo "$IN_RUN" | grep -qE '^[0-9]+$' || { echo "bad run id '$IN_RUN'"; exit 1; }
if [ "$CURRENT_RUN" != true ]; then
# only runs of code from this repository: a pull request from a fork builds packages too,
# and those binaries are not run here
info=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$IN_RUN")
[ "$(jq -r .path <<< "$info")" = .github/workflows/release.yml ] || { echo "run $IN_RUN is not a Release run"; exit 1; }
[ "$(jq -r .head_repository.full_name <<< "$info")" = "$GITHUB_REPOSITORY" ] || { echo "run $IN_RUN built code from another repository"; exit 1; }
[ "$(jq -r .conclusion <<< "$info")" = success ] || { echo "run $IN_RUN did not succeed"; exit 1; }
fi
echo "the packages of Release run $IN_RUN"
printf 'mode=run\nrun=%s\ntag=\n' "$IN_RUN" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "$run" | grep -qE '^[0-9]+$' || { echo "bad run id '$run'"; exit 1; }
info=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$run")
[ "$(jq -r .path <<< "$info")" = .github/workflows/release.yml ] || { echo "run $run is not a Release run"; exit 1; }
[ "$(jq -r .head_repository.full_name <<< "$info")" = "$GITHUB_REPOSITORY" ] || { echo "run $run built code from another repository"; exit 1; }
[ "$(jq -r .conclusion <<< "$info")" = success ] || { echo "run $run did not succeed"; exit 1; }
echo "Release run $run"
echo "run=$run" >> "$GITHUB_OUTPUT"
tag="$IN_TAG"
if [ -z "$tag" ]; then
tag=$(gh release list --repo "$GITHUB_REPOSITORY" --limit 50 --json tagName,isDraft,isPrerelease \
--jq '[.[] | select((.isDraft or .isPrerelease) | not) | .tagName | select(startswith("community-v"))][0]')
fi
echo "$tag" | grep -qE '^community-v[0-9A-Za-z._-]+$' || { echo "no published community release found ('$tag')"; exit 1; }
echo "the packages of the published release $tag"
printf 'mode=tag\nrun=\ntag=%s\n' "$tag" >> "$GITHUB_OUTPUT"

sync:
name: Sync (${{ matrix.os }})
Expand Down Expand Up @@ -93,7 +132,8 @@ jobs:
- name: Python packages
run: python -m pip install --quiet thriftpy2 base58 pynacl

- name: Download the packages
- name: Download the packages of the run
if: needs.resolve.outputs.mode == 'run'
uses: actions/download-artifact@v4
with:
run-id: ${{ needs.resolve.outputs.run }}
Expand All @@ -102,6 +142,36 @@ jobs:
merge-multiple: true
path: packages

# what users download: the package of this system and the checksum files, checked here
- name: Download the packages of the release
if: needs.resolve.outputs.mode == 'tag'
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ needs.resolve.outputs.tag }}
PACKAGE: ${{ matrix.package }}
run: |
mkdir packages
gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --dir packages --pattern "$PACKAGE" --pattern 'SHA256SUMS*'
python -I - packages <<'PY'
import glob, hashlib, os, sys
root = sys.argv[1]
sums = {}
for f in glob.glob(os.path.join(root, "SHA256SUMS*")):
for line in open(f):
parts = line.split()
if len(parts) == 2:
sums[parts[1].lstrip("*")] = parts[0]
checked = 0
for f in glob.glob(os.path.join(root, "credits-node-*")):
name = os.path.basename(f)
h = hashlib.sha256(open(f, "rb").read()).hexdigest()
if sums.get(name) != h:
sys.exit(f"{name}: checksum {h} is not the published one {sums.get(name)}")
checked += 1
print(f"{name}: checksum ok")
sys.exit(0 if checked else "no package downloaded")
PY

- name: Unpack
env:
PACKAGE: ${{ matrix.package }}
Expand Down Expand Up @@ -235,4 +305,20 @@ jobs:
if bad or len(common) < need:
sys.exit(1)
print("the three systems agree")
# a clean stop: Linux and macOS exit with status 0 (Windows is stopped by taskkill: no status to
# read), and macOS leaves no crash report (the stop of a macOS node crashed once)
unclean = []
for os_name in ("linux", "macos"):
path = os.path.join(root, f"exit-{os_name}.txt")
text = open(path, errors="replace").read().strip() if os.path.exists(path) else "no exit status recorded"
print(f"{os_name}: {text}")
if not text.endswith("status 0"):
unclean.append(f"{os_name}: {text}")
reports = [f for f in os.listdir(root) if f.endswith(".ips")]
if reports:
unclean.append("crash reports: " + ", ".join(reports))
if unclean:
print("NOT A CLEAN STOP: " + "; ".join(unclean))
sys.exit(1)
print("the nodes stopped cleanly")
EOF
49 changes: 41 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ name: Release
# release ships, and the official configuration files kept in packaging/mainnet.
#
# A tag community-v<version> publishes a release; a manual run builds the packages as workflow
# artifacts and publishes only when asked.
# artifacts and publishes only when asked. The Linux packages are published at once; the Windows and
# macOS ones follow when the platform consensus check (platform-sync.yml) has passed on them.
on:
push:
tags: ['community-v*']
Expand Down Expand Up @@ -45,10 +46,6 @@ env:
TEMURIN_WINDOWS_SHA256: d5008f02174c1ad21c10407cbf104815cb390ec4c263d53946e8d0507d7a77f9
TEMURIN_MACOS: OpenJDK11U-jdk_aarch64_mac_hotspot_11.0.32.1_1.tar.gz
TEMURIN_MACOS_SHA256: c487a1c3a56588b3a32d0d07cdd526bf3d401c4b8422be772ca178bfcd647f3f
# the Windows and macOS packages join a published release: a node of each system matched the Linux
# state digests on mainnet (platform-sync.yml, run on the packages of this commit before the tag).
# 'false': they stay workflow artifacts
PUBLISH_PLATFORMS: 'true'

jobs:
# the node for Ubuntu 20.04 and later (glibc 2.31); the default build below needs glibc 2.38
Expand Down Expand Up @@ -221,7 +218,7 @@ jobs:

- node: ${GITHUB_REPOSITORY}@${GITHUB_SHA}
- contract executor: EnzinoBB/contract-executor release ${EXECUTOR_TAG}
- JDK: ojdkbuild 11.0.4, the one the official release ships
- JDK: ojdkbuild 11.0.4, the one the official release ships (Linux); Eclipse Temurin 11 (Windows, macOS)

One package for full and pruned storage: \`config.ini\` runs a full node, \`config.pruned.ini\` a pruned one on LMDB
(\`./node --config-file config.pruned.ini\`).
Expand Down Expand Up @@ -306,9 +303,45 @@ jobs:
path: dist/
retention-days: 30

# a node of each system, started from these packages, restores the published snapshot and syncs
# mainnet to its head: the state digests of the three systems must be the same, and the nodes must
# stop cleanly. A macOS job that finds no runner is cancelled by GitHub after 15 minutes: run the
# failed jobs again
platform-check:
name: Platform consensus check
needs: [package, platform-packages]
# a pull request that touches the packaging builds the packages only; a release (or a manual run)
# checks them against mainnet
if: needs.package.outputs.publish == 'true' || github.event_name == 'workflow_dispatch'
permissions:
contents: read
actions: read
uses: ./.github/workflows/platform-sync.yml
with:
release_run: ${{ github.run_id }}
current_run: true

# the Windows and macOS packages join the published release only once the check has passed
publish-platforms:
name: Publish the Windows and macOS packages
needs: [package, platform-check]
if: needs.package.outputs.publish == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 15
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.package.outputs.version }}
steps:
- name: Download the packages
uses: actions/download-artifact@v4
with:
name: credits-node-${{ env.VERSION }}-windows-macos
path: dist

- name: Publish
if: env.PUBLISH == 'true' && env.PUBLISH_PLATFORMS == 'true'
run: gh release upload "community-v${VERSION}" dist/* --clobber --repo "$GITHUB_REPOSITORY"
run: |
ls -la dist
gh release upload "community-v${VERSION}" dist/* --clobber --repo "$GITHUB_REPOSITORY"

# the Docker image of the package (the image chooses full or pruned at its first start: the
# package provides the binaries and the configuration template)
Expand Down
4 changes: 3 additions & 1 deletion docs/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ lines under the new release.

## Not released yet

Nothing yet.
| PR | Change |
|---|---|
| #119 | ci: the release checks the Windows and macOS packages on mainnet before publishing them (a node of each system restores the published snapshot, syncs to the head, logs the same state digests as Linux and stops cleanly), and the same check runs weekly on the latest published release |

## community.14 — 2026-10-27

Expand Down
Loading