Skip to content

Commit

Permalink
da: use celestia-openrpc (#187)
Browse files Browse the repository at this point in the history
* op-node: use openrpc to get blobs

* op-batcher: use openrpc to submit blobs

* op-celestia-: use openrpc to fetch blobs

* da: update rpc port

* docker: update rpc port

* readme: devnet - rm unused port

* docker: devnet - restore platform
  • Loading branch information
tuxcanfly committed Nov 14, 2023
1 parent bc6bc81 commit d837184
Show file tree
Hide file tree
Showing 14 changed files with 1,584 additions and 278 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Celestia as the data availability (DA) layer.
Currently, the tests assume a working [Celestia devnet](https://github.com/rollkit/local-celestia-devnet) running locally:

```bash
docker run --platform linux/amd64 -p 26650:26657 -p 26659:26659 ghcr.io/rollkit/local-celestia-devnet:v0.11.0-rc6
docker run --platform linux/amd64 -p 26658:26658 ghcr.io/rollkit/local-celestia-devnet:v0.11.0-rc8
```

The e2e tests can be triggered with:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1
github.com/celestiaorg/go-cnc v0.4.2
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0
github.com/docker/docker v20.10.24+incompatible
github.com/docker/docker v24.0.2+incompatible
github.com/docker/go-connections v0.4.0
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20231030223232-e16eae11e492
Expand Down
1,742 changes: 1,533 additions & 209 deletions go.sum

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions op-celestia/go.mod

This file was deleted.

42 changes: 0 additions & 42 deletions op-celestia/go.sum

This file was deleted.

2 changes: 1 addition & 1 deletion op-e2e/actions/l2_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type L2API interface {

func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher, eng L2API, cfg *rollup.Config, syncCfg *sync.Config) *L2Verifier {
metrics := &testutils.TestDerivationMetrics{}
daCfg, err := rollup.NewDAConfig("http://localhost:26659", "0000e8e5f679bf7116cb")
daCfg, err := rollup.NewDAConfig("http://localhost:26658", "0000e8e5f679bf7116cb", "")
require.NoError(t, err)
pipeline := derive.NewDerivationPipeline(log, cfg, daCfg, l1, eng, metrics, syncCfg)
pipeline.Reset()
Expand Down
2 changes: 1 addition & 1 deletion op-e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ func (cfg SystemConfig) Start(t *testing.T, _opts ...SystemConfigOption) (*Syste
}
node, err := rollupNode.New(context.Background(), &c, l, snapLog, "", metrics.NewMetrics(""))

daCfg, err := rollup.NewDAConfig("http://127.0.0.1:26659", "0000e8e5f679bf7116cb")
daCfg, err := rollup.NewDAConfig("http://127.0.0.1:26658", "0000e8e5f679bf7116cb", "")
if err != nil {
return nil, err
}
Expand Down
9 changes: 8 additions & 1 deletion op-node/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var (
DaRPC = cli.StringFlag{
Name: "da-rpc",
Usage: "Data Availability RPC",
Value: "http://da:26659",
Value: "http://da:26658",
EnvVar: prefixEnvVar("DA_RPC"),
}
NamespaceId = cli.StringFlag{
Expand All @@ -51,6 +51,12 @@ var (
Value: "000008e5f679bf7116cb",
EnvVar: prefixEnvVar("NAMESPACE_ID"),
}
AuthToken = cli.StringFlag{
Name: "auth-token",
Usage: "Authentication Token for DA node",
Value: "",
EnvVar: prefixEnvVar("AUTH_TOKEN"),
}
Network = cli.StringFlag{
Name: "network",
Usage: fmt.Sprintf("Predefined network selection. Available networks: %s", strings.Join(chaincfg.AvailableNetworks(), ", ")),
Expand Down Expand Up @@ -301,6 +307,7 @@ var requiredFlags = []cli.Flag{
RPCListenPort,
DaRPC,
NamespaceId,
AuthToken,
}

var optionalFlags = []cli.Flag{
Expand Down
24 changes: 15 additions & 9 deletions op-node/rollup/da_config.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
package rollup

import (
"context"
"encoding/hex"
"time"

"github.com/celestiaorg/go-cnc"
openrpc "github.com/rollkit/celestia-openrpc"
openrpcns "github.com/rollkit/celestia-openrpc/types/namespace"
"github.com/rollkit/celestia-openrpc/types/share"
)

type DAConfig struct {
Rpc string
Namespace cnc.Namespace
Client *cnc.Client
Namespace openrpcns.Namespace
Client *openrpc.Client
AuthToken string
}

func NewDAConfig(rpc string, ns string) (*DAConfig, error) {
func NewDAConfig(rpc, token, ns string) (*DAConfig, error) {
nsBytes, err := hex.DecodeString(ns)
if err != nil {
return &DAConfig{}, err
}

namespace := cnc.MustNewV0(nsBytes)
namespace, err := share.NewBlobNamespaceV0(nsBytes)
if err != nil {
return nil, err
}

daClient, err := cnc.NewClient(rpc, cnc.WithTimeout(30*time.Second))
client, err := openrpc.NewClient(context.Background(), rpc, token)
if err != nil {
return &DAConfig{}, err
}

return &DAConfig{
Namespace: namespace,
Namespace: namespace.ToAppNamespace(),
Rpc: rpc,
Client: daClient,
Client: client,
}, nil
}
7 changes: 6 additions & 1 deletion op-node/rollup/derive/calldata_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/rollkit/celestia-openrpc/types/share"

"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-service/eth"
Expand Down Expand Up @@ -147,7 +148,11 @@ func DataFromEVMTransactions(config *rollup.Config, daCfg *rollup.DAConfig, batc
return nil, err
}
log.Info("requesting data from celestia", "namespace", hex.EncodeToString(daCfg.Namespace.Bytes()), "height", height)
data, err := daCfg.Client.NamespacedData(context.Background(), daCfg.Namespace, uint64(height))
blobs, err := daCfg.Client.Blob.GetAll(context.Background(), uint64(height), []share.Namespace{daCfg.Namespace.Bytes()})
data := make([][]byte, len(blobs))
for i, blob := range blobs {
data[i] = blob.Data
}
if err != nil {
return nil, NewResetError(fmt.Errorf("failed to retrieve data from celestia: %w", err))
}
Expand Down
4 changes: 4 additions & 0 deletions op-service/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import (
"github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
openrpc "github.com/rollkit/celestia-openrpc"
openrpcns "github.com/rollkit/celestia-openrpc/types/namespace"
"github.com/rollkit/celestia-openrpc/types/blob"
"github.com/rollkit/celestia-openrpc/types/share"

"github.com/ethereum-optimism/optimism/op-service/retry"
"github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
Expand Down
3 changes: 3 additions & 0 deletions ops-bedrock/devnet-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ L2OO_ADDRESS="0x6900000000000000000000000000000000000000"
(
cd ops-bedrock
echo "Bringing up devnet..."
docker-compose -f docker-compose-devnet.yml up -d da
wait_up http://localhost:26659/header/1
export CELESTIA_NODE_AUTH_TOKEN="$(docker exec ops-bedrock-da-1 celestia bridge auth admin --node.store /bridge)"
L2OO_ADDRESS="$L2OO_ADDRESS" \
docker-compose -f docker-compose-devnet.yml up -d op-proposer op-batcher

Expand Down
9 changes: 8 additions & 1 deletion ops-bedrock/docker-compose-devnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ services:
image: "ghcr.io/rollkit/local-celestia-devnet:v0.11.0-rc8"
ports:
- "26657:26657"
- "26658:26658"
- "26659:26659"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:26659/header/1"]
Expand Down Expand Up @@ -101,8 +102,11 @@ services:
--metrics.port=7300
--pprof.enabled
--rpc.enable-admin
--da-rpc=http://da:26659
--da-rpc=http://da:26658
--namespace-id=000008e5f679bf7116cb
--auth-token=$CELESTIA_NODE_AUTH_TOKEN
environment:
OP_NODE_AUTH_TOKEN: $CELESTIA_NODE_AUTH_TOKEN
ports:
- "7545:8545"
- "9003:9003"
Expand Down Expand Up @@ -183,6 +187,9 @@ services:
OP_BATCHER_BATCH_TYPE: 0
OP_BATCHER_NAMESPACE_ID: "e8e5f679bf7116cb"
OP_BATCHER_DA_RPC: http://da:26659
OP_BATCHER_NAMESPACE_ID: "000008e5f679bf7116cb"
OP_BATCHER_DA_RPC: http://da:26658
OP_BATCHER_AUTH_TOKEN: $CELESTIA_NODE_AUTH_TOKEN

artifact-server:
depends_on:
Expand Down
3 changes: 3 additions & 0 deletions ops-bedrock/testnet-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ L2OO_ADDRESS="0x6900000000000000000000000000000000000000"
(
cd ops-bedrock
echo "Bringing up devnet..."
docker-compose -f docker-compose-devnet.yml up -d da
wait_up http://localhost:26659/header/1
export CELESTIA_NODE_AUTH_TOKEN="$(docker exec ops-bedrock-da-1 celestia bridge auth admin --node.store /bridge)"
L2OO_ADDRESS="$L2OO_ADDRESS" \
docker-compose -f docker-compose-testnet.yml up -d op-proposer op-batcher

Expand Down

0 comments on commit d837184

Please sign in to comment.