Skip to content

Commit ecb647f

Browse files
committed
Fix column prefix bug
1 parent 36ab17c commit ecb647f

File tree

1 file changed

+19
-45
lines changed

1 file changed

+19
-45
lines changed

beacon_node/store/src/hot_cold_store.rs

Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use crate::metadata::{
1313
};
1414
use crate::state_cache::{PutStateOutcome, StateCache};
1515
use crate::{
16-
get_data_column_key, get_key_for_col, metrics, parse_data_column_key, BlobSidecarListFromRoot,
17-
DBColumn, DatabaseBlock, Error, ItemStore, KeyValueStoreOp, StoreItem, StoreOp,
16+
get_data_column_key, metrics, parse_data_column_key, BlobSidecarListFromRoot, DBColumn,
17+
DatabaseBlock, Error, ItemStore, KeyValueStoreOp, StoreItem, StoreOp,
1818
};
1919
use itertools::{process_results, Itertools};
2020
use lru::LruCache;
@@ -1259,11 +1259,9 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
12591259

12601260
StoreOp::DeleteState(state_root, slot) => {
12611261
// Delete the hot state summary.
1262-
let state_summary_key =
1263-
get_key_for_col(DBColumn::BeaconStateHotSummary, state_root.as_slice());
12641262
key_value_batch.push(KeyValueStoreOp::DeleteKey(
12651263
DBColumn::BeaconStateHotSummary,
1266-
state_summary_key,
1264+
state_root.as_slice().to_vec(),
12671265
));
12681266

12691267
// Delete the state temporary flag (if any). Temporary flags are commonly
@@ -1279,20 +1277,14 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
12791277
// Full state stored in this position
12801278
key_value_batch.push(KeyValueStoreOp::DeleteKey(
12811279
DBColumn::BeaconStateHotSnapshot,
1282-
get_key_for_col(
1283-
DBColumn::BeaconStateHotSnapshot,
1284-
state_root.as_slice(),
1285-
),
1280+
state_root.as_slice().to_vec(),
12861281
));
12871282
}
12881283
StorageStrategy::DiffFrom(_) => {
12891284
// Diff stored in this position
12901285
key_value_batch.push(KeyValueStoreOp::DeleteKey(
12911286
DBColumn::BeaconStateHotDiff,
1292-
get_key_for_col(
1293-
DBColumn::BeaconStateHotDiff,
1294-
state_root.as_slice(),
1295-
),
1287+
state_root.as_slice().to_vec(),
12961288
));
12971289
}
12981290
StorageStrategy::ReplayFrom(_) => {
@@ -1303,14 +1295,11 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
13031295
// TODO(hdiff): should attempt to delete everything if slot is not available?
13041296
key_value_batch.push(KeyValueStoreOp::DeleteKey(
13051297
DBColumn::BeaconStateHotSnapshot,
1306-
get_key_for_col(
1307-
DBColumn::BeaconStateHotSnapshot,
1308-
state_root.as_slice(),
1309-
),
1298+
state_root.as_slice().to_vec(),
13101299
));
13111300
key_value_batch.push(KeyValueStoreOp::DeleteKey(
13121301
DBColumn::BeaconStateHotDiff,
1313-
get_key_for_col(DBColumn::BeaconStateHotDiff, state_root.as_slice()),
1302+
state_root.as_slice().to_vec(),
13141303
));
13151304
}
13161305
}
@@ -1581,35 +1570,22 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
15811570
ops: &mut Vec<KeyValueStoreOp>,
15821571
) -> Result<(), Error> {
15831572
let slot = state.slot();
1584-
match self.hot_storage_strategy(slot)? {
1585-
StorageStrategy::ReplayFrom(from_slot) => {
1586-
debug!(
1587-
self.log,
1588-
"Storing hot state";
1589-
"strategy" => "replay",
1590-
"from_slot" => from_slot,
1591-
"slot" => slot,
1592-
);
1573+
let storage_strategy = self.hot_storage_strategy(slot)?;
1574+
debug!(
1575+
self.log,
1576+
"Storing hot state";
1577+
"state_root" => ?state_root,
1578+
"state_slot" => slot,
1579+
"strategy" => ?storage_strategy,
1580+
);
1581+
match storage_strategy {
1582+
StorageStrategy::ReplayFrom(_) => {
15931583
// Already have persisted the state summary, don't persist anything else
15941584
}
15951585
StorageStrategy::Snapshot => {
1596-
debug!(
1597-
self.log,
1598-
"Storing hot state";
1599-
"strategy" => "snapshot",
1600-
"slot" => slot,
1601-
);
16021586
self.store_hot_state_as_snapshot(state_root, state, ops)?;
16031587
}
16041588
StorageStrategy::DiffFrom(from_slot) => {
1605-
debug!(
1606-
self.log,
1607-
"Storing hot state";
1608-
"strategy" => "diff",
1609-
"from_slot" => from_slot,
1610-
"slot" => slot,
1611-
);
1612-
16131589
let from_root = get_ancenstor_state_root(self, state, from_slot)?.ok_or(
16141590
HotColdDBError::HdiffGetPriorStateRootError(state.slot(), from_slot),
16151591
)?;
@@ -1637,10 +1613,9 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
16371613
let target_buffer = HDiffBuffer::from_state(state.clone());
16381614
let diff = HDiff::compute(&base_buffer, &target_buffer, &self.config)?;
16391615
let diff_bytes = diff.as_ssz_bytes();
1640-
let key = get_key_for_col(DBColumn::BeaconStateHotDiff, state_root.as_slice());
16411616
ops.push(KeyValueStoreOp::PutKeyValue(
16421617
DBColumn::BeaconStateHotDiff,
1643-
key,
1618+
state_root.as_slice().to_vec(),
16441619
diff_bytes,
16451620
));
16461621
Ok(())
@@ -1971,10 +1946,9 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
19711946
out
19721947
};
19731948

1974-
let key = get_key_for_col(DBColumn::BeaconStateHotSnapshot, state_root.as_slice());
19751949
ops.push(KeyValueStoreOp::PutKeyValue(
19761950
DBColumn::BeaconStateHotSnapshot,
1977-
key,
1951+
state_root.as_slice().to_vec(),
19781952
compressed_value,
19791953
));
19801954
Ok(())

0 commit comments

Comments
 (0)