Skip to content

Instantly share code, notes, and snippets.

@d13co
Last active June 26, 2023 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d13co/edca626cedc62240b41becffcc0dd18d to your computer and use it in GitHub Desktop.
Save d13co/edca626cedc62240b41becffcc0dd18d to your computer and use it in GitHub Desktop.
calculate participation key generation factors
#!/bin/bash
set -e
address=$1
duration=$2
duration=${duration:-650000}
if [ "$address" == "" ]; then
echo "Usage: $0 <address> [<duration>]"
echo "address is mandatory. duration is optional"
exit 1
fi
start=$(goal node status | grep 'Last committed' | cut -d: -f2)
echo Current round: $start
start=$((start + 1))
echo "Start round: $start (+1)"
end=$((start + duration))
echo "End round: $end (+$duration)"
sqrt=`echo "scale=0; sqrt($((end-start)))" | bc`
echo "Dilution (sqrt(end-start)): $sqrt"
echo Command to run:
echo ""
echo "goal account addpartkey -a $address --roundFirstValid=$start --roundLastValid=$end --keyDilution=$sqrt"
@d13co
Copy link
Author

d13co commented Jun 26, 2023

To use this version:

Delete any old one if necessary

rm gen.sh

Download it

wget https://gist.githubusercontent.com/d13co/edca626cedc62240b41becffcc0dd18d/raw/9e777accb9d40c067634c055acd000caa4aa58a0/gen.sh

Make it executable

chmod +x gen.sh

Run it

./gen.sh <your-address> <participation-duration-in-number-of-rounds>

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