Skip to content

Commit

Permalink
Revert beacon chain changes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Aug 9, 2023
1 parent 6b146c7 commit 1a86fab
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 50 deletions.
27 changes: 5 additions & 22 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2942,7 +2942,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// Optimistically imported blocks are not added to the cache since the cache is only useful
// for a small window of time and the complexity of keeping track of the optimistic status
// is not worth it.
let mut block_time_applied_to_early_attester_cache = None;
if !payload_verification_status.is_optimistic()
&& block.slot() + EARLY_ATTESTER_CACHE_HISTORIC_SLOTS >= current_slot
{
Expand All @@ -2964,12 +2963,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
"error" => ?e
);
}
debug!(
self.log,
"Inserted block into early attester cache";
"root" => ?block_root
);
block_time_applied_to_early_attester_cache = Some(timestamp_now());
} else {
warn!(
self.log,
Expand Down Expand Up @@ -3423,15 +3416,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// the cache during sync.
if block_delay_total < self.slot_clock.slot_duration() * 64 {
// Store the timestamp of the block being imported into the cache.
let mut block_times_cache = self.block_times_cache.write();
block_times_cache.set_time_imported(block_root, current_slot, block_time_imported);
if let Some(time) = block_time_applied_to_early_attester_cache {
block_times_cache.set_time_applied_to_early_attester_cache(
block_root,
current_slot,
time,
);
}
self.block_times_cache.write().set_time_imported(
block_root,
current_slot,
block_time_imported,
);
}

// Do not store metrics if the block was > 4 slots old, this helps prevent noise during
Expand All @@ -3451,12 +3440,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.imported
.unwrap_or_else(|| Duration::from_secs(0)),
);
if let Some(delay) = block_delays.applied_to_early_attester_cache {
metrics::observe_duration(
&metrics::BEACON_BLOCK_EARLY_ATTESTER_OBSERVED_DELAY_TIME,
delay,
);
}
}

if let Some(event_handler) = self.event_handler.as_ref() {
Expand Down
22 changes: 0 additions & 22 deletions beacon_node/beacon_chain/src/block_times_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub struct Timestamps {
pub observed: Option<Duration>,
pub imported: Option<Duration>,
pub set_as_head: Option<Duration>,
pub applied_to_early_attester_cache: Option<Duration>,
}

// Helps arrange delay data so it is more relevant to metrics.
Expand All @@ -29,7 +28,6 @@ pub struct BlockDelays {
pub observed: Option<Duration>,
pub imported: Option<Duration>,
pub set_as_head: Option<Duration>,
pub applied_to_early_attester_cache: Option<Duration>,
}

impl BlockDelays {
Expand All @@ -43,17 +41,10 @@ impl BlockDelays {
let set_as_head = times
.set_as_head
.and_then(|set_as_head_time| set_as_head_time.checked_sub(times.imported?));
let applied_to_early_attester_cache =
times
.applied_to_early_attester_cache
.and_then(|applied_to_early_attester_cache| {
applied_to_early_attester_cache.checked_sub(times.observed?)
});
BlockDelays {
observed,
imported,
set_as_head,
applied_to_early_attester_cache,
}
}
}
Expand Down Expand Up @@ -124,19 +115,6 @@ impl BlockTimesCache {
block_times.timestamps.set_as_head = Some(timestamp);
}

pub fn set_time_applied_to_early_attester_cache(
&mut self,
block_root: BlockRoot,
slot: Slot,
timestamp: Duration,
) {
let block_times = self
.cache
.entry(block_root)
.or_insert_with(|| BlockTimesCacheValue::new(slot));
block_times.timestamps.applied_to_early_attester_cache = Some(timestamp);
}

pub fn get_block_delays(
&self,
block_root: BlockRoot,
Expand Down
6 changes: 0 additions & 6 deletions beacon_node/beacon_chain/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,12 +835,6 @@ lazy_static! {
// [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5]
decimal_buckets(-2,-1)
);
pub static ref BEACON_BLOCK_EARLY_ATTESTER_OBSERVED_DELAY_TIME: Result<Histogram> = try_create_histogram_with_buckets(
"beacon_block_early_attester_observed_delay_time",
"Duration between the time the block was observed and the time when it was applied to the early attester cache.",
// [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5]
decimal_buckets(-2,0)
);
pub static ref BEACON_BLOCK_HEAD_SLOT_START_DELAY_TIME: Result<Histogram> = try_create_histogram_with_buckets(
"beacon_block_head_slot_start_delay_time",
"Duration between the start of the block's slot and the time when it was set as head.",
Expand Down

0 comments on commit 1a86fab

Please sign in to comment.