@@ -12,8 +12,9 @@ import (
1212 "sync"
1313 "time"
1414
15- node "github.com/celestiaorg/celestia-node/api/rpc /client"
15+ txclient "github.com/celestiaorg/celestia-node/api/client"
1616 "github.com/celestiaorg/celestia-node/blob"
17+ "github.com/celestiaorg/celestia-node/nodebuilder/p2p"
1718 "github.com/celestiaorg/celestia-node/state"
1819 libshare "github.com/celestiaorg/go-square/v2/share"
1920 "github.com/celestiaorg/nitro-das-celestia/celestiagen"
@@ -38,7 +39,15 @@ type DAConfig struct {
3839 NamespaceId string `koanf:"namespace-id" `
3940 AuthToken string `koanf:"auth-token" reload:"hot"`
4041 ReadAuthToken string `koanf:"read-auth-token" reload:"hot"`
42+ CoreToken string `koanf:"core-token" reload:"hot"`
43+ CoreURL string `koanf:"core-url" reload:"hot"`
44+ CoreNetwork string `koanf:"core-network" reload:"hot"`
45+ KeyName string `koanf:"key-name" reload:"hot"`
46+ KeyPath string `koanf:"key-path" reload:"hot"`
47+ BackendName string `koanf:"backend-name" reload:"hot"`
4148 NoopWriter bool `koanf:"noop-writer" reload:"hot"`
49+ EnableDATLS bool `koanf:"enable-da-tls" reload:"hot"`
50+ EnableCoreTLS bool `koanf:"enable-core-tls" reload:"hot"`
4251 ValidatorConfig ValidatorConfig `koanf:"validator-config" reload:"hot"`
4352 ReorgOnReadFailure bool `koanf:"dangerous-reorg-on-read-failure"`
4453 CacheCleanupTime time.Duration `koanf:"cache-time"`
@@ -87,8 +96,8 @@ func IsCelestiaMessageHeaderByte(header byte) bool {
8796
8897type CelestiaDA struct {
8998 Cfg * DAConfig
90- Client * node .Client
91- ReadClient * node .Client
99+ Client * txclient .Client
100+ ReadClient * txclient .Client
92101
93102 Namespace * libshare.Namespace
94103
@@ -104,6 +113,14 @@ func CelestiaDAConfigAddOptions(prefix string, f *pflag.FlagSet) {
104113 f .String (prefix + ".namespace-id" , "" , "Celestia Namespace to post data to" )
105114 f .String (prefix + ".auth-token" , "" , "Auth token for Celestia Node" )
106115 f .String (prefix + ".read-auth-token" , "" , "Auth token for Celestia Node" )
116+ f .String (prefix + ".core-token" , "" , "Auth token for Core Celestia Node Endpoint" )
117+ f .String (prefix + ".core-url" , "" , "URL to Celestia Core endpoint" )
118+ f .String (prefix + ".core-network" , "celestia" , "Celestia Network to use" )
119+ f .String (prefix + ".key-name" , "my_key" , "key name to use" )
120+ f .String (prefix + ".key-path" , "./keys" , "key path to use" )
121+ f .String (prefix + ".backend-name" , "test" , "keyring backend to use" )
122+ f .Bool (prefix + ".enable-da-tls" , false , "enable TLS for DA node" )
123+ f .Bool (prefix + ".enable-core-tls" , false , "enable TLS for Core node" )
107124 f .Bool (prefix + ".noop-writer" , false , "Noop writer (disable posting to celestia)" )
108125 f .String (prefix + ".validator-config" + ".eth-rpc" , "" , "Parent chain connection, only used for validation" )
109126 f .String (prefix + ".validator-config" + ".blobstream" , "" , "Blobstream address, only used for validation" )
@@ -116,19 +133,53 @@ func NewCelestiaDA(cfg *DAConfig) (*CelestiaDA, error) {
116133 if cfg == nil {
117134 return nil , errors .New ("celestia cfg cannot be blank" )
118135 }
119- daClient , err := node .NewClient (context .Background (), cfg .Rpc , cfg .AuthToken )
136+ // Create a keyring
137+ kr , err := txclient .KeyringWithNewKey (txclient.KeyringConfig {
138+ KeyName : cfg .KeyName ,
139+ BackendName : cfg .BackendName ,
140+ }, cfg .KeyPath )
120141 if err != nil {
121142 return nil , err
122143 }
123144
124- var readClient * node.Client
145+ // Configure the client
146+ clientCfg := txclient.Config {
147+ ReadConfig : txclient.ReadConfig {
148+ BridgeDAAddr : cfg .Rpc ,
149+ DAAuthToken : cfg .AuthToken ,
150+ EnableDATLS : cfg .EnableDATLS ,
151+ },
152+ SubmitConfig : txclient.SubmitConfig {
153+ DefaultKeyName : cfg .KeyName ,
154+ Network : p2p .Network (cfg .CoreNetwork ),
155+ CoreGRPCConfig : txclient.CoreGRPCConfig {
156+ Addr : cfg .CoreURL ,
157+ TLSEnabled : cfg .EnableCoreTLS ,
158+ AuthToken : cfg .CoreToken ,
159+ },
160+ },
161+ }
162+
163+ celestiaClient , err := txclient .New (context .Background (), clientCfg , kr )
164+ if err != nil {
165+ return nil , err
166+ }
167+
168+ var readClient * txclient.Client
125169 if cfg .ReadRpc != "" && cfg .ReadAuthToken != "" {
126- readClient , err = node .NewClient (context .Background (), cfg .ReadRpc , cfg .ReadAuthToken )
170+ readClientCfg := txclient.Config {
171+ ReadConfig : txclient.ReadConfig {
172+ BridgeDAAddr : cfg .ReadRpc ,
173+ DAAuthToken : cfg .ReadAuthToken ,
174+ EnableDATLS : cfg .EnableDATLS ,
175+ },
176+ }
177+ readClient , err = txclient .New (context .Background (), readClientCfg , kr )
127178 if err != nil {
128179 return nil , err
129180 }
130181 } else {
131- readClient = daClient
182+ readClient = celestiaClient
132183 }
133184
134185 if cfg .NamespaceId == "" {
@@ -146,7 +197,7 @@ func NewCelestiaDA(cfg *DAConfig) (*CelestiaDA, error) {
146197
147198 da := & CelestiaDA {
148199 Cfg : cfg ,
149- Client : daClient ,
200+ Client : celestiaClient ,
150201 ReadClient : readClient ,
151202 Namespace : & namespace ,
152203 }
0 commit comments