chore: do not mount lightpush without relay (fixes #2808) (#3540)

* chore: do not mount lightpush without relay (fixes #2808)

- Change mountLightPush signature to return Result[void, string]
- Return error when relay is not mounted
- Update all call sites to handle Result return type
- Add test verifying mounting fails without relay
- Only advertise lightpush capability when relay is enabled

* chore: don't mount legacy lightpush without relay
This commit is contained in:
Sergei Tikhomirov
2025-12-11 10:51:47 +01:00
committed by GitHub
parent 868d43164e
commit 7d1c6abaac
9 changed files with 88 additions and 44 deletions
+20 -3
View File
@@ -13,6 +13,7 @@ import
node/peer_manager,
node/waku_node,
node/kernel_api,
node/kernel_api/lightpush,
waku_lightpush_legacy,
waku_lightpush_legacy/common,
waku_lightpush_legacy/protocol_metrics,
@@ -56,7 +57,7 @@ suite "Waku Legacy Lightpush - End To End":
(await server.mountRelay()).isOkOr:
assert false, "Failed to mount relay"
await server.mountLegacyLightpush() # without rln-relay
check (await server.mountLegacyLightpush()).isOk() # without rln-relay
client.mountLegacyLightpushClient()
serverRemotePeerInfo = server.peerInfo.toRemotePeerInfo()
@@ -147,7 +148,7 @@ suite "RLN Proofs as a Lightpush Service":
(await server.mountRelay()).isOkOr:
assert false, "Failed to mount relay"
await server.mountRlnRelay(wakuRlnConfig)
await server.mountLegacyLightPush()
check (await server.mountLegacyLightPush()).isOk()
client.mountLegacyLightPushClient()
let manager1 = cast[OnchainGroupManager](server.wakuRlnRelay.groupManager)
@@ -213,7 +214,7 @@ suite "Waku Legacy Lightpush message delivery":
assert false, "Failed to mount relay"
(await bridgeNode.mountRelay()).isOkOr:
assert false, "Failed to mount relay"
await bridgeNode.mountLegacyLightPush()
check (await bridgeNode.mountLegacyLightPush()).isOk()
lightNode.mountLegacyLightPushClient()
discard await lightNode.peerManager.dialPeer(
@@ -249,3 +250,19 @@ suite "Waku Legacy Lightpush message delivery":
## Cleanup
await allFutures(lightNode.stop(), bridgeNode.stop(), destNode.stop())
suite "Waku Legacy Lightpush mounting behavior":
asyncTest "fails to mount when relay is not mounted":
## Given a node without Relay mounted
let
key = generateSecp256k1Key()
node = newTestWakuNode(key, parseIpAddress("0.0.0.0"), Port(0))
# Do not mount Relay on purpose
check node.wakuRelay.isNil()
## Then mounting Legacy Lightpush must fail
let res = await node.mountLegacyLightPush()
check:
res.isErr()
res.error == MountWithoutRelayError
+20 -3
View File
@@ -13,6 +13,7 @@ import
node/peer_manager,
node/waku_node,
node/kernel_api,
node/kernel_api/lightpush,
waku_lightpush,
waku_rln_relay,
],
@@ -55,7 +56,7 @@ suite "Waku Lightpush - End To End":
(await server.mountRelay()).isOkOr:
assert false, "Failed to mount relay"
await server.mountLightpush() # without rln-relay
check (await server.mountLightpush()).isOk() # without rln-relay
client.mountLightpushClient()
serverRemotePeerInfo = server.peerInfo.toRemotePeerInfo()
@@ -147,7 +148,7 @@ suite "RLN Proofs as a Lightpush Service":
(await server.mountRelay()).isOkOr:
assert false, "Failed to mount relay"
await server.mountRlnRelay(wakuRlnConfig)
await server.mountLightPush()
check (await server.mountLightPush()).isOk()
client.mountLightPushClient()
let manager1 = cast[OnchainGroupManager](server.wakuRlnRelay.groupManager)
@@ -213,7 +214,7 @@ suite "Waku Lightpush message delivery":
assert false, "Failed to mount relay"
(await bridgeNode.mountRelay()).isOkOr:
assert false, "Failed to mount relay"
await bridgeNode.mountLightPush()
check (await bridgeNode.mountLightPush()).isOk()
lightNode.mountLightPushClient()
discard await lightNode.peerManager.dialPeer(
@@ -251,3 +252,19 @@ suite "Waku Lightpush message delivery":
## Cleanup
await allFutures(lightNode.stop(), bridgeNode.stop(), destNode.stop())
suite "Waku Lightpush mounting behavior":
asyncTest "fails to mount when relay is not mounted":
## Given a node without Relay mounted
let
key = generateSecp256k1Key()
node = newTestWakuNode(key, parseIpAddress("0.0.0.0"), Port(0))
# Do not mount Relay on purpose
check node.wakuRelay.isNil()
## Then mounting Lightpush must fail
let res = await node.mountLightPush()
check:
res.isErr()
res.error == MountWithoutRelayError
+4 -4
View File
@@ -282,7 +282,7 @@ suite "Sharding":
asyncTest "lightpush":
# Given a connected server and client subscribed to the same pubsub topic
client.mountLegacyLightPushClient()
await server.mountLightpush()
check (await server.mountLightpush()).isOk()
let
topic = "/waku/2/rs/0/1"
@@ -405,7 +405,7 @@ suite "Sharding":
asyncTest "lightpush (automatic sharding filtering)":
# Given a connected server and client using the same content topic (with two different formats)
client.mountLegacyLightPushClient()
await server.mountLightpush()
check (await server.mountLightpush()).isOk()
let
contentTopicShort = "/toychat/2/huilong/proto"
@@ -563,7 +563,7 @@ suite "Sharding":
asyncTest "lightpush - exclusion (automatic sharding filtering)":
# Given a connected server and client using different content topics
client.mountLegacyLightPushClient()
await server.mountLightpush()
check (await server.mountLightpush()).isOk()
let
contentTopic1 = "/toychat/2/huilong/proto"
@@ -874,7 +874,7 @@ suite "Sharding":
asyncTest "Waku LightPush Sharding (Static Sharding)":
# Given a connected server and client using two different pubsub topics
client.mountLegacyLightPushClient()
await server.mountLightpush()
check (await server.mountLightpush()).isOk()
# Given a connected server and client subscribed to multiple pubsub topics
let