Skip to content

Commit

Permalink
more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ZanCorDX committed Dec 19, 2024
1 parent b2a21b1 commit 8fb5a8b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/rbuilder/src/live_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ use crate::{
watchdog::spawn_watchdog_thread,
},
telemetry::inc_active_slots,
utils::{error_storage::spawn_error_storage_writer, Signer},
utils::{
error_storage::spawn_error_storage_writer, provider_head_state::ProviderHeadState, Signer,
},
};
use ahash::HashSet;
use alloy_consensus::Header;
Expand Down Expand Up @@ -218,13 +220,16 @@ where
?current_time,
payload_timestamp = ?payload.timestamp(),
?time_to_slot,
parent_hash = ?payload.parent_block_hash(),
provider_head_state = ?ProviderHeadState::new(&self.provider),
"Received payload, time till slot timestamp",
);

let time_until_slot_end = time_to_slot + timings.slot_proposal_duration;
if time_until_slot_end.is_negative() {
warn!(
slot = payload.slot(),
parent_hash = ?payload.parent_block_hash(),
"Slot already ended, skipping block building"
);
continue;
Expand All @@ -238,7 +243,7 @@ where
{
Ok(header) => header,
Err(err) => {
warn!("Failed to get parent header for new slot: {:?}", err);
warn!(parent_hash = ?payload.parent_block_hash(),"Failed to get parent header for new slot: {:?}", err);
continue;
}
}
Expand All @@ -247,6 +252,7 @@ where
debug!(
slot = payload.slot(),
block = payload.block(),
parent_hash = ?payload.parent_block_hash(),
"Got header for slot"
);

Expand Down
1 change: 1 addition & 0 deletions crates/rbuilder/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mod reconnect;
mod test_data_generator;
mod tx_signer;

pub mod provider_head_state;
#[cfg(test)]
pub mod test_utils;
pub mod tracing;
Expand Down
43 changes: 43 additions & 0 deletions crates/rbuilder/src/utils/provider_head_state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//! Mod for gathering info about reth's head.
use alloy_primitives::BlockNumber;
use reth_errors::ProviderResult;
use reth_provider::{BlockHashReader, BlockNumReader};
use revm_primitives::B256;

/// For debugging. Results of asking for block number + hash to a BlockHashReader+BlockNumReader
#[derive(Debug)]
pub struct ProviderHeadStateBlockHash {
/// Result of getting some (last/best) block number from the BlockNumReader
pub block_number: ProviderResult<BlockNumber>,
/// If block_number.is_ok -> Some(BlockHashReader::block_hash(block_number))
pub block_hash: Option<ProviderResult<Option<B256>>>,
}

impl ProviderHeadStateBlockHash {
pub fn new<P: BlockHashReader>(
provider: &P,
block_number: ProviderResult<BlockNumber>,
) -> Self {
Self {
block_number: block_number.clone(),
block_hash: block_number.map_or(None, |b| Some(provider.block_hash(b))),
}
}
}

/// For debugging. Results of asking to the StateProviderFactory info about last_block and best block.
#[derive(Debug)]
pub struct ProviderHeadState {
pub last_block: ProviderHeadStateBlockHash,
pub best_block: ProviderHeadStateBlockHash,
}

impl ProviderHeadState {
pub fn new<P: BlockNumReader>(provider: &P) -> Self {
Self {
last_block: ProviderHeadStateBlockHash::new(provider, provider.last_block_number()),
best_block: ProviderHeadStateBlockHash::new(provider, provider.best_block_number()),
}
}
}

0 comments on commit 8fb5a8b

Please sign in to comment.