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

Don't subscribe in AttestationTopicSubscriber if subscription is outdated #8837

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zilm13
Copy link
Contributor

@zilm13 zilm13 commented Nov 19, 2024

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

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

@@ -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);
Copy link
Contributor

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())) {
Copy link
Contributor

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

Comment on lines 110 to 111
if (lastSlot.get() != null
&& subnetSubscription.unsubscriptionSlot().isLessThan(lastSlot.get())) {
Copy link
Contributor

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();
Copy link
Contributor

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...

@zilm13
Copy link
Contributor Author

zilm13 commented Nov 20, 2024

Thank you for feedback, @rolfyone, updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants