lighthouse/beacon_node/store/src
Michael Sproul ed1fc7cca6 Fix I/O atomicity issues with checkpoint sync (#2671)
## Issue Addressed

This PR addresses an issue found by @YorickDowne during testing of v2.0.0-rc.0.

Due to a lack of atomic database writes on checkpoint sync start-up, it was possible for the database to get into an inconsistent state from which it couldn't recover without `--purge-db`. The core of the issue was that the store's anchor info was being stored _before_ the `PersistedBeaconChain`. If a crash occured so that anchor info was stored but _not_ the `PersistedBeaconChain`, then on restart Lighthouse would think the database was unitialized and attempt to compare-and-swap a `None` value, but would actually find the stale info from the previous run.

## Proposed Changes

The issue is fixed by writing the anchor info, the split point, and the `PersistedBeaconChain` atomically on start-up. Some type-hinting ugliness was required, which could possibly be cleaned up in future refactors.
2021-10-05 03:53:17 +00:00
..
impls Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
chunk_writer.rs Implement checkpoint sync (#2244) 2021-09-22 00:37:28 +00:00
chunked_iter.rs Implement checkpoint sync (#2244) 2021-09-22 00:37:28 +00:00
chunked_vector.rs Implement checkpoint sync (#2244) 2021-09-22 00:37:28 +00:00
config.rs Implement checkpoint sync (#2244) 2021-09-22 00:37:28 +00:00
errors.rs Implement checkpoint sync (#2244) 2021-09-22 00:37:28 +00:00
forwards_iter.rs Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
garbage_collection.rs Compact database on finalization (#1871) 2020-11-09 07:02:21 +00:00
hot_cold_store.rs Fix I/O atomicity issues with checkpoint sync (#2671) 2021-10-05 03:53:17 +00:00
impls.rs Implement checkpoint sync (#2244) 2021-09-22 00:37:28 +00:00
iter.rs Implement checkpoint sync (#2244) 2021-09-22 00:37:28 +00:00
leveldb_store.rs update dependencies (#2032) 2020-12-07 08:20:33 +00:00
lib.rs Fix I/O atomicity issues with checkpoint sync (#2671) 2021-10-05 03:53:17 +00:00
memory_store.rs Compact database on finalization (#1871) 2020-11-09 07:02:21 +00:00
metadata.rs Implement checkpoint sync (#2244) 2021-09-22 00:37:28 +00:00
metrics.rs Implement slasher (#1567) 2020-11-23 03:43:22 +00:00
partial_beacon_state.rs Fix I/O atomicity issues with checkpoint sync (#2671) 2021-10-05 03:53:17 +00:00
reconstruct.rs Fix I/O atomicity issues with checkpoint sync (#2671) 2021-10-05 03:53:17 +00:00