Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0dfafb2
Add check_bootnode script and github action
s3krit Mar 14, 2023
5bb0a9e
fix mktemp for linux machines
s3krit Mar 14, 2023
2350fb5
Update check_bootnodes.sh
s3krit Mar 14, 2023
7470da0
fix ephemeral ports and fetch polkadot
s3krit Mar 15, 2023
2d31104
Merge branch 'mp-bootnode-checker' of github.com:paritytech/polkadot …
s3krit Mar 15, 2023
134127c
fix check-bootnodes.yml
s3krit Mar 15, 2023
1af8d0b
increase node spawn holdoff
s3krit Mar 15, 2023
c668286
disable fail-fast
s3krit Mar 15, 2023
1cebfd8
refactor, separate out check_bootnodes and make it posix-compliant
s3krit Mar 15, 2023
1170e84
add new job for detecting new bootnodes
s3krit Mar 15, 2023
feec2e4
fix check-bootnodes.yml
s3krit Mar 15, 2023
da4da9a
only check all bootnodes on release
s3krit Mar 15, 2023
540dd97
Add test bad bootnode
s3krit Mar 15, 2023
5ee885a
fix paths
s3krit Mar 15, 2023
5b465ab
fix paths and git... hopefully
s3krit Mar 15, 2023
9d1a4be
this better work...
s3krit Mar 15, 2023
1e106e7
fix
s3krit Mar 15, 2023
db27961
test
s3krit Mar 15, 2023
fc9a45e
last test
s3krit Mar 15, 2023
db701fb
Revert "Add test bad bootnode"
s3krit Mar 15, 2023
c815413
Merge remote-tracking branch 'origin' into mp-bootnode-checker
s3krit Mar 16, 2023
1733e63
Update check_bootnodes.sh
s3krit Mar 16, 2023
9f76d0e
optimisations
s3krit Mar 16, 2023
9dc9a6a
Merge branch 'mp-bootnode-checker' of github.com:paritytech/polkadot …
s3krit Mar 16, 2023
3f9d31b
increase holdoff to 5 seconds
s3krit Mar 16, 2023
ea5f71c
dont delete chainspec til we kill the node
s3krit Mar 16, 2023
45a94cc
Update check-bootnodes.yml
s3krit Mar 20, 2023
cce201e
Remove checking bootnodes on pushing of this branch
s3krit Mar 20, 2023
90c3faa
Merge remote-tracking branch 'origin/master' into mp-bootnode-checker
Mar 21, 2023
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
Prev Previous commit
Next Next commit
add new job for detecting new bootnodes
  • Loading branch information
s3krit committed Mar 15, 2023
commit 1170e847047953d8f5a34089e09135058f3775e3
25 changes: 25 additions & 0 deletions .github/workflows/check-new-bootnodes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# If a chainspec file is updated with new bootnodes, we check to make sure those bootnodes are contactable

name: Check new bootnodes
on:
pull_request:
paths:
- 'node/service/chain-specs/*.json'

jobs:
check_bootnodes:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Install polkadot
shell: bash
run: |
curl -L "$(curl -s https://api.github.com/repos/paritytech/polkadot/releases/latest \
| jq -r '.assets | .[] | select(.name == "polkadot").browser_download_url')" \
| sudo tee /usr/local/bin/polkadot > /dev/null
sudo chmod +x /usr/local/bin/polkadot
polkadot --version
- name: Check new bootnodes
shell: bash
run: scripts/ci/github/check_new_bootnodes.sh
16 changes: 6 additions & 10 deletions scripts/ci/github/check_bootnodes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@
# been able to contact any other nodes, we can reason that the bootnode we used is not well-connected
# or is otherwise uncontactable.

# Root of the polkadot dir
ROOT="$(dirname "${0}")/../../.."
# shellcheck source=scripts/ci/common/lib.sh
source "$ROOT/scripts/ci/common/lib.sh"
RUNTIME="$1"
source "$(dirname "${0}")/../common/lib.sh"
CHAINSPEC_FILE="$1"
RUNTIME=$(basename "$CHAINSPEC_FILE" | cut -d '.' -f 1)

trap cleanup EXIT INT TERM

cleanup(){
echo "[+] Script interrupted or ended. Cleaning up..."
# Kill all the polkadot processes
killall polkadot > /dev/null 2>&1
exit $1
}

# For each runtime
CHAINSPEC_FILE="$ROOT/node/service/chain-specs/$RUNTIME.json"
# count the number of bootnodes
BOOTNODES=$( jq -r '.bootNodes | length' "$CHAINSPEC_FILE" )
# Make a temporary dir for chainspec files
Expand Down Expand Up @@ -66,10 +64,8 @@ if [ ${#BAD_BOOTNODES[@]} -gt 0 ]; then
for i in "${BAD_BOOTNODES[@]}"; do
echo " $i"
done
cleanup
exit 1
cleanup 1
else
echo "[+] All bootnodes for $RUNTIME are contactable"
cleanup
exit 0
cleanup 0
fi
41 changes: 41 additions & 0 deletions scripts/ci/github/check_new_bootnodes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
ROOT="$(dirname "${0}")/../../.."
source "$ROOT/scripts/ci/common/lib.sh"

# This script checks any new bootnodes added since the last git commit

RUNTIMES=( kusama westend polkadot )

WAS_ERROR=0

for RUNTIME in "${RUNTIMES[@]}"; do
CHAINSPEC_FILE="$ROOT/node/service/chain-specs/$RUNTIME.json"
# Get the bootnodes from master's chainspec
git show origin/master:"$CHAINSPEC_FILE" | jq '{"oldNodes": .bootNodes}' > "$RUNTIME-old-bootnodes.json"
# Get the bootnodes from the current branch's chainspec
git show HEAD:"$CHAINSPEC_FILE" | jq '{"newNodes": .bootNodes}' > "$RUNTIME-new-bootnodes.json"
# Make a chainspec containing only the new bootnodes
jq ".bootNodes = $(jq -rs '.[0] * .[1] | .newNodes-.oldNodes' \
"$RUNTIME-new-bootnodes.json" "$RUNTIME-old-bootnodes.json")" \
< "$ROOT/node/service/chain-specs/$RUNTIME.json" \
> "$RUNTIME-new-chainspec.json"
# exit early if the new chainspec has no bootnodes
if [ "$(jq -r '.bootNodes | length' "$RUNTIME-new-chainspec.json")" -eq 0 ]; then
echo "[+] No new bootnodes for $RUNTIME"
# Clean up the temporary files
rm "$RUNTIME-new-chainspec.json" "$RUNTIME-old-bootnodes.json" "$RUNTIME-new-bootnodes.json"
continue
fi
# Check the new bootnodes
if ! "$ROOT/scripts/ci/github/check_bootnodes.sh" "$RUNTIME-new-chainspec.json"; then
WAS_ERROR=1
fi
# Clean up the temporary files
rm "$RUNTIME-new-chainspec.json" "$RUNTIME-old-bootnodes.json" "$RUNTIME-new-bootnodes.json"
done


if [ $WAS_ERROR -eq 1 ]; then
echo "[!] One of the new bootnodes failed to connect. Please check logs above."
exit 1
fi