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

Refactor subnets subscriptions. #14711

Merged
merged 4 commits into from
Dec 17, 2024
Merged

Conversation

nalepae
Copy link
Contributor

@nalepae nalepae commented Dec 11, 2024

What type of PR is this?
Other

What does this PR do? Why is it needed?
This pull requests refactors subnets subscriptions.

It removes subscribeDynamicWithSubnets and subscribeStaticWithSyncSubnets to only use subscribeDynamicWithSubnets and subscribeStaticWithSubnets.

It also paves the way of future data columns (for peerDAS) subscriptions without the need to add specifics functions.

Acknowledgements

  • I have read CONTRIBUTING.md.
  • I have made an appropriate entry to CHANGELOG.md.
  • I have added a description to this PR with sufficient context for reviewers to understand this PR.

@nalepae nalepae added the Networking P2P related items label Dec 11, 2024
@nalepae nalepae force-pushed the refactor-subnets-subscriptions branch from c453cc3 to 2d92c53 Compare December 11, 2024 10:16
@nalepae nalepae marked this pull request as ready for review December 11, 2024 10:55
@nalepae nalepae requested a review from a team as a code owner December 11, 2024 10:55
@@ -87,18 +107,23 @@ func (s *Service) registerSubscribers(epoch primitives.Epoch, digest [4]byte) {
)
if flags.Get().SubscribeToAllSubnets {
s.subscribeStaticWithSubnets(
"Attestation",
Copy link
Member

Choose a reason for hiding this comment

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

Can we provide the actual topic or object type here ? Its better than using hardcoded strings here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This description string is only used in:

log.WithField("digest", digest).Infof("%s subnets with are no longer valid, unsubscribing from all of them.", description)

Before, we had the log hardcoded version:

log.Warnf("Attestation subnets with digest %#x are no longer valid, unsubscribing from all of them.", digest)

So, it was already hard-coded before, but not at the same location.
I can for sure use the actual topic instead, but the log will be less human readable.

Copy link
Member

@nisdas nisdas Dec 12, 2024

Choose a reason for hiding this comment

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

Could you possibly use a helper function with a switch of all topics to derive this (ex: If the topic is the attestation subnet, then the description will always be Attestation . And so on. This way we don't need to add in an additional argument

if flags.Get().SubscribeToAllSubnets {
s.subscribeStaticWithSyncSubnets(
s.subscribeStaticWithSubnets(
"Sync committee",
Copy link
Member

Choose a reason for hiding this comment

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

We already add in the SyncCommitteeSubnetTopicFormat topic, so do we need to add this again ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See other comment.

@nalepae nalepae force-pushed the refactor-subnets-subscriptions branch from 7a52666 to 260a1f3 Compare December 16, 2024 15:21
@nalepae nalepae added the Cleanup Code health! label Dec 16, 2024
// subscribeDynamicWithSyncSubnets subscribes to a dynamically changing list of subnets.
func (s *Service) subscribeDynamicWithSyncSubnets(
// subscribeSubnets subscribes to a list of subnets.
func (s *Service) subscribeSubnets(
Copy link
Member

Choose a reason for hiding this comment

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

can you rename this or subscribeToSubnets ? They sound too similar to each other which makes it easy to confuse between both of them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3f49c6a.

@nalepae nalepae force-pushed the refactor-subnets-subscriptions branch from a0144ba to 3f49c6a Compare December 17, 2024 11:40
@nalepae nalepae added this pull request to the merge queue Dec 17, 2024
Merged via the queue into develop with commit 29237cb Dec 17, 2024
15 checks passed
@nalepae nalepae deleted the refactor-subnets-subscriptions branch December 17, 2024 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cleanup Code health! Networking P2P related items
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants