Repository navigation
gossip-sqlite: cap relays per public key (MAX_RELAYS_PER_PK) - #1512
Open
ZeroPointSynergy wants to merge 3 commits into
Open
ZeroPointSynergy wants to merge 3 commits into
ZeroPointSynergy wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Cover the MAX_RELAYS_PER_PK cap added to `update_relay_per_user`, which codecov reported as uncovered (patch coverage 81.25% < 81.76% target), failing the codecov/patch check. The test asserts, against the SQLite backend: - a public key stores at most MAX_RELAYS_PER_PK + 1 distinct relays, mirroring the in-memory backend; - further distinct relays are skipped instead of growing the table; - already-known relays keep being updated once the key is capped, so the cap does not suppress `received_events`/flags updates; - the cap is scoped per public key, so a capped key cannot starve others. Verified by mutation testing: disabling the cap (11 vs 8 rows), changing `>` to `>=` (7 vs 8), dropping the `exists` check (received_events 1 vs 2) and unscoping the COUNT query (second key 0 vs 8) each make the test fail.
Author
|
Added a test to cover the relay cap, since the codecov patch check was failing (81.25% vs 81.76% target — the new
I mutation-tested the test rather than trusting a green run — each of these broken implementations makes it fail:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1433 (SQLite backend part).
Summary
The in-memory gossip backend already caps distinct relays per public key at MAX_RELAYS_PER_PK (+1, mirroring ). The SQLite backend had no such cap in , allowing unbounded growth of rows via a connected relay.
This change mirrors the in-memory cap in the SQLite backend: skip inserting a new relay once the per-key count exceeds MAX_RELAYS_PER_PK, and propagate DB errors instead of masking them.
Verification