Skip to content

Fix timestamp-aware gateway resolution in snapshots and caches - #1230

Merged
bbalser merged 1 commit into
helium:mainfrom
grandpig:main
Aug 25, 2026
Merged

Fix timestamp-aware gateway resolution in snapshots and caches#1230
bbalser merged 1 commit into
helium:mainfrom
grandpig:main

Conversation

@grandpig

@grandpig grandpig commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix gateway resolution so the inserted_at onboarding boundary is consistently enforced by both the snapshot and fallback-cache paths.

Closes #1229

Problem

The per-gateway Trino queries evaluate gateway existence using:

inserted_at <= :timestamp

but the in-memory snapshots do not retain inserted_at, so snapshot hits ignore the supplied query timestamp.

Fallback results are also cached only by public key even though the result depends on both public key and timestamp. This can cause a lookup for one report timestamp to incorrectly determine the result for another timestamp.

Changes

  • Include inserted_at in gateway snapshot entries.
  • Check inserted_at against the supplied query timestamp on every snapshot lookup.
  • Cache timestamp-independent gateway entries instead of final boolean/resolution results.
  • Apply the timestamp cutoff after reading from the fallback cache.
  • Preserve the existing fail-closed behavior for Trino query failures.

Tests

Added regression coverage for:

  • snapshot lookup before onboarding;
  • snapshot lookup at or after onboarding;
  • fallback lookup before onboarding followed by one after onboarding;
  • fallback lookup after onboarding followed by one before onboarding.

These cases are covered for both mobile_packet_verifier and mobile_verifier.

Signed-off-by: grandpig <grandpig@outlook.com>
@grandpig

Copy link
Copy Markdown
Contributor Author

@michaeldjeffrey Just following up on this in case it got buried. The main semantic change is to retain each gateway's inserted_at in both the snapshot and fallback cache, so resolution remains timestamp-aware regardless of cache order. The regression tests cover both before→after and after→before lookup orderings. Would appreciate a look when you have time. Thanks!

@bbalser
bbalser merged commit da826b0 into helium:main Aug 25, 2026
28 checks passed
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.

Gateway snapshots and fallback caches ignore timestamp-dependent onboarding checks

3 participants