Skip to content

fix: remove enr padding #38

fix: remove enr padding

fix: remove enr padding #38

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: Install protobuf-compiler
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Install enr-cli
run: cargo install enr-cli
- name: Install .yaml parser
run: wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
- 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: Check ENR Strings with enr-cli
run: |
for FILE in $(find . -type f \( -name 'bootnodes.yaml' -o -name 'bootstrap_nodes.txt' \)); do
echo "Testing decoding in file: $FILE"
while IFS= read -r LINE; do
if [[ "$LINE" =~ enr: ]]; then
if [[ "$FILE" == *".yaml" ]]; then
BASE64_STRING=${LINE#enr:}
elif [[ "$FILE" == *".txt" ]]; then
BASE64_STRING=$(echo "$LINE" | grep -o 'enr:.*')
else
echo "Unsupported file type: $FILE"
exit 1
fi
BASE64_STRING=$(echo "$BASE64_STRING" | awk '{gsub(/"/, "", $0); print}')
if [[ -n "$BASE64_STRING" ]]; then
enr-cli read "$BASE64_STRING" 1>/dev/null
if [ $? -ne 0 ]; then
echo "Error: ENR could not be decoded in $FILE: enr:$BASE64_STRING"
exit 1
fi
fi
fi
done < "$FILE"
done