blueprint icon indicating copy to clipboard operation
blueprint copied to clipboard

[FEAT] Blueprint -> DstackApp adapter

Open Serial-ATA opened this issue 5 months ago • 0 comments

We need:

  • [ ] A way to query the operators for a service ID in solidity.
  • [ ] A registry of operators to deviceIds
  • [ ] A way for operators to register new deviceIds

isAppAllowed would check the blueprint hash against the composeHash and deviceId against the registered operators.

contract TangleAppAuth is IAppAuth {
    IOperatorRegistry public operatorRegistry;
    bytes32 public blueprintHash;

    function isAppAllowed(
        IAppAuth.AppBootInfo calldata bootInfo
    ) external view override returns (bool isAllowed, string memory reason) {
        // 1. Check blueprint.json hash
        if (!blueprintHash == bootInfo.composeHash) {
            return (false, "Blueprint hash not allowed");
        }

        // 2. Find the operator of `deviceId`
        address operator = operatorRegistry.getOperatorOfDevice(bootInfo.deviceId);
        if (operator == address(0)) {
            return (false, "Device not registered to any operator");
        }

        // 3. Check if the operator is registered for this blueprint
        if (!operatorRegistry.isOperatorActive(operator, bootInfo.appId)) {
            return (false, "Operator is not active");
        }

        return (true, "");
    }
}

Mapping of Tangle -> Dstack terminology:

Serial-ATA avatar Jul 29 '25 15:07 Serial-ATA