Skip to content

Commit 3056290

Browse files
MoonBoi9001claude
andcommitted
perf(index-node): make proofOfIndexing resolver async
Remove synchronous `block_on` call in `resolve_proof_of_indexing` which was blocking tokio worker threads while waiting for database queries. Before this change, each POI query blocked an entire tokio worker thread. After this change, POI queries properly yield to the async runtime while waiting for database I/O, allowing the connection pool to be fully utilized. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6af75ba commit 3056290

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

server/index-node/src/resolver.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,10 @@ where
352352
))
353353
}
354354

355-
fn resolve_proof_of_indexing(&self, field: &a::Field) -> Result<r::Value, QueryExecutionError> {
355+
async fn resolve_proof_of_indexing(
356+
&self,
357+
field: &a::Field,
358+
) -> Result<r::Value, QueryExecutionError> {
356359
let deployment_id = field
357360
.get_required::<DeploymentHash>("subgraph")
358361
.expect("Valid subgraphId required");
@@ -381,7 +384,7 @@ where
381384
let poi_fut = self
382385
.store
383386
.get_proof_of_indexing(&deployment_id, &indexer, block.clone());
384-
let poi = match graph::futures03::executor::block_on(poi_fut) {
387+
let poi = match poi_fut.await {
385388
Ok(Some(poi)) => r::Value::String(format!("0x{}", hex::encode(poi))),
386389
Ok(None) => r::Value::Null,
387390
Err(e) => {
@@ -791,7 +794,7 @@ where
791794
field.name.as_str(),
792795
scalar_type.name.as_str(),
793796
) {
794-
("Query", "proofOfIndexing", "Bytes") => self.resolve_proof_of_indexing(field),
797+
("Query", "proofOfIndexing", "Bytes") => self.resolve_proof_of_indexing(field).await,
795798
("Query", "blockData", "JSONObject") => self.resolve_block_data(field).await,
796799
("Query", "blockHashFromNumber", "Bytes") => {
797800
self.resolve_block_hash_from_number(field).await

0 commit comments

Comments
 (0)