From 43dff68f496d37e372c38b430532b2d578bb64f6 Mon Sep 17 00:00:00 2001 From: stubbsta Date: Tue, 7 Jul 2026 10:03:48 +0200 Subject: [PATCH] Fix ResultDefect on success and stale test stubs in lightpush retry path Two bugs left by a bad merge: 1. lightpush.nim: isRlnRelatedFailure was computed before firstResult.isOk() was checked, accessing firstResult.error unconditionally. When publish succeeds, this raises a ResultDefect. Reorder the guard so isOk()/isNone() short-circuits before the error fields are touched. 2. test_wakunode_lightpush.nim: the 420-retry stubs used descriptions ("simulated stale merkle path", "still stale") that don't contain RlnValidatorErrorMsg. The code gates 420 retries on that substring to distinguish RLN rejections from unrelated INVALID_MESSAGE responses (e.g. oversized messages). Update stubs to emit RlnValidatorErrorMsg so the retry path fires as the tests expect. Co-Authored-By: Claude Sonnet 4.6 --- logos_delivery/waku/node/waku_node/lightpush.nim | 7 ++++--- tests/node/test_wakunode_lightpush.nim | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/logos_delivery/waku/node/waku_node/lightpush.nim b/logos_delivery/waku/node/waku_node/lightpush.nim index e0ebb48f2..ae502233c 100644 --- a/logos_delivery/waku/node/waku_node/lightpush.nim +++ b/logos_delivery/waku/node/waku_node/lightpush.nim @@ -335,13 +335,14 @@ proc lightpushPublish*( # also returned for non-RLN rejections (e.g. oversized messages), so require # the error description to contain RlnValidatorErrorMsg — matching the legacy # lightpush path — to avoid unbounded on-chain RPCs on non-RLN errors. + if firstResult.isOk() or rln.isNone(): + return firstResult let isRlnRelatedFailure = - firstResult.error.code == LightPushErrorCode.OUT_OF_RLN_PROOF or - ( + firstResult.error.code == LightPushErrorCode.OUT_OF_RLN_PROOF or ( firstResult.error.code == LightPushErrorCode.INVALID_MESSAGE and firstResult.error.desc.get("").contains(RlnValidatorErrorMsg) ) - if firstResult.isOk() or rln.isNone() or not isRlnRelatedFailure: + if not isRlnRelatedFailure: return firstResult info "lightpush send rejected; refreshing merkle proof and retrying once", diff --git a/tests/node/test_wakunode_lightpush.nim b/tests/node/test_wakunode_lightpush.nim index de771348c..1db89374a 100644 --- a/tests/node/test_wakunode_lightpush.nim +++ b/tests/node/test_wakunode_lightpush.nim @@ -231,7 +231,7 @@ suite "RLN Proofs as a Lightpush Service": inc callCount if callCount == 1: return lighpushErrorResult( - LightPushErrorCode.INVALID_MESSAGE, "simulated stale merkle path" + LightPushErrorCode.INVALID_MESSAGE, RlnValidatorErrorMsg ) return lightpushSuccessResult(1) server.wakuLightPush.pushHandler = stub @@ -287,7 +287,7 @@ suite "RLN Proofs as a Lightpush Service": pubsubTopic: PubsubTopic, message: WakuMessage ): Future[WakuLightPushResult] {.async.} = inc callCount - return lighpushErrorResult(LightPushErrorCode.INVALID_MESSAGE, "still stale") + return lighpushErrorResult(LightPushErrorCode.INVALID_MESSAGE, RlnValidatorErrorMsg) server.wakuLightPush.pushHandler = stub let response = await server.lightpushPublish(some(pubsubTopic), message)