mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Fixups (still loading epoch boundary states)
This commit is contained in:
@@ -68,7 +68,6 @@ use state_processing::{
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::time::Duration;
|
|
||||||
use store::{Error as DBError, HotColdDB, KeyValueStore, StoreOp};
|
use store::{Error as DBError, HotColdDB, KeyValueStore, StoreOp};
|
||||||
use tree_hash::TreeHash;
|
use tree_hash::TreeHash;
|
||||||
use types::{
|
use types::{
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ use crate::{BeaconChain, BeaconChainError, BeaconChainTypes};
|
|||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
pub use lighthouse_metrics::*;
|
pub use lighthouse_metrics::*;
|
||||||
use slot_clock::SlotClock;
|
use slot_clock::SlotClock;
|
||||||
use std::time::Duration;
|
|
||||||
use types::{BeaconState, Epoch, EthSpec, Hash256, Slot};
|
use types::{BeaconState, Epoch, EthSpec, Hash256, Slot};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ use lru::LruCache;
|
|||||||
use parking_lot::{Mutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
use safe_arith::SafeArith;
|
use safe_arith::SafeArith;
|
||||||
use serde_derive::{Deserialize, Serialize};
|
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::{Decode, Encode};
|
||||||
use ssz_derive::{Decode, Encode};
|
use ssz_derive::{Decode, Encode};
|
||||||
use state_processing::{BlockProcessingError, BlockReplayer, SlotProcessingError};
|
use state_processing::{BlockProcessingError, BlockReplayer, SlotProcessingError};
|
||||||
@@ -407,7 +407,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
return Ok(Some(cached));
|
return Ok(Some(cached));
|
||||||
}
|
}
|
||||||
Ok(self
|
Ok(self
|
||||||
.get_hot_state(&state_root, StateRootStrategy::Accurate)?
|
.get_hot_state(&state_root)?
|
||||||
.map(|state| (state_root, state)))
|
.map(|state| (state_root, state)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,9 +532,6 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
}) = self.load_hot_state_summary(state_root)?
|
}) = self.load_hot_state_summary(state_root)?
|
||||||
{
|
{
|
||||||
// NOTE: minor inefficiency here because we load an unnecessary hot state summary
|
// 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(
|
let state = self.get_hot_state(&epoch_boundary_state_root)?.ok_or(
|
||||||
HotColdDBError::MissingEpochBoundaryState(epoch_boundary_state_root),
|
HotColdDBError::MissingEpochBoundaryState(epoch_boundary_state_root),
|
||||||
)?;
|
)?;
|
||||||
@@ -681,11 +678,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get a post-finalization state from the database or store.
|
/// Get a post-finalization state from the database or store.
|
||||||
pub fn get_hot_state(
|
pub fn get_hot_state(&self, state_root: &Hash256) -> Result<Option<BeaconState<E>>, Error> {
|
||||||
&self,
|
|
||||||
state_root: &Hash256,
|
|
||||||
state_root_strategy: StateRootStrategy,
|
|
||||||
) -> Result<Option<BeaconState<E>>, Error> {
|
|
||||||
if let Some(state) = self.state_cache.lock().get_by_state_root(*state_root) {
|
if let Some(state) = self.state_cache.lock().get_by_state_root(*state_root) {
|
||||||
return Ok(Some(state));
|
return Ok(Some(state));
|
||||||
}
|
}
|
||||||
@@ -695,7 +688,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
"state_root" => ?state_root,
|
"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 {
|
if let Some((state, block_root)) = state_from_disk {
|
||||||
self.state_cache
|
self.state_cache
|
||||||
@@ -1371,7 +1364,7 @@ pub fn migrate_database<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>>(
|
|||||||
|
|
||||||
if slot % store.config.slots_per_restore_point == 0 {
|
if slot % store.config.slots_per_restore_point == 0 {
|
||||||
let state: BeaconState<E> = store
|
let state: BeaconState<E> = store
|
||||||
.get_hot_state(&state_root, StateRootStrategy::Accurate)?
|
.get_hot_state(&state_root)?
|
||||||
.ok_or(HotColdDBError::MissingStateToFreeze(state_root))?;
|
.ok_or(HotColdDBError::MissingStateToFreeze(state_root))?;
|
||||||
|
|
||||||
store.store_cold_state(&state_root, &state, &mut cold_db_ops)?;
|
store.store_cold_state(&state_root, &state, &mut cold_db_ops)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user