geolocation: add target_update_count to GeoProbe for lightweight target change detection#3337
Merged
geolocation: add target_update_count to GeoProbe for lightweight target change detection#3337
Conversation
4f1dcb1 to
f6a9929
Compare
Contributor
|
I think there's a race condition because:
Fix it by running target discovery immediately after parent discovery? |
Contributor
|
We should probably explicitly handle (and log) when the counter wraps. |
Contributor
Author
I don't think it's relevant. We're only ever looking for change. 0 to 1 is functionally identical to 4,294,967,295 to 0. |
nikw9944
approved these changes
Mar 23, 2026
…added or removed.
…ery, since it's now used in main.
99e5f75 to
eb03518
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3304
Summary of Changes
target_update_count: u32field to the onchainGeoProbeaccount, incremented byadd_targetandremove_targetprocessors. Non-breaking: usesBorshDeserializeIncrementalso existing accounts default to 0.atomic.Uint32, and target discovery skips the expensiveGetGeolocationUsersRPC scan when the counter hasn't changed. A forced full refresh every 5th tick (~5 min at 60s intervals) catches non-counter changes like payment status updates.Diff Breakdown
~80% of the diff is tests; core logic is compact.
Key files (click to expand)
controlplane/telemetry/internal/geoprobe/target_discovery.go— skip-scan logic: check sharedtarget_update_countatomic, force full refresh every 5th tick, nil-return for skipped scanssmartcontract/programs/doublezero-geolocation/src/state/geo_probe.rs— addtarget_update_countfield withBorshDeserializeIncremental, backward-compat deserialization, updated Display/testscontrolplane/telemetry/internal/geoprobe/onchain_discovery.go— parent discovery storesprobe.TargetUpdateCountinto shared atomic after each pollcontrolplane/telemetry/cmd/geoprobe-agent/main.go— create sharedatomic.Uint32, pass to both parent and target discovery configssdk/geolocation/go/state.go— addTargetUpdateCount uint32to GoGeoProbestruct, backward-compat deserializationTesting Verification
target_update_countaccountstarget_update_countincrements afteradd_target/remove_target, unchanged afterupdate_payment_statustarget_update_countis stored in the shared atomiccargo build,cargo clippy,rust-fmt,go test,golangci-lintall pass