mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 05:14:35 +00:00
Fix subnet unsubscription time (#6890)
Hopefully fixes https://github.com/sigp/lighthouse/issues/6732 In our `scheduled_subscriptions`, we were setting unsubscription slot to be `current_slot + 1`. Given that we were subscribing to the subnet at `duty.slot - 1`, the unsubscription slot ended up being `duty.slot`. So we were unsubscribing to the subnet at the beginning of the duty slot which is insane. Fixes the `scheduled_subscriptions` to unsubscribe at `duty.slot + 1`.
This commit is contained in:
@@ -216,6 +216,12 @@ impl<T: BeaconChainTypes> SubnetService<T> {
|
||||
|| self.permanent_attestation_subscriptions.contains(subnet)
|
||||
}
|
||||
|
||||
/// Returns whether we are subscribed to a permanent subnet for testing purposes.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn is_subscribed_permanent(&self, subnet: &Subnet) -> bool {
|
||||
self.permanent_attestation_subscriptions.contains(subnet)
|
||||
}
|
||||
|
||||
/// Processes a list of validator subscriptions.
|
||||
///
|
||||
/// This is fundamentally called form the HTTP API when a validator requests duties from us
|
||||
@@ -629,9 +635,10 @@ impl<T: BeaconChainTypes> Stream for SubnetService<T> {
|
||||
// expire subscription.
|
||||
match self.scheduled_subscriptions.poll_next_unpin(cx) {
|
||||
Poll::Ready(Some(Ok(exact_subnet))) => {
|
||||
let ExactSubnet { subnet, .. } = exact_subnet;
|
||||
let current_slot = self.beacon_chain.slot_clock.now().unwrap_or_default();
|
||||
if let Err(e) = self.subscribe_to_subnet_immediately(subnet, current_slot + 1) {
|
||||
let ExactSubnet { subnet, slot } = exact_subnet;
|
||||
// Set the `end_slot` for the subscription to be `duty.slot + 1` so that we unsubscribe
|
||||
// only at the end of the duty slot.
|
||||
if let Err(e) = self.subscribe_to_subnet_immediately(subnet, slot + 1) {
|
||||
debug!(self.log, "Failed to subscribe to short lived subnet"; "subnet" => ?subnet, "err" => e);
|
||||
}
|
||||
self.waker
|
||||
|
||||
Reference in New Issue
Block a user