mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-20 06:18:31 +00:00
Remove schema migrations for v28 and earlier (#9031)
With LH v8.1.3 supporting Fulu-on-Gnosis, we no longer need these DB migrations. All Lighthouse nodes running in prod will soon be updated to LH v8.0.0+ and schema v28+. This PR helps with Gloas fork choice changes, by allowing us to avoid updating old schema migrations when adding V29 for Gloas: - https://github.com/sigp/lighthouse/pull/9025 Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
@@ -186,10 +186,8 @@ impl<E: EthSpec> LevelDB<E> {
|
||||
)
|
||||
};
|
||||
|
||||
for (start_key, end_key) in [
|
||||
endpoints(DBColumn::BeaconState),
|
||||
endpoints(DBColumn::BeaconStateSummary),
|
||||
] {
|
||||
{
|
||||
let (start_key, end_key) = endpoints(DBColumn::BeaconStateHotSummary);
|
||||
self.db.compact(&start_key, &end_key);
|
||||
}
|
||||
|
||||
|
||||
@@ -3270,12 +3270,10 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
Some(mut split) => {
|
||||
debug!(?split, "Loaded split partial");
|
||||
// Load the hot state summary to get the block root.
|
||||
let latest_block_root = self
|
||||
.load_block_root_from_summary_any_version(&split.state_root)
|
||||
.ok_or(HotColdDBError::MissingSplitState(
|
||||
split.state_root,
|
||||
split.slot,
|
||||
))?;
|
||||
let latest_block_root =
|
||||
self.load_block_root_from_summary(&split.state_root).ok_or(
|
||||
HotColdDBError::MissingSplitState(split.state_root, split.slot),
|
||||
)?;
|
||||
split.block_root = latest_block_root;
|
||||
Ok(Some(split))
|
||||
}
|
||||
@@ -3306,29 +3304,11 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
.map_err(|e| Error::LoadHotStateSummary(*state_root, e.into()))
|
||||
}
|
||||
|
||||
/// Load a hot state's summary in V22 format, given its root.
|
||||
pub fn load_hot_state_summary_v22(
|
||||
&self,
|
||||
state_root: &Hash256,
|
||||
) -> Result<Option<HotStateSummaryV22>, Error> {
|
||||
self.hot_db
|
||||
.get(state_root)
|
||||
.map_err(|e| Error::LoadHotStateSummary(*state_root, e.into()))
|
||||
}
|
||||
|
||||
/// Load the latest block root for a hot state summary either in modern form, or V22 form.
|
||||
///
|
||||
/// This function is required to open a V22 database for migration to V24, or vice versa.
|
||||
pub fn load_block_root_from_summary_any_version(
|
||||
&self,
|
||||
state_root: &Hash256,
|
||||
) -> Option<Hash256> {
|
||||
/// Load the latest block root for a hot state summary.
|
||||
pub fn load_block_root_from_summary(&self, state_root: &Hash256) -> Option<Hash256> {
|
||||
if let Ok(Some(summary)) = self.load_hot_state_summary(state_root) {
|
||||
return Some(summary.latest_block_root);
|
||||
}
|
||||
if let Ok(Some(summary)) = self.load_hot_state_summary_v22(state_root) {
|
||||
return Some(summary.latest_block_root);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
@@ -4287,30 +4267,6 @@ impl HotStateSummary {
|
||||
}
|
||||
}
|
||||
|
||||
/// Legacy hot state summary used in schema V22 and before.
|
||||
///
|
||||
/// This can be deleted when we remove V22 support.
|
||||
#[derive(Debug, Clone, Copy, Encode, Decode)]
|
||||
pub struct HotStateSummaryV22 {
|
||||
pub slot: Slot,
|
||||
pub latest_block_root: Hash256,
|
||||
pub epoch_boundary_state_root: Hash256,
|
||||
}
|
||||
|
||||
impl StoreItem for HotStateSummaryV22 {
|
||||
fn db_column() -> DBColumn {
|
||||
DBColumn::BeaconStateSummary
|
||||
}
|
||||
|
||||
fn as_store_bytes(&self) -> Vec<u8> {
|
||||
self.as_ssz_bytes()
|
||||
}
|
||||
|
||||
fn from_store_bytes(bytes: &[u8]) -> Result<Self, Error> {
|
||||
Ok(Self::from_ssz_bytes(bytes)?)
|
||||
}
|
||||
}
|
||||
|
||||
/// Struct for summarising a state in the freezer database.
|
||||
#[derive(Debug, Clone, Copy, Default, Encode, Decode)]
|
||||
pub(crate) struct ColdStateSummary {
|
||||
|
||||
@@ -77,11 +77,7 @@ pub trait KeyValueStore<E: EthSpec>: Sync + Send + Sized + 'static {
|
||||
fn compact(&self) -> Result<(), Error> {
|
||||
// Compact state and block related columns as they are likely to have the most churn,
|
||||
// i.e. entries being created and deleted.
|
||||
for column in [
|
||||
DBColumn::BeaconState,
|
||||
DBColumn::BeaconStateHotSummary,
|
||||
DBColumn::BeaconBlock,
|
||||
] {
|
||||
for column in [DBColumn::BeaconStateHotSummary, DBColumn::BeaconBlock] {
|
||||
self.compact_column(column)?;
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user