Skip to content

Conversation

@juan-malbeclabs
Copy link
Contributor

This PR adds the ability to update a device’s location while properly managing the reference counters for both the previous and the new location.

Device Location Management Enhancements

  • Added an optional location field to the CLI (UpdateDeviceCliCommand) and SDK (UpdateDeviceCommand) update device commands, allowing users to specify a device location public key. [1] [2]
  • Updated the smart contract processor (process_update_device) to handle location account updates: checks if the location changes, validates the old location, updates reference counts for both old and new locations, and writes the changes to the respective accounts. [1] [2]
  • Modified account meta construction in SDK and tests to include both old and new location accounts for device updates, ensuring proper context for location changes. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Error Handling Improvements

  • Introduced a new error variant InvalidActualLocation in DoubleZeroError to handle cases where the device's location public key does not match the expected account, with corresponding conversions and tests. [1] [2] [3] [4]

Testing and Validation

  • Updated and expanded tests across CLI, SDK, and smart contract modules to cover scenarios involving location updates, including both valid and invalid cases and reference count changes. [1] [2] [3] [4] [5]

Codebase Maintenance

  • Minor refactoring and import adjustments to support new functionality and ensure all required modules (e.g., location::Location) are available.

These changes collectively ensure that device location updates are handled safely and consistently, with proper error reporting and test coverage.

Testing Verification

  • Show evidence of testing the change

@juan-malbeclabs juan-malbeclabs linked an issue Oct 23, 2025 that may be closed by this pull request
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces functionality for updating a device's location while maintaining proper reference counting for both the old and new location accounts. The changes enable users to specify a new location via CLI and SDK commands, with the smart contract processor validating the location change and adjusting reference counts accordingly.

Key Changes:

  • Added optional location_pk field to update device commands in CLI and SDK
  • Implemented location account validation and reference counter management in the smart contract processor
  • Added InvalidActualLocation error variant for handling mismatched location accounts

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
smartcontract/sdk/rs/src/commands/device/update.rs Added location_pk field and updated account metadata to include both old and new location accounts
smartcontract/programs/doublezero-serviceability/src/processors/device/update.rs Implemented location update logic with validation and reference count management
smartcontract/programs/doublezero-serviceability/src/error.rs Added InvalidActualLocation error variant with conversions
smartcontract/cli/src/device/update.rs Added location CLI argument and conversion logic
smartcontract/programs/doublezero-serviceability/tests/*.rs Updated tests to include location accounts in device update operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@juan-malbeclabs juan-malbeclabs force-pushed the 1967-support-updating-dzd-location-onchain branch 2 times, most recently from 02f7989 to 070f656 Compare October 23, 2025 20:13
@juan-malbeclabs juan-malbeclabs force-pushed the 1967-support-updating-dzd-location-onchain branch 2 times, most recently from 16fc043 to 956e143 Compare November 14, 2025 14:59

### Breaking

- Updated the device update command to allow modifying a device’s location.
Copy link
Contributor

@snormore snormore Nov 14, 2025

Choose a reason for hiding this comment

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

Can this be removed from Breaking now that it's compatible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change is compatible with other versions.

Copy link
Contributor

@snormore snormore Nov 17, 2025

Choose a reason for hiding this comment

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

Since it's compatible can you remove this entry from the Breaking section

@juan-malbeclabs juan-malbeclabs force-pushed the 1967-support-updating-dzd-location-onchain branch from e348ce4 to d7fa8c2 Compare November 17, 2025 19:49
update device location instruction for reference counter management
@juan-malbeclabs juan-malbeclabs force-pushed the 1967-support-updating-dzd-location-onchain branch from d7fa8c2 to 935a9b7 Compare November 17, 2025 19:58
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.

Support Updating DZD Location Onchain

4 participants