@@ -43,21 +43,26 @@ pub fn upgrade_to_v23<T: BeaconChainTypes>(
43
43
let state_root = state_root_result?;
44
44
debug ! (
45
45
?state_root,
46
- "Deleting temporary state flag on v23 schema migration"
46
+ "Deleting temporary state on v23 schema migration"
47
47
) ;
48
48
ops. push ( KeyValueStoreOp :: DeleteKey (
49
49
DBColumn :: BeaconStateTemporary ,
50
50
state_root. as_slice ( ) . to_vec ( ) ,
51
51
) ) ;
52
- // Here we SHOULD delete the items for key `state_root` in columns `BeaconState` and
53
- // `BeaconStateSummary`. However, in the event we have dangling temporary states at the time
54
- // of the migration, the first pruning routine will prune them. They will be a tree branch /
55
- // root not part of the finalized tree and trigger a warning log once.
56
- //
57
- // We believe there may be race conditions concerning temporary flags where a necessary
58
- // canonical state is marked as temporary. In current stable, a restart with that DB will
59
- // corrupt the DB. In the unlikely case this happens we choose to leave the states and
60
- // allow pruning to clean them.
52
+
53
+ // We also delete the temporary states themselves. Although there are known issue with
54
+ // temporary states and this could lead to DB corruption, we will only corrupt the DB in
55
+ // cases where the DB would be corrupted by restarting on v7.0.x. We consider these DBs
56
+ // "too far gone". Deleting here has the advantage of not generating warnings about
57
+ // disjoint state DAGs in the v24 upgrade, or the first pruning after migration.
58
+ ops. push ( KeyValueStoreOp :: DeleteKey (
59
+ DBColumn :: BeaconState ,
60
+ state_root. as_slice ( ) . to_vec ( ) ,
61
+ ) ) ;
62
+ ops. push ( KeyValueStoreOp :: DeleteKey (
63
+ DBColumn :: BeaconStateSummary ,
64
+ state_root. as_slice ( ) . to_vec ( ) ,
65
+ ) ) ;
61
66
}
62
67
63
68
Ok ( ops)
0 commit comments