Repository navigation
feat(nip43): publish the relay-signed kind 13534 membership list - #1403
Conversation
🦋 Changeset detectedLatest commit: 513115f The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Caution Review failedThe pull request is closed. Walkthrough
Change: Feature
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. |
|
Head moved after approval, and not from the factory:
The outside merge adds 9 files / 150 lines (the #1400 UTF-16 change, its tests, a fuzz target, ADR 0002 and fuzz docs, a changeset) and touches none of this branch's own hunks. |
Confidence Score: 4/5
[High impact] When enabled, the relay makes its member list readable to clients. Fix refresh ownership before merging so a client disconnect cannot leave the published membership list stale. Findings
|
| let _guard = PUBLISH_LOCK.lock().await; | ||
|
|
||
| let members = match context | ||
| .stores | ||
| .users | ||
| .find_admitted_pubkeys(QUERY_LIMIT) | ||
| .await |
There was a problem hiding this comment.
Disconnect cancels the refresh
publish_membership_list runs inside the requesting socket's handler. If the client disconnects while it waits for PUBLISH_LOCK or a storage read, run_connection aborts the handler after the membership change has committed. A departing member can then remain in the stored list until another membership change. The v3 queue explicitly survives the requesting client's disconnect.
Run the refresh in a relay-owned task or queue. Await its result before sending OK, but do not let socket cleanup cancel it.
Coverage Report for CI Build 47538800147Coverage remained the same at 77.86%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
Ports v3's NIP-43 kind 13534 membership list to the rewrite (
main, PR #1199,e58ddc02).A v3 relay publishes a relay-signed, replaceable kind 13534 event listing every admitted, non-vanished member (NIP-70
-tag, onemembertag per pubkey, capped at 10,000), gated bynip43.publishMembershipListand refreshed on membership changes. v4 implemented only the join request and the 28935 answer, so a v4 relay publishes nothing that clients read.What ships
nip43.publishMembershipList(default false, documented as the privacy consequence inCONFIGURATION.md, the field's doc comment andCLI.md).build_invite_code_event: kind 13534,content: "", tags exactly[["-"]]then one["member", <pubkey>]per member in ascending order, signed by the key derived fromSECRET.nostream-relay/src/nip43_membership.rs): gate first, v3'sinfo.selfrule (hex or npub; unparsablenpub1…refuses),UserRepository::find_admitted_pubkeys(10_001)cut to 10,000,created_at = max(now, stored + 1),upsertthroughEventRecord::from_event, broadcast only when the upsert reports a count, all under a process-wide mutex acquired after the gate.EventRepository::find_stored_replaceableandrecords::default_deduplication_for, so the slot read uses exactly the key the writer writes.crate-map.md,nip-porting.md,CLI.md,CONFIGURATION.md, ADR 0004'sinfo.selfsection.Two corrections to the issue, measured before the spec
MembershipListPublisher.refresh()is a per-process promise queue called only from the join, leave and vanish strategies. The port matches that; a timer would be a new, unsourced interval.dtag — 13534 is replaceable by kind range, not addressable.Measured
The 524,288-byte
maxPayloadSizebounds inbound frames only; a connected client is asserted to receive the full frame.Review
Three rounds. Round 1: code and architecture CHANGES (a criterion naming a test that did not exist, two missing observations, three record defects), security and performance PASS. Rounds 2–3 closed every finding; the code lens ran 23 per-condition inversions and all reddened.
Follow-ups (not blocking, both measured)
Closes #1366is inert on this repository (the default branch ismain; this PR targetsrewrite/main); the issue is closed by hand after the merge.Summary by CodeRabbit
New Features
Documentation