Skip to content

device-health-oracle: update link.health and device.health #2669

@nikw9944

Description

@nikw9944

TODO: Review and update plan.

Modify the device-health-oracle to actively write health status to the blockchain (instead of just reading).

  1. Go SDK enum overhaul (smartcontract/sdk/go/serviceability/state.go)
  • Change Device/Link status enums from sequential iota to explicit values with gaps, matching the Rust smart contract. Remove Suspended/Deleted statuses, replace with Deleting. Reorder HardDrained/SoftDrained values for links.
  • Start health enums with Unknown = 0 (new), shifting Pending to 1, etc.
  • Change all String() methods from array indexing to switch statements (safer with non-sequential values).
  1. Smart contract changes
  • Device creation (create.rs): Start devices with DeviceHealth::Pending (was hardcoded to ReadyForUsers as a TODO workaround). Change default desired_status from Pending to Activated.
  • Link creation (create.rs): Same pattern — start links with LinkHealth::Pending (was ReadyForService), change default desired_status to Activated.
  • CLI authority display: Rename access_authority to sentinel_authority, add health_oracle field.
  1. Device-health-oracle worker (the core change)
  • Add new ServiceabilityExecutor interface with SetDeviceHealthBatch and SetLinkHealthBatch — enabling the oracle to write to the blockchain.
  • Add signer keypair as a required flag, load at startup, and pass to the executor.
  • Rewrite worker logic: on each tick, fetch all devices/links, find those in provisioning state with Pending/Unknown health, and batch-update their health to ReadyForUsers/ReadyForService (batches of 8, sized for Solana's 1232-byte tx
    limit).
  • Add underflow protection for slot arithmetic on fresh environments.
  1. E2E test infrastructure
  • Pass the manager keypair to the device-health-oracle container as a signer.
  • Add WaitForAllDevicesAndLinksActivated to main_test.go — polls until all devices/links reach activated/drained state.
  • Update several tests (device_maxusers_rollover, link_onchain_allocation, multi_client, user_ban) to wait for the oracle to do its work.
  1. Smart contract Rust tests (many files)
  • Add an explicit SetDeviceHealth(ReadyForUsers) or SetLinkHealth(ReadyForService) step before asserting activated status in all tests that create devices/links and expect immediate activation — reflecting the new two-phase activation.
  1. RFC + Changelog
  • Update RFC12: change DeviceDesiredStatus enum values (remove Unknown/Deleted, renumber Drained).
  • Add changelog entry for the device-health-oracle feature.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions