Skip to content

Commit b9937aa

Browse files
triple-CCCFerret-sanchendechen
authored
merge v0.5.2 (#6)
* Update README.md * Update README.md * Update README.md * add docker examples * add "daprovider" name to rpc server * Add methods and response types for daclient api * add fallback to das with daprovider * update deps and fix fallback preimages --------- Co-authored-by: Diego <31937514+Ferret-san@users.noreply.github.com> Co-authored-by: Diego <diego@celestia.org> Co-authored-by: chendechen <dechen.chen@debank.com>
1 parent 778a78a commit b9937aa

25 files changed

+33912
-255
lines changed

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A data availability server for the Arbitrum Nitro stack, leveraging Celestia DA
88

99
## Docker
1010

11-
`FROM ghcr.io/celestiaorg/nitro-das-celestia:v0.4.2`
11+
`FROM ghcr.io/celestiaorg/nitro-das-celestia:v0.4.3`
1212

1313

1414
## Example usage
@@ -23,6 +23,21 @@ A data availability server for the Arbitrum Nitro stack, leveraging Celestia DA
2323
--celestia.rpc $CELESTIA_NODE_ENDPOINT
2424
```
2525

26+
## Running Docker Image
27+
28+
```
29+
docker run --name celestia-server \
30+
-p 26657:26657 \
31+
-e AUTH_TOKEN=your_token \
32+
-e NAMESPACEID=your_namespace \
33+
-e CELESTIA_NODE_ENDPOINT=your_node_endpoint \
34+
ghcr.io/celestiaorg/nitro-das-celestia:v0.4.3
35+
```
36+
37+
## Example Docker Compose
38+
39+
For an example on how to use the images in conjunction with other containers, check the [docker-compose.yaml](https://github.com/celestiaorg/nitro-das-celestia/blob/main/docker-compose.yaml) in this repository for an example
40+
2641
## Flags
2742

2843
```
@@ -61,6 +76,31 @@ Usage of daserver:
6176
--rpc-server-timeouts.write-timeout duration the maximum duration before timing out writes of the response (http.Server.WriteTimeout) (default 30s)
6277
```
6378

79+
## Running a da server for an Orbit x Celestia chain
80+
81+
Before proceeding, it is highly encouraged to familiarize yourself with [Celestia](https://docs.celestia.org/) and more specifically with [DA Nodes](https://docs.celestia.org/how-to-guides/light-node) (light, full, bridge)
82+
83+
## Running a Batch Poster
84+
85+
If you are running a celestia-sever for a batch poster node, you need to take the following into account:
86+
87+
- if you don't provide a `gas-price` and a `gas-multipler`, you will be automatically opting for gas estimation from your celestia-node
88+
- you should run this on the same machine as your nitro batch poster node
89+
- you WILL NOT be able to use a hosted provider for your celestia-node endpoint. You will have to run your own celestia-node in order to post data to Celestia
90+
- you can get the `auth token` for your node like [this](https://docs.celestia.org/how-to-guides/quick-start#get-your-auth-token)
91+
- you will need to pick a [namespace](https://docs.celestia.org/tutorials/node-tutorial#namespaces) were to write data to and make sure to use this in other nodes and share with node runners.
92+
93+
## Running a Full Node
94+
95+
If you are running a celestia-server as part of a full node setup for an orbit x celestia da chain, note the folloing:
96+
97+
- you don't need to provide a `gas-price` or a `gas-multiplier`, since the node won't be submitting data to celestia
98+
- you should run this on the same machine as your nitro full node or block the `store` endpoint if you are not running a batch poster
99+
- you only need a namespace to use when fetching data from Celestia (the rollup should make this clear and accesible to you), and a celestia-node endpoint (core / consensus endpoints won't work!). If you do not wish to run your own celestia light node, or da bridge node, you can get a hosted endpoint from providers like:
100+
- [Quicknode](https://www.quicknode.com/docs/celestia)
101+
102+
103+
64104
## Running a Validator
65105
>[!CAUTION]
66106
> The celestia server binary won't throw an error if you forget to set the validator config, if you are running validators for your chain, please read carefully

cmd/celestiadaserver.go

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ import (
1212

1313
flag "github.com/spf13/pflag"
1414

15-
"github.com/ethereum/go-ethereum/log"
15+
gethlog "github.com/ethereum/go-ethereum/log"
1616
"github.com/ethereum/go-ethereum/metrics"
1717
"github.com/ethereum/go-ethereum/metrics/exp"
1818

1919
"github.com/offchainlabs/nitro/cmd/genericconf"
2020
"github.com/offchainlabs/nitro/cmd/util/confighelpers"
21+
"github.com/offchainlabs/nitro/daprovider/daclient"
2122
"github.com/offchainlabs/nitro/util/headerreader"
23+
"github.com/offchainlabs/nitro/util/rpcclient"
2224

23-
"github.com/celestiaorg/nitro-das-celestia/das"
25+
das "github.com/celestiaorg/nitro-das-celestia/daserver"
26+
"github.com/celestiaorg/nitro-das-celestia/daserver/types"
2427
)
2528

2629
type CelestiaDAServerConfig struct {
@@ -32,6 +35,10 @@ type CelestiaDAServerConfig struct {
3235

3336
CelestiaDa das.DAConfig `koanf:"celestia"`
3437

38+
DasClientConfig daclient.ClientConfig `koanf:"das"`
39+
40+
FallbackEnabled bool `koanf:"fallback-enabled"`
41+
3542
LogLevel string `koanf:"log-level"`
3643
LogType string `koanf:"log-type"`
3744

@@ -47,17 +54,19 @@ var DefaultCelestiaDAServerConfig = CelestiaDAServerConfig{
4754
RPCPort: 9876,
4855
RPCServerTimeouts: genericconf.HTTPServerTimeoutConfigDefault,
4956
RPCServerBodyLimit: genericconf.HTTPServerBodyLimitDefault,
57+
FallbackEnabled: true,
5058
LogLevel: "INFO",
5159
LogType: "plaintext",
5260
Metrics: false,
5361
MetricsServer: genericconf.MetricsServerConfigDefault,
5462
PProf: false,
5563
PprofCfg: genericconf.PProfDefault,
64+
DasClientConfig: daclient.DefaultClientConfig,
5665
}
5766

5867
func main() {
5968
if err := startup(); err != nil {
60-
log.Error("Error running CelestiaDAServer", "err", err)
69+
gethlog.Error("Error running CelestiaDAServer", "err", err)
6170
}
6271
}
6372

@@ -83,8 +92,12 @@ func parseDAServer(args []string) (*CelestiaDAServerConfig, error) {
8392
f.String("log-level", DefaultCelestiaDAServerConfig.LogLevel, "log level, valid values are CRIT, ERROR, WARN, INFO, DEBUG, TRACE")
8493
f.String("log-type", DefaultCelestiaDAServerConfig.LogType, "log type (plaintext or json)")
8594

95+
f.Bool("fallback-enabled", DefaultCelestiaDAServerConfig.FallbackEnabled, "enable fallbacks to arbitrum anytrust")
96+
8697
das.CelestiaDAConfigAddOptions("celestia", f)
8798

99+
daclient.ClientConfigAddOptions("das", f)
100+
88101
k, err := confighelpers.BeginCommonParse(f, args)
89102
if err != nil {
90103
return nil, err
@@ -117,7 +130,7 @@ func (c *L1ReaderCloser) String() string {
117130
func startMetrics(cfg *CelestiaDAServerConfig) error {
118131
mAddr := fmt.Sprintf("%v:%v", cfg.MetricsServer.Addr, cfg.MetricsServer.Port)
119132
pAddr := fmt.Sprintf("%v:%v", cfg.PprofCfg.Addr, cfg.PprofCfg.Port)
120-
if cfg.Metrics && !metrics.Enabled {
133+
if cfg.Metrics && cfg.PProf && mAddr == pAddr {
121134
return fmt.Errorf("metrics must be enabled via command line by adding --metrics, json config has no effect")
122135
}
123136
if cfg.Metrics && cfg.PProf && mAddr == pAddr {
@@ -154,9 +167,9 @@ func startup() error {
154167
flag.Usage()
155168
return fmt.Errorf("error parsing log type when creating handler: %w", err)
156169
}
157-
glogger := log.NewGlogHandler(handler)
170+
glogger := gethlog.NewGlogHandler(handler)
158171
glogger.Verbosity(logLevel)
159-
log.SetDefault(log.NewLogger(glogger))
172+
gethlog.SetDefault(gethlog.NewLogger(glogger))
160173

161174
if err := startMetrics(serverConfig); err != nil {
162175
return err
@@ -168,18 +181,32 @@ func startup() error {
168181
ctx, cancel := context.WithCancel(context.Background())
169182
defer cancel()
170183
celestiaDA, err := das.NewCelestiaDA(&serverConfig.CelestiaDa)
171-
var celestiaReader das.CelestiaReader
172-
var celestiaWriter das.CelestiaWriter
184+
var celestiaReader types.CelestiaReader
185+
var celestiaWriter types.CelestiaWriter
173186
var rpcServer *http.Server
174187
if serverConfig.EnableRPC {
175188
if err != nil {
176189
return err
177190
}
178191
celestiaReader = celestiaDA
179192
celestiaWriter = celestiaDA
180-
rpcServer, err = das.StartDASRPCServer(ctx, serverConfig.RPCAddr, serverConfig.RPCPort, serverConfig.RPCServerTimeouts, serverConfig.RPCServerBodyLimit, celestiaReader, celestiaWriter)
181-
if err != nil {
182-
return err
193+
194+
if serverConfig.FallbackEnabled {
195+
clientConfig := serverConfig.DasClientConfig.RPC
196+
client, err := daclient.NewClient(ctx, func() *rpcclient.ClientConfig { return &clientConfig })
197+
if err != nil {
198+
panic(fmt.Sprintf("Failed to create client: %v", err))
199+
}
200+
defer client.Close()
201+
rpcServer, err = das.StartDASRPCServer(ctx, serverConfig.RPCAddr, serverConfig.RPCPort, serverConfig.RPCServerTimeouts, serverConfig.RPCServerBodyLimit, celestiaReader, celestiaWriter, client, true)
202+
if err != nil {
203+
panic(fmt.Sprintf("Failed to create client: %v", err))
204+
}
205+
} else {
206+
rpcServer, err = das.StartDASRPCServer(ctx, serverConfig.RPCAddr, serverConfig.RPCPort, serverConfig.RPCServerTimeouts, serverConfig.RPCServerBodyLimit, celestiaReader, celestiaWriter, nil, false)
207+
if err != nil {
208+
return err
209+
}
183210
}
184211
}
185212

File renamed without changes.

das/blobstream_test.go renamed to daserver/blobstream_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
libshare "github.com/celestiaorg/go-square/v2/share"
1616
"github.com/celestiaorg/nitro-das-celestia/celestiagen"
17+
"github.com/celestiaorg/nitro-das-celestia/daserver/types"
1718
"github.com/ethereum/go-ethereum"
1819
"github.com/ethereum/go-ethereum/common"
1920
"github.com/ethereum/go-ethereum/ethclient"
@@ -79,6 +80,8 @@ func setupNetworkTest(t *testing.T) (*CelestiaDA, string, func(), context.Contex
7980
1024*1024*2, // 2MB body limit
8081
celestiaDA,
8182
celestiaDA,
83+
nil,
84+
false,
8285
)
8386
require.NoError(t, err)
8487

@@ -117,7 +120,7 @@ func TestGetProofVerification(t *testing.T) {
117120
commitment, err := base64.StdEncoding.DecodeString(os.Getenv("COMMITMENT"))
118121
require.NoError(t, err)
119122

120-
header, err := celestiaDA.Client.Header.GetByHeight(ctx, height)
123+
header, _ := celestiaDA.Client.Header.GetByHeight(ctx, height)
121124

122125
dataBlob, err := celestiaDA.Client.Blob.Get(ctx, height, namespace, commitment)
123126
require.NoError(t, err)
@@ -148,17 +151,16 @@ func TestGetProofVerification(t *testing.T) {
148151

149152
startIndexOds := blobIndex - odsSize*startRow
150153

151-
blobPointer := BlobPointer{
154+
blobPointer := types.BlobPointer{
152155
BlockHeight: height,
153156
Start: uint64(startIndexOds),
154157
SharesLength: uint64(sharesLength),
155-
TxCommitment: txCommitment,
156158
DataRoot: dataRoot,
157159
}
158160

159161
t.Run("Read Message BlobPointer", func(t *testing.T) {
160162
// Read through RPC
161-
var readResult ReadResult
163+
var readResult types.ReadResult
162164
err = client.Call(&readResult, "celestia_read", &blobPointer)
163165
require.NoError(t, err)
164166
require.NotNil(t, readResult)
@@ -238,7 +240,7 @@ func TestGetProofVerification(t *testing.T) {
238240
ethRpc, err := ethclient.Dial(celestiaDA.Cfg.ValidatorConfig.EthClient)
239241
require.NoError(t, err)
240242

241-
packedData, err := verifyProofABI.Inputs.Pack(
243+
packedData, _ := verifyProofABI.Inputs.Pack(
242244
args.Blobstream,
243245
celestiagen.NamespaceNode{
244246
Min: celestiagen.Namespace(args.RowRoot.Min),

0 commit comments

Comments
 (0)