Skip to content

[FEAT] Blueprint -> DstackApp adapter #1109

@Serial-ATA

Description

@Serial-ATA

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature ➕Tasks that are functional additions or enhancements

    Projects

    Status

    Not Started 🕧

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions