mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 13:24:44 +00:00
Fix bugs in proposer calculation post-Fulu (#8101)
As identified by a researcher during the Fusaka security competition, we were computing the proposer index incorrectly in some places by computing without lookahead. - [x] Add "low level" checks to computation functions in `consensus/types` to ensure they error cleanly - [x] Re-work the determination of proposer shuffling decision roots, which are now fork aware. - [x] Re-work and simplify the beacon proposer cache to be fork-aware. - [x] Optimise `with_proposer_cache` to use `OnceCell`. - [x] All tests passing. - [x] Resolve all remaining `FIXME(sproul)`s. - [x] Unit tests for `ProtoBlock::proposer_shuffling_root_for_child_block`. - [x] End-to-end regression test. - [x] Test on pre-Fulu network. - [x] Test on post-Fulu network. Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
@@ -497,7 +497,7 @@ impl<E: EthSpec> ValidatorMonitor<E> {
|
||||
});
|
||||
|
||||
// Add missed non-finalized blocks for the monitored validators
|
||||
self.add_validators_missed_blocks(state);
|
||||
self.add_validators_missed_blocks(state, spec);
|
||||
self.process_unaggregated_attestations(state, spec);
|
||||
|
||||
// Update metrics for individual validators.
|
||||
@@ -588,7 +588,7 @@ impl<E: EthSpec> ValidatorMonitor<E> {
|
||||
}
|
||||
|
||||
/// Add missed non-finalized blocks for the monitored validators
|
||||
fn add_validators_missed_blocks(&mut self, state: &BeaconState<E>) {
|
||||
fn add_validators_missed_blocks(&mut self, state: &BeaconState<E>, spec: &ChainSpec) {
|
||||
// Define range variables
|
||||
let current_slot = state.slot();
|
||||
let current_epoch = current_slot.epoch(E::slots_per_epoch());
|
||||
@@ -616,8 +616,8 @@ impl<E: EthSpec> ValidatorMonitor<E> {
|
||||
if block_root == prev_block_root {
|
||||
let slot_epoch = slot.epoch(E::slots_per_epoch());
|
||||
|
||||
if let Ok(shuffling_decision_block) =
|
||||
state.proposer_shuffling_decision_root_at_epoch(slot_epoch, *block_root)
|
||||
if let Ok(shuffling_decision_block) = state
|
||||
.proposer_shuffling_decision_root_at_epoch(slot_epoch, *block_root, spec)
|
||||
{
|
||||
// Update the cache if it has not yet been initialised, or if it is
|
||||
// initialised for a prior epoch. This is an optimisation to avoid bouncing
|
||||
|
||||
Reference in New Issue
Block a user