Repository navigation
Add workflow that opens a PR bumping the min overlay version #5475
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| name: Overlay min version | ||
|
|
||
| # Once pubnet has upgraded to a new ledger protocol, opens a PR raising | ||
| # OVERLAY_PROTOCOL_MIN_VERSION to the lowest overlay version of the releases | ||
| # that support that protocol (see scripts/check-overlay-min-version.sh). | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '0 15 * * *' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| bump-overlay-min-version: | ||
| if: github.repository == 'stellar/stellar-core' | ||
| runs-on: ubuntu-24.04 | ||
| env: | ||
| BRANCH: bot/bump-overlay-min-version | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Get pubnet ledger protocol version | ||
| id: pubnet | ||
| run: | | ||
| PROTOCOL=$(curl -sSf --retry 3 https://horizon.stellar.org/ | jq -er '.current_protocol_version | numbers') | ||
| echo "Pubnet is on protocol $PROTOCOL" | ||
| echo "protocol=$PROTOCOL" >> "$GITHUB_OUTPUT" | ||
| - name: Raise OVERLAY_PROTOCOL_MIN_VERSION if possible | ||
| env: | ||
| PROTOCOL: ${{ steps.pubnet.outputs.protocol }} | ||
| run: | | ||
| set -o pipefail | ||
| ./scripts/check-overlay-min-version.sh --apply "$PROTOCOL" | tee "$RUNNER_TEMP/check.txt" | ||
| - name: Open or update PR | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| PROTOCOL: ${{ steps.pubnet.outputs.protocol }} | ||
| BASE: ${{ github.ref_name }} | ||
| run: | | ||
| if git diff --quiet | ||
| then | ||
| echo "OVERLAY_PROTOCOL_MIN_VERSION is up to date" | ||
| exit 0 | ||
| fi | ||
| MIN=$(sed -n 's/^[[:space:]]*OVERLAY_PROTOCOL_MIN_VERSION[[:space:]]*=[[:space:]]*\([0-9][0-9]*\).*/\1/p' src/main/Config.cpp) | ||
| # Leave an open PR alone if it already makes the same change. | ||
| OPEN_PR=$(gh pr list --head "$BRANCH" --base "$BASE" --state open --json number --jq '.[].number') | ||
| if [ -n "$OPEN_PR" ] && | ||
| git fetch --depth=1 origin "$BRANCH" 2>/dev/null && | ||
| git diff --quiet FETCH_HEAD -- src/main/Config.cpp | ||
| then | ||
| echo "$BRANCH already raises OVERLAY_PROTOCOL_MIN_VERSION to $MIN" | ||
| exit 0 | ||
| fi | ||
| git config user.name 'github-actions[bot]' | ||
| git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
| git checkout -B "$BRANCH" | ||
| git commit -qam "Bump OVERLAY_PROTOCOL_MIN_VERSION to $MIN" \ | ||
| -m "Pubnet is on protocol $PROTOCOL, and no release supporting it has an overlay version below $MIN." | ||
| git push -f origin "$BRANCH" | ||
| BODY="$RUNNER_TEMP/body.md" | ||
| { | ||
| echo "Pubnet is on protocol $PROTOCOL, and no release supporting it has an overlay version below $MIN, so this raises \`OVERLAY_PROTOCOL_MIN_VERSION\` to $MIN. Opened by the \`${{ github.workflow }}\` workflow." | ||
| echo | ||
| echo "**Reviewer:** before merging, verify that pubnet is on protocol $PROTOCOL and that every release supporting it, including any not tagged in this repo, has \`OVERLAY_PROTOCOL_VERSION\` of at least $MIN. Nodes below $MIN will be disconnected." | ||
| echo | ||
| echo '```' | ||
| cat "$RUNNER_TEMP/check.txt" | ||
| echo '```' | ||
| } > "$BODY" | ||
| if [ -z "$OPEN_PR" ] | ||
| then | ||
| gh pr create --base "$BASE" --head "$BRANCH" \ | ||
| --title "Bump OVERLAY_PROTOCOL_MIN_VERSION to $MIN" --body-file "$BODY" | ||
| else | ||
| gh pr edit "$OPEN_PR" \ | ||
| --title "Bump OVERLAY_PROTOCOL_MIN_VERSION to $MIN" --body-file "$BODY" | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| #!/bin/sh | ||
|
|
||
| # This script checks OVERLAY_PROTOCOL_MIN_VERSION (in src/main/Config.cpp) | ||
| # against the ledger protocol version a network is running. | ||
| # | ||
| # Once a network is on ledger protocol P, nodes need software supporting P to | ||
| # stay in sync, so the minimum overlay version can be raised to the lowest | ||
| # maximum overlay version (OVERLAY_PROTOCOL_VERSION) of any release that | ||
| # supports P. It should never be higher than that, or it would disconnect | ||
| # nodes running a release that can still follow the network. | ||
| # | ||
| # Usage: check-overlay-min-version.sh [--apply] <network-protocol> | ||
| # | ||
| # Takes the releases supporting <network-protocol> to be the release tags | ||
| # v<major>... with <major> at least <network-protocol>, relying on a release's | ||
| # major version being the ledger protocol version it supports, and compares | ||
| # OVERLAY_PROTOCOL_MIN_VERSION in the working tree against the lowest | ||
| # OVERLAY_PROTOCOL_VERSION among them. Exits with a non-zero status if the | ||
| # minimum is too high. If the minimum can be raised, says so, and with --apply | ||
| # rewrites it in the working tree. | ||
| # | ||
| # Requires the release tags to have been fetched. | ||
|
|
||
| set -e | ||
|
|
||
| SRCDIR=$(realpath "$(dirname "$0")/..") | ||
| CONFIG_CPP=src/main/Config.cpp | ||
|
|
||
| APPLY= | ||
| if [ "$1" = "--apply" ] | ||
| then | ||
| APPLY=1 | ||
| shift | ||
| fi | ||
|
|
||
| if [ $# -ne 1 ] | ||
| then | ||
| echo "usage: $0 [--apply] <network-protocol>" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| NETWORK_LEDGER=$1 | ||
| case "$NETWORK_LEDGER" in | ||
| ''|*[!0-9]*) | ||
| echo "error: network protocol must be a number, got '$NETWORK_LEDGER'" >&2 | ||
| exit 2 | ||
| ;; | ||
| esac | ||
|
|
||
| cd "$SRCDIR" | ||
|
|
||
| # file_at <rev> <file>: print the contents of <file> at <rev>, or the | ||
| # working tree copy if <rev> is empty. | ||
| file_at() | ||
| { | ||
| if [ -n "$1" ] | ||
| then | ||
| git show "$1:$2" | ||
| else | ||
| cat "$2" | ||
| fi | ||
| } | ||
|
|
||
| # extract <rev> <file> <name> <sed-expr>: print the numeric value assigned | ||
| # to <name> in <file> at <rev>, failing unless exactly one assignment is | ||
| # found. | ||
| extract() | ||
| { | ||
| if ! CONTENTS=$(file_at "$1" "$2") | ||
| then | ||
| echo "error: failed to read $2 at ${1:-working tree}" >&2 | ||
| exit 2 | ||
| fi | ||
| VAL=$(printf '%s\n' "$CONTENTS" | sed -n "$4") | ||
| case "$VAL" in | ||
| ''|*[!0-9]*) | ||
| echo "error: expected exactly one numeric assignment to $3 in $2 at ${1:-working tree}, got '$VAL'" >&2 | ||
| echo "(if the definition of $3 changed shape, update $0 to match)" >&2 | ||
| exit 2 | ||
| ;; | ||
| esac | ||
| echo "$VAL" | ||
| } | ||
|
|
||
| OVERLAY_EXPR='s/^[[:space:]]*OVERLAY_PROTOCOL_VERSION[[:space:]]*=[[:space:]]*\([0-9][0-9]*\).*/\1/p' | ||
| MIN_EXPR='s/^[[:space:]]*OVERLAY_PROTOCOL_MIN_VERSION[[:space:]]*=[[:space:]]*\([0-9][0-9]*\).*/\1/p' | ||
|
|
||
| # List the releases supporting ledger protocol $NETWORK_LEDGER, and set | ||
| # TARGET_MIN to the lowest OVERLAY_PROTOCOL_VERSION among them and TARGET_TAG | ||
| # to a release that has it. | ||
| release_target() | ||
| { | ||
| TARGET_MIN= | ||
| TARGET_TAG= | ||
| for T in $(git tag -l 'v[0-9]*' --sort=-v:refname) | ||
| do | ||
| MAJOR=${T#v} | ||
| MAJOR=${MAJOR%%[!0-9]*} | ||
| if [ "$MAJOR" -lt "$NETWORK_LEDGER" ] | ||
| then | ||
| break | ||
| fi | ||
| OVERLAY=$(extract "$T" "$CONFIG_CPP" OVERLAY_PROTOCOL_VERSION "$OVERLAY_EXPR") | ||
| echo " $T: OVERLAY_PROTOCOL_VERSION $OVERLAY" | ||
| if [ -z "$TARGET_MIN" ] || [ "$OVERLAY" -lt "$TARGET_MIN" ] | ||
| then | ||
| TARGET_MIN=$OVERLAY | ||
| TARGET_TAG=$T | ||
| fi | ||
| done | ||
| if [ -z "$TARGET_MIN" ] | ||
| then | ||
| echo "error: no release tag supports ledger protocol $NETWORK_LEDGER (tags not fetched?)" >&2 | ||
| exit 2 | ||
| fi | ||
| } | ||
|
|
||
| CODE_MIN=$(extract "" "$CONFIG_CPP" OVERLAY_PROTOCOL_MIN_VERSION "$MIN_EXPR") | ||
|
|
||
| echo "Releases supporting ledger protocol $NETWORK_LEDGER:" | ||
| release_target | ||
| echo "Lowest OVERLAY_PROTOCOL_VERSION among them: $TARGET_MIN ($TARGET_TAG)" | ||
| echo "OVERLAY_PROTOCOL_MIN_VERSION: $CODE_MIN" | ||
|
|
||
| if [ "$CODE_MIN" -gt "$TARGET_MIN" ] | ||
| then | ||
| echo "error: OVERLAY_PROTOCOL_MIN_VERSION ($CODE_MIN) is higher than the overlay version" >&2 | ||
| echo "of $TARGET_TAG ($TARGET_MIN), which supports protocol $NETWORK_LEDGER, so it would" >&2 | ||
| echo "disconnect nodes that can still follow the network." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$CODE_MIN" -eq "$TARGET_MIN" ] | ||
| then | ||
| echo "OK" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "OVERLAY_PROTOCOL_MIN_VERSION can be raised from $CODE_MIN to $TARGET_MIN" | ||
| if [ -n "$APPLY" ] | ||
| then | ||
| sed "s/^\([[:space:]]*OVERLAY_PROTOCOL_MIN_VERSION[[:space:]]*=[[:space:]]*\)$CODE_MIN;/\1$TARGET_MIN;/" "$CONFIG_CPP" > "$CONFIG_CPP.tmp" | ||
| mv "$CONFIG_CPP.tmp" "$CONFIG_CPP" | ||
| NEW_MIN=$(extract "" "$CONFIG_CPP" OVERLAY_PROTOCOL_MIN_VERSION "$MIN_EXPR") | ||
| if [ "$NEW_MIN" != "$TARGET_MIN" ] | ||
| then | ||
| echo "error: failed to update OVERLAY_PROTOCOL_MIN_VERSION in $CONFIG_CPP" >&2 | ||
| exit 2 | ||
| fi | ||
| echo "Updated $CONFIG_CPP" | ||
| fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.