Skip to content

sdk/geolocation: add Go write SDK for user lifecycle and result destination#3567

Open
ben-dz wants to merge 3 commits intomainfrom
bdz/doublezero-3557-user-lifecycle
Open

sdk/geolocation: add Go write SDK for user lifecycle and result destination#3567
ben-dz wants to merge 3 commits intomainfrom
bdz/doublezero-3557-user-lifecycle

Conversation

@ben-dz
Copy link
Copy Markdown
Contributor

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

Stacked on #3558. Once that merges, GitHub retargets this PR to main automatically.

Summary of Changes

  • Adds the remaining Go write SDK surface deferred out of sdk/geolocation: add Go write SDK for add/remove target operations #3558: instruction builders for CreateGeolocationUser, UpdateGeolocationUser, DeleteGeolocationUser, and SetResultDestination.
  • Adds a high-level executor.SetResultDestination(ctx, code, destination, opts) helper that fetches the user, derives the exact set of probe accounts from user.Targets via the exported DeriveUniqueProbePKs, and submits the instruction — so Go consumers don't have to re-implement the dedupe logic the Rust CLI does today.
  • Extends ExecutorRPCClient with GetAccountInfo so the executor can read onchain state before writing.

Diff Breakdown

Category Files Lines (+/-) Net
Core logic 5 +287 / -2 +285
Tests 7 +712 / -3 +709

Pure-additive; ~70% of the diff is tests.

Testing Verification

  • Borsh serialization tests pin discriminator bytes, field ordering, and Option<Pubkey> encoding against the Rust program's expected layout for each new instruction.
  • Account-meta ordering verified against the Rust SDK command builders.
  • SetResultDestination helper error paths covered: missing signer, missing program ID, account not found, owner mismatch, empty code; dedupe behavior covered via pure-function tests of DeriveUniqueProbePKs (empty, all-unique, duplicates-preserving-first-occurrence).

@ben-dz ben-dz force-pushed the bdz/doublezero-3557-user-lifecycle branch from 871966e to 8b51d23 Compare April 22, 2026 19:59
ben-dz added a commit that referenced this pull request Apr 23, 2026
…3558)

Resolves: #3557

## Summary of Changes
- New Go write SDK for the geolocation program focused on target
management: instruction builders for `AddTarget` and `RemoveTarget`,
plus a transaction executor.
- Instruction builders follow the telemetry write SDK pattern:
`*InstructionConfig` struct + `Validate()` + `Build*Instruction()`
returning a self-contained `solana.Instruction`, using `near/borsh-go`
to match the Rust program's Borsh layout.
- User lifecycle (`CreateGeolocationUser`, `UpdateGeolocationUser`,
`DeleteGeolocationUser`) and `SetResultDestination` are deferred to a
follow-on PR (#3567) to keep this reviewable — my immediate consumer
only needs add/remove targets.

## Diff Breakdown
| Category   | Files | Lines (+/-) |  Net |
|------------|-------|-------------|------|
| Core logic |     5 | +475 / -0   | +475 |
| Tests      |     4 | +389 / -0   | +389 |

Pure-additive new package; ~45% of the diff is tests.

## Testing Verification
- Borsh serialization tests pin discriminator bytes, field ordering, and
IP/port/target-pk layout against the Rust program's expected layout for
Add/Remove.
- Private-IP validation covers all reserved ranges (10/8, 172.16/12,
192.168/16, 127/8, 0.0.0.0) for outbound target types.
- Account-meta ordering verified against the Rust SDK command builders.
- Executor error paths covered: missing signer, missing program ID.
Base automatically changed from bdz/doublezero-3557 to main April 23, 2026 16:34
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.

1 participant