Skip to content

Commit 7d8343f

Browse files
committed
Use same hierarchy for hot and cold
This is nice as it enables us to avoid recomputing diffs, we can just copy.
1 parent e1475a1 commit 7d8343f

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

beacon_node/beacon_chain/src/migrate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
632632
// Compute the set of finalized state roots that we must keep to make the dynamic HDiff system
633633
// work.
634634
let required_finalized_diff_state_slots = store
635-
.hierarchy_hot
635+
.hierarchy
636636
.closest_layer_points(new_finalized_slot, store.hot_hdiff_start_slot()?);
637637

638638
// We don't know which blocks are shared among abandoned chains, so we buffer and delete

beacon_node/store/src/config.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,18 @@ pub struct StoreConfig {
6565

6666
/// Variant of `StoreConfig` that gets written to disk. Contains immutable configuration params.
6767
#[superstruct(
68-
variants(V1, V22, V24),
68+
variants(V1, V22),
6969
variant_attributes(derive(Debug, Clone, PartialEq, Eq, Encode, Decode))
7070
)]
7171
#[derive(Clone, Debug, PartialEq, Eq)]
7272
pub struct OnDiskStoreConfig {
7373
#[superstruct(only(V1))]
7474
pub slots_per_restore_point: u64,
7575
/// Prefix byte to future-proof versions of the `OnDiskStoreConfig` post V1
76-
#[superstruct(only(V22, V24))]
76+
#[superstruct(only(V22))]
7777
version_byte: u8,
78-
#[superstruct(only(V22, V24))]
78+
#[superstruct(only(V22))]
7979
pub hierarchy_config: HierarchyConfig,
80-
// TODO(hdiff): Should persist the hot hierarchy_config too?
8180
}
8281

8382
impl OnDiskStoreConfigV22 {
@@ -225,7 +224,6 @@ impl StoreItem for OnDiskStoreConfig {
225224
match self {
226225
OnDiskStoreConfig::V1(value) => value.as_ssz_bytes(),
227226
OnDiskStoreConfig::V22(value) => value.as_ssz_bytes(),
228-
OnDiskStoreConfig::V24(value) => value.as_ssz_bytes(),
229227
}
230228
}
231229

@@ -237,8 +235,6 @@ impl StoreItem for OnDiskStoreConfig {
237235
return Ok(Self::V1(value));
238236
}
239237

240-
// TODO(hdiff): handle V24 conversion
241-
242238
Ok(Self::V22(OnDiskStoreConfigV22::from_ssz_bytes(bytes)?))
243239
}
244240
}

beacon_node/store/src/hot_cold_store.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ pub struct HotColdDB<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> {
5858
/// The starting slots for the range of data columns stored in the database.
5959
data_column_info: RwLock<DataColumnInfo>,
6060
pub(crate) config: StoreConfig,
61-
pub(crate) hierarchy: HierarchyModuli,
62-
pub hierarchy_hot: HierarchyModuli,
61+
pub hierarchy: HierarchyModuli,
6362
/// Cold database containing compact historical data.
6463
pub cold_db: Cold,
6564
/// Database containing blobs. If None, store falls back to use `cold_db`.
@@ -209,11 +208,9 @@ impl<E: EthSpec> HotColdDB<E, MemoryStore<E>, MemoryStore<E>> {
209208
config.verify::<E>()?;
210209

211210
let hierarchy = config.hierarchy_config.to_moduli()?;
212-
// TODO(hdiff): Use different exponents
211+
213212
// NOTE: Anchor slot is initialized to 0, which is only valid for new DBs. We shouldn't
214213
// be reusing memory stores, but if we want to do that we should redo this.
215-
let hierarchy_hot = config.hierarchy_config.to_moduli()?;
216-
217214
let db = HotColdDB {
218215
split: RwLock::new(Split::default()),
219216
anchor_info: RwLock::new(ANCHOR_UNINITIALIZED),
@@ -233,7 +230,6 @@ impl<E: EthSpec> HotColdDB<E, MemoryStore<E>, MemoryStore<E>> {
233230
)),
234231
config,
235232
hierarchy,
236-
hierarchy_hot,
237233
spec,
238234
_phantom: PhantomData,
239235
};
@@ -260,9 +256,6 @@ impl<E: EthSpec> HotColdDB<E, BeaconNodeBackend<E>, BeaconNodeBackend<E>> {
260256

261257
let hierarchy = config.hierarchy_config.to_moduli()?;
262258

263-
// TODO(hdiff): Use different exponents
264-
let hierarchy_hot = config.hierarchy_config.to_moduli()?;
265-
266259
debug!(?hot_path, "Opening LevelDB");
267260
let hot_db = BeaconNodeBackend::open(&config, hot_path)?;
268261

@@ -288,7 +281,6 @@ impl<E: EthSpec> HotColdDB<E, BeaconNodeBackend<E>, BeaconNodeBackend<E>> {
288281
)),
289282
config,
290283
hierarchy,
291-
hierarchy_hot,
292284
spec,
293285
_phantom: PhantomData,
294286
};
@@ -451,7 +443,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
451443

452444
pub fn hot_storage_strategy(&self, slot: Slot) -> Result<StorageStrategy, Error> {
453445
Ok(self
454-
.hierarchy_hot
446+
.hierarchy
455447
.storage_strategy(slot, self.hot_hdiff_start_slot()?)?)
456448
}
457449

0 commit comments

Comments
 (0)