Repository navigation
mesh: answer a newcomer, keep presence 10 s apart (NFX-10 §6.6); §6.2 early gathering - #149
Draft
SovereignTechnology wants to merge 1 commit into
Draft
SovereignTechnology wants to merge 1 commit into
SovereignTechnology wants to merge 1 commit into
Conversation
…'s early gathering From the spec review of main 93f52f4. - NFX-10 §6.6 says how a member tells a newcomer it is there. Relays keep no ephemeral event, so a newcomer whose key is lower (it is the one to offer) waited for the member's next presence, up to 30 s. On a newcomer's `connect`, a member with room for another peer sends its own out of turn: a node each time, a page at most once per 30 s per room. - No two `connect`s of a session in one room go less than 10 s apart, as NFX-04 §2 admits one presence per 10 s per key, room and type (nfxd answered every 5 s, which a scoped relay may refuse). One due sooner is deferred, never dropped, and serves every newcomer seen meanwhile. - §6.2 allows what the page already does: stop gathering 300 ms after the first server-reflexive candidate, so a STUN server that never answers no longer costs 5 s per side; a native client may gather once and reuse it. nfxd: `RoomState::presence_now` gates the join, the 30 s round and the newcomer answer, and the tick sends a deferred presence when it falls due (nfx-proto `PRESENCE_MIN_GAP`). Page: `PresenceClock` (signal-book.ts) does the same for the signaler, which now answers newcomers.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
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.
Two gaps the spec review of main (93f52f4) found in NFX-10 §6: one in how a newcomer meets a room, and one in how long a peer gathers candidates.
1. Telling a newcomer (§6.6)
Relays keep no ephemeral event, so a session that joins a room hears of a member only at the member's next presence, up to 30 s away. When the newcomer's key is the lower one, the newcomer is the one to offer (§6.6 glare), so it waits for that presence. nfxd already answered such a newcomer with an out-of-turn
connect. The spec said nothing about it, and the web client did not do it.connectfrom a peer it held no presence for, whose key is lower, and with room for another peer, a session sends its ownconnectagain, out of turn. A node does so each time; a page at most once per 30 s per room, since most members of a busy room are pages.connects in one room less than 10 s apart, out of turn or not. NFX-04 §2 admits one presence per 10 s per key, room and type, and nfxd's 5 s was under that, so a scoped relay could refuse it. Aconnectdue sooner is sent when the 10 s have passed, not dropped, and one such serves every newcomer seen meanwhile. Aconnectsent only to a relay that has just been connected is not counted.nfxd (
nfx-node/src/mesh/mod.rs):RoomState::presence_nowgates the join, the 30 s round and the newcomer answer.next_wakeincludes it.nfx_proto::signal::PRESENCE_MIN_GAP(10 s), which replacesREANNOUNCE_EVERY(5 s, and dropped when early).Page (
signal-book.ts,signal-nostr.ts):PresenceClockdoes the same timing. The signaler now answers a newcomer that is to offer, when it has room for another peer.2. Gathering (§6.2)
§6.2 said a peer waits for ICE gathering to finish, at most 5 s, so a STUN server that never answers cost 5 s per side. The page already stops 300 ms after its first server-reflexive candidate (#130). The text now allows that, and lets a native client gather once and reuse it, as nfxd does. No code changes for this part.
Nothing on the wire changes. NFX-10's changelog has the entry.
Tests
All in Kata:
cargo test --no-fail-fastfor nfx-proto and nfx-wasm, nfx-node lib (104,presence_keeps_10_s_apart_and_one_due_sooner_waitsnew;the_lower_key_offers_and_its_offer_standsnow checks that a second newcomer within 10 s is deferred, not dropped) and the mesh e2e (7);-D warnings; the nfxd and nfx-package build;unit.ts824/824 (thePresenceClockcases new),sources-unit.ts,fetcher-unit.ts,policy-unit.tsandbook-unit.ts;e2e:nostr-node,e2e:nostr,e2e:peer-firstande2e: PASS.e2e:nostrsettles with no timers or sockets left, so the page's deferred presence is cleared when it leaves.Merging
Held until the nfx 0.1.4 cut is fixed: this changes nfxd's mesh code and must not ship in 0.1.4. This touches
mesh/mod.rsandsignal-nostr.ts, as #142 (W2) does. W2's video-room presence (§6.9 in #133) follows the same 10 s rule, and #142 will take this from main.