Task Logic

Overview

The Othentic Stack allows developers to write an AVSLogic contract, which provides pre and post execution hooks for task submission on-chain, and enables highly configurable and customized logic.

Interface

The interface defines two functions: beforeTaskSubmission and afterTaskSubmission. As their names suggest, these functions allow developers to implement custom AVS logic before and after task submission within the contract.

These functions are called in the submitTask function in AttestationCenter which is called by the aggregator.


Use cases

Handle Multiple Data Types

Add custom logic based on the Type of the Task data . By using type-prefixed encoding, you can specify the data type, and the AVS logic hook can efficiently decode and process it accordingly.

Key Components:

  1. Type Identifier Prefix: First 4 bytes specify data type

  2. Payload Structure: Remaining bytes contain the encoded data

  3. Type-Specific Decoding: Switch logic based on data type

Usage

1

Define Supported Data Types

Define different data types you plan to use:

  • PRICE_TYPE: uint256

  • MESSAGE_TYPE: String

  • STATUS_TYPE: Tuple of (bool, address)

2

Encode Data with Type Prefix

Add data type identifier PRICE_TYPE at the beginning of the data field

3

Decode and Process Data in AVS Hook

The afterTaskSubmission function extracts the first 4 bytes to determine the data type, then decodes the payload accordingly.


Task Management

In certain cases, it may be necessary to track and manage tasks even after their completion. For example, you can have an array of task results, allowing anyone to retrieve task history and data.

This functionality can be implemented using the AVS Logic afterTaskSubmission function to store task details on-chain, which other contracts can access via a getter function.

  • Random Number Generator: After completing a task, the generated random number is stored in the AvsLogic contract through afterTaskSubmission, making it available for retrieval.

  • EigenDA: A task is considered complete when the confirmBatch function is called. This function records batch details in a contract mapping, ensuring they are persistently stored.

Note that the function also checks the quorum and emits an event, but these steps have already been executed in the submitTask function.


Updating arbitrary contracts

Depending on your design, your AVS may follow an IFTTT (If This Then That) architecture, requiring on-chain post-execution tasks.

Usage

If the AVS functions as an Oracle service, it may fetch the latest query data. Once operators submit the final result and the task is processed, you might need to update a separate Oracle contract with the latest data.

Use AvsLogic hook to implement this by directly interacting with the contract, ensuring its state reflects the most recent task data.


Cross chain messaging

The AVS Logic hook enables seamless communication between different chains by dispatching messages after task execution. This ensures that data or task verification results can be reflected on another chain.

Usage

AVS tasks are executed off-chain, and task verification remains chain-agnostic and can take place on any blockchain. To maintain verification trails on a different chain, you can utilize the AVS Logic Hook to send a cross-chain message upon task completion.

For instance, if a task is executed on Base, the AVS Logic Hook can transmit a cross-chain message to notify the target blockchain. Additionally, if a particular chain is not natively supported by the Stack, this hook enables cross-chain messaging to ensure the task completion event is successfully relayed.

Last updated