Skip to content

geolocation: add AddParentDevice and RemoveParentDevice instructions#3151

Open
nikw9944 wants to merge 1 commit intomainfrom
bdz/doublezero-2952-part-3-parent-devices
Open

geolocation: add AddParentDevice and RemoveParentDevice instructions#3151
nikw9944 wants to merge 1 commit intomainfrom
bdz/doublezero-2952-part-3-parent-devices

Conversation

@nikw9944
Copy link
Contributor

@nikw9944 nikw9944 commented Mar 2, 2026

Resolves: #2952

Summary of Changes

  • Add AddParentDevice instruction that validates a device is activated in the Serviceability Program before adding it to a GeoProbe's parent_devices list (foundation-gated)
  • Add RemoveParentDevice instruction that removes a device pubkey from parent_devices by args (no device account validation needed — device may already be deactivated)
  • AddParentDevice is a unit variant (no args) per CLAUDE.md convention — device pubkey is taken directly from the passed account. RemoveParentDevice takes RemoveParentDeviceArgs { device_pk } since no device account is passed

Diff Breakdown

Category Files Lines (+/-) Net
Core logic 4 +152 / -1 +151
Scaffolding 1 +2 / -0 +2
Tests 1 +16 / -1 +15

Compact PR — all new code is core instruction logic with minimal scaffolding

Key files (click to expand)
  • smartcontract/programs/doublezero-geolocation/src/processors/geo_probe/add_parent_device.rs — new processor: foundation allowlist check, device ownership + activation validation via Serviceability CPI, duplicate detection, push + realloc via try_acc_write
  • smartcontract/programs/doublezero-geolocation/src/processors/geo_probe/remove_parent_device.rs — new processor: foundation allowlist check, not-found detection, retain-based removal + realloc via try_acc_write
  • smartcontract/programs/doublezero-geolocation/src/instructions.rs — add AddParentDevice and RemoveParentDevice enum variants + roundtrip test cases
  • smartcontract/programs/doublezero-geolocation/src/error.rs — add ParentDeviceAlreadyExists (7) and ParentDeviceNotFound (8) error variants
  • smartcontract/programs/doublezero-geolocation/src/entrypoint.rs — wire up two new match arms

Testing Verification

  • All 40 unit tests pass including new instruction roundtrip tests for both variants
  • 3 integration tests pass (ProgramConfig update scenarios)
  • Clippy clean with -Dclippy::all -Dwarnings
  • MAX_PARENT_DEVICES (5) enforcement is covered by existing GeoProbe::validate() tests and enforced at write time via try_acc_write
  • Related RFC: rfcs/rfc16-geolocation-verification.md

Add two foundation-gated instructions for managing GeoProbe parent
devices. AddParentDevice validates the device is an activated Device in
the Serviceability Program before adding to parent_devices.
RemoveParentDevice removes by pubkey without requiring device account
validation (device may already be deactivated).
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.

geolocation: program account types, instructions, processors, and deployment

1 participant