@@ -13,8 +13,8 @@ use crate::metadata::{
13
13
} ;
14
14
use crate :: state_cache:: { PutStateOutcome , StateCache } ;
15
15
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 ,
18
18
} ;
19
19
use itertools:: { process_results, Itertools } ;
20
20
use lru:: LruCache ;
@@ -1259,11 +1259,9 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
1259
1259
1260
1260
StoreOp :: DeleteState ( state_root, slot) => {
1261
1261
// Delete the hot state summary.
1262
- let state_summary_key =
1263
- get_key_for_col ( DBColumn :: BeaconStateHotSummary , state_root. as_slice ( ) ) ;
1264
1262
key_value_batch. push ( KeyValueStoreOp :: DeleteKey (
1265
1263
DBColumn :: BeaconStateHotSummary ,
1266
- state_summary_key ,
1264
+ state_root . as_slice ( ) . to_vec ( ) ,
1267
1265
) ) ;
1268
1266
1269
1267
// 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>
1279
1277
// Full state stored in this position
1280
1278
key_value_batch. push ( KeyValueStoreOp :: DeleteKey (
1281
1279
DBColumn :: BeaconStateHotSnapshot ,
1282
- get_key_for_col (
1283
- DBColumn :: BeaconStateHotSnapshot ,
1284
- state_root. as_slice ( ) ,
1285
- ) ,
1280
+ state_root. as_slice ( ) . to_vec ( ) ,
1286
1281
) ) ;
1287
1282
}
1288
1283
StorageStrategy :: DiffFrom ( _) => {
1289
1284
// Diff stored in this position
1290
1285
key_value_batch. push ( KeyValueStoreOp :: DeleteKey (
1291
1286
DBColumn :: BeaconStateHotDiff ,
1292
- get_key_for_col (
1293
- DBColumn :: BeaconStateHotDiff ,
1294
- state_root. as_slice ( ) ,
1295
- ) ,
1287
+ state_root. as_slice ( ) . to_vec ( ) ,
1296
1288
) ) ;
1297
1289
}
1298
1290
StorageStrategy :: ReplayFrom ( _) => {
@@ -1303,14 +1295,11 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
1303
1295
// TODO(hdiff): should attempt to delete everything if slot is not available?
1304
1296
key_value_batch. push ( KeyValueStoreOp :: DeleteKey (
1305
1297
DBColumn :: BeaconStateHotSnapshot ,
1306
- get_key_for_col (
1307
- DBColumn :: BeaconStateHotSnapshot ,
1308
- state_root. as_slice ( ) ,
1309
- ) ,
1298
+ state_root. as_slice ( ) . to_vec ( ) ,
1310
1299
) ) ;
1311
1300
key_value_batch. push ( KeyValueStoreOp :: DeleteKey (
1312
1301
DBColumn :: BeaconStateHotDiff ,
1313
- get_key_for_col ( DBColumn :: BeaconStateHotDiff , state_root. as_slice ( ) ) ,
1302
+ state_root. as_slice ( ) . to_vec ( ) ,
1314
1303
) ) ;
1315
1304
}
1316
1305
}
@@ -1581,35 +1570,22 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
1581
1570
ops : & mut Vec < KeyValueStoreOp > ,
1582
1571
) -> Result < ( ) , Error > {
1583
1572
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 ( _) => {
1593
1583
// Already have persisted the state summary, don't persist anything else
1594
1584
}
1595
1585
StorageStrategy :: Snapshot => {
1596
- debug ! (
1597
- self . log,
1598
- "Storing hot state" ;
1599
- "strategy" => "snapshot" ,
1600
- "slot" => slot,
1601
- ) ;
1602
1586
self . store_hot_state_as_snapshot ( state_root, state, ops) ?;
1603
1587
}
1604
1588
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
-
1613
1589
let from_root = get_ancenstor_state_root ( self , state, from_slot) ?. ok_or (
1614
1590
HotColdDBError :: HdiffGetPriorStateRootError ( state. slot ( ) , from_slot) ,
1615
1591
) ?;
@@ -1637,10 +1613,9 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
1637
1613
let target_buffer = HDiffBuffer :: from_state ( state. clone ( ) ) ;
1638
1614
let diff = HDiff :: compute ( & base_buffer, & target_buffer, & self . config ) ?;
1639
1615
let diff_bytes = diff. as_ssz_bytes ( ) ;
1640
- let key = get_key_for_col ( DBColumn :: BeaconStateHotDiff , state_root. as_slice ( ) ) ;
1641
1616
ops. push ( KeyValueStoreOp :: PutKeyValue (
1642
1617
DBColumn :: BeaconStateHotDiff ,
1643
- key ,
1618
+ state_root . as_slice ( ) . to_vec ( ) ,
1644
1619
diff_bytes,
1645
1620
) ) ;
1646
1621
Ok ( ( ) )
@@ -1971,10 +1946,9 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
1971
1946
out
1972
1947
} ;
1973
1948
1974
- let key = get_key_for_col ( DBColumn :: BeaconStateHotSnapshot , state_root. as_slice ( ) ) ;
1975
1949
ops. push ( KeyValueStoreOp :: PutKeyValue (
1976
1950
DBColumn :: BeaconStateHotSnapshot ,
1977
- key ,
1951
+ state_root . as_slice ( ) . to_vec ( ) ,
1978
1952
compressed_value,
1979
1953
) ) ;
1980
1954
Ok ( ( ) )
0 commit comments