cleanup(01-dry): use watchMembershipConfirmation helper + bump nwaku

Replaces the duplicated watcher proc body with a single call to the
new gifter-client helper. Net change: 38-line inline watcher -> 10
lines invoking the helper. Bumps vendor/nwaku for the helper itself.
This commit is contained in:
Arseniy Klempner 2026-05-21 12:17:56 -06:00
parent 295b8d7933
commit cbbf4b23ae
No known key found for this signature in database
GPG Key ID: 51653F18863BD24B
2 changed files with 11 additions and 39 deletions

View File

@ -458,44 +458,16 @@ proc start*(client: WakuClient) {.async.} =
# materialises for our id; if the authoritative leaf differs,
# rewrite lezGm.membershipIndex so subsequent proofs are valid. The
# pre-publish self-verify rejects bad proofs in the meantime.
let optimisticLeafChat = success.leafIndex
let watcherClient = gifterClient
let watcherPeer = gifterPeer
let watcherIdCommit = idCommitmentBytes
asyncSpawn (proc(): Future[void] {.async.} =
const pollEveryMs = 30_000
const deadlineMs = 1_800_000
let deadline = Moment.now() + chronos.milliseconds(deadlineMs)
while Moment.now() < deadline:
try:
await sleepAsync(chronos.milliseconds(pollEveryMs))
except CancelledError:
return
let qr =
try:
await watcherClient.queryMembershipStatus(
watcherPeer, configAccountId, watcherIdCommit)
except CancelledError:
return
except CatchableError as e:
Result[rln_gifter_protocol.MembershipStatusResponse, string].err(
"queryMembershipStatus raised: " & e.msg)
if qr.isErr: continue
let resp = qr.get()
if resp.errorMessage.isSome: continue
if not resp.registered: continue
if resp.leafIndex.isSome:
let authLeaf = resp.leafIndex.get()
if authLeaf != optimisticLeafChat:
info "Chat-client membership leaf corrected from optimistic",
optimistic = optimisticLeafChat, authoritative = authLeaf
lezGm.membershipIndex =
some(onchain_group_manager.MembershipIndex(authLeaf))
mix_lez_client.setRlnConfig(configAccountId, authLeaf.int)
return
warn "Chat-client membership confirmation timed out",
optimisticLeaf = optimisticLeafChat
)()
let watcherLezGm = lezGm
let watcherConfigAccount = configAccountId
asyncSpawn gifterClient.watchMembershipConfirmation(
gifterPeer, configAccountId, idCommitmentBytes, success.leafIndex,
"Chat-client",
proc(authLeaf: uint64) {.gcsafe, raises: [].} =
watcherLezGm.membershipIndex =
some(onchain_group_manager.MembershipIndex(authLeaf))
mix_lez_client.setRlnConfig(watcherConfigAccount, authLeaf.int),
)
asyncSpawn taskKeepAlive(client)

2
vendor/nwaku vendored

@ -1 +1 @@
Subproject commit ce6f5c2d5e184b7c94a65068d4e5f29936259020
Subproject commit f354e9b2367be7a5cf9df352f7321b2283ad1a87