geolocation: add AddParentDevice and RemoveParentDevice instructions#3151
Open
geolocation: add AddParentDevice and RemoveParentDevice instructions#3151
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves: #2952
Summary of Changes
AddParentDeviceinstruction that validates a device is activated in the Serviceability Program before adding it to a GeoProbe'sparent_deviceslist (foundation-gated)RemoveParentDeviceinstruction that removes a device pubkey fromparent_devicesby args (no device account validation needed — device may already be deactivated)AddParentDeviceis a unit variant (no args) per CLAUDE.md convention — device pubkey is taken directly from the passed account.RemoveParentDevicetakesRemoveParentDeviceArgs { device_pk }since no device account is passedDiff Breakdown
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_writesmartcontract/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_writesmartcontract/programs/doublezero-geolocation/src/instructions.rs— addAddParentDeviceandRemoveParentDeviceenum variants + roundtrip test casessmartcontract/programs/doublezero-geolocation/src/error.rs— addParentDeviceAlreadyExists(7) andParentDeviceNotFound(8) error variantssmartcontract/programs/doublezero-geolocation/src/entrypoint.rs— wire up two new match armsTesting Verification
-Dclippy::all -DwarningsMAX_PARENT_DEVICES(5) enforcement is covered by existingGeoProbe::validate()tests and enforced at write time viatry_acc_write