Fix some low-hanging FIXMEs

This commit is contained in:
Michael Sproul
2022-10-24 15:02:43 +11:00
parent 84ae7b2976
commit 59c1972df7
6 changed files with 12 additions and 14 deletions

View File

@@ -197,7 +197,6 @@ where
}; };
let finalized_checkpoint = justified_checkpoint; let finalized_checkpoint = justified_checkpoint;
// FIXME(sproul): avoid `to_vec` perf penalty
Self { Self {
store, store,
balances_cache: <_>::default(), balances_cache: <_>::default(),

View File

@@ -626,7 +626,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.get_full_block(&new_view.head_block_root, None)? .get_full_block(&new_view.head_block_root, None)?
.ok_or(Error::MissingBeaconBlock(new_view.head_block_root))?; .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_root = beacon_block.state_root();
let beacon_state: BeaconState<T::EthSpec> = self let beacon_state: BeaconState<T::EthSpec> = self
.get_state(&beacon_state_root, Some(beacon_block.slot()))? .get_state(&beacon_state_root, Some(beacon_block.slot()))?
@@ -1288,8 +1287,7 @@ fn observe_head_block_delays<E: EthSpec, S: SlotClock>(
// If the block was enshrined as head too late for attestations to be created for it, // If the block was enshrined as head too late for attestations to be created for it,
// log a debug warning and increment a metric. // log a debug warning and increment a metric.
if late_head { 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!( debug!(
log, log,
"Delayed head block"; "Delayed head block";

View File

@@ -72,7 +72,6 @@ pub use store;
pub use timeout_rw_lock::TimeoutRwLock; pub use timeout_rw_lock::TimeoutRwLock;
pub use types; pub use types;
// FIXME(sproul): compatibility shim
pub mod validator_pubkey_cache { pub mod validator_pubkey_cache {
use crate::BeaconChainTypes; use crate::BeaconChainTypes;

View File

@@ -813,6 +813,11 @@ lazy_static! {
// [0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50] // [0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50]
decimal_buckets(-1,2) decimal_buckets(-1,2)
); );
pub static ref BEACON_BLOCK_HEAD_SLOT_START_DELAY_EXCEEDED_TOTAL: Result<IntCounter> = 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<IntCounter> = try_create_int_counter( pub static ref BEACON_BLOCK_HEAD_MISSED_ATT_DEADLINE_LATE: Result<IntCounter> = try_create_int_counter(
"beacon_block_head_missed_att_deadline_late", "beacon_block_head_missed_att_deadline_late",
"Total number of delayed head blocks that arrived late" "Total number of delayed head blocks that arrived late"

View File

@@ -513,8 +513,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
return Ok(None); return Ok(None);
}; };
// FIXME(sproul): dodgy compression factor estimation let mut ssz_bytes = Vec::with_capacity(self.config.estimate_decompressed_size(bytes.len()));
let mut ssz_bytes = Vec::with_capacity(2 * bytes.len());
let mut decoder = Decoder::new(&*bytes).map_err(Error::Compression)?; let mut decoder = Decoder::new(&*bytes).map_err(Error::Compression)?;
decoder decoder
.read_to_end(&mut ssz_bytes) .read_to_end(&mut ssz_bytes)
@@ -550,12 +549,11 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
&slot.as_u64().to_be_bytes(), &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 ssz_bytes = block.as_ssz_bytes();
let mut compressed_value = Vec::with_capacity(ssz_bytes.len() / 2); let mut compressed_value =
let mut encoder = Vec::with_capacity(self.config.estimate_compressed_size(ssz_bytes.len()));
Encoder::new(&mut compressed_value, compression_level).map_err(Error::Compression)?; 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.write_all(&ssz_bytes).map_err(Error::Compression)?;
encoder.finish().map_err(Error::Compression)?; encoder.finish().map_err(Error::Compression)?;

View File

@@ -100,8 +100,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> ValidatorPubkeyCache<E,
self.import( self.import(
state state
.validators() .validators()
.iter_from(self.pubkeys.len()) .iter_from(self.pubkeys.len())?
.unwrap() // FIXME(sproul)
.map(|v| v.immutable.clone()), .map(|v| v.immutable.clone()),
store, store,
) )