From b8709fdcab399f3ca44c7f22a85c1969ace7db4d Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Tue, 15 Feb 2022 12:10:02 +1100 Subject: [PATCH] Fixups (still loading epoch boundary states) --- .../beacon_chain/src/block_verification.rs | 1 - beacon_node/beacon_chain/src/metrics.rs | 1 - beacon_node/store/src/hot_cold_store.rs | 17 +++++------------ 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/beacon_node/beacon_chain/src/block_verification.rs b/beacon_node/beacon_chain/src/block_verification.rs index cdc23e08b1..60f08abe14 100644 --- a/beacon_node/beacon_chain/src/block_verification.rs +++ b/beacon_node/beacon_chain/src/block_verification.rs @@ -68,7 +68,6 @@ use state_processing::{ use std::borrow::Cow; use std::fs; use std::io::Write; -use std::time::Duration; use store::{Error as DBError, HotColdDB, KeyValueStore, StoreOp}; use tree_hash::TreeHash; use types::{ diff --git a/beacon_node/beacon_chain/src/metrics.rs b/beacon_node/beacon_chain/src/metrics.rs index 7eb2b19b62..4ee0904e23 100644 --- a/beacon_node/beacon_chain/src/metrics.rs +++ b/beacon_node/beacon_chain/src/metrics.rs @@ -4,7 +4,6 @@ use crate::{BeaconChain, BeaconChainError, BeaconChainTypes}; use lazy_static::lazy_static; pub use lighthouse_metrics::*; use slot_clock::SlotClock; -use std::time::Duration; use types::{BeaconState, Epoch, EthSpec, Hash256, Slot}; lazy_static! { diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 9e529d6209..f764323843 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -25,7 +25,7 @@ use lru::LruCache; use parking_lot::{Mutex, RwLock}; use safe_arith::SafeArith; use serde_derive::{Deserialize, Serialize}; -use slog::{debug, error, info, trace, Logger}; +use slog::{debug, error, info, trace, warn, Logger}; use ssz::{Decode, Encode}; use ssz_derive::{Decode, Encode}; use state_processing::{BlockProcessingError, BlockReplayer, SlotProcessingError}; @@ -407,7 +407,7 @@ impl, Cold: ItemStore> HotColdDB return Ok(Some(cached)); } Ok(self - .get_hot_state(&state_root, StateRootStrategy::Accurate)? + .get_hot_state(&state_root)? .map(|state| (state_root, state))) } @@ -532,9 +532,6 @@ impl, Cold: ItemStore> HotColdDB }) = self.load_hot_state_summary(state_root)? { // NOTE: minor inefficiency here because we load an unnecessary hot state summary - // - // `StateRootStrategy` should be irrelevant here since we never replay blocks for an epoch - // boundary state in the hot DB. let state = self.get_hot_state(&epoch_boundary_state_root)?.ok_or( HotColdDBError::MissingEpochBoundaryState(epoch_boundary_state_root), )?; @@ -681,11 +678,7 @@ impl, Cold: ItemStore> HotColdDB } /// Get a post-finalization state from the database or store. - pub fn get_hot_state( - &self, - state_root: &Hash256, - state_root_strategy: StateRootStrategy, - ) -> Result>, Error> { + pub fn get_hot_state(&self, state_root: &Hash256) -> Result>, Error> { if let Some(state) = self.state_cache.lock().get_by_state_root(*state_root) { return Ok(Some(state)); } @@ -695,7 +688,7 @@ impl, Cold: ItemStore> HotColdDB "state_root" => ?state_root, ); - let state_from_disk = self.load_hot_state(state_root, state_root_strategy)?; + let state_from_disk = self.load_hot_state(state_root)?; if let Some((state, block_root)) = state_from_disk { self.state_cache @@ -1371,7 +1364,7 @@ pub fn migrate_database, Cold: ItemStore>( if slot % store.config.slots_per_restore_point == 0 { let state: BeaconState = store - .get_hot_state(&state_root, StateRootStrategy::Accurate)? + .get_hot_state(&state_root)? .ok_or(HotColdDBError::MissingStateToFreeze(state_root))?; store.store_cold_state(&state_root, &state, &mut cold_db_ops)?;