Commit edabcf5
refactor(messaging): lift rfc26 decoding to Transport (#7524)
* feat(messaging): add neutral ReceivedMessage push seam on the waku adapter
Adds the receive half of the logos-delivery-shaped MessagingAPI: a reliable
push channel of neutral ReceivedMessages (mirroring the logos-delivery
MessageReceived event), published from processMessage in parallel with the
existing NotifyWatchers decode/match path. Nothing consumes it yet, so
reception behaviour is unchanged; the transport-side decode/match handler
follows.
- types.ReceivedMessage: neutral, send-symmetric shape {Hash, ContentTopic,
Payload, Ephemeral, Meta} plus transitional Version/Timestamp (status-go#7522).
- types.Waku / transport.MessagingAPI gain Subscribe/UnsubscribeMessageReceived.
- *Waku implements them with a single reliable buffered channel (blocking with
backpressure, ctx-guarded, no-op until subscribed).
Refs #7464
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(messaging): move receive decode/route/match into the transport
The transport now owns the reception pipeline: a receiveLoop consumes the
adapter's neutral ReceivedMessage push channel, routes each message by content
topic to the matching filters, decodes it via rfc26 using the filter's key
material, and buffers the decoded result. RetrieveRawAll drains that buffer
(instead of polling waku.GetFilterMessages) and dedups against the persistent
processed-message cache. The matched-tickle (SubscribeFilterMatched) now
originates in the transport.
The waku adapter's processMessage stops decoding/matching/buffering and just
forwards every received envelope; the transport's processed-message cache is
the single de-duplication authority (keyed by message hash), so the adapter
marks nothing processed — preserving store re-fetch for late-installed filters.
- FiltersManager: WatchersByContentTopic + a runtime-only decodeKeys map
(sym/asym key material captured at subscribe time; never on the persisted
Filter), cleaned on Remove/RemoveNoListenFilters.
- transport.decode mirrors transport.encode (version==0 passthrough);
signature/sender match collapses since common.Filter.Src was always nil.
- New TestReceivePushPath covers route -> decode -> drain end to end.
The adapter-side decode/match/buffer (NotifyWatchers, Open, MemoryMessageStore,
GetFilterMessages) is now dead and removed in the next commit.
Refs #7464
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(messaging): remove the dead waku-side reception pipeline
With decode/route/match now in the transport, delete the adapter-side
reception machinery and the wrong-direction dependency it carried:
- waku/common: drop Open (and its transport/rfc26 import — the wrong-direction
dependency the staged refactor was working off), NotifyWatchers, MatchMessage,
the per-filter MemoryMessageStore + Trigger/Retrieve, the topic-match index,
and the matchedPublisher. common.Filter is now just a wire-subscription record.
- waku adapter: drop GetFilterMessages, ToWakuMessage, MarkP2PMessageAsProcessed,
the SubscribeFilterMatched delegation, the write-only storeMsgIDs state, and the
per-filter buffer wiring in Subscribe/Clean.
- Trim types.Waku and transport.MessagingAPI accordingly; drop the now-unused
MarkP2PMessageAsProcessed facade method and its messenger call (it only deleted
from the dead storeMsgIDs map; dedup is the transport's processed-message cache).
- Port the waku/common filter tests to the registry-only shape; the decode/match
coverage now lives in the transport (TestReceivePushPath).
make statusgo ✅
Refs #7464
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(messaging): per-candidate decode, pubsub routing, reuse sym keys
Addresses review feedback on the receive pipeline:
- Routing keys on (pubsubTopic, contentTopic) again, not content topic alone.
PubsubTopic is carried on the neutral ReceivedMessage (transitional, #7522) and
a filter with no explicit pubsub topic is normalized to the default shard, so
the waku layer's routing is preserved.
- Decode per candidate instead of "decode once, reuse". Content topics are a
4-byte hash of the chat id, so distinct chats can collide on one content topic
with different keys; each candidate is now decoded with its own key and a
successful authenticated decrypt is what confirms the match (this also replaces
the old per-filter key-hash check).
- Drop the redundant symmetric entries from the runtime key map: symmetric keys
are resolved on demand via keysManager.RawSymKey(SymKeyID) (the same path the
send side uses). Only asymmetric private keys — not reachable from a persisted
Filter — are kept in the runtime map (renamed decodeKeys -> asymKeys).
TestReceivePushPath gains a wrong-key case (message on the right topic but the
wrong key is dropped). make statusgo / make lint clean.
Refs #7464
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(messaging): deliver received messages over the envelope feed
Replace the bespoke SubscribeMessageReceived channel with the existing envelope
event feed, addressing review feedback:
- The waku adapter no longer exposes a dedicated received-message channel. Its
processMessage attaches the neutral *types.ReceivedMessage as the Data of the
existing EventEnvelopeAvailable envelope event. MessagingAPI now exposes the
generic SubscribeEnvelopeEvents (one event seam, the shape logos-delivery
uses) instead of a per-event method; the transport's receiveLoop consumes it
and decodes/routes the available events.
- This fixes reception in unit tests, where a single waku instance is shared by
multiple cores: the previous single-consumer channel let one core steal
another core's messages. The envelope feed is a broadcast, so every core's
transport sees every event and routes it against its own filters (matching the
old NotifyWatchers fan-out).
- Drops the "reliable channel" wording, which collided with logos-delivery's
unrelated ReliableChannelsAPI.
make statusgo / make lint clean; protocol MessengerSuite reception tests
(own/their public, their private 1:1, group, non-existing chats) pass.
Refs #7464
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(communities): wait for bob to learn alice is a poster before she posts
TestAnnouncementsChannelPermissions relied on bob receiving the community
description that promotes alice to poster before he received alice's channel
message. Reception order is not guaranteed (Waku), so when bob processed the
message first he rejected it ("user can't post in community") against stale
community state and never retried it — the known, deferred limitation in #3869.
Make the test deterministic: after the owner reevaluates members, wait for bob
to apply the change (alice == poster, 2 channel members) before alice posts, so
ordering no longer decides the outcome. This is a test-only change; #3869 itself
is unchanged.
Refs #7464, #3869
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(profile-showcase): wait for showcased communities before asserting
TestProfileShowcaseProofOfMembershipEncryptedCommunity asserted on the first
profile-showcase update for alice's contact. The showcased communities are
validated and populated asynchronously (membership proof for the encrypted
community arrives separately), so under CI timing the entries could be absent
when asserted — the showcase came back empty and the test failed with
"[]" should have 2 item(s), but has 0.
Wait until bob's stored showcase for alice actually has both communities before
asserting their data, instead of on the first showcase update. Test-only change;
reception order no longer decides the outcome (see #3869).
Refs #7464, #3869
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(messaging): dedup received messages by hash within a drain
The push receive buffer was a per-filter slice, so the same envelope
pushed more than once before RetrieveRawAll drained it was returned
(and processed) multiple times — the persistent processed-message cache
only dedups across drains, not within one. The waku adapter's old
per-filter store was a hash-keyed map and collapsed these duplicates on
insert. Restore that invariant by keying the buffer on message hash.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(push-notification): re-advertise so alice learns both paired devices
Each paired device advertises only its own installation's push info on
the shared contact-code topic, and processing one such advertisement
stamps a query timestamp that suppresses the authoritative server query
for 24h. Under the new push receive path alice processes the later
device's advertisement before she sends her message (on the old poll
path she queried first), so she permanently sees only one installation.
Re-advertise from both devices inside the retry loop, after alice is
subscribed to the contact-code topic, so she receives both.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent b11c24c commit edabcf5
17 files changed
Lines changed: 485 additions & 675 deletions
File tree
- pkg/messaging
- layers/transport
- waku
- common
- types
- protocol
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | 6 | | |
9 | 7 | | |
10 | 8 | | |
| |||
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | 39 | | |
46 | 40 | | |
47 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| |||
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
72 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
73 | 116 | | |
74 | 117 | | |
75 | 118 | | |
| |||
281 | 324 | | |
282 | 325 | | |
283 | 326 | | |
| 327 | + | |
284 | 328 | | |
285 | 329 | | |
286 | 330 | | |
| |||
312 | 356 | | |
313 | 357 | | |
314 | 358 | | |
| 359 | + | |
315 | 360 | | |
316 | 361 | | |
317 | 362 | | |
| |||
677 | 722 | | |
678 | 723 | | |
679 | 724 | | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
680 | 728 | | |
681 | 729 | | |
682 | 730 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
0 commit comments