Skip to content

Commit f4dd6fe

Browse files
committed
Clean up temporary flags on migration
1 parent 11cfa1c commit f4dd6fe

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

beacon_node/beacon_chain/src/schema_change/migration_schema_v23.rs

Lines changed: 14 additions & 2 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 {
@@ -31,6 +31,18 @@ pub fn upgrade_to_v23<T: BeaconChainTypes>(
3131

3232
let ops = vec![persisted_beacon_chain.as_kv_store_op(BEACON_CHAIN_DB_KEY)];
3333

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+
}
45+
3446
Ok(ops)
3547
}
3648

beacon_node/store/src/lib.rs

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

4747
const DATA_COLUMN_DB_KEY_SIZE: usize = 32 + 8;
4848

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

@@ -290,6 +284,12 @@ pub enum DBColumn {
290284
/// Mapping from state root to `ColdStateSummary` in the cold DB.
291285
#[strum(serialize = "bcs")]
292286
BeaconColdStateSummary,
287+
/// DEPRECATED.
288+
///
289+
/// Previously used for the list of temporary states stored during block import, and then made
290+
/// non-temporary by the deletion of their state root from this column.
291+
#[strum(serialize = "bst")]
292+
BeaconStateTemporary,
293293
/// Execution payloads for blocks more recent than the finalized checkpoint.
294294
#[strum(serialize = "exp")]
295295
ExecPayload,
@@ -388,6 +388,7 @@ impl DBColumn {
388388
| Self::BeaconBlob
389389
| Self::BeaconStateSummary
390390
| Self::BeaconColdStateSummary
391+
| Self::BeaconStateTemporary
391392
| Self::ExecPayload
392393
| Self::BeaconChain
393394
| Self::OpPool

0 commit comments

Comments
 (0)