From cda48e25f74595d79f18d652f861b1b93cabe4bc Mon Sep 17 00:00:00 2001 From: Simon-Pierre Vivier Date: Thu, 20 Mar 2025 15:30:29 -0400 Subject: [PATCH] fix: filter out ephemeral msg from waku sync (#3332) --- waku/waku_archive/archive.nim | 3 +++ waku/waku_store_sync/reconciliation.nim | 6 ++++++ waku/waku_store_sync/transfer.nim | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/waku/waku_archive/archive.nim b/waku/waku_archive/archive.nim index 4088b42a8..c296e2a6f 100644 --- a/waku/waku_archive/archive.nim +++ b/waku/waku_archive/archive.nim @@ -132,6 +132,9 @@ proc syncMessageIngress*( pubsubTopic: PubsubTopic, msg: WakuMessage, ): Future[Result[void, string]] {.async.} = + if msg.ephemeral: + return err("ephemeral message, will not store") + let msgHashHex = msgHash.to0xHex() trace "handling message in syncMessageIngress", diff --git a/waku/waku_store_sync/reconciliation.nim b/waku/waku_store_sync/reconciliation.nim index 10e8aed52..6a5e7bbd5 100644 --- a/waku/waku_store_sync/reconciliation.nim +++ b/waku/waku_store_sync/reconciliation.nim @@ -68,6 +68,9 @@ type SyncReconciliation* = ref object of LPProtocol proc messageIngress*( self: SyncReconciliation, pubsubTopic: PubsubTopic, msg: WakuMessage ) = + if msg.ephemeral: + return + let msgHash = computeMessageHash(pubsubTopic, msg) let id = SyncID(time: msg.timestamp, hash: msgHash) @@ -78,6 +81,9 @@ proc messageIngress*( proc messageIngress*( self: SyncReconciliation, msgHash: WakuMessageHash, msg: WakuMessage ) = + if msg.ephemeral: + return + let id = SyncID(time: msg.timestamp, hash: msgHash) self.storage.insert(id).isOkOr: diff --git a/waku/waku_store_sync/transfer.nim b/waku/waku_store_sync/transfer.nim index 4613c64cd..0ac959de0 100644 --- a/waku/waku_store_sync/transfer.nim +++ b/waku/waku_store_sync/transfer.nim @@ -118,6 +118,10 @@ proc needsReceiverLoop(self: SyncTransfer) {.async.} = error "failed to query archive", error = error continue + if response.messages.len < 1: + error "failed to fetch message from db" + continue + let msg = WakuMessageAndTopic(pubsub: response.topics[0], message: response.messages[0])