Skip to content

Commit 2f3388d

Browse files
Remove multiple external DA provider configuration
In an earlier commit 05ac6df we removed mulitple external DA provider registration, this commit follows up by removing configuration of more than one external DA provider.
1 parent aedd678 commit 2f3388d

File tree

5 files changed

+11
-112
lines changed

5 files changed

+11
-112
lines changed

arbnode/node.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -582,34 +582,30 @@ func getDAProviders(
582582
// 1. External DA (if enabled)
583583
// 2. AnyTrust (if enabled)
584584

585-
// Create external DA clients for each configured provider
586-
for i := range config.DA.ExternalProviders {
587-
providerConfig := &config.DA.ExternalProviders[i]
588-
if !providerConfig.Enable {
589-
log.Info("Skipping disabled external DA provider", "providerIndex", i)
590-
continue
591-
}
585+
// Create external DA client if enabled
586+
if config.DA.ExternalProvider.Enable {
587+
providerConfig := &config.DA.ExternalProvider
592588

593-
log.Info("Creating external DA client", "providerIndex", i, "url", providerConfig.RPC.URL, "withWriter", providerConfig.WithWriter)
589+
log.Info("Creating external DA client", "url", providerConfig.RPC.URL, "withWriter", providerConfig.WithWriter)
594590
externalDAClient, err := daclient.NewClient(ctx, providerConfig, data_streaming.PayloadCommiter())
595591
if err != nil {
596-
return nil, nil, nil, fmt.Errorf("failed to create external DA client[%d]: %w", i, err)
592+
return nil, nil, nil, fmt.Errorf("failed to create external DA client: %w", err)
597593
}
598594

599595
// Add to writers array if batch poster is enabled and WithWriter is true
600596
if providerConfig.WithWriter && config.BatchPoster.Enable {
601597
writers = append(writers, externalDAClient)
602-
log.Info("Added external DA writer", "providerIndex", i, "writerIndex", len(writers)-1, "totalWriters", len(writers))
598+
log.Info("Added external DA writer")
603599
}
604600

605601
// Register external DA client as both reader and validator
606602
result, err := externalDAClient.GetSupportedHeaderBytes().Await(ctx)
607603
if err != nil {
608-
return nil, nil, nil, fmt.Errorf("failed to get supported header bytes from external DA client[%d]: %w", i, err)
604+
return nil, nil, nil, fmt.Errorf("failed to get supported header bytes from external DA client: %w", err)
609605
}
610606
for _, hb := range result.HeaderBytes {
611607
if err := dapRegistry.Register(hb, externalDAClient, externalDAClient); err != nil {
612-
return nil, nil, nil, fmt.Errorf("failed to register DA provider[%d]: %w", i, err)
608+
return nil, nil, nil, fmt.Errorf("failed to register DA provider: %w", err)
613609
}
614610
}
615611
}

cmd/nitro/config_test.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919

2020
"github.com/offchainlabs/nitro/cmd/genericconf"
2121
"github.com/offchainlabs/nitro/cmd/util/confighelpers"
22-
"github.com/offchainlabs/nitro/daprovider/daclient"
2322
"github.com/offchainlabs/nitro/daprovider/das"
2423
"github.com/offchainlabs/nitro/util/colors"
2524
"github.com/offchainlabs/nitro/util/testhelpers"
@@ -32,8 +31,6 @@ func TestEmptyCliConfig(t *testing.T) {
3231
Require(t, err)
3332
err = das.FixKeysetCLIParsing("node.data-availability.rpc-aggregator.backends", k)
3433
Require(t, err)
35-
err = daclient.FixExternalProvidersCLIParsing("node.da.external-providers", k)
36-
Require(t, err)
3734
var emptyCliNodeConfig NodeConfig
3835
err = confighelpers.EndCommonParse(k, &emptyCliNodeConfig)
3936
Require(t, err)
@@ -85,23 +82,6 @@ func TestExternalProviderSingularConfig(t *testing.T) {
8582
Require(t, err)
8683
}
8784

88-
func TestExternalProvidersConfig(t *testing.T) {
89-
args := strings.Split("--persistent.chain /tmp/data --init.dev-init --node.parent-chain-reader.enable=false --parent-chain.id 5 --chain.id 421613 --node.batch-poster.parent-chain-wallet.pathname /l1keystore --node.batch-poster.parent-chain-wallet.password passphrase --http.addr 0.0.0.0 --ws.addr 0.0.0.0 --node.sequencer --execution.sequencer.enable --node.feed.output.enable --node.feed.output.port 9642 --node.da.external-providers [{\"rpc\":{\"url\":\"http://localhost:8547\"},\"with-writer\":true},{\"rpc\":{\"url\":\"http://localhost:8548\"},\"with-writer\":false}] --node.transaction-streamer.track-block-metadata-from=10", " ")
90-
_, _, err := ParseNode(context.Background(), args)
91-
Require(t, err)
92-
}
93-
94-
func TestExternalProviderConflict(t *testing.T) {
95-
args := strings.Split("--persistent.chain /tmp/data --init.dev-init --node.parent-chain-reader.enable=false --parent-chain.id 5 --chain.id 421613 --node.batch-poster.parent-chain-wallet.pathname /l1keystore --node.batch-poster.parent-chain-wallet.password passphrase --http.addr 0.0.0.0 --ws.addr 0.0.0.0 --node.sequencer --execution.sequencer.enable --node.feed.output.enable --node.feed.output.port 9642 --node.da.external-provider.rpc.url http://localhost:8547 --node.da.external-providers [{\"rpc\":{\"url\":\"http://localhost:8548\"}}] --node.transaction-streamer.track-block-metadata-from=10", " ")
96-
_, _, err := ParseNode(context.Background(), args)
97-
if err == nil {
98-
Fail(t, "expected error when both external-provider and external-providers are specified")
99-
}
100-
if !strings.Contains(err.Error(), "cannot specify both external-provider and external-providers") {
101-
Fail(t, "error message should mention conflict between singular and plural config, got:", err.Error())
102-
}
103-
}
104-
10585
func TestReloads(t *testing.T) {
10686
var check func(node reflect.Value, cold bool, path string)
10787
check = func(node reflect.Value, cold bool, path string) {

cmd/nitro/nitro.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ import (
5555
"github.com/offchainlabs/nitro/cmd/util"
5656
"github.com/offchainlabs/nitro/cmd/util/confighelpers"
5757
"github.com/offchainlabs/nitro/daprovider"
58-
"github.com/offchainlabs/nitro/daprovider/daclient"
5958
"github.com/offchainlabs/nitro/daprovider/das"
6059
"github.com/offchainlabs/nitro/execution/gethexec"
6160
_ "github.com/offchainlabs/nitro/execution/nodeInterface"
@@ -926,10 +925,6 @@ func ParseNode(ctx context.Context, args []string) (*NodeConfig, *genericconf.Wa
926925
return nil, nil, err
927926
}
928927

929-
if err = daclient.FixExternalProvidersCLIParsing("node.da.external-providers", k); err != nil {
930-
return nil, nil, err
931-
}
932-
933928
var nodeConfig NodeConfig
934929
if err := confighelpers.EndCommonParse(k, &nodeConfig); err != nil {
935930
return nil, nil, err

daprovider/config/config.go

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
package config
55

66
import (
7-
"fmt"
8-
97
"github.com/spf13/pflag"
108

119
"github.com/offchainlabs/nitro/daprovider/daclient"
@@ -14,32 +12,17 @@ import (
1412
// DAConfig contains configuration for all DA providers
1513
// TODO move "DAS" configuration here and rename to Anytrust
1614
type DAConfig struct {
17-
ExternalProvider daclient.ClientConfig `koanf:"external-provider" reload:"hot"`
18-
ExternalProviders daclient.ExternalProviderConfigList `koanf:"external-providers" reload:"hot"`
15+
ExternalProvider daclient.ClientConfig `koanf:"external-provider" reload:"hot"`
1916
}
2017

2118
var DefaultDAConfig = DAConfig{
22-
ExternalProvider: daclient.DefaultClientConfig,
23-
ExternalProviders: nil,
19+
ExternalProvider: daclient.DefaultClientConfig,
2420
}
2521

2622
func DAConfigAddOptions(prefix string, f *pflag.FlagSet) {
2723
daclient.ClientConfigAddOptions(prefix+".external-provider", f)
28-
daclient.ExternalProviderConfigAddPluralOptions(prefix+".external-provider", f)
2924
}
3025

3126
func (c *DAConfig) Validate() error {
32-
if len(c.ExternalProviders) > 0 && c.ExternalProvider.RPC.URL != "" {
33-
return fmt.Errorf("cannot specify both external-provider and external-providers; use only external-providers for multiple providers")
34-
}
35-
if len(c.ExternalProviders) == 0 {
36-
c.ExternalProviders = daclient.ExternalProviderConfigList{c.ExternalProvider}
37-
}
38-
39-
for i := range c.ExternalProviders {
40-
if err := c.ExternalProviders[i].RPC.Validate(); err != nil {
41-
return fmt.Errorf("failed to validate external-providers[%d].rpc: %w", i, err)
42-
}
43-
}
44-
return nil
27+
return c.ExternalProvider.RPC.Validate()
4528
}

daprovider/daclient/daclient.go

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ package daclient
55

66
import (
77
"context"
8-
"encoding/json"
98
"fmt"
109
"strings"
1110

12-
"github.com/knadh/koanf"
13-
"github.com/knadh/koanf/providers/confmap"
1411
"github.com/spf13/pflag"
1512

1613
"github.com/ethereum/go-ethereum/common"
@@ -73,32 +70,6 @@ var DefaultStreamRpcMethods = data_streaming.DataStreamingRPCMethods{
7370

7471
var DefaultStoreRpcMethod = "daprovider_store"
7572

76-
type ExternalProviderConfigList []ClientConfig
77-
78-
func (l *ExternalProviderConfigList) String() string {
79-
b, _ := json.Marshal(*l)
80-
return string(b)
81-
}
82-
83-
func (l *ExternalProviderConfigList) Set(value string) error {
84-
return l.UnmarshalJSON([]byte(value))
85-
}
86-
87-
func (l *ExternalProviderConfigList) UnmarshalJSON(data []byte) error {
88-
var tmp []ClientConfig
89-
if err := json.Unmarshal(data, &tmp); err != nil {
90-
return err
91-
}
92-
*l = tmp
93-
return nil
94-
}
95-
96-
func (l *ExternalProviderConfigList) Type() string {
97-
return "externalProviderConfigList"
98-
}
99-
100-
var parsedExternalProvidersConf ExternalProviderConfigList
101-
10273
func ClientConfigAddOptions(prefix string, f *pflag.FlagSet) {
10374
f.Bool(prefix+".enable", DefaultClientConfig.Enable, "enable daprovider client")
10475
f.Bool(prefix+".with-writer", DefaultClientConfig.WithWriter, "implies if the daprovider rpc server supports writer interface")
@@ -108,32 +79,6 @@ func ClientConfigAddOptions(prefix string, f *pflag.FlagSet) {
10879
f.String(prefix+".store-rpc-method", DefaultClientConfig.StoreRpcMethod, "name of the store rpc method on the daprovider server (used when data streaming is disabled)")
10980
}
11081

111-
func ExternalProviderConfigAddPluralOptions(prefix string, f *pflag.FlagSet) {
112-
f.Var(&parsedExternalProvidersConf, prefix+"s", "JSON array of external DA provider configurations. This can be specified on the command line as a JSON array, eg: [{\"rpc\":{\"url\":\"...\"},\"with-writer\":true},...], or as a JSON array in the config file.")
113-
}
114-
115-
func FixExternalProvidersCLIParsing(path string, k *koanf.Koanf) error {
116-
// Reset global variable at start to avoid test pollution
117-
parsedExternalProvidersConf = nil
118-
119-
rawProviders := k.Get(path)
120-
if providers, ok := rawProviders.(string); ok {
121-
err := parsedExternalProvidersConf.UnmarshalJSON([]byte(providers))
122-
if err != nil {
123-
return err
124-
}
125-
126-
tempMap := map[string]interface{}{
127-
path: parsedExternalProvidersConf,
128-
}
129-
130-
if err = k.Load(confmap.Provider(tempMap, "."), nil); err != nil {
131-
return err
132-
}
133-
}
134-
return nil
135-
}
136-
13782
func NewClient(ctx context.Context, config *ClientConfig, payloadSigner *data_streaming.PayloadSigner) (*Client, error) {
13883
rpcClient := rpcclient.NewRpcClient(func() *rpcclient.ClientConfig { return &config.RPC }, nil)
13984
var err error

0 commit comments

Comments
 (0)