Repository navigation
fix: register wakes again before the gateway retires the device - #1958
Conversation
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
[Medium impact] The PR appears safe to merge. Summary
Reviews (1) · Last reviewed commit: "fix: register wakes again before the gat..." · Reviewed by Greptile |
|
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
left a comment
There was a problem hiding this comment.
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:
registerAtwriteslastTimestampSecstogether withfingerprint = nullbefore the request, so a failed send fails the fingerprint check and retries regardless of age. - Device clock ahead pins
lastTimestampSecsin the future and suppresses refresh:nextRegistrationTimestamponly 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
isRegistrationDuetreats a missing time as due once, which re-registers once and records it. - Refresh never fires for a wallet that is open for weeks:
syncruns 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
left a comment
There was a problem hiding this comment.
Approving at 82442d5: no findings. This closes my LOW from #1944.
What I checked:
- Re-registration.
syncnow re-sends an unchanged registration oncelastTimestampSecsis 30 days old (isRegistrationDue), well inside the gateway's 270-dayidle_device_days. - Failed sends.
registerAtwriteslastTimestampSecstogether withfingerprint = nullbefore 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).
Closes #1959
Part of #1804
Follow-up to #1944: jvsena42's LOW on this thread.
Description
WakeReposends 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_daysin 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.Out of Scope
WakeRepo.kt: registering again on a presence 401. The max age covers it, since every node start syncs.WakeManager.swifthas the same skip (feat: register with the deployed wake gateways bitkit-ios#1349). It gets the same fix separately.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
WakeRepoTest.kt: a registration 271 days old is sent again (the reproduction from the review)WakeRepoTest.kt: an unchanged registration stays up to date until 30 days, then registers once and starts a new ageWakeRepoTest.kt:isRegistrationDueat its boundaries, with no recorded time and with a clock stepped backEvidence
82442d5: see checks.Gaps
just compile,just testandjust lintare left to CI.