Skip to content

Commit b49272f

Browse files
committed
Merge remote-tracking branch 'origin/drop-headtracker' into tree-states-hot-rebase
2 parents 1c81c93 + a322463 commit b49272f

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

beacon_node/beacon_chain/src/schema_change/migration_schema_v23.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use fork_choice::{ForkChoice, ResetPayloadStatuses};
77
use ssz::{Decode, Encode};
88
use ssz_derive::{Decode, Encode};
99
use std::sync::Arc;
10-
use store::{DBColumn, Error, HotColdDB, KeyValueStoreOp, StoreItem};
10+
use store::{DBColumn, Error, HotColdDB, KeyValueStore, KeyValueStoreOp, StoreItem};
1111
use types::{Hash256, Slot};
1212

1313
/// Dummy value to use for the canonical head block root, see below.
@@ -16,7 +16,7 @@ pub const DUMMY_CANONICAL_HEAD_BLOCK_ROOT: Hash256 = Hash256::repeat_byte(0xff);
1616
pub fn upgrade_to_v23<T: BeaconChainTypes>(
1717
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>,
1818
) -> Result<Vec<KeyValueStoreOp>, Error> {
19-
// Set the head-tracker to empty
19+
// 1) Set the head-tracker to empty
2020
let Some(persisted_beacon_chain_v22) =
2121
db.get_item::<PersistedBeaconChainV22>(&BEACON_CHAIN_DB_KEY)?
2222
else {
@@ -29,7 +29,19 @@ pub fn upgrade_to_v23<T: BeaconChainTypes>(
2929
genesis_block_root: persisted_beacon_chain_v22.genesis_block_root,
3030
};
3131

32-
let ops = vec![persisted_beacon_chain.as_kv_store_op(BEACON_CHAIN_DB_KEY)];
32+
let mut ops = vec![persisted_beacon_chain.as_kv_store_op(BEACON_CHAIN_DB_KEY)];
33+
34+
// 2) Wipe out all state temporary flags. While un-used in V23, if there's a rollback we could
35+
// end-up with an inconsistent DB.
36+
for state_root_result in db
37+
.hot_db
38+
.iter_column_keys::<Hash256>(DBColumn::BeaconStateTemporary)
39+
{
40+
ops.push(KeyValueStoreOp::DeleteKey(
41+
DBColumn::BeaconStateTemporary,
42+
state_root_result?.as_slice().to_vec(),
43+
));
44+
}
3345

3446
Ok(ops)
3547
}

beacon_node/store/src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ pub use types::*;
4949

5050
const DATA_COLUMN_DB_KEY_SIZE: usize = 32 + 8;
5151

52-
// TODO: check that these are not used by any variant of `DBColumn` using strum_macros
53-
const _DEPRECATED_COLUMN_PREFIXES: &[&str] = &[
54-
// BeaconStateTemporary, deleted in Mar 2025.
55-
"bst",
56-
];
57-
5852
pub type ColumnIter<'a, K> = Box<dyn Iterator<Item = Result<(K, Vec<u8>), Error>> + 'a>;
5953
pub type ColumnKeyIter<'a, K> = Box<dyn Iterator<Item = Result<K, Error>> + 'a>;
6054

@@ -319,6 +313,12 @@ pub enum DBColumn {
319313
/// Mapping from state root to `ColdStateSummary` in the cold DB.
320314
#[strum(serialize = "bcs")]
321315
BeaconColdStateSummary,
316+
/// DEPRECATED.
317+
///
318+
/// Previously used for the list of temporary states stored during block import, and then made
319+
/// non-temporary by the deletion of their state root from this column.
320+
#[strum(serialize = "bst")]
321+
BeaconStateTemporary,
322322
/// Execution payloads for blocks more recent than the finalized checkpoint.
323323
#[strum(serialize = "exp")]
324324
ExecPayload,
@@ -420,6 +420,7 @@ impl DBColumn {
420420
| Self::BeaconStateHotSnapshot
421421
| Self::BeaconStateHotSummary
422422
| Self::BeaconColdStateSummary
423+
| Self::BeaconStateTemporary
423424
| Self::ExecPayload
424425
| Self::BeaconChain
425426
| Self::OpPool

0 commit comments

Comments
 (0)