LogoLogo
  • Imua
    • About
  • Manifesto
    • The Problems
    • The Principles
  • Architecture
    • Imua Design Principles
    • Imua Network
    • Imua Modules
    • Client Chain Bridges
      • Trustless Verification of Client Chain State
      • Handling Race Conditions between Imua and Client Chains
    • Client Chain Contracts
  • Concepts
    • Ecosystem
      • Re/stakers
      • Operators
      • Services (AVS)
        • Service Integration with Imua
        • Service Committee
        • Service Integration Details
    • restaked Proof-of-Stake (rPOS)
    • Multi-Token Restaking
    • Multi-Chain Restaking with Trustless Bridging
    • Voting Power
    • Price Oracle
    • Flexible Integration with AVS
    • Tribe Staking
  • Governance
  • Risk Management
    • Risk Analysis
      • Risk Modeling
      • Risk Parameters
      • Crypto-Economic Risk
      • Unintended Slashing
      • Black Swan Events
    • Risk Mitigation
      • Smart Contract Simplicity
      • Audits
      • Slashing Prevention
      • Slashing Vetos
      • Insurance Pools
      • Circuit Breakers
  • Components
    • Testnet
    • Oracle Module
      • Reaching Consensus on Asset Prices
      • Penalty
      • Implementation Detail
    • Smart Contracts
    • Explorer
    • Registry
  • Validator Setup
    • Prerequisites
    • Node Install
    • Compiling Binary from Source
    • Oracle Price Feeder
    • Running the Node
    • Snapshot
    • Register Option 1 (Bootstrap)
    • Register Option 2 (Post Network Launch)
    • Deposit Tokens
    • Delegating Tokens
    • Confirm Election Status
    • Faucets
    • Managing The Validator
    • Security Best Practices
    • Risks & Mitigation
    • Participation in Governance
    • FAQs & Resources
  • Testnet Upgrade to v1.1.1
  • AVS Setup
    • AVS Overview
    • Prerequisites
    • Building the AVS in Imua
    • Hello-World-AVS Example
    • Becoming AVS Operator
    • AVS Register and Deploy
    • AVS Task Example
    • Enhanced and Automated Edition of hello-avs integration guide&example
  • Whitepaper (2023)
    • .pdf
  • FAQ
    • What problems is Imua solving?
    • What are the main design trade-offs that had to be made with an omnichain design?
    • Does the omnichain design imply added trust assumptions (relative to a single-chain design)?
    • What concurrency-related challenges would you face with a different design?
    • How does Imua integrate with new chains?
    • Do specific chains prove unique challenges w.r.t. integration?
    • How is the cross-chain communication is achieved?
    • What are the known attack / censorship vectors here, if any?
    • Are the restaked tokens being pooled in a centralized account?
    • Who will run the validators in the Imua network?
    • Is Imua an AVS?
    • How does Imua address the risks of overloading L1 social consensus?
    • Does the Imua queuing system raise concerns around latency?
    • What are the main benefits of an omnichain design?
Powered by GitBook
On this page
  1. AVS Setup

AVS Task Example

PreviousAVS Register and DeployNextEnhanced and Automated Edition of hello-avs integration guide&example

Last updated 2 months ago

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.

Imua-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 , and transmit their signature to the Aggregator entity.

  4. The Aggregator consolidates these signatures into a single aggregated signature using . 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 Imuachain:

	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
imuad tx avs submit-task-result \\
    --bls-signature 92ef6e20aedaaa2d7a45dc2c0ca3cd19ef91f0b497931f0db0ed7c3fff178be4bfeb02253e57b780bfce144616a633b214dac7b1750b2dee5be91bdc61bc7a0cb24dc8877ac7ae4991fe1cd7546667938c33227e3a8f6f96b94ec69db04b000f \\
    --stage 1 \\
    --task-contract-address 0x96949787E6a209AFb4dE035754F79DC9982D3F2a \\
    --task-id 17 \\
    --from dev1.info \\
    --home "/Users/trestin/.tmp-imuad" \\
    --chain-id "imuachaintestnet_233-1" \\
    --keyring-backend test \\
    --fees 50000000000hua

Task status query

# Execute the following command to query the task status
imuad query avs SubmitTaskResult 0x96949787E6a209AFb4dE035754F79DC9982D3F2a 17 im1mq6pj6f5tafmgkk6lehew5radfq3w20g38t6j3

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