Skip to content

fix: remove enr padding #23

fix: remove enr padding

fix: remove enr padding #23

name: Check Bootnodes ENRs
on:
pull_request:
branches:
- main
jobs:
check_enrs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Check bootnodes ENRs for padding
run: |
files_with_padding=""
for FILE in $(find . -type f \( -name 'bootnodes.yaml' -o -name 'bootstrap_nodes.txt' \)); do
echo "Checking paddings in file: $FILE"
while read -r LINE; do
if [[ "$LINE" =~ enr: ]]; then
BASE64_STRING=${LINE#enr:}
if [[ "$BASE64_STRING" =~ = ]]; then
if [[ "$files_with_padding" != *"$FILE"* ]]; then
echo "Error: ENR in $FILE contains padding: $LINE"
files_with_padding="$files_with_padding $FILE"
fi
fi
fi
done < "$FILE"
done
if [ -n "$files_with_padding" ]; then
echo "Error: Bootnodes ENR strings contain padding in the following files:"
echo "$files_with_padding"
exit 1
fi
- name: Decode Base64
run: |
files_with_decoding_issue=""
for FILE in $(find . -type f \( -name 'bootnodes.yaml' -o -name 'bootstrap_nodes.txt' \)); do
echo "Testing decoding in file: $FILE"
while read -r LINE; do
if [[ "$LINE" =~ enr: ]]; then
BASE64_STRING=${LINE#enr:}
BASE64_STRING="${BASE64_STRING%%\"*}" # Trim any trailing double quotes
echo "$BASE64_STRING"
base64 -d <<< "$BASE64_STRING" 1>/dev/null
if [ $? -ne 0 ]; then
if [[ "$files_with_decoding_issue" != *"$FILE"* ]]; then
echo "Error: ENR could not be decoded in $FILE: $LINE"
files_with_decoding_issue="$files_with_decoding_issue $FILE"
fi
fi
fi
done < "$FILE"
done
if [ -n "$files_with_decoding_issue" ]; then
echo "Error: Bootnodes ENR strings have decoding issues in the following files:"
echo "$files_with_decoding_issue"
exit 1
fi