Skip to content

Commit

Permalink
feat: updated avs docs (#88)
Browse files Browse the repository at this point in the history
* feat: updated avs docs

* chore: prettier

* fix: update broken context links

* fix: update broken context links
  • Loading branch information
Tjemmmic authored Dec 4, 2024
1 parent 9ad2cc1 commit f65b397
Show file tree
Hide file tree
Showing 14 changed files with 241 additions and 38 deletions.
6 changes: 3 additions & 3 deletions pages/developers/blueprint-contexts/eigenlayer-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ The `EigenlayerContext` trait provides access to core Eigenlayer services and fu
- Monitor stake across different quorums

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/sdk/src/ctx.rs"
fromLine={125}
toLine={238}
url="https://github.com/tangle-network/gadget/blob/main/sdk/src/contexts/eigenlayer.rs"
fromLine={16}
toLine={140}
title="EigenlayerContext Trait Definition"
/>

Expand Down
10 changes: 5 additions & 5 deletions pages/developers/blueprint-contexts/evm-provider-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ The `EvmProviderContext` trait provides a standardized [alloy-rs](https://github
The `EvmProviderContext` trait provides access to an EVM provider:

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/sdk/src/ctx.rs"
fromLine={81}
toLine={90}
url="https://github.com/tangle-network/gadget/blob/main/sdk/src/contexts/evm_provider.rs"
fromLine={3}
toLine={12}
title="EvmProviderContext Trait Definition"
/>

Expand All @@ -26,7 +26,7 @@ The `EvmProviderContext` trait provides access to an EVM provider:
First, define your context struct that implements the `EvmProviderContext` trait:

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/01_basic.rs"
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/basic.rs"
fromLine={4}
toLine={9}
title="EVM Provider Context Definition"
Expand All @@ -37,7 +37,7 @@ First, define your context struct that implements the `EvmProviderContext` trait
You can then use this context to access EVM provider parameters:

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/01_basic.rs"
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/basic.rs"
fromLine={18}
toLine={18}
title="Accessing EVM Provider Parameters"
Expand Down
10 changes: 5 additions & 5 deletions pages/developers/blueprint-contexts/keystore-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ The `KeystoreContext` trait provides access to a `GenericKeystore` that implemen
- Key Import/Export - Import existing keys and export key data

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/sdk/src/ctx.rs"
fromLine={69}
toLine={73}
url="https://github.com/tangle-network/gadget/blob/main/sdk/src/contexts/keystore.rs"
fromLine={4}
toLine={7}
title="KeystoreContext Trait Definition"
/>

Expand All @@ -32,7 +32,7 @@ The `KeystoreContext` trait provides access to a `GenericKeystore` that implemen
First, define your context struct that implements the `KeystoreContext` trait:

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/01_basic.rs"
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/basic.rs"
fromLine={4}
toLine={9}
title="Keystore Context Definition"
Expand All @@ -43,7 +43,7 @@ First, define your context struct that implements the `KeystoreContext` trait:
You can then use this context to access the keystore and perform key operations:

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/01_basic.rs"
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/basic.rs"
fromLine={17}
toLine={17}
title="Accessing Keystore Functionality"
Expand Down
10 changes: 5 additions & 5 deletions pages/developers/blueprint-contexts/service-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ The `ServiceContext` trait provides access to service-related functionality that
- Multi-Party Coordination - Build complex services leveraging operator data

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/sdk/src/ctx.rs"
fromLine={101}
toLine={123}
url="https://github.com/tangle-network/gadget/blob/main/sdk/src/contexts/services.rs"
fromLine={11}
toLine={136}
title="ServiceContext Trait Definition"
/>

Expand All @@ -31,7 +31,7 @@ The `ServiceContext` trait provides access to service-related functionality that
First, define your context struct that implements the `ServiceContext` trait:

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/01_basic.rs"
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/basic.rs"
fromLine={4}
toLine={9}
title="Service Context Definition"
Expand All @@ -42,7 +42,7 @@ First, define your context struct that implements the `ServiceContext` trait:
You can then use this context to access service operator data and metadata:

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/01_basic.rs"
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/basic.rs"
fromLine={20}
toLine={20}
title="Accessing Service Information"
Expand Down
10 changes: 5 additions & 5 deletions pages/developers/blueprint-contexts/tangle-client-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ The `TangleClientContext` trait provides access to a Subxt client that enables:
- RPC Calls - Make direct RPC calls to Tangle nodes

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/sdk/src/ctx.rs"
fromLine={92}
toLine={99}
url="https://github.com/tangle-network/gadget/blob/main/sdk/src/contexts/tangle_client.rs"
fromLine={3}
toLine={10}
title="TangleClientContext Trait Definition"
/>

Expand All @@ -31,7 +31,7 @@ The `TangleClientContext` trait provides access to a Subxt client that enables:
First, define your context struct that implements the `TangleClientContext` trait:

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/01_basic.rs"
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/basic.rs"
fromLine={4}
toLine={9}
title="Tangle Client Context Definition"
Expand All @@ -42,7 +42,7 @@ First, define your context struct that implements the `TangleClientContext` trai
You can then use this context to access the Subxt client and interact with Tangle:

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/01_basic.rs"
url="https://github.com/tangle-network/gadget/blob/main/macros/context-derive/tests/ui/basic.rs"
fromLine={19}
toLine={19}
title="Accessing Subxt Client Functionality"
Expand Down
2 changes: 1 addition & 1 deletion pages/developers/blueprint-macros/context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ The Gadget SDK provides several built-in Context Extensions that offer common fu
3. `TangleClientContext`: Provides access to the Tangle Client (Subxt), used for interacting with the Tangle network.
4. `ServicesContext`: Allows access to the current Service instance properties, useful for service-specific operations.

for more documentation about the built-in extensions, please refer to the [API Documentation](https://docs.rs/gadget-sdk/latest/gadget_sdk/ctx/index.html).
for more documentation about the built-in extensions, please refer to the [API Documentation](https://docs.rs/gadget-sdk/latest/gadget_sdk/contexts/index.html).

These extensions can be easily added to your Context using derive macros, as shown in the following example.

Expand Down
6 changes: 6 additions & 0 deletions pages/developers/eigenlayer-avs/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"overview": "Overview",
"incredible-squaring-avs": "Incredible Squaring AVS",
"bls-template": "Eigenlayer BLS Template",
"ecdsa-template": "Eigenlayer ECDSA Template"
}
70 changes: 70 additions & 0 deletions pages/developers/eigenlayer-avs/bls-template.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: Using the EigenLayer BLS Template
---

# Building AVS with the EigenLayer BLS Template

## Introduction

This will guide you through the process of utilizing our BLS Template for starting your own AVS with BLS-oriented Smart
Contracts. The [Incredible Squaring AVS](/developers/eigenlayer-avs/incredible-squaring-avs) is an example of an AVS
that uses BLS contracts.

## Generating your project with Cargo Tangle

### 1. Installation

If you haven't already, you will need to install cargo-tangle. To install it, run the following command:

> Supported on Linux, MacOS, and Windows (WSL2)
```shell
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/tangle-network/gadget/releases/download/cargo-tangle/v0.1.1-beta.7/cargo-tangle-installer.sh | sh
```

Or, if you prefer to install the CLI from source:

```shell
cargo install cargo-tangle --git https://github.com/tangle-network/gadget --force
```

### 2. Generating your Project

To create a new BLS AVS, use the following command:

```shell
cargo tangle blueprint create --name <blueprint_name> --eigenlayer
```

Just replace `<blueprint_name>` with the desired name for your AVS. Once you run this command, you will be asked a series
of questions regarding the configurations and setup for your project. Simply answer those questions when prompted; if
you aren't sure about a question, you likely just want the default selection that it starts on.

#### Note

If you choose to use `foundry.toml` for the Soldeer configuration (the default), you will need to delete the following files from the `contracts` directory:

- `foundry.toml`
- `remappings.txt`
- `soldeer.lock`

This will allow the generated project to correct populate the dependencies and build out of the box. This will be fixed in the future so that nothing needs to be deleted.

### 4. Hello, World!

Now that you have generated the project, you can test out the simple example by running:

```shell
cargo test
```

This test just shows that the template generates you a fresh, working AVS structure. All that's left is to add what you want!

### 5. Customizing your AVS

What you do from here is completely up to you, but we have plenty of resources to help you:

- The contracts generated with this template will be called TangleServiceManager.sol, TangleTaskManager.sol, and
ITangleTaskManager.sol by default. You can use the find-and-replace function to change these to whatever you would like.
- Examples of different types of event listeners can be found [here](/developers/blueprint-event-listeners/introduction).
- A deeper dive into how jobs work can be found in the [jobs section](/developers/blueprint-macros/jobs).
73 changes: 73 additions & 0 deletions pages/developers/eigenlayer-avs/ecdsa-template.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: Using the EigenLayer ECDSA Template
---

# Building AVS with the EigenLayer ECDSA Template

## Introduction

This guide will walk you through the process of utilizing our ECDSA Template to initiate your own AVS with
ECDSA-oriented Smart Contracts. For reference, the [Tangle AVS](https://github.com/tangle-network/avs) demonstrates an
implementation of an AVS using ECDSA contracts.

## Generating your project with Cargo Tangle

### 1. Installation

Before proceeding, ensure you have cargo-tangle installed. If not, you can install it using the following command:

> Supported on Linux, MacOS, and Windows (WSL2)
```shell
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/tangle-network/gadget/releases/download/cargo-tangle/v0.1.1-beta.7/cargo-tangle-installer.sh | sh
```

Alternatively, if you prefer installing the CLI from source:

```shell
cargo install cargo-tangle --git https://github.com/tangle-network/gadget --force
```

### 2. Generating your Project

To generate your project, execute the following command:

```shell
cargo tangle blueprint create --name <blueprint_name> --eigenlayer ecdsa
```

Replace `<blueprint_name>` with your preferred AVS name. Upon running this command, you'll be prompted with a
series of questions regarding your project's configuration and setup. Answer these questions as they appear; if
uncertain, the default selection is generally best.

#### Note

If you choose to use `foundry.toml` for the Soldeer configuration (the default), you will need to delete the following
files from the `contracts` directory:

- `foundry.toml`
- `remappings.txt`
- `soldeer.lock`

This step allows the generated project to correctly populate dependencies and build out of the box. We plan to address
this in future updates to eliminate the need for manual file deletion.

### 4. Hello, World!

Now that you have generated the project, you can test out the simple example by running:

```shell
cargo test
```

This test just shows that the template generates you a fresh, working AVS structure. All that's left is to add what you want!

### 5. Customizing your AVS

The next steps depend on your specific requirements, but we offer several resources to assist you:

- By default, the AVS contract generated with this template is named TangleServiceManager.sol (along with related test
files TestTangleServiceManager.sol and TangleServiceManager.t.sol). You can use your text editor's find-and-replace
function to rename these as desired.
- For various types of event listener examples, refer to [this page](/developers/blueprint-event-listeners/introduction).
- To gain a deeper understanding of how jobs function, consult the [jobs section](/developers/blueprint-macros/jobs).
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: Build an EigenLayer AVS
title: EigenLayer Incredible Squaring AVS
---

import GithubFileReaderDisplay from "/components/GithubFileReaderDisplay";

# Building EVM Event Listeners for EigenLayer AVS
# Incredible Squaring AVS Example

## Introduction

Expand All @@ -30,7 +30,7 @@ First, define the contract interface using the `sol!` and `load_abi!` macros. Th

### 2. Job Definition with Event Handler

Use the [`#[job]`](./blueprint-macros/jobs.mdx) macro to define a function that will handle specific events. Include the `event_listener` attribute to specify the event details:
Use the [`#[job]`](/developers/blueprint-macros/jobs) macro to define a function that will handle specific events. Include the `event_listener` attribute to specify the event details:

<GithubFileReaderDisplay
url="https://github.com/tangle-network/gadget/blob/main/blueprints/incredible-squaring-eigenlayer/src/jobs/initialize_task.rs"
Expand Down Expand Up @@ -85,6 +85,39 @@ Use the `BlueprintRunner` to execute the jobs and background services:
title="BlueprintRunner setup"
/>

## Testing the Incredible Squaring AVS

### 1. Prerequisites

Before you begin, ensure you have the following installed:

Anvil
Docker

### 2. Installation

Clone this repository:

```shell
git clone https://github.com/tangle-network/gadget.git
cd gadget
```

Install Anvil:

```shell
curl -L https://foundry.paradigm.xyz | bash
foundryup
```

Running the AVS on a Testnet

We have a test for running this AVS Blueprint on a local Anvil Testnet. You can run the test with the following:

```shell
RUST_LOG=gadget=trace cargo test --package incredible-squaring-blueprint-eigenlayer test_eigenlayer_incredible_squaring_blueprint -- --nocapture
```

## Best Practices and Considerations

1. **Error Handling**: Implement robust error handling in your event listener functions to manage potential failures gracefully.
Expand Down
25 changes: 25 additions & 0 deletions pages/developers/eigenlayer-avs/overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import CardGrid from "../../../components/CardGrid.tsx"

# Building an EigenLayer AVS

## Getting Started

<CardGrid
cards={[
{
title: "Incredible Squaring AVS",
description: "Explore the Incredible Squaring AVS example to understand how we implement an AVS.",
link: "/developers/eigenlayer-avs/incredible-squaring-avs"
},
{
title: "EigenLayer BLS AVS Template",
description: "Kickstart your AVS development with this BLS template.",
link: "/developers/eigenlayer-avs/bls-template"
},
{
title: "EigenLayer ECDSA AVS Template",
description: "Simplify your AVS development process using this ECDSA template.",
link: "/developers/eigenlayer-avs/ecdsa-template"
}
]}
/>
4 changes: 2 additions & 2 deletions pages/operators/node-basics/faq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## Where can I get help?

Our documentation at [https://docs.tangle.tools](/) has the most up-to-date information, and you can ask questions at our Discord, the best place to get assistance with your node or other questions about the project. See http://tangle.tools/community for links to Discord and more.
Our documentation at [https://docs.tangle.tools](/) has the most up-to-date information, and you can ask questions at our Discord, the best place to get assistance with your node or other questions about the project.

## How do I stay up to date?

All upgrades and important technical information are announced on Discord and Twitter, in the #tangle-network channel. See http://tangle.tools/community for links to Discord and more.
All upgrades and important technical information are announced on Discord and Twitter, in the #tangle-network channel.

## What are the hardware requirements?

Expand Down
Loading

0 comments on commit f65b397

Please sign in to comment.