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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

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.

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

Successfully merging this pull request may close these issues.

2 participants