Othentic
  • Introduction
    • Introducing Othentic Stack
    • Use Cases
  • AVS Framework
    • Abstract
    • Quick Start
    • Othentic CLI
      • Key Management
      • Contracts Deployment
      • Operator Registration
      • AVS Logic Implementation
      • Operator Deposit
      • Node Operators
      • Rewards Distribution
      • P2P Config
        • Custom P2P Messaging
        • P2P Auth Layer
        • Metrics and Monitoring
        • Logging
        • Persistent storage
        • Latency
      • CLI Command Reference
    • Smart Contracts
      • AVS Governance
      • Attestation Center
      • Hooks
        • Task Logic
        • Operator Management
        • Rewards Fee Calculator
      • OBLS
      • Othentic Registry
      • Message Handlers
    • Othentic Consensus
      • Abstract
      • Task & Task Definitions
      • Leader Election
      • Proof of Task
      • Execution Service
      • Validation Service
      • Voting Power
      • Rewards and Penalties
      • Internal Tasks
    • FAQ
    • Supported Networks
    • Explainers
      • Networking
      • Multichain
      • Production Guidelines
      • Operator Allowlisting
      • Governance Multisig
  • External
    • AVS Examples
  • GitHub
  • Othentic Hub
Powered by GitBook
On this page
  • Overview
  • Interface
  • Deployment & Setup
  • Use cases
  • Dynamic Operator Allocation to Task Definition
  • Gated Operator Registrations
  • Post Registration Benefits
  1. AVS Framework
  2. Smart Contracts
  3. Hooks

Operator Management

PreviousTask LogicNextRewards Fee Calculator

Last updated 1 month ago

Overview

The AVSGovernance contract is responsible for operator registration and deregistration. The Othentic Stack allows developers to implement their custom logics during this process.

The IAVSGovernanceLogic provides pre and post execution hooks for operator registration and deregistration on-chain.

Interface

The interface defines four functions: before and after operator registration, as well as before and after unregistration. Developers can use these functions to implement custom logic during these events.

// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.20;

/**
 * @author Othentic Labs LTD.
 * @notice Terms of Service: https://www.othentic.xyz/terms-of-service
 * @notice Depending on the application, it may be necessary to add reentrancy gaurds to hooks
 */
interface IAvsGovernanceLogic {
    function beforeOperatorRegistered(address _operator, uint256 _numOfShares, uint256[4] calldata _blsKey) external;
    function afterOperatorRegistered(address _operator, uint256 _numOfShares, uint256[4] calldata _blsKey) external;
    function beforeOperatorUnregistered(address _operator) external;
    function afterOperatorUnregistered(address _operator) external;
}

function _registerAsOperator(address _operator, uint256[4] calldata _blsKey) internal {
        AvsGovernanceStorageData storage _avsGovernanceStorageData = _getStorage();
        IAvsGovernanceLogic _avsGovernanceLogic = _avsGovernanceStorageData.avsGovernanceLogic;
        bool _isAvsGovernanceLogicSet = address(_avsGovernanceLogic) != address(0);
        
        if (_isAvsGovernanceLogicSet) {
            _avsGovernanceLogic.beforeOperatorRegistered(_operator, _numOfShares, _blsKey);
        }
        ...
        if (_isAvsGovernanceLogicSet) {
            _avsGovernanceLogic.afterOperatorRegistered(_operator, _numOfShares, _blsKey);
        }
    }

Deployment & Setup

After implementation, you can deploy the contract on the same L1 network as the AvsGovernance.

You should deploy the AVS contracts before deploying the AVSGovernanceLogic.

Note that only the AVS Governance Multisig is authorized to call this function.

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

/*______     __      __                              __      __ 
 /      \   /  |    /  |                            /  |    /  |
/$$$$$$  | _$$ |_   $$ |____    ______   _______   _$$ |_   $$/   _______ 
$$ |  $$ |/ $$   |  $$      \  /      \ /       \ / $$   |  /  | /       |
$$ |  $$ |$$$$$$/   $$$$$$$  |/$$$$$$  |$$$$$$$  |$$$$$$/   $$ |/$$$$$$$/ 
$$ |  $$ |  $$ | __ $$ |  $$ |$$    $$ |$$ |  $$ |  $$ | __ $$ |$$ |
$$ \__$$ |  $$ |/  |$$ |  $$ |$$$$$$$$/ $$ |  $$ |  $$ |/  |$$ |$$ \_____ 
$$    $$/   $$  $$/ $$ |  $$ |$$       |$$ |  $$ |  $$  $$/ $$ |$$       |
 $$$$$$/     $$$$/  $$/   $$/  $$$$$$$/ $$/   $$/    $$$$/  $$/  $$$$$$$/
*/
/**
 * @author Othentic Labs LTD.
 * @notice Terms of Service: https://www.othentic.xyz/terms-of-service
 */

import {Script, console} from "forge-std/Script.sol";
import "../src/IAvsGocernance.sol";
import "../src/AvsGovernanceLogic.sol";

// forge script AvsGovernanceLogicScript --rpc-url $L1_RPC --private-key $PRIVATE_KEY
// --broadcast -vvvv --verify --etherscan-api-key $L1_ETHERSCAN_API_KEY --chain
// $L1_CHAIN --verifier-url $L1_VERIFIER_URL --sig="run(address)" $ATTESTATION_CENTER_ADDRESS
contract AvsGovernanceLogicScript is Script {
    function setUp() public {}

    function run(address avsGovernance) public {
        vm.broadcast();
        AvsGovernanceLogic avsGovernanceLogic = new AvsGovernanceLogic(avsGovernance);
        IAvsGovernance(avsGovernance).setAvsGovernanceLogic(address(avsGovernanceLogic));
    }
}

Now, the AVS contracts are set and ready to be used ✅


Use cases

Dynamic Operator Allocation to Task Definition

Usage

  • Operators can be assigned dynamically to specific Task definition based on their expertise.

function afterOperatorRegistered(address _operator, uint256 _numOfShares, uint256[4] calldata _blsKey) external override {
         _assignOperatorToTasks(_operator);
         emit OperatorAssignedToTask();
}
 
function _assignOperatorToTasks(address _operator) internal {
     // Custom logic to dynamically set operators for tasks
}

Gated Operator Registrations

AVSs may require whitelisting operators before allowing registration. This can be enforced via the beforeOperatorRegistered function.

Usage

  • Whitelisting: Maintain a list of approved operators.

function beforeOperatorRegistered(address _operator, uint256 _numOfShares, uint256[4] calldata _blsKey) external {
    require(isWhitelisted[_operator], "Operator is not whitelisted");
}
  • Token-Gated Access: Require operators to hold a specific NFT or ERC-20 token.

  • Reputation-Based Selection: Only allow operators with a certain reputation score to register.


Post Registration Benefits

Operators that register to your AVS can be granted NFTs or whitelisted to use certain services in your AVS. These can be enabled using the afterOperatorRegistered function.

Usage

  • NFT Minting: Reward operators with a proof-of-registration NFT.

  • Exclusive Access: Enable operators to use specific AVS features.

  • Token Incentives: Distribute rewards for registered operators.


These functions are called inside the and functions respectively.

After deployment, you must call the function on the AvsGovernance , providing the address of the AvsGovernanceLogic contract as a parameter, as shown in the below example.

AVSs may require dynamically assigning specific operators to based on predefined conditions. This can be implemented using the beforeOperatorRegistered and afterOperatorRegistered hooks.

registerAsOperator
unRegisterAsOperator
setAvsGovernanceLogic
AVS Governance Logic Hook
Task Definition