lighthouse icon indicating copy to clipboard operation
lighthouse copied to clipboard

Avoid subscribing to all subnets with an optimistic head

Open paulhauner opened this issue 3 years ago • 3 comments

Description

The BN can follow the beacon chain whilst the EE is syncing, this is called optimistic sync. A node has an optimistic head when the head of the beacon chain has not been verified by the EE because that EE is syncing. An optimistic head can be identified with:

head_is_optimsitic = chain.canonical_head.head_execution_status().is_optimsitic()

When the head is optimistic, the BN cannot produce attestations since it would be unsafe to attest to a block that has not been fully verified.

When a new BN+EE pair is started, we expect the BN to be checkpoint synced and to reach the beacon chain head in minutes. However, the EE needs to sync the entire chain; a process which might take hours or days. Presently, once the BN reaches the head and it has validators or uses the --subscribe-all-subnets flag it will start verifying all attestations and use significant CPU doing so. When the BN and EE are on the same host this might significantly slow down EE sync. Since the BN can't produce attestations whilst the EE is syncing, this seems unnecessary.

I propose that we disable subnet subscriptions when the EE is syncing in a similar way to how we disable them whilst the BN is syncing.

paulhauner avatar Jul 12 '22 05:07 paulhauner

We currently disable all gossipsub subscriptions whilst we are syncing. We call these CoreTopics.

I guess if we are an aggregator for a subnet we should still subscribe to these subnets. I guess you're suggesting to just delay subscribing to the long-lived subnets and/or those included by --subsribe-all-subnets.

We are working on a new long-lived subnet subscription model, but its to be tested.

AgeManning avatar Jul 12 '22 05:07 AgeManning

I guess if we are an aggregator for a subnet we should still subscribe to these subnets

We're not going to be an aggregator when we have an optimistic head either.

I guess you're suggesting to just delay subscribing to the long-lived subnets and/or those included by --subsribe-all-subnets.

Yep, I think that sounds right.

paulhauner avatar Jul 12 '22 23:07 paulhauner

I'm dropping the v2.5.0 tag after a chat with @AgeManning. I think it's totally fine that this isn't in v2.5.0 and I wouldn't like to rush this or delay the release :relaxed:

paulhauner avatar Jul 27 '22 04:07 paulhauner