Skip to content
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

WIP - v2 Golang Dispersal Guide #47

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
105 changes: 105 additions & 0 deletions docs/integrations-guides/dispersal/v2/golang-client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
sidebar_position: 1
title: Golang Client
---

# EigenDA Payment and Blob Dispersal Guide
This guide walks through the process of setting up payments and dispersing blobs using EigenDA.

## On Demand Data Dispersal
### On-chain setup
To disperse to the network you will need a balance to pull from. If you would like to learn more about EigenDA's Payment Module, check the reference *here (insert ref to Payments)*.

To start make sure you have ETH on the Ethereum Holesky testnet, we'll deposit into the payment vault and then any other DA requests charges will be pulled from here.

To start we will deposit into the payment vault using `Foundry's` `cast`. If you have not installed Foundry, follow their install commands [here](https://book.getfoundry.sh/getting-started/installation).

This will deposit 1 ETH into the Payment Vault on Holesky.


```bash
cast send --rpc-url <YOUR_RPC_URL> \
--private-key <YOUR_PRIVATE_KEY> \
0x3660d586f792320a1364637715ca7e9439daa2c7 \
"depositOnDemand(address)" \
<YOUR_ADDRESS> \
--value 100000000000000000
```
Now that we have the account setup for on-demand payments, let's disperse data.

## Dispersing Data
### Setup
To disperse a data, we'll start by setting up our `Disperser Client` to interact with the EigenDA disperser.

Let's start by setting up a project directory
```bash
mkdir v2disperse
cd v2disperse
```
Setup your environment by setting your private key in a `.env` file with the `EIGENDA_AUTH_PK` value set to your private key for the account dispersing data.
```bash
echo "EIGENDA_AUTH_PK=your_private_key_here" > .env
```

We'll be working out of a `main.go` file
```bash
touch main.go
```
### Implementation
#### 1. Import Dependencies
```Golang
package main

import (
"context"
"fmt"
"time"

"github.com/Layr-Labs/eigenda/api/clients/v2"
authv2 "github.com/Layr-Labs/eigenda/core/auth/v2"
corev2 "github.com/Layr-Labs/eigenda/core/v2"
"github.com/Layr-Labs/eigenda/encoding/utils/codec"
)
```

#### 2. Create Disperser Client
<!-- Notes -->
<!-- This should be the same account as you deposited using -->
<!-- Each request will be -->
:::note
Your signer should be the same address you deposited from
:::
```Golang
signer := authv2.NewLocalBlobRequestSigner(authKey)
disp, err := clients.NewDisperserClient(&clients.DisperserClientConfig{
Hostname: "disperser-preprod-holesky.eigenda.xyz",
Port: "443",
UseSecureGrpcFlag: true,
}, signer, nil, nil)
if err != nil {
println("Error creating disperser client")
panic(err)
}
```


#### 3. Setup Context and Data
```Golang
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
```

#### 4. Data to Send
```Golang
bytesToSend := []byte("Hello, World!")
bytesToSend = codec.ConvertByPaddingEmptyByte(bytesToSend)
quorums := []uint8{0, 1}
```
#### 5. Dispersing Data
Call `DisperseBlob()` to send your data to EigenDA
```Golang
status, request_id, err := disp.DisperseBlob(ctx, bytesToSend, 0, quorums, 0)
if err != nil {
panic(err)
}
```
4 changes: 2 additions & 2 deletions docs/integrations-guides/rollup-guides/op-stack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ deployed independently to power third-party rollups.

By default, the OP Stack sequencer's [op-batcher](https://github.com/ethereum-optimism/optimism/tree/develop/op-batcher) writes batches to Ethereum in the form of calldata or 4844 blobs to commit to the transactions included in the canonical L2 chain. In Alt-DA mode, the op-batcher and op-nodes (validators) are configured to talk to a third-party HTTP proxy server for writing (op-batcher) and reading (op-node) tx batches to and from DA. Optimism's Alt-DA [spec](https://specs.optimism.io/experimental/alt-da.html) contains a more in-depth breakdown of how these systems interact.

To implement this server spec, EigenDA provides [EigenDA Proxy](../../dispersal/clients/eigenda-proxy.md) which is ran as a dependency alongside OP Stack sequencers and full nodes to securely communicate with the EigenDA disperser.
To implement this server spec, EigenDA provides [EigenDA Proxy](../../dispersal/v1/clients/eigenda-proxy.md) which is ran as a dependency alongside OP Stack sequencers and full nodes to securely communicate with the EigenDA disperser.

## Deploying

Expand Down Expand Up @@ -81,7 +81,7 @@ When you are ready to onboard your rollup to mainnet you can fill out the follow

## Security Guarantees

This setup provides Stage 0 security guarantees without adding an unnecessary trust assumption on the EigenDA disperser. The EigenDA Proxy [docs page](../../dispersal/clients/eigenda-proxy.md) and [repo readme](https://github.com/Layr-Labs/eigenda-proxy/blob/main/README.md) explain how this is achieved.
This setup provides Stage 0 security guarantees without adding an unnecessary trust assumption on the EigenDA disperser. The EigenDA Proxy [docs page](../../dispersal/v1/clients/eigenda-proxy.md) and [repo readme](https://github.com/Layr-Labs/eigenda-proxy/blob/main/README.md) explain how this is achieved.

### OP Stack DA Challenge Contract

Expand Down
2 changes: 1 addition & 1 deletion docs/integrations-guides/rollup-guides/orbit/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Labs](https://www.offchainlabs.com/) to enable rollup developers to build

## EigenDA Proxy

Arbitrum nodes communicate with EigenDA via the proxy for secure communication and low code overhead. More information can be found [here](./../../dispersal/clients/eigenda-proxy.md). An instance of proxy **must** be spun-up to use this integration. In your node config, this will look like:
Arbitrum nodes communicate with EigenDA via the proxy for secure communication and low code overhead. More information can be found [here](../../dispersal/v1/clients/eigenda-proxy.md). An instance of proxy **must** be spun-up to use this integration. In your node config, this will look like:
```
"eigen-da": {"enable": true,"rpc": "http://eigenda_proxy:4242"}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations-guides/rollup-guides/orbit/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For replicating EigenDA interactions in a local testing environment, we utilize

### EigenDA Proxy

[EigenDA Proxy](https://github.com/Layr-Labs/eigenda-proxy) is used for secure and optimized communication between the rollup and the EigenDA disperser. Arbitrum uses the [*Simple Commitment Mode*](https://github.com/Layr-Labs/eigenda-proxy?tab=readme-ov-file#simple-commitment-mode) for client/server interaction and representing DA certificates. Read more about EigenDA Proxy and its respective security features [here](./../../dispersal/clients/eigenda-proxy.md).
[EigenDA Proxy](https://github.com/Layr-Labs/eigenda-proxy) is used for secure and optimized communication between the rollup and the EigenDA disperser. Arbitrum uses the [*Simple Commitment Mode*](https://github.com/Layr-Labs/eigenda-proxy?tab=readme-ov-file#simple-commitment-mode) for client/server interaction and representing DA certificates. Read more about EigenDA Proxy and its respective security features [here](../../dispersal/v1/clients/eigenda-proxy.md).

### Posting batches to EigenDA

Expand Down
4 changes: 2 additions & 2 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ const config = {
},
{
from: "/eigenda/integrations-guides/dispersal/disperser-golang-grpc-client",
to: "/integrations-guides/dispersal/clients/golang-client",
to: "/integrations-guides/dispersal/v1/clients/golang-client",
},
{
from: "/eigenda/integrations-guides/dispersal/clients/golang-client",
to: "/integrations-guides/dispersal/clients/golang-client",
to: "/integrations-guides/dispersal/v1/clients/golang-client",
},
],
createRedirects(existingPath) {
Expand Down