Skip to content

Commit 69bfa3f

Browse files
committed
Use spn network.
1 parent 3dcd2dc commit 69bfa3f

2 files changed

Lines changed: 35 additions & 38 deletions

File tree

script/bin/operator.rs

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -306,39 +306,36 @@ impl SP1AvailLightClientOperator {
306306
async fn run(&mut self, loop_delay_mins: u64) -> Result<()> {
307307
info!("Starting SP1 Helios operator for Avail");
308308

309-
loop {
310-
// Get the current slot from the contract
311-
let start = Instant::now();
312-
let slot = self.get_head().await?;
313-
info!("Current slot: {}", slot);
314-
315-
// Fetch the checkpoint at that slot
316-
let checkpoint = get_checkpoint(slot).await;
317-
318-
// Get the client from the checkpoint
319-
let client = get_client(checkpoint).await;
320-
321-
// Request an update
322-
match self.request_update(client).await {
323-
Ok(Some(proof)) => {
324-
self.relay_vector_update(proof).await?;
325-
}
326-
Ok(None) => {
327-
// Contract is up to date. Nothing to update.
328-
}
329-
Err(e) => {
330-
error!("Request for update failed: {}", e);
331-
info!("Retrying...");
332-
continue;
333-
}
334-
};
335-
let duration = start.elapsed();
336-
337-
info!("duration" = duration.as_secs(), "Loop finished");
338-
339-
info!("Sleeping for {:?} minutes", loop_delay_mins);
340-
tokio::time::sleep(tokio::time::Duration::from_secs(60 * loop_delay_mins)).await;
341-
}
309+
// Get the current slot from the contract
310+
let start = Instant::now();
311+
let slot = self.get_head().await?;
312+
info!("Current slot: {}", slot);
313+
314+
// Fetch the checkpoint at that slot
315+
let checkpoint = get_checkpoint(slot).await;
316+
317+
// Get the client from the checkpoint
318+
let client = get_client(checkpoint).await;
319+
320+
// Request an update
321+
match self.request_update(client).await {
322+
Ok(Some(proof)) => {
323+
self.relay_vector_update(proof).await?;
324+
}
325+
Ok(None) => {
326+
// Contract is up to date. Nothing to update.
327+
}
328+
Err(e) => {
329+
error!("Request for update failed: {}", e);
330+
return Err(e);
331+
}
332+
};
333+
let duration = start.elapsed();
334+
335+
info!("duration" = duration.as_secs(), "Loop finished");
336+
337+
info!("Sleeping for {:?} minutes", loop_delay_mins);
338+
Ok(())
342339
}
343340

344341
/// get_head reads head from the Avail chain
@@ -441,11 +438,11 @@ async fn main() -> Result<()> {
441438
.parse()?;
442439

443440
let mut operator = SP1AvailLightClientOperator::new().await;
444-
loop {
445-
if let Err(e) = operator.run(loop_delay_mins).await {
446-
error!("Error running operator: {}", e);
447-
}
441+
if let Err(e) = operator.run(loop_delay_mins).await {
442+
error!("Error running operator: {}", e);
443+
return Err(anyhow!("Error running operator: {}", e));
448444
}
445+
Ok(())
449446
}
450447

451448
#[cfg(test)]

script/bin/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async fn main() -> Result<()> {
2525
get_checkpoint(slot).await
2626
} else {
2727
// test slot
28-
get_checkpoint(7121216).await
28+
get_checkpoint(8386048).await
2929
};
3030

3131
// Setup client.

0 commit comments

Comments
 (0)