Skip to content

Commit

Permalink
jwt fix
Browse files Browse the repository at this point in the history
  • Loading branch information
debjit-bw committed Oct 11, 2024
1 parent 444badb commit 08ff5c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/post-merge-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
- name: Test jq is installed
run: jq --help
# Vectors are already generated, but this serves as a test
# - name: Generate vectors
# run: bash ./scripts/generate_test_vectors_nethermind.sh
- name: Generate vectors
run: bash ./scripts/generate_test_vectors_nethermind.sh
# Test vectors against nethermind
- name: Install jwt and add to path
run: cargo install jwt-cli && export PATH=$HOME/.cargo/bin:$PATH
Expand Down
35 changes: 7 additions & 28 deletions scripts/generate_test_vectors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,43 +29,23 @@ check_nethermind_availability() {
# return 0
}

echo "Waiting for Nethermind to become available..."

# Wait for Nethermind to become available
while ! check_nethermind_availability; do
sleep 2
done

echo "Nethermind is available"

BLOCK_COUNTER=0
MAX_RETRIES=3

function make_block() {
((BLOCK_COUNTER++))
RETRIES=0

while [ $RETRIES -lt $MAX_RETRIES ]; do
HEAD_BLOCK=$(curl -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false],"id":1}' \
http://localhost:8545)

# Extract block hash and proceed if it's valid
HEAD_BLOCK_HASH=$(echo $HEAD_BLOCK | jq --raw-output '.result.hash')
if [ "$HEAD_BLOCK_HASH" != "null" ]; then
echo "HEAD_BLOCK_HASH=$HEAD_BLOCK_HASH"
break
fi

echo "Failed to get head block, retrying... ($RETRIES/$MAX_RETRIES)"
RETRIES=$((RETRIES + 1))
sleep 2
done

if [ $RETRIES -ge $MAX_RETRIES ]; then
echo "Failed to retrieve head block after $MAX_RETRIES attempts, exiting."
exit 1
fi
HEAD_BLOCK=$(curl -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false],"id":1}' \
http://localhost:8545)

# --raw-output remove the double quotes
HEAD_BLOCK_HASH=$(echo $HEAD_BLOCK | jq --raw-output '.result.hash')
echo HEAD_BLOCK_HASH=$HEAD_BLOCK_HASH

# The ASCII representation of `2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a`
JWT_SECRET="********************************"
Expand Down Expand Up @@ -177,7 +157,6 @@ N=5

for ((i = 1; i <= N; i++)); do
echo "Making block $i"
sleep 2
make_block
done

0 comments on commit 08ff5c1

Please sign in to comment.