Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronize with L1 Slot Start Time #96

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Node/src/ethereum_l1/slot_clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl SlotClock {
self.slots_per_epoch
}

fn duration_to_next_slot(&self) -> Result<Duration, Error> {
pub fn duration_to_next_slot(&self) -> Result<Duration, Error> {
let now = SystemTime::now().duration_since(UNIX_EPOCH)?;
self.duration_to_next_slot_from(now)
}
Expand Down
9 changes: 6 additions & 3 deletions Node/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use tokio::sync::{
mpsc::{Receiver, Sender},
Mutex,
};
use tokio::time::{sleep, Duration};
use tracing::info;

pub mod block_proposed_receiver;
Expand Down Expand Up @@ -240,9 +241,11 @@ impl Node {
}

async fn preconfirmation_loop(&mut self) {
// TODO syncronize with slot clock
let mut interval =
tokio::time::interval(std::time::Duration::from_secs(self.l2_slot_duration_sec));
// Synchronize with L1 Slot Start Time
mikhailUshakoff marked this conversation as resolved.
Show resolved Hide resolved
let duration_to_next_slot = self.ethereum_l1.slot_clock.duration_to_next_slot().unwrap();
sleep(duration_to_next_slot).await;
// start preconfirmation loop
let mut interval = tokio::time::interval(Duration::from_secs(self.l2_slot_duration_sec));
loop {
interval.tick().await;

Expand Down
Loading