Skip to content

Commit

Permalink
Format timestamp in logs (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvush authored Mar 7, 2025
1 parent 43d7a9d commit 651e7d9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions crates/rbuilder/src/live_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ use crate::{
provider::StateProviderFactory,
telemetry::{inc_active_slots, mark_building_started, reset_histogram_metrics},
utils::{
error_storage::spawn_error_storage_writer, provider_head_state::ProviderHeadState, Signer,
error_storage::spawn_error_storage_writer, format_offset_datetime_rfc3339,
provider_head_state::ProviderHeadState, Signer,
},
};
use alloy_consensus::Header;
Expand Down Expand Up @@ -223,9 +224,8 @@ where
slot = payload.slot(),
block = payload.block(),
payload_id = payload.payload_id,
?current_time,
payload_timestamp = ?payload.timestamp(),
?time_to_slot,
payload_timestamp = format_offset_datetime_rfc3339(&payload.timestamp()),
time_to_slot_s = time_to_slot.as_seconds_f64(),
parent_hash = ?payload.parent_block_hash(),
provider_head_state = ?ProviderHeadState::new(&self.provider),
"Received payload, time till slot timestamp",
Expand Down
4 changes: 2 additions & 2 deletions crates/rbuilder/src/live_builder/payload_events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{
SlotSource,
},
primitives::mev_boost::{MevBoostRelayID, MevBoostRelaySlotInfoProvider},
utils::timestamp_ms_to_offset_datetime,
utils::{format_offset_datetime_rfc3339, timestamp_ms_to_offset_datetime},
};
use alloy_eips::{merge::SLOT_DURATION, BlockNumHash};
use alloy_primitives::{utils::format_ether, Address, B256, U256};
Expand Down Expand Up @@ -162,7 +162,7 @@ impl MevBoostSlotDataGenerator {
slot,
block,
?parent_hash,
?timestamp,
payload_timestamp = format_offset_datetime_rfc3339(&timestamp),
"Payload attributes received from CL client"
);

Expand Down
8 changes: 7 additions & 1 deletion crates/rbuilder/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use reth_chainspec::ChainSpec;
use reth_evm_ethereum::revm_spec_by_timestamp_and_block_number;
use revm_primitives::{CfgEnv, CfgEnvWithHandlerCfg};
pub use test_data_generator::TestDataGenerator;
use time::OffsetDateTime;
use time::{format_description::well_known::Rfc3339, OffsetDateTime};
pub use tx_signer::Signer;

/// de/serializes U256 as decimal value (U256 serde default is hexa). Needed to interact with some JSONs (eg:ProposerPayloadDelivered in relay provider API)
Expand Down Expand Up @@ -200,6 +200,12 @@ pub fn extract_onchain_block_txs(
Ok(result)
}

pub fn format_offset_datetime_rfc3339(datetime: &OffsetDateTime) -> String {
datetime
.format(&Rfc3339)
.expect("failed to format datetime")
}

#[cfg(test)]
mod test {
use super::*;
Expand Down

0 comments on commit 651e7d9

Please sign in to comment.