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 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
121 changes: 121 additions & 0 deletions docs/integrations-guides/dispersal/v2/golang-client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
sidebar_position: 1
title: Golang Client
---

# EigenDA Payment and Data Dispersal Guide
This guide walks through the process of setting up payments and dispersing data using EigenDA on Holesky.

## On Demand Data Dispersal
### On-chain setup
:::info Prerequisites
- ETH on the Ethereum Holesky testnet
- [Foundry](https://book.getfoundry.sh/getting-started/installation) installed
- RPC URL for Holesky
- Private key for transactions
:::

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 EigenDA requests charges will be pulled from here.

To start we will deposit into the payment vault using `Foundry's` `cast`.
:::note Installation
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:
:::note Deposits
Calculate the amount of data needed to send, funds deposited into the payment vault are non-refundable.
:::

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

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

1. Create a project directory
```bash
mkdir v2disperse
cd v2disperse
```
2. Environment Variable setup

```bash
echo "EIGENDA_AUTH_PK=<YOUR_PRIVATE_KEY>" > .env
```

3. Create the main 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
:::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. Prepare Data to Send
```Golang
bytesToSend := []byte("Hello, World!")
bytesToSend = codec.ConvertByPaddingEmptyByte(bytesToSend)
quorums := []uint8{0, 1}
```
#### 5. Sending 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)
}
```

#### 6. Check a Blob status
Call `GetBlobStatus()` to interact with the data
```Golang
blobStatus, err = disp.GetBlobStatus(ctx, request_id)
```
Comment on lines +117 to +121
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be nice to have the whole code as a single copy-pastable block at the end. I personally don't like following tutorial where I need to copy-paste a gazillion things.

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