-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e2cc8f
commit f8b4918
Showing
12 changed files
with
147 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use std::time::SystemTime; | ||
|
||
use anyhow::bail; | ||
use log::debug; | ||
use tokio::time::{sleep, Duration}; | ||
|
||
use super::{config::FullLightClientProverConfig, Result}; | ||
use crate::node::Node; | ||
|
||
pub type LightClientProver = Node<FullLightClientProverConfig>; | ||
|
||
impl LightClientProver { | ||
// TODO: remove _l at the end | ||
pub async fn wait_for_l1_height_l(&self, height: u64, timeout: Option<Duration>) -> Result<()> { | ||
let start = SystemTime::now(); | ||
let timeout = timeout.unwrap_or(Duration::from_secs(600)); | ||
loop { | ||
debug!("Waiting for light client prover height {}", height); | ||
let latest_block = self.client.ledger_get_last_scanned_l1_height().await?; | ||
|
||
if latest_block >= height { | ||
break; | ||
} | ||
|
||
let now = SystemTime::now(); | ||
if start + timeout <= now { | ||
bail!( | ||
"Timeout. Latest light client prover L1 height is {}", | ||
latest_block | ||
); | ||
} | ||
|
||
sleep(Duration::from_secs(1)).await; | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.