Skip to content

Instantly share code, notes, and snippets.

@garethtdavies
Last active January 8, 2023 20:47
Show Gist options
  • Select an option

  • Save garethtdavies/408530cb44c1d8129bc8a877da7ffe17 to your computer and use it in GitHub Desktop.

Select an option

Save garethtdavies/408530cb44c1d8129bc8a877da7ffe17 to your computer and use it in GitHub Desktop.
Hacky export of snark pool
# Get snark-jobs.json from mina advanced snark-job-list > snark-jobs.json
# Get snark-pool.json from mina advanced snark-pool-list > snark-pool.json
import json
import numpy as np
import pandas as pd
output = []
# Trees are indexed from 0
treeNumber = 0
with open('./snark-jobs.json') as json_file:
data = json.load(json_file)
for tree in data:
for d in tree:
# Is this a merge or base transaction SNARK work
for key in d[1]:
workType = key
# Do we have any work for this slot?
if d[1][workType] and workType == "B":
# Base transactions just have a single work id
workId = d[1][workType][0]["Work_id"]
order = d[1][workType][1]
status = d[1][workType][2]["Status"]
elif d[1][workType] and workType == "M":
# Merge transactions have two work ids
workId = [d[1][workType][0]["Work_id"],d[1][workType][1]["Work_id"]]
order = d[1][workType][2]
status = d[1][workType][3]["Status"]
else:
workId = ""
order = ""
status = "Not used"
# Format the output
work = {
"tree": treeNumber,
"slot": d[0],
"type": workType,
"workId": workId,
"order": order,
"status": status,
"fees": 0,
"prover": "pending"
}
output.append(work)
treeNumber += 1
# Now append the fees
with open('./snark-pool.json') as json_file:
data = json.load(json_file)
for work in output:
if work["workId"]:
# Merge proofs have multiple work ids so check first
if work["type"] == "M":
workId = work["workId"][0]
#print(workId)
else:
workId = work["workId"]
# Is there matching work in the pool?
for d in data:
if workId in d["work_ids"]:
work["fees"] = float(d["fee"])
work["prover"] = d["prover"]
with open('./data.json', 'w') as outfile:
json.dump(output, outfile, indent=2)
df = pd.DataFrame(output)
#pd.set_option('display.max_rows', 150)
#pd.set_option('display.float_format', lambda x: '%.9f' % x)
todo = df[df.status=='Todo'].groupby(["fees", "prover"])["tree"].count()
print(todo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment