Skip to content

Conversation

@juan-malbeclabs
Copy link
Contributor

This pull request primarily unifies the device "drained" statuses in the smart contract codebase by replacing the previous SoftDrained and HardDrained statuses with a single Drained status. It also updates the logic and tests to reflect this simplification. Additionally, there are improvements to account creation in the global config processor for better clarity and correctness.

Device Status Unification and Logic Updates:

  • Replaced SoftDrained and HardDrained with a single Drained status in both DeviceStatus and DeviceDesiredStatus enums, updating all associated conversion, display, and parsing logic accordingly. [1] [2] [3] [4] [5] [6] [7]
  • Simplified the device status transition logic in process_update_device to only allow transitions between Activated and Drained, removing the previous multi-step drained transitions.

Test Updates:

  • Updated device-related tests to use the new Drained status, removing tests for SoftDrained and HardDrained, and adjusting test step numbering for clarity. [1] [2] [3] [4]

Global Config Processor Improvements:

  • Improved account creation in process_set_globalconfig by using try_acc_create instead of the removed try_create_account, and added a check to ensure the correct system program is passed in. [1] [2] [3] [4]

Makefile Update:

  • Renamed the test-sbf target to test and updated it to use cargo test for consistency.

Testing Verification

  • Show evidence of testing the change

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 simplifies device status management by consolidating SoftDrained and HardDrained into a single Drained status, reducing complexity in device lifecycle transitions. The change affects enum definitions, parsing logic, display formatting, and state transition rules.

Changes:

  • Replaced SoftDrained and HardDrained with unified Drained status in both DeviceStatus and DeviceDesiredStatus enums
  • Simplified device status transition logic to allow only ActivatedDrained transitions
  • Refactored global config account creation to use try_acc_create with proper system program validation

Reviewed changes

Copilot reviewed 5 out of 5 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 Consolidates drain statuses in enums and updates all conversion/display implementations
smartcontract/programs/doublezero-serviceability/src/processors/device/update.rs Simplifies status transition logic to two-way Activated/Drained transitions
smartcontract/programs/doublezero-serviceability/tests/device_test.rs Updates test cases to reflect new unified Drained status and renumbers test steps
smartcontract/programs/doublezero-serviceability/src/processors/globalconfig/set.rs Improves account creation using try_acc_create and adds system program validation
smartcontract/Makefile Renames test target from test-sbf to test

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

@malbeclabs malbeclabs deleted a comment from Copilot AI Jan 9, 2026
@juan-malbeclabs juan-malbeclabs merged commit f2c7020 into main Jan 9, 2026
21 checks passed
@juan-malbeclabs juan-malbeclabs deleted the jo/fix_device_draining branch January 9, 2026 21:35
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.

3 participants