Task Model
This page provides detailed documentation of the task data model in the EigenLayer-AVS system, including the structure of tasks, nodes, edges, and triggers.
This page provides detailed documentation of the task data model in the EigenLayer-AVS system, including the structure of tasks, nodes, edges, and triggers. For information about task execution, see Virtual Machine.
Overview#
The Task Model defines the core data structures that represent automated workflows in the EigenLayer-AVS system. Tasks are structured as directed graphs of operations (nodes) connected by execution paths (edges), with trigger conditions that determine when tasks should execute.
Sources:
Task Structure#
A Task represents a complete workflow definition with the following key components:
Field | Type | Description |
---|---|---|
id | string | Unique identifier (ULID format) |
owner | string | Ethereum address of the task owner |
smart_wallet_address | string | Smart wallet address used to execute the task |
start_at | int64 | Task won't be checked before this timestamp (milliseconds) |
expired_at | int64 | Task won't run after this timestamp (milliseconds) |
name | string | Human-readable task name (limited to 255 characters) |
max_execution | int64 | Maximum number of times this task can run (0 = unlimited) |
total_execution | int64 | Number of times this task has executed |
last_ran_at | int64 | Timestamp of last execution (milliseconds) |
status | TaskStatus | Current state of the task |
trigger | TaskTrigger | Defines when the task should run |
nodes | []TaskNode | Collection of operations in the task |
edges | []TaskEdge | Connections between nodes that define execution flow |
Tasks are created through the CreateTask
method in the Task Engine, which validates the task structure before storing it.
Sources:
Task Lifecycle#
Tasks transition through different states during their lifetime:
The defined task states are:
Status | Description |
---|---|
Active | Task is eligible to be triggered and executed |
Executing | Task is currently running |
Completed | Task has reached its max_execution or expiration time |
Failed | Task encountered an unrecoverable error |
Canceled | Task was explicitly canceled by its owner |
A task is considered "runable" if it hasn't reached its maximum execution count and hasn't expired.
Sources:
Task Nodes#
Nodes represent individual operations within a task. Each node has a specific type that determines its behavior. The TaskNode structure includes a common id and name, plus a type-specific payload.
Sources:
The system supports the following node types:
External Integration Nodes#
These nodes interact with external systems:
-
ETHTransferNode: Transfers ETH to a specified destination
- Parameters: destination address, amount
-
ContractWriteNode: Executes a write operation on a smart contract
- Parameters: contract_address, call_data, contract_abi (optional)
- Output: transaction hash and receipt
-
ContractReadNode: Reads data from a smart contract
- Parameters: contract_address, call_data, contract_abi
- Output: contract method return values
-
GraphQLQueryNode: Executes a GraphQL query
- Parameters: url, query, variables
- Output: GraphQL response data
-
RestAPINode: Makes HTTP requests to REST APIs
- Parameters: url, method, headers, body
- Output: API response data
Sources:
Logic and Control Flow Nodes#
These nodes handle data processing and flow control:
-
CustomCodeNode: Executes custom JavaScript code
- Parameters: source code
- Output: code execution result
-
BranchNode: Implements conditional branching
- Parameters: array of conditions with expressions
- Output: ID of the matching condition
-
FilterNode: Filters arrays based on expressions
- Parameters: expression, input node ID
- Output: filtered array
-
LoopNode: Iterates over collections
- Note: Currently not fully implemented
- Parameters: input, iter_val, iter_key, and a runner node
Sources:
Task Edges#
Edges connect nodes together to form a directed graph that defines the execution flow. Each edge has three components:
Field | Description |
---|---|
id | Unique identifier for the edge |
source | ID of the node where the edge begins |
target | ID of the node where the edge ends |
The set of edges determines how data and control flow through the task. After executing a node, the system follows the edges to determine which nodes to execute next.
Sources:
Task Triggers#
Triggers determine when a task should be executed. The system supports various trigger mechanisms to accommodate different use cases.
Sources:
The system supports the following trigger types:
Manual Trigger#
Tasks with manual triggers are executed explicitly by calling the TriggerTask
method.
Time-Based Triggers#
-
FixedTimeCondition: Triggers at specific timestamps (epochs)
-
CronCondition: Triggers based on cron-like schedules
Blockchain-Based Triggers#
-
BlockCondition: Triggers at specific block intervals
-
EventCondition: Triggers in response to on-chain events
Event triggers are particularly powerful, allowing tasks to react to blockchain events like token transfers by matching on event topics and other parameters.
Sources:
Execution Model#
When a task is triggered, an execution is created to track the progress and results of the run.
Sources:
The execution model includes:
-
Execution: Records the overall result of a task run
- Contains start/end timestamps, success state, and error messages
- Includes the trigger reason and a sequence of execution steps
- Stores output data specific to the trigger type
-
Steps: Track the execution of individual nodes
- Each step corresponds to a node in the task graph
- Records the start/end time, success state, and any errors
- Stores type-specific output data from the node execution
- Tracks inputs used by the node
-
TriggerReason: Provides detailed information about what triggered the task
- For block triggers: records the block number
- For event triggers: includes transaction hash, log index
- For time triggers: includes the epoch timestamp
This detailed execution history enables precise tracking and debugging of task runs.
Sources:
Implementation Architecture#
The Task Model is implemented through several components in the EigenLayer-AVS system:
The primary components involved in the Task Model are:
-
Task Engine - Central component that manages task creation, storage, and execution coordination
- Implemented in
core/taskengine/engine.go
- Handles creating, triggering, listing, and managing tasks
- Implemented in
-
Storage System - Persists tasks and executions using BadgerDB
- Tasks are stored with various prefixes based on their status
- Executions are linked to their parent tasks
-
Operator Network - Distributed system for monitoring triggers
- Operators watch for time, block, and event triggers
- When triggers are detected, operators notify the Aggregator
-
Virtual Machine - Executes task nodes based on the task graph
- Processes each node according to its type
- Follows edges to determine execution flow
- Records detailed execution steps
Sources:
Task Model API#
The system provides a comprehensive API for working with tasks:
Operation | Description |
---|---|
CreateTask | Creates a new task with specified nodes, edges, and trigger |
GetTask | Retrieves a task by its ID |
ListTasks | Lists tasks based on filtering criteria |
TriggerTask | Manually triggers a task execution |
CancelTask | Cancels an active task |
DeleteTask | Permanently removes a task |
GetExecution | Retrieves execution details by task ID and execution ID |
ListExecutions | Lists executions for a given task |
GetExecutionStatus | Checks the status of a specific execution |
These API methods are exposed through the gRPC interface provided by the Aggregator service.
Sources:
Constraints and Validation#
The Task Model enforces several constraints to ensure valid task definitions:
-
Tasks must have at least one node
-
Tasks must have at least one edge
-
Tasks must include a trigger definition
-
Smart wallet addresses must be valid and owned by the task creator
-
Task IDs are generated as ULIDs (Universally Unique Lexicographically Sortable Identifiers)
Sources:
Feature this wiki to auto refresh weekly
Try DeepWiki on your private codebase with Devin