prysm icon indicating copy to clipboard operation
prysm copied to clipboard

rm Archive Points

Open kasey opened this issue 2 years ago • 0 comments

What type of PR is this?

Other - cleanup/simplification

What does this PR do? Why is it needed?

This PR updates the database feature called Archive Points. Some background: while tracing through the cold state migration code I noticed there were a few tests that relied on a database structures kept in state-slot-indices, a feature called "Archive Points" elsewhere. This seems to be a feature that was once more central to the hot/cold state saving mechanism, but today the only code using archive point values is p2p startup code, which only needs to retrieve a recent state to get an estimate for the current number of validators for the purpose of setting peer scoring weights. @nisdas suggested that the finalized state used to start stategen/blockchain would also work to initialize p2p scores, meaning that we can excise this entire database feature, saving some runtime overhead that comes with maintaining these data structures, while also simplifying the codebase.

With this PR, the finalized root retrieved by the BeaconNode service for stategen is subsequently used to initialize p2p. As this was the only dependency between p2p and the database, the DB struct field was removed from the p2p.Config struct and replaced by a uint. BeaconNode sets this uint value when starting the p2p service. One note from Nishant was to take care to handle zero-roots. In the stategen initialization code which this change relies on, when the finalized block is zero'd out, it will look up the genesis block and use stategen to get the state for that root, which will return the genesis state.

kasey avatar Aug 25 '22 19:08 kasey