diff --git a/tig-benchmarker/master/master/client_manager.py b/tig-benchmarker/master/master/client_manager.py index 3d3ea743..f46667ed 100644 --- a/tig-benchmarker/master/master/client_manager.py +++ b/tig-benchmarker/master/master/client_manager.py @@ -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, diff --git a/tig-benchmarker/master/master/job_manager.py b/tig-benchmarker/master/master/job_manager.py index c1a461c5..82bbc0a6 100644 --- a/tig-benchmarker/master/master/job_manager.py +++ b/tig-benchmarker/master/master/job_manager.py @@ -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) diff --git a/tig-benchmarker/master/master/slave_manager.py b/tig-benchmarker/master/master/slave_manager.py index 39fcd6f4..100f2ffb 100644 --- a/tig-benchmarker/master/master/slave_manager.py +++ b/tig-benchmarker/master/master/slave_manager.py @@ -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 @@ -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("_") @@ -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 ) @@ -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("_") @@ -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 ) diff --git a/tig-benchmarker/postgres/init.sql b/tig-benchmarker/postgres/init.sql index c130c915..a822447d 100644 --- a/tig-benchmarker/postgres/init.sql +++ b/tig-benchmarker/postgres/init.sql @@ -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"