Skip to content

Conversation

@juan-malbeclabs
Copy link
Contributor

This pull request introduces comprehensive health management capabilities for Devices and Links, refactors CLI commands to support health operations, and updates tests and core logic to reflect new health-related states. The changes enhance the system's ability to explicitly track, authorize, and update health status for network components, improving operational control and reliability.

Health Management Enhancements

  • Added health_oracle to the smart contract global configuration, enabling management and authorization of health-related operations for Devices and Links. [1] [2]
  • Introduced explicit health states and desired status for Devices and Links, including new enums like DeviceHealth, DeviceDesiredStatus, LinkHealth, and LinkDesiredStatus, and updated relevant state, processor, and test logic. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17]

CLI Refactoring for Health Operations

  • Deprecated Suspend and Resume device commands in favor of new internal SetHealth commands for Devices and Links, allowing authorized health status updates via CLI. [1] [2] [3] [4] [5] [6] [7] [8]

Processor and Metrics Updates

  • Updated device and link event processing logic to reflect new health states, including changes to logging and metrics to track health-related transitions (e.g., DeviceProvisioning, ReadyForService). [1] [2] [3]

Test Suite Expansion

  • Extended and updated test cases across activator, CLI, and user flows to include health state initialization and assertions, ensuring robust coverage of new health management features. [1] [2] [3] [4] [5] [6] [7] [8]

Changelog Documentation

  • Updated CHANGELOG.md to document all notable health management changes, including the addition of health_oracle, health state tracking, and introduction of "desired status" for Devices and Links.

Closes #2026
Closes #2297

Testing Verification

  • all test ok

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 pull request implements a comprehensive health management framework for Devices and Links, transitioning from simple suspend/resume operations to an intent-based provisioning model with explicit health tracking. The changes introduce a health_oracle authority, new health and desired status enums, and updated state transition logic to support multi-stage device and link provisioning workflows.

Key Changes:

  • Added health_oracle_pk to global state for authorizing health operations
  • Replaced suspend/resume commands with set-health commands and desired_status fields
  • Introduced new provisioning states (DeviceProvisioning, LinkProvisioning, ReadyForService) for devices and links

Reviewed changes

Copilot reviewed 111 out of 111 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
smartcontract/programs/doublezero-serviceability/src/state/device.rs Added DeviceHealth, DeviceDesiredStatus enums and status transition logic
smartcontract/programs/doublezero-serviceability/src/state/link.rs Added LinkHealth, LinkDesiredStatus enums and status transition logic
smartcontract/programs/doublezero-serviceability/src/state/globalstate.rs Added health_oracle_pk field to global state
smartcontract/programs/doublezero-serviceability/src/processors/device/sethealth.rs New processor for setting device health status
smartcontract/programs/doublezero-serviceability/src/processors/link/sethealth.rs New processor for setting link health status
smartcontract/programs/doublezero-serviceability/src/processors/device/update.rs Updated to support desired_status field and call check_status_transition
smartcontract/programs/doublezero-serviceability/src/processors/link/update.rs Updated to support desired_status field and call check_status_transition
smartcontract/sdk/rs/src/commands/device/sethealth.rs New SDK command for setting device health
smartcontract/sdk/rs/src/commands/link/sethealth.rs New SDK command for setting link health
smartcontract/cli/src/device/sethealth.rs New CLI command for setting device health
smartcontract/cli/src/link/sethealth.rs New CLI command for setting link health
Various test files Updated test data to include new health and desired status fields

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@juan-malbeclabs juan-malbeclabs changed the base branch from main to jo/desired_status January 6, 2026 18:22
@juan-malbeclabs juan-malbeclabs force-pushed the jo/device_link_provisioning branch from 2fdfe85 to e4d7b3c Compare January 6, 2026 18:51
Base automatically changed from jo/desired_status to main January 7, 2026 15:26
@juan-malbeclabs juan-malbeclabs force-pushed the jo/device_link_provisioning branch 2 times, most recently from 896f91a to 9d06b77 Compare January 7, 2026 15:56
@juan-malbeclabs juan-malbeclabs force-pushed the jo/device_link_provisioning branch from a1c258f to e3f8efc Compare January 13, 2026 17:27
@juan-malbeclabs juan-malbeclabs force-pushed the jo/device_link_provisioning branch 3 times, most recently from a758863 to 9537945 Compare January 15, 2026 15:37
juan-malbeclabs and others added 3 commits January 15, 2026 15:38
- Introduced DeviceHealth and LinkHealth enums to represent the health status of devices and links.
- Implemented sethealth functionality for devices and links, allowing updates to their health status.
- Updated global state to include health_oracle_pk for managing health-related operations.
- Modified existing processors and state structures to accommodate health management features.
- Enhanced tests to validate health status changes and ensure proper functionality.

feat: add health attribute to device and link structures and update related functionality

feat: enhance health management for devices and links with new states and updates

fix: update comments for DeviceHealth enum and correct user_airdrop_lamports calculation

fix: update log message in process_set_health_device function

Update device health status from ReadyForService to ReadyForUsers

- Changed instances of DeviceHealth::ReadyForService to DeviceHealth::ReadyForUsers across multiple files in the activator, client, and smartcontract directories.
- Updated related test cases to reflect the new device health status.
- Adjusted the DeviceHealth enum to include ReadyForLinks and modify the corresponding string representations.

Add changelog

feat: add health management for devices and links

- Introduced DeviceHealth and LinkHealth enums to represent the health status of devices and links.
- Implemented sethealth functionality for devices and links, allowing updates to their health status.
- Updated global state to include health_oracle_pk for managing health-related operations.
- Modified existing processors and state structures to accommodate health management features.
- Enhanced tests to validate health status changes and ensure proper functionality.

feat: add health attribute to device and link structures and update related functionality

feat: enhance health management for devices and links with new states and updates

fix: update comments for DeviceHealth enum and correct user_airdrop_lamports calculation

fix: update log message in process_set_health_device function

Update device health status from ReadyForService to ReadyForUsers

- Changed instances of DeviceHealth::ReadyForService to DeviceHealth::ReadyForUsers across multiple files in the activator, client, and smartcontract directories.
- Updated related test cases to reflect the new device health status.
- Adjusted the DeviceHealth enum to include ReadyForLinks and modify the corresponding string representations.

Refactor device and link status management to incorporate provisioning states

- Updated device status checks in tests and processors to reflect new provisioning states.
- Changed device status from `Activated` to `DeviceProvisioning` in multiple test cases.
- Introduced `LinkDesiredStatus` and `DeviceDesiredStatus` enums to manage desired states.
- Removed deprecated `suspend` and `resume` commands for devices and links.
- Added comprehensive provisioning documentation outlining device and link state transitions.
- Adjusted health checks to align with new provisioning logic.

feat(cli): add set health commands for devices and links

- Implemented `SetDeviceHealthCliCommand` for updating device health status via CLI.
- Added corresponding tests to ensure successful health updates and error handling for existing codes and public IPs.
- Created `SetLinkHealthCliCommand` for updating link health status with similar functionality and tests.
- Introduced `SetDeviceHealthCommand` and `SetLinkHealthCommand` in the SDK for executing health updates on devices and links.
- Enhanced error handling in the commands to manage existing device codes and public IP conflicts.

test: add status transition tests for devices and links

fix(changelog): correct typo in desired status entry for Devices and Links

cleanup: remove unnecessary blank lines in test module

feat: update device and link health management to include status transitions

update latency sample tests to use contributor accounts

improve code formatting and readability in latency sample tests

feat: add allow_latency method for Device and Link; update error messages for activation status

update code in tests

fix: improve command formatting in link creation and updates for better readability

fix: reorder link health setting for correct execution flow in user ban test

feat: update device activation status during creation and set health to ready-for-service

Update last rebase

fix e2e

fix e2e

fix rebase errors

feat: enhance device and link activation tests with health status updates

feat: add desired status option for device and link creation commands

- Introduced `desired_status` field in `CreateDeviceCliCommand` and `CreateDZXLinkCliCommand` to allow specifying the desired status during device and link creation.
- Updated the `CreateWANLinkCliCommand` similarly to support desired status.
- Modified the `process_create_device` and `process_create_link` functions to handle the new desired status field.
- Enhanced tests to validate the desired status functionality for devices and links.
- Updated relevant test cases to assert the correct status after activation.
…s updates

- Removed redundant health status updates for devices in `GetOrCreateDeviceOnchain` and `CreateDeviceOnchain` methods.
- Updated test scripts to create devices and links with desired status in a single command, eliminating separate health status commands.
- Adjusted the `start-test.sh` script to reflect the new command structure for device and link creation.
- Ensured consistency across various test files by applying the new command structure for link creation.
@juan-malbeclabs juan-malbeclabs force-pushed the jo/device_link_provisioning branch from 9537945 to c3c5cad Compare January 15, 2026 15:39
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.

serviceability: add DeviceProvisioning and LinkProvisioning to device.status serviceability: add new LinkStatus - Provisioning

4 participants