Skip to content

Commit

Permalink
fix: solve aggregator initialization race condition (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjemmmic authored Nov 20, 2024
1 parent c1037b3 commit 9cc7c80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,16 @@ impl AggregatorContext {
let task_index = task_response.referenceTaskIndex;
let task_response_digest = keccak256(TaskResponse::abi_encode(&task_response));

// Check if we have the task initialized first
if !self.tasks.lock().await.contains_key(&task_index) {
info!(
"Task {} not yet initialized, caching response for later processing",
task_index
);
self.response_cache.lock().await.push_back(resp);
return Ok(());
}

if self
.tasks_responses
.lock()
Expand Down
6 changes: 5 additions & 1 deletion blueprints/incredible-squaring-eigenlayer/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ pub async fn setup_task_spawner(
let quorums = Bytes::from(vec![0]);
async move {
loop {
tokio::time::sleep(std::time::Duration::from_millis(5000)).await;
// Increased delay to allow for proper task initialization
tokio::time::sleep(std::time::Duration::from_secs(10)).await;

info!("Creating a new task...");
if get_receipt(
Expand All @@ -270,6 +271,9 @@ pub async fn setup_task_spawner(
info!("Updated operators for quorum...");
}

// Wait for task initialization to complete
tokio::time::sleep(std::time::Duration::from_secs(2)).await;

tokio::process::Command::new("sh")
.arg("-c")
.arg(format!(
Expand Down

0 comments on commit 9cc7c80

Please sign in to comment.