Skip to content

Commit 8a3769f

Browse files
sanityclaude
andauthored
fix: wait for stretto cache insert before validation (#2215)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent f77ccfe commit 8a3769f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

crates/core/src/wasm_runtime/contract_store.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ impl ContractStore {
138138
let data = code.data().to_vec();
139139
self.contract_cache
140140
.insert(*code_hash, Arc::new(ContractCode::from(data)), size);
141+
// Wait for the cache insert to be visible. Stretto uses background threads
142+
// for inserts, and without wait() the value may not be immediately visible
143+
// to subsequent get() calls (eventual consistency). This is critical because
144+
// validate_state() needs to fetch the contract immediately after storing.
145+
let _ = self.contract_cache.wait();
141146

142147
// save on disc
143148
let version = APIVersion::from(contract);

crates/core/src/wasm_runtime/delegate_store.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ impl DelegateStore {
117117
let code_size = data.len() as i64;
118118
self.delegate_cache
119119
.insert(*code_hash, delegate.code().clone().into_owned(), code_size);
120+
// Wait for the cache insert to be visible. Stretto uses background threads
121+
// for inserts, and without wait() the value may not be immediately visible
122+
// to subsequent get() calls (eventual consistency).
123+
let _ = self.delegate_cache.wait();
120124

121125
// save on disc
122126
let version = APIVersion::from(delegate.clone());

0 commit comments

Comments
 (0)