mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 13:58:28 +00:00
Satisfy Clippy, remove non-tree-states code
This commit is contained in:
@@ -558,17 +558,6 @@ pub fn load_variable_list_from_db<F: VariableLengthField<E>, E: EthSpec, S: KeyV
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// Index into a field of the state, avoiding out of bounds and division by 0.
|
||||
#[cfg(not(feature = "milhouse"))]
|
||||
fn safe_modulo_index<T: Copy>(values: &[T], index: u64) -> Result<T, ChunkError> {
|
||||
if values.is_empty() {
|
||||
Err(ChunkError::ZeroLengthVector)
|
||||
} else {
|
||||
Ok(values[index as usize % values.len()])
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "milhouse")]
|
||||
fn safe_modulo_index_list<T: TreeHash + Copy, N: Unsigned>(
|
||||
values: &VList<T, N>,
|
||||
index: u64,
|
||||
@@ -583,7 +572,6 @@ fn safe_modulo_index_list<T: TreeHash + Copy, N: Unsigned>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "milhouse")]
|
||||
fn safe_modulo_index_vect<T: TreeHash + Copy, N: Unsigned>(
|
||||
values: &FixedVector<T, N>,
|
||||
index: u64,
|
||||
|
||||
@@ -3,10 +3,7 @@ use crate::config::StoreConfigError;
|
||||
use crate::hot_cold_store::HotColdDBError;
|
||||
use ssz::DecodeError;
|
||||
use state_processing::BlockReplayError;
|
||||
use types::{BeaconStateError, Hash256, Slot};
|
||||
|
||||
#[cfg(feature = "milhouse")]
|
||||
use types::milhouse;
|
||||
use types::{milhouse, BeaconStateError, Hash256, Slot};
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
@@ -46,7 +43,6 @@ pub enum Error {
|
||||
MissingStateRoot(Slot),
|
||||
MissingState(Hash256),
|
||||
BlockReplayError(BlockReplayError),
|
||||
#[cfg(feature = "milhouse")]
|
||||
MilhouseError(milhouse::Error),
|
||||
Compression(std::io::Error),
|
||||
MissingPersistedBeaconChain,
|
||||
@@ -110,7 +106,6 @@ impl From<StoreConfigError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "milhouse")]
|
||||
impl From<milhouse::Error> for Error {
|
||||
fn from(e: milhouse::Error) -> Self {
|
||||
Self::MilhouseError(e)
|
||||
|
||||
@@ -1037,13 +1037,14 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
.minimal_block_root_verification()
|
||||
.state_root_iter(state_root_iter)
|
||||
.apply_blocks(blocks, Some(target_slot))
|
||||
.and_then(|block_replayer| {
|
||||
.map(|block_replayer| {
|
||||
// FIXME(sproul): tweak state miss condition
|
||||
if block_replayer.state_root_miss() && false {
|
||||
/*
|
||||
if block_replayer.state_root_miss() {
|
||||
Err(Error::MissingStateRoot(target_slot))
|
||||
} else {
|
||||
Ok(block_replayer.into_state())
|
||||
}
|
||||
*/
|
||||
block_replayer.into_state()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use ssz::{DecodeError, Encode};
|
||||
use ssz_derive::Encode;
|
||||
use std::convert::TryInto;
|
||||
use std::sync::Arc;
|
||||
use types::beacon_state::{CloneConfig, CommitteeCache, CACHED_EPOCHS};
|
||||
use types::beacon_state::{CommitteeCache, CACHED_EPOCHS};
|
||||
|
||||
pub fn store_full_state<E: EthSpec>(
|
||||
state_root: &Hash256,
|
||||
@@ -56,7 +56,7 @@ impl<T: EthSpec> StorageContainer<T> {
|
||||
/// Create a new instance for storing a `BeaconState`.
|
||||
pub fn new(state: &BeaconState<T>) -> Self {
|
||||
Self {
|
||||
state: state.clone_with(CloneConfig::none()),
|
||||
state: state.clone(),
|
||||
committee_caches: state.committee_caches().to_vec(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,11 +191,12 @@ impl<E: EthSpec> KeyValueStore<E> for LevelDB<E> {
|
||||
Box::new(
|
||||
iter.take_while(move |(key, _)| key.matches_column(column))
|
||||
.map(move |(bytes_key, value)| {
|
||||
let key = bytes_key.remove_column(column).ok_or_else(|| {
|
||||
HotColdDBError::IterationError {
|
||||
unexpected_key: bytes_key,
|
||||
}
|
||||
})?;
|
||||
let key =
|
||||
bytes_key
|
||||
.remove_column(column)
|
||||
.ok_or(HotColdDBError::IterationError {
|
||||
unexpected_key: bytes_key,
|
||||
})?;
|
||||
Ok((key, value))
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -44,6 +44,8 @@ use parking_lot::MutexGuard;
|
||||
use strum::{EnumString, IntoStaticStr};
|
||||
pub use types::*;
|
||||
|
||||
pub type ColumnIter<'a> = Box<dyn Iterator<Item = Result<(Hash256, Vec<u8>), Error>> + 'a>;
|
||||
|
||||
pub trait KeyValueStore<E: EthSpec>: Sync + Send + Sized + 'static {
|
||||
/// Retrieve some bytes in `column` with `key`.
|
||||
fn get_bytes(&self, column: &str, key: &[u8]) -> Result<Option<Vec<u8>>, Error>;
|
||||
@@ -78,10 +80,7 @@ pub trait KeyValueStore<E: EthSpec>: Sync + Send + Sized + 'static {
|
||||
fn compact(&self) -> Result<(), Error>;
|
||||
|
||||
/// Iterate through all values in a particular column.
|
||||
fn iter_column<'a>(
|
||||
&'a self,
|
||||
_column: DBColumn,
|
||||
) -> Box<dyn Iterator<Item = Result<(Hash256, Vec<u8>), Error>> + 'a> {
|
||||
fn iter_column(&self, _column: DBColumn) -> ColumnIter {
|
||||
// Default impl for non LevelDB databases
|
||||
Box::new(std::iter::empty())
|
||||
}
|
||||
|
||||
@@ -318,8 +318,6 @@ macro_rules! impl_try_into_beacon_state {
|
||||
committee_caches: <_>::default(),
|
||||
pubkey_cache: <_>::default(),
|
||||
exit_cache: <_>::default(),
|
||||
#[cfg(not(feature = "milhouse"))]
|
||||
tree_hash_cache: <_>::default(),
|
||||
|
||||
// Variant-specific fields
|
||||
$(
|
||||
|
||||
@@ -203,22 +203,3 @@ impl BlockMap {
|
||||
self.blocks.remove(block_root)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use std::mem::size_of;
|
||||
use types::{
|
||||
beacon_state::PubkeyCache, BeaconBlockHeader, BeaconState, BeaconStateAltair,
|
||||
BeaconStateMerge, MainnetEthSpec,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn state_size() {
|
||||
println!("{}", size_of::<BeaconStateAltair<MainnetEthSpec>>());
|
||||
println!("{}", size_of::<BeaconStateMerge<MainnetEthSpec>>());
|
||||
println!("{}", size_of::<BeaconState<MainnetEthSpec>>());
|
||||
println!("{}", size_of::<PubkeyCache>());
|
||||
assert!(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user