Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ralexstokes/f71e23d934eb9ee0b2ea087c27406d2f to your computer and use it in GitHub Desktop.
Save ralexstokes/f71e23d934eb9ee0b2ea087c27406d2f to your computer and use it in GitHub Desktop.
import itertools
import time
import requests
LH_URL = "http://<host-elided>/consensus/global_votes"
MEDALLA_GENESIS_TIME = 1596546008
def _current_epoch():
t = int(time.time())
return (t - MEDALLA_GENESIS_TIME) // 12 // 32
def _query_rate(epoch):
url = f"{LH_URL}?epoch={epoch}"
status = requests.get(url).json()
attesting_gwei = status["previous_epoch_attesting_gwei"]
total_gwei = status["previous_epoch_active_gwei"]
return attesting_gwei / total_gwei
def main():
for _ in itertools.count():
epoch = _current_epoch() - 1
participation_rate = _query_rate(epoch)
print(f"rate at epoch {epoch}: {participation_rate}")
time.sleep(32 * 12) # SLOTS_PER_EPOCH * SECONDS_PER_SLOT
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment