mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 10:11:44 +00:00
Fix attestations not getting added to the aggregation pool (#5863)
* Remove from delay_map 2 slots after duty * Cleanup
This commit is contained in:
@@ -29,6 +29,10 @@ pub(crate) const MIN_PEER_DISCOVERY_SLOT_LOOK_AHEAD: u64 = 2;
|
|||||||
/// Currently a whole slot ahead.
|
/// Currently a whole slot ahead.
|
||||||
const ADVANCE_SUBSCRIBE_SLOT_FRACTION: u32 = 1;
|
const ADVANCE_SUBSCRIBE_SLOT_FRACTION: u32 = 1;
|
||||||
|
|
||||||
|
/// The number of slots after an aggregator duty where we remove the entry from
|
||||||
|
/// `aggregate_validators_on_subnet` delay map.
|
||||||
|
const UNSUBSCRIBE_AFTER_AGGREGATOR_DUTY: u32 = 2;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
|
||||||
pub(crate) enum SubscriptionKind {
|
pub(crate) enum SubscriptionKind {
|
||||||
/// Long lived subscriptions.
|
/// Long lived subscriptions.
|
||||||
@@ -462,8 +466,6 @@ impl<T: BeaconChainTypes> AttestationService<T> {
|
|||||||
) -> Result<(), &'static str> {
|
) -> Result<(), &'static str> {
|
||||||
let slot_duration = self.beacon_chain.slot_clock.slot_duration();
|
let slot_duration = self.beacon_chain.slot_clock.slot_duration();
|
||||||
|
|
||||||
// Calculate how long before we need to subscribe to the subnet.
|
|
||||||
let time_to_subscription_start = {
|
|
||||||
// The short time we schedule the subscription before it's actually required. This
|
// The short time we schedule the subscription before it's actually required. This
|
||||||
// ensures we are subscribed on time, and allows consecutive subscriptions to the same
|
// ensures we are subscribed on time, and allows consecutive subscriptions to the same
|
||||||
// subnet to overlap, reducing subnet churn.
|
// subnet to overlap, reducing subnet churn.
|
||||||
@@ -474,11 +476,17 @@ impl<T: BeaconChainTypes> AttestationService<T> {
|
|||||||
.slot_clock
|
.slot_clock
|
||||||
.duration_to_slot(slot)
|
.duration_to_slot(slot)
|
||||||
.unwrap_or_default(); // If this is a past slot we will just get a 0 duration.
|
.unwrap_or_default(); // If this is a past slot we will just get a 0 duration.
|
||||||
time_to_subscription_slot.saturating_sub(advance_subscription_duration)
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// Calculate how long before we need to subscribe to the subnet.
|
||||||
|
let time_to_subscription_start =
|
||||||
|
time_to_subscription_slot.saturating_sub(advance_subscription_duration);
|
||||||
|
|
||||||
|
// The time after a duty slot where we no longer need it in the `aggregate_validators_on_subnet`
|
||||||
|
// delay map.
|
||||||
|
let time_to_unsubscribe =
|
||||||
|
time_to_subscription_slot + UNSUBSCRIBE_AFTER_AGGREGATOR_DUTY * slot_duration;
|
||||||
if let Some(tracked_vals) = self.aggregate_validators_on_subnet.as_mut() {
|
if let Some(tracked_vals) = self.aggregate_validators_on_subnet.as_mut() {
|
||||||
tracked_vals.insert(ExactSubnet { subnet_id, slot });
|
tracked_vals.insert_at(ExactSubnet { subnet_id, slot }, time_to_unsubscribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the subscription should be done in the future, schedule it. Otherwise subscribe
|
// If the subscription should be done in the future, schedule it. Otherwise subscribe
|
||||||
|
|||||||
Reference in New Issue
Block a user