Initialize trusted block providers only once - #8062
Conversation
getTrustedBsqBlockProviders() used the emptiness of the provider set as its lazy initialization guard. An empty set is a legitimate outcome: regtest bundles no providers, the resource file can be absent, and the deny list may filter out every entry. In those cases lazyInitialize() ran again on every call, re-reading the resource on a path that DaoBlockSignatureVerifier walks per block. Populating the set in place also handed callers a live reference to it, and left it briefly empty between clear() and addAll(). Every caller reaches this singleton on the user thread today, so that window is not observable in practice, but nothing in the class enforces it. Track initialization in an explicit flag, synchronize the accessor and publish the providers as an immutable set, so the guard is atomic and callers cannot mutate shared state. Addresses the review comment on PR bisq-network#7966.
|
Thanks for opening this pull request! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
ChangesTrusted BSQ provider initialization
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Trusted provider initialization now runs once even when no providers are available, and callers receive an immutable provider collection. The covered behavior has no remaining actionable merge risk. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
|
CI is green on my fork for this commit — ubuntu-24.04, macos-15 and |
Fixes #7973 — the review comment it points to:
#7966 (comment)
getTrustedBsqBlockProviders()used the emptiness of the provider set as its lazy initialization guard. An empty set is a legitimate outcome: regtest bundles no providers, the resource file can be absent, and the deny list may filter out every entry. In those cases,lazyInitialize()ran again on every call, re-reading the resource on a path thatDaoBlockSignatureVerifierwalks per block.Populating the set in place also handed callers a live reference to it, and left it briefly empty between
clear()andaddAll(). Every caller reaches this singleton on the user thread today, so that window is not observable in practice, but nothing in the class enforces it.Track initialization in an explicit flag, synchronize the accessor, and publish the providers as an immutable set, so the guard is atomic and callers cannot mutate shared state.
Two new tests cover this; both fail without the production change.
Summary by CodeRabbit