Skip to content

Commit

Permalink
logging improved, read lookahead at before preconf loop (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
mskrzypkows authored Sep 19, 2024
1 parent 26c9fbb commit 0f88573
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
14 changes: 11 additions & 3 deletions Node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@ async fn main() -> Result<(), Error> {
}

fn init_logging() {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG)
.init();
use tracing_subscriber::{fmt, EnvFilter};

let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| {
EnvFilter::new("debug")
.add_directive("reqwest=info".parse().unwrap())
.add_directive("hyper=info".parse().unwrap())
.add_directive("alloy_transport=info".parse().unwrap())
.add_directive("alloy_rpc_client=info".parse().unwrap())
});

fmt().with_env_filter(filter).init();
}
10 changes: 9 additions & 1 deletion Node/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ impl Node {
// Synchronize with L1 Slot Start Time
let duration_to_next_slot = self.ethereum_l1.slot_clock.duration_to_next_slot().unwrap();
sleep(duration_to_next_slot).await;

if let Err(err) = self.operator.update_preconfer_lookahead_for_epoch().await {
tracing::error!(
"Failed to update preconfer lookahead before starting preconfirmation loop: {}",
err
);
}

// start preconfirmation loop
let mut interval = tokio::time::interval(Duration::from_secs(self.l2_slot_duration_sec));
loop {
Expand Down Expand Up @@ -316,7 +324,7 @@ impl Node {
}

async fn new_epoch_started(&mut self, new_epoch: u64) -> Result<(), Error> {
tracing::debug!("Current epoch changed from {} to {}", self.epoch, new_epoch);
tracing::info!("Current epoch changed from {} to {}", self.epoch, new_epoch);
self.epoch = new_epoch;

self.operator = Operator::new(self.ethereum_l1.clone(), new_epoch)?;
Expand Down
7 changes: 7 additions & 0 deletions Node/src/node/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ impl Operator {
}

pub async fn update_preconfer_lookahead_for_epoch(&mut self) -> Result<(), Error> {
tracing::debug!(
"Updating preconfer lookahead for epoch: {}",
self.ethereum_l1
.slot_clock
.get_epoch_for_timestamp(self.epoch_begin_timestamp)?
);

if let Some(lookahead_preconfer_addresses_next_epoch) =
self.lookahead_preconfer_addresses_next_epoch.take()
{
Expand Down

0 comments on commit 0f88573

Please sign in to comment.