@@ -12,13 +12,15 @@ 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
2325 das "github.com/celestiaorg/nitro-das-celestia/daserver"
2426 "github.com/celestiaorg/nitro-das-celestia/daserver/types"
@@ -33,7 +35,9 @@ type CelestiaDAServerConfig struct {
3335
3436 CelestiaDa das.DAConfig `koanf:"celestia"`
3537
36- DasClientConfig das.ClientConfig `koanf:"das"`
38+ DasClientConfig daclient.ClientConfig `koanf:"das"`
39+
40+ FallbackEnabled bool `koanf:"fallback-enabled"`
3741
3842 LogLevel string `koanf:"log-level"`
3943 LogType string `koanf:"log-type"`
@@ -50,18 +54,19 @@ var DefaultCelestiaDAServerConfig = CelestiaDAServerConfig{
5054 RPCPort : 9876 ,
5155 RPCServerTimeouts : genericconf .HTTPServerTimeoutConfigDefault ,
5256 RPCServerBodyLimit : genericconf .HTTPServerBodyLimitDefault ,
57+ FallbackEnabled : true ,
5358 LogLevel : "INFO" ,
5459 LogType : "plaintext" ,
5560 Metrics : false ,
5661 MetricsServer : genericconf .MetricsServerConfigDefault ,
5762 PProf : false ,
5863 PprofCfg : genericconf .PProfDefault ,
59- DasClientConfig : das . DefaultConfig ,
64+ DasClientConfig : daclient . DefaultClientConfig ,
6065}
6166
6267func main () {
6368 if err := startup (); err != nil {
64- log .Error ("Error running CelestiaDAServer" , "err" , err )
69+ gethlog .Error ("Error running CelestiaDAServer" , "err" , err )
6570 }
6671}
6772
@@ -87,9 +92,11 @@ func parseDAServer(args []string) (*CelestiaDAServerConfig, error) {
8792 f .String ("log-level" , DefaultCelestiaDAServerConfig .LogLevel , "log level, valid values are CRIT, ERROR, WARN, INFO, DEBUG, TRACE" )
8893 f .String ("log-type" , DefaultCelestiaDAServerConfig .LogType , "log type (plaintext or json)" )
8994
95+ f .Bool ("fallback-enabled" , DefaultCelestiaDAServerConfig .FallbackEnabled , "enable fallbacks to arbitrum anytrust" )
96+
9097 das .CelestiaDAConfigAddOptions ("celestia" , f )
9198
92- das .ClientConfigAddOptions ("das" , f )
99+ daclient .ClientConfigAddOptions ("das" , f )
93100
94101 k , err := confighelpers .BeginCommonParse (f , args )
95102 if err != nil {
@@ -123,7 +130,7 @@ func (c *L1ReaderCloser) String() string {
123130func startMetrics (cfg * CelestiaDAServerConfig ) error {
124131 mAddr := fmt .Sprintf ("%v:%v" , cfg .MetricsServer .Addr , cfg .MetricsServer .Port )
125132 pAddr := fmt .Sprintf ("%v:%v" , cfg .PprofCfg .Addr , cfg .PprofCfg .Port )
126- if cfg .Metrics && ! metrics . Enabled {
133+ if cfg .Metrics && cfg . PProf && mAddr == pAddr {
127134 return fmt .Errorf ("metrics must be enabled via command line by adding --metrics, json config has no effect" )
128135 }
129136 if cfg .Metrics && cfg .PProf && mAddr == pAddr {
@@ -160,9 +167,9 @@ func startup() error {
160167 flag .Usage ()
161168 return fmt .Errorf ("error parsing log type when creating handler: %w" , err )
162169 }
163- glogger := log .NewGlogHandler (handler )
170+ glogger := gethlog .NewGlogHandler (handler )
164171 glogger .Verbosity (logLevel )
165- log .SetDefault (log .NewLogger (glogger ))
172+ gethlog .SetDefault (gethlog .NewLogger (glogger ))
166173
167174 if err := startMetrics (serverConfig ); err != nil {
168175 return err
@@ -184,8 +191,9 @@ func startup() error {
184191 celestiaReader = celestiaDA
185192 celestiaWriter = celestiaDA
186193
187- if serverConfig .DasClientConfig .EnableFallback {
188- client , err := das .NewClient (serverConfig .DasClientConfig )
194+ if serverConfig .FallbackEnabled {
195+ clientConfig := serverConfig .DasClientConfig .RPC
196+ client , err := daclient .NewClient (ctx , func () * rpcclient.ClientConfig { return & clientConfig })
189197 if err != nil {
190198 panic (fmt .Sprintf ("Failed to create client: %v" , err ))
191199 }
0 commit comments