mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-16 12:28:24 +00:00
Fix race condition in VC block proposal service (#1282)
Closes #918 Closes #923
This commit is contained in:
@@ -510,7 +510,13 @@ impl<T: EthSpec> BeaconState<T> {
|
||||
///
|
||||
/// Spec v0.12.1
|
||||
pub fn get_beacon_proposer_index(&self, slot: Slot, spec: &ChainSpec) -> Result<usize, Error> {
|
||||
// Proposer indices are only known for the current epoch, due to the dependence on the
|
||||
// effective balances of validators, which change at every epoch transition.
|
||||
let epoch = slot.epoch(T::slots_per_epoch());
|
||||
if epoch != self.current_epoch() {
|
||||
return Err(Error::SlotOutOfBounds);
|
||||
}
|
||||
|
||||
let seed = self.get_beacon_proposer_seed(slot, spec)?;
|
||||
let indices = self.get_active_validator_indices(epoch, spec)?;
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ fn test_cache_initialization<'a, T: EthSpec>(
|
||||
state.build_committee_cache(relative_epoch, spec).unwrap();
|
||||
|
||||
// Assert a call to a cache-using function passes.
|
||||
let _ = state.get_beacon_proposer_index(slot, spec).unwrap();
|
||||
state.get_beacon_committee(slot, 0).unwrap();
|
||||
|
||||
// Drop the cache.
|
||||
state.drop_committee_cache(relative_epoch);
|
||||
|
||||
Reference in New Issue
Block a user