Skip to content

Instantly share code, notes, and snippets.

@garethtdavies
Created June 28, 2021 23:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garethtdavies/2eb8ecf459653b9c2aa93bc2512f17d6 to your computer and use it in GitHub Desktop.
Save garethtdavies/2eb8ecf459653b9c2aa93bc2512f17d6 to your computer and use it in GitHub Desktop.
Evaluate VRF output
# Generate the input for the epoch
for i in {49980..57120}; do echo "{\"globalSlot\": \"$i\",\"epochSeed\": \"2vb6kwsBmK8ZqJmoLeTXpofEMkXirHmtD6ixTEaiBzzqKmqyNQBD\",\"delegatorIndex\": 1276}"; done > input.txt
# Generate the batch witnesses
cat input.txt | mina advanced vrf batch-generate-witness --privkey-path ~/path-to-my-wallet > batch-generated.txt
# Add in the threshold for VRF evaluation
sed -i 's/]/],"vrfThreshold":{"delegatedStake":"1704440.324956633","totalStake":"829489852.840039300"}/g' batch-generated.txt
# Optional: Remove the using password lines if using env vars
sed -i -e 1,3d batch-generated.txt
# Generate the batch-check-witnesses
cat batch-generated.txt | mina advanced vrf batch-check-witness > batch-check.txt
# How many slots did we win
cat batch-check.txt | grep true | wc -l
# Which slots did we win
cat batch-check.txt | grep -B19 true | awk -F '\n' 'ln ~ /^$/ { ln = "matched"; print $1 } $1 ~ /^--$/ { ln = "" }'
@garethtdavies
Copy link
Author

Make a local GraphQL request to Mina daemon:

curl -d '{"query": "{
  account(publicKey: \"B62qpDpnXsUFR4TmaUYaBqcCUV1L1wsdsCcb7iRrvzJcU3ehiiUyoJd\") {
    index
  }
}"}' -H 'Content-Type: application/json' http://localhost:3085/graphql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment