Skip to content

geolocation: add AddParentDevice and RemoveParentDevice instructions#3151

Merged
nikw9944 merged 2 commits intomainfrom
bdz/doublezero-2952-part-3-parent-devices
Mar 4, 2026
Merged

geolocation: add AddParentDevice and RemoveParentDevice instructions#3151
nikw9944 merged 2 commits 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
  • CHANGELOG.md update is not necessary, there's already an entry that covers this change

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

@nikw9944 nikw9944 added this to the Geo Location milestone Mar 3, 2026
Copy link
Contributor

@karl-dz karl-dz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of comments

@nikw9944 nikw9944 force-pushed the bdz/doublezero-2952-part-3-parent-devices branch from 23631b1 to 5defaba Compare March 3, 2026 21:40
nikw9944 added 2 commits March 4, 2026 18:59
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).
@nikw9944 nikw9944 force-pushed the bdz/doublezero-2952-part-3-parent-devices branch from 5defaba to 4528eaa Compare March 4, 2026 19:10
@nikw9944 nikw9944 enabled auto-merge (squash) March 4, 2026 19:17
@nikw9944 nikw9944 merged commit 92e7568 into main Mar 4, 2026
30 checks passed
@nikw9944 nikw9944 deleted the bdz/doublezero-2952-part-3-parent-devices branch March 4, 2026 19:23
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.

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

3 participants