Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ydm/57da75322a4b5e8a5d46c3cd08565646 to your computer and use it in GitHub Desktop.
Save ydm/57da75322a4b5e8a5d46c3cd08565646 to your computer and use it in GitHub Desktop.
#!/bin/bash
# NODE=${BEACON_NODE:-http://127.0.0.1:3500}
NODE=${BEACON_NODE:-http://testing.mainnet.beacon-api.nimbus.team}
out() { printf "%s %s\n" "$1" "$2"; }
error() { out "==> ERROR:" "$@"; } >&2
die() { error "$@"; exit 1; }
[ -z "$1" ] && die "usage: $0 <slot> <index>"
[ -z "$2" ] && die "usage: $0 <slot> <index>"
SLOT=$1
VALIDATOR=$2
HEADER="/tmp/header_${SLOT}.json"
STATE="/tmp/state_${SLOT}.json"
# Fetch the block header.
if [ ! -s "$HEADER" ] ; then
out "Fetching header: slot=$SLOT output=$HEADER ..."
curl \
--no-progress-meter \
"$NODE/eth/v1/beacon/headers/$SLOT" \
>"$HEADER"
fi
# Fetch the block state.
if [ ! -s "$STATE" ] ; then
out "Fetching state: slot=$SLOT output=$STATE ..."
curl \
--no-progress-meter \
"$NODE/eth/v2/debug/beacon/states/$SLOT" \
>"$STATE"
fi
# Generate proofs.
OUTPUT="fields_${SLOT}.json"
out "Generating fields proof: slot=$SLOT output=$OUTPUT ..."
./generation/generation \
-command ValidatorFieldsProof \
-oracleBlockHeaderFile "$HEADER" \
-stateFile "$STATE" \
-validatorIndex "$VALIDATOR" \
-outputFile "$OUTPUT" \
-chainID 1
# rm "$HEADER"
# rm "$STATE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment