Skip to content

Commit

Permalink
add ci to verify if blocks are the same across snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
skylenet committed Oct 21, 2024
1 parent b3c7e2f commit 4953b26
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/verify-holesky.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Verify Sepolia

on:
schedule:
- cron: '*/30 * * * *'
workflow_dispatch:

jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run script
run: ./.hack/verify.sh holesky
16 changes: 16 additions & 0 deletions .github/workflows/verify-sepolia.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Verify Sepolia

on:
schedule:
- cron: '*/30 * * * *'
workflow_dispatch:

jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run script
run: ./.hack/verify.sh sepolia
38 changes: 38 additions & 0 deletions .hack/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Set the baseURL and network as configurable variables
network=${1:-sepolia}
baseURL=${2:-https://snapshots.ethpandaops.io}

# Array to store block numbers
block_numbers=()

# List of clients
clients=("geth" "besu" "nethermind" "reth")

echo "Verifying snapshot block numbers for network: $network"

# Loop through each client and fetch block numbers
for client in "${clients[@]}"; do
block_number=$(printf '%d\n' $(curl -s "$baseURL/$network/$client/latest/_snapshot_eth_getBlockByNumber.json" | jq -r '.result.number'))
block_numbers+=("$block_number")
echo "Block: $block_number ($client)"
done

# Verify if all block numbers are the same
first_block_number="${block_numbers[0]}"
all_same=true

for i in "${!clients[@]}"; do
if [[ "${block_numbers[$i]}" != "$first_block_number" ]]; then
echo "Block number mismatch detected for client: ${clients[$i]}"
all_same=false
fi
done

if [ "$all_same" = true ]; then
echo "✅ All block numbers are the same: https://${network}.etherscan.io/block/${first_block_number}"
else
echo "❌ Some block numbers are different."
exit 1
fi

0 comments on commit 4953b26

Please sign in to comment.