Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix subnet unsubscription time #6890

Open
wants to merge 4 commits into
base: unstable
Choose a base branch
from

Conversation

pawanjay176
Copy link
Member

Issue Addressed

Hopefully fixes #6732

Proposed Changes

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.

Additional Info

Running this on kurtosis made me realise that we do not send subscriptions for the first couple of slots because of https://github.com/sigp/lighthouse/blob/unstable/validator_client/validator_services/src/duties_service.rs#L79-L85

Not sure if we want to handle that.

@pawanjay176 pawanjay176 requested a review from jxs as a code owner January 30, 2025 22:11
Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!

The fix makes sense to me.

The testnet case is interesting, but I think a fix for that can wait for another PR. I guess we might want to special-case the VC's/BN's handling of the first ~2 slots of a network (feels kind of dumb), or remove the loud warnings for late subscriptions from the BN and just track them with a metric.

@michaelsproul
Copy link
Member

Looks like one of the tests is failing. It might actually be expecting the old behaviour 👀

@michaelsproul michaelsproul added waiting-on-author The reviewer has suggested changes and awaits thier implementation. v6.1.0 New release c. Q1 2025 labels Jan 30, 2025
@pawanjay176
Copy link
Member Author

I fixed the failing test according to my understanding.
I think prior to #6146 , the test was checking if we bundled multiple unsubscriptions together into a single one (e.g. if we need to unsubscribe from subnet X at slot 9 and 12, then skip the unsubscribe at 9).

After the refactor, we decide to extend the unsubscription only in subscribe_to_subnet_immediately 1 slot before the subscription. So multiple unsubscriptions will get bundled together only in the case where there's overlap between an existing subscription and the new one (e.g. if we are subscribing at slot 11 and there's a planned unsubscription event at slot 12, then we just extend the subscription).

TL;DR: the test test_subscribe_same_subnet_several_slots_apart wasn't refactored with the logic change in #6146 , and started failing when we fixed a bug. cbf7dca refactors the test.

@pawanjay176 pawanjay176 added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Jan 31, 2025
Copy link
Member

@jimmygchen jimmygchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find! 👍

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;
if let Err(e) = self.subscribe_to_subnet_immediately(subnet, slot + 1) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add some comments referencing the issue and the reason for slot + 1 in the code. Useful if we ever refactor this and git blame breaks

@pawanjay176 pawanjay176 force-pushed the fix-unsubscription-time branch from 1f7c612 to 53fb5ea Compare February 1, 2025 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review The code is ready for review v6.1.0 New release c. Q1 2025
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants