Skip to content

fix: register wakes again before the gateway retires the device - #1958

Merged
coreyphillips merged 1 commit into
masterfrom
fix/wake-reregister-before-idle
Nov 18, 2026
Merged

coreyphillips merged 1 commit into
masterfrom
fix/wake-reregister-before-idle

Conversation

@coreyphillips

@coreyphillips coreyphillips commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1959
Part of #1804

Follow-up to #1944: jvsena42's LOW on this thread.

Description

  • WakeRepo sends an unchanged registration again once it is 30 days old (REGISTRATION_MAX_AGE). The gateway retires a device with no accepted push or registration for 270 days (retention.idle_device_days in synonymdev/wake) and presence does not count, so a wallet that got no wake for about nine months stopped receiving wakes until its FCM token changed. Every node start syncs, so a wallet opened at least once a month stays registered, and one opened after a longer gap registers again on that start.
  • No changelog fragment: wakes through the gateway have not shipped in a release yet.

Out of Scope

Design

N/A: no UI changes.

Preview

N/A

QA Notes

Setup

N/A: covered by unit tests. Reproducing on a device needs a registration older than 30 days.

Journeys

N/A: no user-visible behaviour change.

Manual Tests

N/A

Automated Checks

  • added WakeRepoTest.kt: a registration 271 days old is sent again (the reproduction from the review)
  • added WakeRepoTest.kt: an unchanged registration stays up to date until 30 days, then registers once and starts a new age
  • added WakeRepoTest.kt: isRegistrationDue at its boundaries, with no recorded time and with a clock stepped back

Evidence

  • CI on 82442d5: see checks.

Gaps

  • Not built locally: Gradle could not resolve the GitHub Packages dependencies in this environment, so just compile, just test and just lint are left to CI.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Regtest APK

Built from 82442d5 (run).

Download bitkit-dev-debug universal APK (expires in 30 days).

@coreyphillips
coreyphillips marked this pull request as ready for review November 17, 2026 17:30
@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

WakeRepo now resends an unchanged registration once it is 30 days old.

  • Wake registrations renew every 30 days when their details stay the same.

Reviews (1) · Last reviewed commit: "fix: register wakes again before the gat..." · Reviewed by Greptile

@ovitrif

ovitrif commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Triage: this PR closes #1959, in the 3.2.0 milestone. Wakes through the gateway ship in 3.2.0, so the re-registration has to land before the release, together with its iOS side in synonymdev/bitkit-ios#1349.

@talosmachina talosmachina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings. Sends an unchanged wake registration again once its last timestamp is 30 days old, so a device that rarely receives a wake is not retired by the gateway's idle sweep. Reviewed 82442d5, light tier (19 production lines; not a security path).

What I checked, and 4 candidates I ruled out

Read in full: WakeRepo.kt (sync, register, registerAt, optOut, observeRegistration, syncUntilSettled), WakeCredentialStore.kt (WakeRegistrationState), the new tests in WakeRepoTest.kt.
Call sites traced: syncRegistration from syncUntilSettled (node lifecycle / opt-in / Pubky key observer, onNewPushToken from FcmService) and DevSettingsViewModel (forced).
Build: not built here. On the Bitkit Android track an automatic review reasons from the code and CI and never runs the branch's Gradle build.
CI at review time: detekt and lint green; build-and-test and compose-ui still running on this head; the red build gate is the earlier run whose Compose job was cancelled.

Ruled out

  • Failed re-registration leaves the device looking fresh: registerAt writes lastTimestampSecs together with fingerprint = null before the request, so a failed send fails the fingerprint check and retries regardless of age.
  • Device clock ahead pins lastTimestampSecs in the future and suppresses refresh: nextRegistrationTimestamp only moves past the last value by one second, and a stale-timestamp rejection re-signs at the gateway's time, so the stored value tracks gateway time, not a skewed local clock.
  • Existing installs with a fingerprint but no recorded time: both fields are written in the same place, and isRegistrationDue treats a missing time as due once, which re-registers once and records it.
  • Refresh never fires for a wallet that is open for weeks: sync runs only on observer changes, so a node that stays up longer than 30 days without a restart waits for the next start, but the 270-day window leaves that far outside reach.

Merge confidence: 4/5, no findings; the unit tests that cover the change had not finished on this head when I read it.

Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the run metadata available to this reviewer carries the model id only)

@jvsena42 jvsena42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 82442d5: no findings. This closes my LOW from #1944.

What I checked:

  • Re-registration. sync now re-sends an unchanged registration once lastTimestampSecs is 30 days old (isRegistrationDue), well inside the gateway's 270-day idle_device_days.
  • Failed sends. registerAt writes lastTimestampSecs together with fingerprint = null before the request (WakeRepo.kt:239), so a failed re-send fails the fingerprint check and retries regardless of age.
  • Existing installs. An install with no recorded time counts as due once, re-registers, and records the time.
  • Clock skew. A device clock behind the stored time gives a negative age, which counts as fresh until the clock passes it. There's no busy loop either way.
  • Test. It covers my 271-day case.

Device gate: no device check needed — no UI or journey change. perf: not relevant; at most one extra registration per 30 days.
Skipped — covered by CI at 82442d5: unit tests, compose UI tests, detekt, lint, e2e (all green).

@coreyphillips
coreyphillips merged commit a03af91 into master Nov 18, 2026
37 of 39 checks passed
@coreyphillips
coreyphillips deleted the fix/wake-reregister-before-idle branch November 18, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: wakes stop after the gateway retires an idle device

4 participants