AVS Task Example

The Task is executed off-chain, with the result of the computation being attested by multiple operators' signatures. These signatures are subsequently aggregated before the final validation and on-chain value writing occurs.

Exocore-AVS-Task Lifecycle (Flow)

Each task request follows a specific process. To illustrate this, let's examine the example of summing two numbers.

  1. The Task Generator entity transmits the two numbers to be summed to the AVS contract.

  2. The AVS contract emits a NewTaskCreated event, representing the two numbers to be summed.

  3. Operators listen to the AVS contract for this event, perform the summation, sign the result using a BLS signature, and transmit their signature to the Aggregator entity.

  4. The Aggregator consolidates these signatures into a single aggregated signature using BLS signature aggregation. Once the required threshold is met, the Aggregator submits the aggregated signature back to the AVS contract.

  5. The AVS contract verifies that the thresholds have been met and that the aggregated signature is valid. Upon successful verification, the execution result is accepted.

Task Creation

The following parameters are utilized to create tasks and can use them to register essential information on the Exocore Network:

	TaskContractAddress   string `json:"task_contract_address"`
	TaskName              string `json:"name"`
	Hash                  []byte `json:"hash"`
	TaskID                uint64 `json:"task_id"`
	TaskResponsePeriod    uint64 `json:"task_response_period"`
	TaskStatisticalPeriod uint64 `json:"task_statistical_period"`
	TaskChallengePeriod   uint64 `json:"task_challenge_period"`
	ThresholdPercentage   uint64 `json:"threshold_percentage"`
	StartingEpoch         uint64 `json:"starting_epoch"`
	OperatorAddress       string `json:"operator_address"`
	TaskResponseHash      string `json:"task_response_hash"`
	TaskResponse          []byte `json:"task_response"`
	BlsSignature          []byte `json:"bls_signature"`
	Stage                 string `json:"stage"`
	ActualThreshold       uint64 `json:"actual_threshold"`
	OptInCount            uint64 `json:"opt_in_count"`
	SignedCount           uint64 `json:"signed_count"`
	NoSignedCount         uint64 `json:"no_signed_count"`
	ErrSignedCount        uint64 `json:"err_signed_count"`
	CallerAddress         string `json:"caller_address"`

The function for creating a task is as follows:

    /// @dev CreateTask , avs owner create a new task
    /// @param sender The external address for calling this method.
    /// @param name The name of the task.
    /// @param hash The data supplied by the contract, usually ABI-encoded.
    /// @param taskResponsePeriod The deadline for task response.
    /// @param taskChallengePeriod The challenge period for the task.
    /// @param thresholdPercentage The signature threshold percentage.
    /// @param taskStatisticalPeriod The statistical period for the task.
    function createTask(
        address sender,
        string memory name,
        bytes calldata hash,
        uint64 taskResponsePeriod,
        uint64 taskChallengePeriod,
        uint64 thresholdPercentage,
        uint64 taskStatisticalPeriod
    ) external returns (bool success);

An illustrative example demonstrating task submission utilizing the aforementioned parameters is as follows:

// Example task structure provided by AVS
taskResponse := types.TaskResponse{
    TaskID:    17,
    NumberSum: big.NewInt(1000),
}

// Task execution results
TaskResult: 000000000000000000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000003e8
ResultHash: 070d7ad3b1d9d5ac46577330e53e62e08da159f533e6c325443122a5cc670582
BlsSignature: 92ef6e20aedaaa2d7a45dc2c0ca3cd19ef91f0b497931f0db0ed7c3fff178be4bfeb02253e57b780bfce144616a633b214dac7b1750b2dee5be91bdc61bc7a0cb24dc8877ac7ae4991fe1cd7546667938c33227e3a8f6f96b94ec69db04b000f

// Command to submit task result
exocored tx avs submit-task-result \\
    --bls-signature 92ef6e20aedaaa2d7a45dc2c0ca3cd19ef91f0b497931f0db0ed7c3fff178be4bfeb02253e57b780bfce144616a633b214dac7b1750b2dee5be91bdc61bc7a0cb24dc8877ac7ae4991fe1cd7546667938c33227e3a8f6f96b94ec69db04b000f \\
    --stage 1 \\
    --task-contract-address 0x96949787E6a209AFb4dE035754F79DC9982D3F2a \\
    --task-id 17 \\
    --from dev1.info \\
    --home "/Users/trestin/.tmp-exocored" \\
    --chain-id "exocoretestnet_233-1" \\
    --keyring-backend test \\
    --fees 50000000000aexo

Task status query

# Execute the following command to query the task status
exocored query avs SubmitTaskResult 0x96949787E6a209AFb4dE035754F79DC9982D3F2a 17 exo1mq6pj6f5tafmgkk6lehew5radfq3w20gpegzs5

# Response output
Response:
  BLS Signature: ad9b563bc7d986b4e39207e644b90c1286c4c0169000d4b54fce0fcb4e167b91d5b2f5e31d3428564050ca281f818f4009c58d93a775a0fc8f38cc95a6d258ec009bc283843ee98191df47f00c13b04d1e1529b24aef2d2f7a2e21718e704dd3+V8mot+Evfxm
  Operator Address: exo1mq6pj6f5tafmgkk6lehew5radfq3w20gpegzs5
  Stage: 2
  Task Contract Address: 0x96949787E6a209AFb4dE035754F79DC9982D3F2a
  Task ID: 2
  Task Response: eyJUYXNrSUQiOjEsIk51bWJlclN1bSI6MTAwfQ==
  Task Response Hash: 0x597bd5ccb1a3a7fbd0ae6a83ece927a0ec100ac5c0a3910e2a32a90eef97ce18

Last updated