lodestar icon indicating copy to clipboard operation
lodestar copied to clipboard

Resubscribe to beacon subnets if current epoch dependent root changed

Open nflaig opened this issue 2 years ago • 0 comments

Describe the bug

We have this function handleAttesterDutiesReorg which is mostly called when head (onNewHead) is updated

  • and dependent root for next epoch changed
  • or dependent root for current epoch changed

https://github.com/ChainSafe/lodestar/blob/1aa656191c84e3b55281bb8f21c9f4a529282500/packages/validator/src/services/attestationDuties.ts#L348

In both those cases we handle the reorg by

  • getting updated attestater duties (getAttesterDuties)
  • update cached duties (dutiesByIndexByEpoch)
  • recalculate proof (is_aggregator)

But I noticed we are not resubscribing to beacon subnets (prepareBeaconCommitteeSubnet). This is not an issue if the dependent root for the next epoch changed as we re-/subscribe to current (N) and next epoch (N+1) at the start of each epoch. https://github.com/ChainSafe/lodestar/blob/1aa656191c84e3b55281bb8f21c9f4a529282500/packages/validator/src/services/attestationDuties.ts#L196

However, this is an issue if dependent root for current epoch changed as previous subscriptions are no longer valid

  • validator duties changed (slot, committee index, etc.)
  • is_aggregator results are different

Expected behavior

Validators should be resubscribed to beacon committee subnets if current epoch dependent root changed.

Ideally, should just always resubscribe when handleAttesterDutiesReorg is called even if dependent root for next epoch changed as the subscriptions for epoch N+1 are outdated as well and the sooner we subscribe to subnets, the more likely it is to find good peers.

Steps to reproduce

No response

Additional context

No response

Operating system

Linux

Lodestar version or commit hash

v1.11.3 / unstable (1aa656191c84e3b55281bb8f21c9f4a529282500)

nflaig avatar Oct 12 '23 10:10 nflaig