Skip to content

geolocation: add result destination for LocationOffsets#3480

Open
ben-dz wants to merge 2 commits intomainfrom
bdz/geolocation-alt-offset-dest
Open

geolocation: add result destination for LocationOffsets#3480
ben-dz wants to merge 2 commits intomainfrom
bdz/geolocation-alt-offset-dest

Conversation

@ben-dz
Copy link
Copy Markdown
Contributor

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

Summary of Changes

  • Add optional result_destination string field to GeolocationUser so measurement results (LocationOffsets) can be sent to an alternate endpoint instead of the target IP — critical for ICMP targets that aren't running geolocation software, and useful for centralizing result collection
  • Supports both IP and domain destinations in host:port format (e.g., 185.199.108.1:9000 or results.example.com:9000); empty string = not set
  • New SetResultDestination onchain instruction validates the destination (public IP or valid domain + port), updates the field, and bumps target_update_count on all referenced probes so agents re-discover the change
  • CLI: dz-cli geolocation user set-result-destination --user <code> --destination <host:port> (or --clear), with client-side validation before transaction submission
  • Go SDK deserializes the new field with backwards compatibility (old accounts default to "")
  • Known limitation: If a user with targets that use more than 25 unique probes tries to change their destination IP, the command will fail. This is unlikely in early days and will be addressed by batching in the future.

RFC: rfcs/rrfc16-geolocation-verification.md

Diff Breakdown

Category Files Lines (+/-) Net
Core logic 8 +427 / -35 +392
Scaffolding 11 +314 / -0 +314
Tests 2 +494 / -4 +490
Docs 1 +1 / -0 +1

~40% of net additions are tests; core logic includes the onchain processor with domain/IP validation, Rust SDK command, and Go SDK deserialization.

Key files (click to expand)
  • smartcontract/cli/src/geolocation/user/set_result_destination.rs — CLI command with clap args, client-side destination validation (IP + domain), mock tests
  • smartcontract/programs/doublezero-geolocation/src/processors/geolocation_user/set_result_destination.rs — onchain processor: validates signer, parses host:port, checks IP routability or domain format, bumps probe target_update_count
  • smartcontract/sdk/rs/src/geolocation/geolocation_user/set_result_destination.rs — Rust SDK command that builds the transaction with user PDA + probe account metas
  • smartcontract/programs/doublezero-geolocation/src/state/geolocation_user.rs — new result_destination: String field with BorshDeserializeIncremental, backwards-compat via #[incremental(default)]
  • sdk/geolocation/go/state.go — Go SDK struct + serialize/deserialize with try-decode-default for old accounts
  • smartcontract/programs/doublezero-geolocation/src/instructions.rsSetResultDestination variant added to instruction enum

Testing Verification

  • 7 integration tests: success with IP destination, success with domain destination, clear, unauthorized signer, invalid IP, invalid format (missing port), no-targets user
  • Backwards-compat unit tests in both Rust and Go: serialize with new field, truncate trailing bytes, verify default
  • Onchain processor unit tests for domain validation (valid domains, edge cases)
  • CLI validation tests covering 9 invalid destination cases (private IPs, bad ports, malformed domains)
  • Instruction roundtrip serialization tests
  • All existing tests pass: 83 geolocation program tests, 165 SDK tests, 288 CLI tests, 49 Go SDK tests

@ben-dz ben-dz added this to the Geo Location milestone Apr 7, 2026
@ben-dz ben-dz marked this pull request as ready for review April 8, 2026 13:00
@ben-dz ben-dz requested review from karl-dz and nikw9944 and removed request for karl-dz and nikw9944 April 8, 2026 13:02
@ben-dz ben-dz marked this pull request as draft April 8, 2026 13:13
@ben-dz ben-dz marked this pull request as ready for review April 8, 2026 15:17
@ben-dz ben-dz requested review from juan-malbeclabs, karl-dz and nikw9944 and removed request for juan-malbeclabs April 8, 2026 15:17
@ben-dz ben-dz force-pushed the bdz/geolocation-alt-offset-dest branch from f4daf9f to 8d29067 Compare April 9, 2026 12:43
ben-dz added 2 commits April 9, 2026 08:45
…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.
Rust SDK command, CLI with client-side destination validation, display in
user get, Go SDK deserialization with backwards compatibility.
@ben-dz ben-dz force-pushed the bdz/geolocation-alt-offset-dest branch from 8d29067 to a822d1c Compare April 9, 2026 12:45
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.

1 participant