-
Notifications
You must be signed in to change notification settings - Fork 286
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
Don't subscribe in AttestationTopicSubscriber if subscription is outdated #8837
base: master
Are you sure you want to change the base?
Conversation
@@ -39,6 +40,7 @@ public class AttestationTopicSubscriber implements SlotEventsChannel { | |||
private final Eth2P2PNetwork eth2P2PNetwork; | |||
private final Spec spec; | |||
private final SettableLabelledGauge subnetSubscriptionsGauge; | |||
private final AtomicReference<UInt64> lastSlot = new AtomicReference<>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is probably better called currentSlot
?
@@ -56,6 +58,14 @@ public synchronized void subscribeToCommitteeForAggregation( | |||
aggregationSlot, UInt64.valueOf(committeeIndex), committeesAtSlot); | |||
final UInt64 currentUnsubscriptionSlot = subnetIdToUnsubscribeSlot.getOrDefault(subnetId, ZERO); | |||
final UInt64 unsubscribeSlot = currentUnsubscriptionSlot.max(aggregationSlot); | |||
if (lastSlot.get() != null && unsubscribeSlot.isLessThan(lastSlot.get())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should really read this once so that its not a concurrency issue
if (lastSlot.get() != null | ||
&& subnetSubscription.unsubscriptionSlot().isLessThan(lastSlot.get())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, read lastSlot into a UInt64
in preference to this so that we can call get once
@@ -97,6 +107,15 @@ public synchronized void subscribeToPersistentSubnets( | |||
|
|||
for (SubnetSubscription subnetSubscription : newSubscriptions) { | |||
int subnetId = subnetSubscription.subnetId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surprising this doesnt need to be final...
Thank you for feedback, @rolfyone, updated |
I think we should do this check, especially as it could come from external validator and is not verified. Otherwise we subscribe for a slot and perform unsubscription on the next one.
PR Description
Fixed Issue(s)
Documentation
doc-change-required
label to this PR if updates are required.Changelog