prysm-pulse/beacon-chain/db/slasherkv
Manu NALEPA 4030614df0
Slasher: Reduce cold start duration. (#13620)
* `getChunk` ==> `getChunkFromDatabase`.

* `loadChunks`: Rename variables.

* `Update`: Use explicit arguments.

* `detect_attestations.go`: Reduce abstraction layers.

* `loadAndUpdateChunks`: Change arguments order.

* `updatedChunkByChunkIndex`: Update all known validators in the chunk.

* `LastEpochWrittenForValidators`: Avoid avoidable `for`loop.

* `chunks.go`: Ensure implementations respect the interface.

* `LastEpochWrittenForValidators`: Stop considering lack of epoch as genesis epoch.

* `updatedChunkByChunkIndex`: Don't update latest updated epoch.

And add a bunch of tests.

* Improve slasher cold boot duration.

Before this commit, on a slasher cold boot (aka, without any db),
the `updatedChunkByChunkIndex` function looped for all validators
AND for all epochs between the genesis epoch and the current epoch.

This could take several dozen of minutes, and it is useless since the
min/max spans are actually a circular buffer with a limited lenght.
Cells of min/max spans can be overwritten (with the same value)
plenty of times.

After this commit, the `updatedChunkByChunkIndex` function loops
for all validators AND AT most 'historyLength' lenght.
Every cell of min/max spans are written AT MOST once.

Time needed for slasher boot goes from `O(nm)` to "only" `O(m)`, where:
- `n` is the number of epochs since the genesis.
- `m` is the number of validators.
2024-02-16 10:10:26 +00:00
..
BUILD.bazel Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
kv_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
kv.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
log.go Optimized Slasher Database Methods (#8805) 2021-04-23 12:06:13 -05:00
metrics.go Optimized Slasher Database Methods (#8805) 2021-04-23 12:06:13 -05:00
pruning_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
pruning.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
schema.go Beacon node slasher improvement (#13549) 2024-01-31 09:49:14 +00:00
slasher_test.go Slasher: Reduce cold start duration. (#13620) 2024-02-16 10:10:26 +00:00
slasher.go Slasher: Reduce cold start duration. (#13620) 2024-02-16 10:10:26 +00:00
slasherkv_test.go Replace ioutil with io and os (#10541) 2022-04-18 20:42:07 +00:00