Skip to content

Commit

Permalink
Merge branch 'blank_slate'
Browse files Browse the repository at this point in the history
  • Loading branch information
FiveMovesAhead committed Dec 18, 2024
2 parents a02d161 + def792a commit e57fd57
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tig-benchmarker/master/master/client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ async def get_jobs():
WHEN B.end_time IS NOT NULL THEN 'COMPLETED'
WHEN B.stopped IS NOT NULL THEN 'STOPPED'
WHEN B.merkle_proofs_ready = true THEN 'SUBMITTING PROOF'
WHEN B.sampled_nonces IS NOT NULL THEN 'COMPUTING PROOF'
WHEN B.sampled_nonces IS NOT NULL AND B.merkle_root_ready THEN 'COMPUTING PROOF'
WHEN B.sampled_nonces IS NULL AND B.merkle_root_ready THEN 'SUBMITTING ROOT'
ELSE 'COMPUTING ROOT'
END AS status,
Expand Down
3 changes: 2 additions & 1 deletion tig-benchmarker/master/master/job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ def run(self):
SELECT A.benchmark_id
FROM proofs_batch A
INNER JOIN job B
ON B.merkle_proofs_ready IS NULL
ON B.merkle_root_ready
AND B.merkle_proofs_ready IS NULL
AND A.benchmark_id = B.benchmark_id
GROUP BY A.benchmark_id
HAVING COUNT(*) = COUNT(A.ready)
Expand Down
28 changes: 20 additions & 8 deletions tig-benchmarker/master/master/slave_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def run(self):
FROM proofs_batch A
INNER JOIN job B
ON A.ready IS NULL
AND B.merkle_root_ready
AND B.stopped IS NULL
AND A.benchmark_id = B.benchmark_id
ORDER BY B.block_started, A.benchmark_id, A.batch_idx
Expand Down Expand Up @@ -168,9 +169,15 @@ async def submit_batch_root(batch_id: str, request: Request):
)
b["end_time"] = time.time() * 1000

logger.debug((await request.body()).decode())
result = await request.json()
logger.debug(f"slave {slave_name} submitted root for {batch_id}")
try:
result = await request.json()
merkle_root = MerkleHash.from_str(result["merkle_root"])
solution_nonces = result["solution_nonces"]
assert isinstance(solution_nonces, list) and all(isinstance(x, int) for x in solution_nonces)
logger.debug(f"slave {slave_name} submitted root for {batch_id}")
except Exception as e:
logger.error(f"slave {slave_name} submitted INVALID root for {batch_id}: {e}")
raise HTTPException(status_code=400, detail="INVALID root")

# Update roots table with merkle root and solution nonces
benchmark_id, batch_idx = batch_id.split("_")
Expand Down Expand Up @@ -198,8 +205,8 @@ async def submit_batch_root(batch_id: str, request: Request):
AND batch_idx = %s
""",
(
result["merkle_root"],
json.dumps(result["solution_nonces"]),
merkle_root.to_str(),
json.dumps(solution_nonces),
benchmark_id,
batch_idx
)
Expand Down Expand Up @@ -229,8 +236,13 @@ async def submit_batch_proofs(batch_id: str, request: Request):
)
b["end_time"] = time.time() * 1000

result = await request.json()
logger.debug(f"slave {slave_name} submitted proofs for {batch_id}")
try:
result = await request.json()
merkle_proofs = [MerkleProof.from_dict(x) for x in result["merkle_proofs"]]
logger.debug(f"slave {slave_name} submitted proofs for {batch_id}")
except Exception as e:
logger.error(f"slave {slave_name} submitted INVALID proofs for {batch_id}: {e}")
raise HTTPException(status_code=400, detail="INVALID proofs")

# Update proofs table with merkle proofs
benchmark_id, batch_idx = batch_id.split("_")
Expand All @@ -254,7 +266,7 @@ async def submit_batch_proofs(batch_id: str, request: Request):
AND batch_idx = %s
""",
(
json.dumps(result["merkle_proofs"]),
json.dumps([x.to_dict() for x in merkle_proofs]),
benchmark_id,
batch_idx
)
Expand Down
8 changes: 4 additions & 4 deletions tig-benchmarker/postgres/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,25 @@ SELECT '
"max_pending_benchmarks": 4,
"algo_selection": {
"satisfiability": {
"algorithm": "sat_global_opt",
"algorithm": "schnoing",
"num_nonces": 40,
"weight": 1,
"base_fee_limit": "10000000000000000"
},
"vehicle_routing": {
"algorithm": "advanced_routing",
"algorithm": "clarke_wright",
"num_nonces": 40,
"weight": 1,
"base_fee_limit": "10000000000000000"
},
"knapsack": {
"algorithm": "classic_quadkp",
"algorithm": "dynamic",
"num_nonces": 40,
"weight": 1,
"base_fee_limit": "10000000000000000"
},
"vector_search": {
"algorithm": "invector_hybrid",
"algorithm": "optimal_ann",
"num_nonces": 40,
"weight": 1,
"base_fee_limit": "10000000000000000"
Expand Down

0 comments on commit e57fd57

Please sign in to comment.