-
-
Save garethtdavies/2eb8ecf459653b9c2aa93bc2512f17d6 to your computer and use it in GitHub Desktop.
Evaluate VRF output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = "" }' |
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
The following inputs are required:
globalSlot - there are 7140 slots in an epoch
epochSeed - get from GraphQL (see query below)
totalStake - get from GraphQL
account index - get from the daemon GraphQL
delegatedStake - can get this from a staking ledger
This query will return the index for an account:
This query will return the epoch seed and total stake for the provided epoch and next epoch from https://graphql.minaexplorer.com/:
This query will return the delegated stake from https://graphql.minaexplorer.com/ given a ledger hash (from above):
If you need the next epoch ledger use
nextstake
rather thanstake