Skip to content

geolocation: onchain portion of alternate offset-destinations#3501

Merged
ben-dz merged 1 commit intomainfrom
bdz/geolocation-alt-offset-onchain-only
Apr 10, 2026
Merged

geolocation: onchain portion of alternate offset-destinations#3501
ben-dz merged 1 commit intomainfrom
bdz/geolocation-alt-offset-onchain-only

Conversation

@ben-dz
Copy link
Copy Markdown
Contributor

@ben-dz ben-dz commented Apr 9, 2026

Summary of Changes

  • Add a result_destination field to the GeolocationUser onchain account, allowing users to specify an IP:port or domain:port where geoprobe results should be sent
  • Add a new SetResultDestination instruction that validates the destination (public IP or valid domain + port), updates the user account, and bumps target_update_count on all referenced probe accounts so they pick up the change
  • Use BorshDeserializeIncremental for backward-compatible deserialization of existing accounts that lack the new field

Diff Breakdown

Category Files Lines (+/-) Net
Core logic 6 +292 / -26 +266
Scaffolding 4 +16 / -1 +15
Tests 2 +445 / -2 +443

~60% tests, ~37% core logic — well-covered new instruction.

Key files (click to expand)
  • smartcontract/programs/doublezero-geolocation/tests/geolocation_user_test.rs — integration tests for set/clear/unauthorized/invalid-IP/missing-probe/domain scenarios
  • smartcontract/programs/doublezero-geolocation/src/processors/geolocation_user/set_result_destination.rs — new processor: validates destination, updates user, bumps probe target_update_count
  • smartcontract/programs/doublezero-geolocation/src/state/geolocation_user.rs — add result_destination field with incremental deserialization, refactor TryFrom impls
  • smartcontract/programs/doublezero-geolocation/src/instructions.rs — register SetResultDestination variant and args
  • smartcontract/programs/doublezero-geolocation/src/entrypoint.rs — route new instruction to processor
  • smartcontract/cli/src/geolocation/user/get.rs — display result_destination in CLI get output
  • smartcontract/programs/doublezero-geolocation/src/error.rs — add TooManyReferencedProbes error variant

Testing Verification

  • Unit tests for destination validation (IP:port, domain:port, private IP rejection, missing port, invalid port, single-label domain, hyphen/underscore edge cases)
  • Backward-compatibility unit test: deserializing old account data without the new field defaults to empty string
  • Integration tests via BanksClient: successful set, clear (empty string), unauthorized signer rejection, invalid IP rejection, missing probe account rejection, domain destination

@ben-dz ben-dz force-pushed the bdz/geolocation-alt-offset-onchain-only branch from b620d03 to 84e4f3b Compare April 9, 2026 17:19
…ion field

Add optional result_destination string field to GeolocationUser (backwards-
compatible via BorshDeserializeIncremental). New SetResultDestination
instruction sets/clears the destination in host:port format (IP or domain),
validates publicly routable IPs and domain format, and bumps
target_update_count on all referenced probes.
@ben-dz ben-dz force-pushed the bdz/geolocation-alt-offset-onchain-only branch from 84e4f3b to 569f815 Compare April 9, 2026 17:31
@ben-dz ben-dz marked this pull request as ready for review April 9, 2026 17:32
@ben-dz ben-dz requested a review from karl-dz April 9, 2026 18:17
@ben-dz ben-dz merged commit b61be7a into main Apr 10, 2026
40 of 41 checks passed
@ben-dz ben-dz deleted the bdz/geolocation-alt-offset-onchain-only branch April 10, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants