Skip to content

Commit 2a3752f

Browse files
committed
fix: avoid block_in_place panic in module_exists
Use sync version that checks cache and filesystem only. Add async version for cases where distributed storage check is needed.
1 parent d1a1601 commit 2a3752f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

bins/validator-node/src/wasm_executor.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,16 +1014,28 @@ impl WasmChallengeExecutor {
10141014
}
10151015

10161016
pub fn module_exists(&self, module_path: &str) -> bool {
1017-
// Check filesystem first
1017+
// Check module cache first
1018+
if self.module_cache.read().contains_key(module_path) {
1019+
return true;
1020+
}
1021+
// Check filesystem
1022+
self.resolve_module_path(module_path).exists()
1023+
}
1024+
1025+
/// Async version that also checks distributed storage
1026+
pub async fn module_exists_async(&self, module_path: &str) -> bool {
1027+
// Check module cache first
1028+
if self.module_cache.read().contains_key(module_path) {
1029+
return true;
1030+
}
1031+
// Check filesystem
10181032
if self.resolve_module_path(module_path).exists() {
10191033
return true;
10201034
}
10211035
// Check distributed storage
10221036
if let Some(ref storage) = self.config.distributed_storage {
10231037
let key = platform_distributed_storage::StorageKey::new("wasm", module_path);
1024-
if let Ok(exists) = tokio::task::block_in_place(|| {
1025-
tokio::runtime::Handle::current().block_on(storage.exists(&key))
1026-
}) {
1038+
if let Ok(exists) = storage.exists(&key).await {
10271039
return exists;
10281040
}
10291041
}

0 commit comments

Comments
 (0)