Skip to content

Hourglass overview #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions docs/products/hourglass-architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
sidebar_position: 5
title: Architecture Overview
---

:::note
Hourglass is currently in public preview, and active development.
:::

Hourglass is a task-based execution framework for building decentralized services (AVSs) requiring verifiable offchain compute.
Hourglass standardizes how developers define, distribute, execute, and verify compute tasks across decentralized operator networks.

## Architecture

[![](/img/hourglass-architecture_v.01.0.svg)](/img/hourglass-architecture_v.01.0.svg)

## Onchain Components

### TaskMailbox

The `TaskMailbox` is an EigenLayer core contract deployed to Ethereum and each support L2 network, and is responsible for:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

support

supported


* Allowing users and apps to create tasks.
* Managing the lifecycle of tasks.
* Verifying the results of tasks against the stake weight of the Operators in the Operator Set performing the work.
* Making the task verification results available for users and apps to query.
* Enabling AVSs to manage their TaskMailbox configurations.

### TaskAVSRegistrar

The `TaskAVSRegistrar` is a per-AVS EigenLayer middleware contract that is responsible for:

* Handling Operator registration for specific Operator Sets of your AVS.
* Providing the offchain components with BLS public keys and socket endpoints for the Aggregator and Executor operators.
Copy link
Member

@seanmcgary seanmcgary Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Providing the offchain components with BLS public keys

This piece is no longer accurate. Keys live in the KeyRegistrar core contract now. The rest about the socket endpoints is correct though


The default `TaskAVSRegistrar` is a copy of the provided contract and works as provided. `TaskAVSRegistrar` can be extended
to include additional onchain logic for your use case.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically the TaskAVSRegistrar "is a minimal contract, inheriting the default functionality of the Hourglass TaskAVSRegistrarBase contract, that can be extended to add or modify functionality"


### AVSTaskHook

The `AVSTaskHook` is a per-AVS EigenLayer Hourglass contract that is responsible for:

* Validating the task lifecycle.
* Creating fee markets for your AVS.

It's empty by default and works out of the box, but can be extended to include additional onchain validation logic for your AVS.
Copy link
Member

@seanmcgary seanmcgary Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably also want to add something like:

Your AVS contract can also implement the AVSTaskHook if you need direct hook functionality, replacing the default AVSTaskHook contract provided.


### CertificateVerifier

The `CertificateVerifier` is an EigenLayer core contract that is responsible for:

* Verifying the validity of Operator certificates.
* Verifying stake threshold requirements for Operator Sets.

## Offchain Components

### Aggregator

The Aggregator is responsible for:

* Listening to events from the Mailbox contract on chain for new tasks
* Discovering Executors by querying the `AVSRegistrar` contract, retrieving their metadata containing a BLS public key and a socket (URL) endpoint that references the Executor's gRPC server.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of date. Peering is done by interacting with the AVSRegistrar (operator sets for exec/aggregator), AllocationManager (operator set members) and KeyRegistrar (public keys for members)

* Distributing tasks to Executors by sending a gRPC request to the Executor's socket endpoint, including the task payload and a signature of the payload signed by the Aggregator. This enables the Executor to validate the message is coming from the expected Aggregator.
* Aggregating results from Executors until a signing threshold has been met.
* Publishing the result back to the Mailbox contract.

### Executor

The Executor is responsible for:

* Launching and managing Performer containers that execute the tasks.
* Listening to gRPC requests from the Aggregator for new tasks.
* Forwarding the task to the correct Performer.
* Signing the result of the task with its BLS private key and sending it back to the Aggregator.

### Performer

The Performer is the component the AVS is responsible for building. At a high level, it is a simple gRPC server that listens
for tasks, runs them and returns the results to the Executor.

The Hourglass framework provides all of the boilerplate and server code for your Performer; you simply need to fill in the logic to
handle tasks for your AVS.

For information on how to implement an AVS using the Hourglass template, refer to [Implementing with Hourglass](implementing-with-hourglass.md).

:::important
Rewards and Slashing are areas that Hourglass does not yet provide opinionated solutions for and must be implemented separately:

* Rewards logic and distribution

Hourglass does not include logic for how Operator rewards are calculated or distributed. Each AVS must design and
implement a reward model that aligns with its own incentives and application-specific goals. This logic can be implemented
onchain or offchain, but is out of scope for the Hourglass framework.

* Slashing Logic and Handling

Hourglass does not provide slashing mechanisms. AVS developers are responsible for defining how to detect operator misbehavior
and determine the conditions and consequences for slashing. This logic must be implemented independently of the Hourglass AVS
contracts and tooling.

These areas are not part of the Hourglass framework and must be handled externally based on the specific needs of the AVS.
:::
67 changes: 67 additions & 0 deletions docs/products/implementing-with-hourglass.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
sidebar_position: 5
title: Using Hourglass to Implement Your AVS
---

## What Hourglass Provides

The Hourglass template provides a basic structure for building an AVS with the Hourglass framework. It includes:

* A stub of Go code for your Performer.
* Default `TaskAVSRegistrar` and `AVSTaskHook` AVS contracts that work out of the box. These contracts can be extended to add additional onchain logic.
* All dependent contracts required by the framework and the scripts to deploy them. The scripts are managed by the Devkit CLI.
* A docker-compose stack to run an Aggregator and Executor locally to test your AVS.
* Integration with the DevKit CLI. DevKit provides a streamlined, modular experience for scaffolding your projects, compiling, running local networks, and testing.

## What You Need to Implement

| Component | Purpose | Developer to Implement | Required or Optional |
|-----------------------------------------------------|-----------------------|----------------------------------------------|----------------------|
| `main.go` | Task logic | Write AVS-specific task processing | Required |
| Smart Contracts (`TaskAVSRegistrar`, `AVSTaskHook`) | Onchain AVS logic | Modify if you need custom onchain behavior | Optional |
| Config files (`.hourglass`, `.devkit`) | Runtime and CLI setup | Customize paths, images, and network | Optional |
| Task Input | Task testing | Create representative input data | Optional |
| `docker-compose.yml` | Local setup | Edit to match your environment | Optional |

## Local Development and Testing

### Task processing in main.go

`main.go` implements the offchain binary run by Operators running the Hourglass Executor. That is, the core business logic
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main.go represents the entrypoint for the Performer process that is managed and run by Operators running an Hourglass Executor

for processing tasks. It contains the business logic of the AVS and performs worked based on the tasks sent to it.

The Hourglass Aggregator ingests tasks from the TaskMailbox and distributes work to Executors configured to run the AVS Performer.

Performers execute the work and return the result to the Executor where the result is signed and returned to the Aggregator to
place in the outbox once the signing threshold is met.

Minimal `VadildateTask` and `HandleTask`functions are provided in `main.go` to get you started. The code can be restructured
as needed for your AVS requirements.

### AVS Onchain Logic in Contract

The example `HelloWorld.sol` contract is included. Delete and replace with a contract implementing your AVS onchain logic.

This contract provides the onchain coordination for your AVS linking offchain task processing with onchain validation.

### Task Callback Logic in AVSTaskHook

Extend `AVSTaskHooks` to include additional onchain logic to:
* Validate the task lifecycle.
* Create a fee market for your AVS.

### Contract Deployment in DeployMyContracts.s.sol

Wire up your contracts in `DeployMyContracts.s.sol`. This script is automatically called during `devkit avs devnet start`.

## Deployment to Testnet

### Operator Registration in TaskAVSRegistrar

`TaskAVSRegistrar` defines which Operators can register as an Operator for your AVS to be an Aggregator and/or an Executor.

:::tip
When running the devnet locally, Operators are set up by Hourglass and Operator registration does not need to be implemented.
:::

For detailed information on the Hourglass framework, refer to the [Readme in the Hourglass repo](https://github.com/Layr-Labs/hourglass-avs-template).
1 change: 1 addition & 0 deletions static/img/hourglass-architecture_v.01.0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.