Skip to content

Remove unnecessary CAS guard from SubscriptionProvider.updateTopics()#8407

Merged
zhangchiqing merged 2 commits intomasterfrom
leo/fix-subscription-scroing-check
Feb 14, 2026
Merged

Remove unnecessary CAS guard from SubscriptionProvider.updateTopics()#8407
zhangchiqing merged 2 commits intomasterfrom
leo/fix-subscription-scroing-check

Conversation

@zhangchiqing
Copy link
Member

@zhangchiqing zhangchiqing commented Feb 11, 2026

Problem

updateTopics() refreshes peer subscription data every 10 minutes, used to penalize peers subscribing to unauthorized topics. An inverted CAS guard caused every other update to be skipped, doubling the check interval to 20 minutes.

Solution

Remove the CAS guard. It's unnecessary since updateTopics() is only called from a single-goroutine ticker loop—no concurrent calls are possible.

Summary by CodeRabbit

  • Refactor
    • Simplified the subscription provider's topic update process to enhance system performance and maintainability without affecting user-facing functionality.

@zhangchiqing zhangchiqing requested a review from a team as a code owner February 11, 2026 00:23
@github-actions
Copy link
Contributor

github-actions bot commented Feb 11, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

Removed atomic-based concurrency guard from SubscriptionProvider's topic update mechanism. The allTopicsUpdate atomic.Bool field and related CompareAndSwap logic were deleted, simplifying updateTopics to rely on single-threaded execution driven by a ticker loop instead of cross-goroutine synchronization.

Changes

Cohort / File(s) Summary
Concurrency Simplification
network/p2p/scoring/subscription_provider.go
Removed allTopicsUpdate atomic.Bool field and CompareAndSwap synchronization logic; updateTopics now assumes single-threaded execution via ticker loop, eliminating the concurrent update guard. Updated comments reflect single-goroutine usage pattern.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 No more atomic guards to hold the line,
The ticker now makes updates align,
Single-threaded, smooth, and serene,
Simplicity reigns in this concurrency scene!
One path forward, no locks to define. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing a CAS guard from the SubscriptionProvider.updateTopics() method to fix a logic bug that was skipping every other refresh.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch leo/fix-subscription-scroing-check

No actionable comments were generated in the recent review. 🎉

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@j1010001 j1010001 added Bug Something isn't working Bugfix labels Feb 11, 2026
@zhangchiqing zhangchiqing added this pull request to the merge queue Feb 13, 2026
Merged via the queue into master with commit 1f21998 Feb 14, 2026
61 checks passed
@zhangchiqing zhangchiqing deleted the leo/fix-subscription-scroing-check branch February 14, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants