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;
// FIXME(sproul): avoid `to_vec` perf penalty
Self {
store,
balances_cache: <_>::default(),

View File

@@ -626,7 +626,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.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<T::EthSpec> = self
.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,
// 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";

View File

@@ -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;

View File

@@ -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<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(
"beacon_block_head_missed_att_deadline_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);
};
// 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<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
&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)?;

View File

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