From 59c1972df726a37d33adb5589fc0d9f2619b272d Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 24 Oct 2022 15:02:43 +1100 Subject: [PATCH] Fix some low-hanging FIXMEs --- .../beacon_chain/src/beacon_fork_choice_store.rs | 1 - beacon_node/beacon_chain/src/canonical_head.rs | 4 +--- beacon_node/beacon_chain/src/lib.rs | 1 - beacon_node/beacon_chain/src/metrics.rs | 5 +++++ beacon_node/store/src/hot_cold_store.rs | 12 +++++------- beacon_node/store/src/validator_pubkey_cache.rs | 3 +-- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs b/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs index dc7bcacd17..6a5ff05932 100644 --- a/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs +++ b/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs @@ -197,7 +197,6 @@ where }; let finalized_checkpoint = justified_checkpoint; - // FIXME(sproul): avoid `to_vec` perf penalty Self { store, balances_cache: <_>::default(), diff --git a/beacon_node/beacon_chain/src/canonical_head.rs b/beacon_node/beacon_chain/src/canonical_head.rs index 47baeba7d9..b776bf5cfb 100644 --- a/beacon_node/beacon_chain/src/canonical_head.rs +++ b/beacon_node/beacon_chain/src/canonical_head.rs @@ -626,7 +626,6 @@ impl BeaconChain { .get_full_block(&new_view.head_block_root, None)? .ok_or(Error::MissingBeaconBlock(new_view.head_block_root))?; - // FIXME(sproul): use advanced state? let beacon_state_root = beacon_block.state_root(); let beacon_state: BeaconState = self .get_state(&beacon_state_root, Some(beacon_block.slot()))? @@ -1288,8 +1287,7 @@ fn observe_head_block_delays( // If the block was enshrined as head too late for attestations to be created for it, // log a debug warning and increment a metric. if late_head { - // FIXME(sproul): restore this metric, idk where it went - // metrics::inc_counter(&metrics::BEACON_BLOCK_HEAD_SLOT_START_DELAY_EXCEEDED_TOTAL); + metrics::inc_counter(&metrics::BEACON_BLOCK_HEAD_SLOT_START_DELAY_EXCEEDED_TOTAL); debug!( log, "Delayed head block"; diff --git a/beacon_node/beacon_chain/src/lib.rs b/beacon_node/beacon_chain/src/lib.rs index 552c16c8e1..7d34c4eef6 100644 --- a/beacon_node/beacon_chain/src/lib.rs +++ b/beacon_node/beacon_chain/src/lib.rs @@ -72,7 +72,6 @@ pub use store; pub use timeout_rw_lock::TimeoutRwLock; pub use types; -// FIXME(sproul): compatibility shim pub mod validator_pubkey_cache { use crate::BeaconChainTypes; diff --git a/beacon_node/beacon_chain/src/metrics.rs b/beacon_node/beacon_chain/src/metrics.rs index a3c7c94865..b71c409b4c 100644 --- a/beacon_node/beacon_chain/src/metrics.rs +++ b/beacon_node/beacon_chain/src/metrics.rs @@ -813,6 +813,11 @@ lazy_static! { // [0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50] decimal_buckets(-1,2) ); + pub static ref BEACON_BLOCK_HEAD_SLOT_START_DELAY_EXCEEDED_TOTAL: Result = try_create_int_counter( + "beacon_block_head_slot_start_delay_exceeded_total", + "Triggered when the duration between the start of the block's slot and the current time \ + will result in failed attestations.", + ); pub static ref BEACON_BLOCK_HEAD_MISSED_ATT_DEADLINE_LATE: Result = try_create_int_counter( "beacon_block_head_missed_att_deadline_late", "Total number of delayed head blocks that arrived late" diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index b2d0d0cca6..eb86336f7a 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -513,8 +513,7 @@ impl, Cold: ItemStore> HotColdDB return Ok(None); }; - // FIXME(sproul): dodgy compression factor estimation - let mut ssz_bytes = Vec::with_capacity(2 * bytes.len()); + let mut ssz_bytes = Vec::with_capacity(self.config.estimate_decompressed_size(bytes.len())); let mut decoder = Decoder::new(&*bytes).map_err(Error::Compression)?; decoder .read_to_end(&mut ssz_bytes) @@ -550,12 +549,11 @@ impl, Cold: ItemStore> HotColdDB &slot.as_u64().to_be_bytes(), ); - // FIXME(sproul): fix compression estimate and level - let compression_level = 3; let ssz_bytes = block.as_ssz_bytes(); - let mut compressed_value = Vec::with_capacity(ssz_bytes.len() / 2); - let mut encoder = - Encoder::new(&mut compressed_value, compression_level).map_err(Error::Compression)?; + let mut compressed_value = + Vec::with_capacity(self.config.estimate_compressed_size(ssz_bytes.len())); + let mut encoder = Encoder::new(&mut compressed_value, self.config.compression_level) + .map_err(Error::Compression)?; encoder.write_all(&ssz_bytes).map_err(Error::Compression)?; encoder.finish().map_err(Error::Compression)?; diff --git a/beacon_node/store/src/validator_pubkey_cache.rs b/beacon_node/store/src/validator_pubkey_cache.rs index 1d8d365da2..1240c6755d 100644 --- a/beacon_node/store/src/validator_pubkey_cache.rs +++ b/beacon_node/store/src/validator_pubkey_cache.rs @@ -100,8 +100,7 @@ impl, Cold: ItemStore> ValidatorPubkeyCache