From 5b2c4e88b2324b07e86d12d9b6cf4e15457313a5 Mon Sep 17 00:00:00 2001 From: Ethen Date: Wed, 4 Dec 2024 04:49:30 +0700 Subject: [PATCH] fix: Disable `SERVICE_MANAGER_ADDR` & `ETH_RPC` as mandatory (#205) * fix: Disable svc manager address & eth rpc as mandatory * fix: Disable svc manager address & eth rpc as mandatory - add eigenda client override when memstore enabled * chore(simple_client): Add explicit ServiceUnavailable error type - address PR comment and add unit test * chore(simple_client): Add explicit ServiceUnavailable error type - address PR comment --- client/simple.go | 2 +- flags/eigendaflags/cli.go | 4 ++-- server/config.go | 16 ++++++++++++++++ server/config_test.go | 23 +++++++++++++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/client/simple.go b/client/simple.go index 88797431..4f381bfc 100644 --- a/client/simple.go +++ b/client/simple.go @@ -20,7 +20,7 @@ type Config struct { // SimpleCommitmentClient implements a simple client for the eigenda-proxy // that can put/get simple commitment data and query the health endpoint. -// It is meant to be used by arbitrum nitro integrations. +// Currently it is meant to be used by Arbitrum nitro integrations but can be extended to others in the future. // Optimism has its own client: https://github.com/ethereum-optimism/optimism/blob/develop/op-alt-da/daclient.go // so clients wanting to send op commitment mode data should use that client. type SimpleCommitmentClient struct { diff --git a/flags/eigendaflags/cli.go b/flags/eigendaflags/cli.go index f186834c..060f555a 100644 --- a/flags/eigendaflags/cli.go +++ b/flags/eigendaflags/cli.go @@ -144,14 +144,14 @@ func CLIFlags(envPrefix, category string) []cli.Flag { Usage: "URL of the Ethereum RPC endpoint. Needed to confirm blobs landed onchain.", EnvVars: []string{withEnvPrefix(envPrefix, "ETH_RPC")}, Category: category, - Required: true, + Required: false, }, &cli.StringFlag{ Name: SvcManagerAddrFlagName, Usage: "Address of the EigenDAServiceManager contract. Required to confirm blobs landed onchain. See https://github.com/Layr-Labs/eigenlayer-middleware/?tab=readme-ov-file#current-mainnet-deployment", EnvVars: []string{withEnvPrefix(envPrefix, "SERVICE_MANAGER_ADDR")}, Category: category, - Required: true, + Required: false, }, // Flags that are proxy specific, and not used by the eigenda-client // TODO: should we move this to a more specific category, like EIGENDA_STORE? diff --git a/server/config.go b/server/config.go index 75a9866c..7ed2e93b 100644 --- a/server/config.go +++ b/server/config.go @@ -45,6 +45,22 @@ func (cfg *Config) Check() error { } } + // provide dummy values to eigenda client config. Since the client won't be called in this + // mode it doesn't matter. + if cfg.MemstoreEnabled { + cfg.EdaClientConfig.SvcManagerAddr = "0x0000000000000000000000000000000000000000" + cfg.EdaClientConfig.EthRpcUrl = "http://0.0.0.0:666" + } + + if !cfg.MemstoreEnabled { + if cfg.EdaClientConfig.SvcManagerAddr == "" { + return fmt.Errorf("service manager address is required for communication with EigenDA") + } + if cfg.EdaClientConfig.EthRpcUrl == "" { + return fmt.Errorf("eth prc url is required for communication with EigenDA") + } + } + // cert verification is enabled // TODO: move this verification logic to verify/cli.go if cfg.VerifierConfig.VerifyCerts { diff --git a/server/config_test.go b/server/config_test.go index 64bde141..45541ed7 100644 --- a/server/config_test.go +++ b/server/config_test.go @@ -89,6 +89,29 @@ func TestConfigVerification(t *testing.T) { err := cfg.Check() require.Error(t, err) }) + + t.Run("EigenDAClientFieldsAreDefaultSetWhenMemStoreEnabled", func(t *testing.T) { + cfg := validCfg() + cfg.MemstoreEnabled = true + cfg.VerifierConfig.VerifyCerts = false + cfg.VerifierConfig.RPCURL = "" + cfg.VerifierConfig.SvcManagerAddr = "" + + err := cfg.Check() + require.NoError(t, err) + require.True(t, len(cfg.EdaClientConfig.EthRpcUrl) > 1) + require.True(t, len(cfg.EdaClientConfig.SvcManagerAddr) > 1) + }) + + t.Run("FailWhenEigenDAClientFieldsAreUnsetAndMemStoreDisabled", func(t *testing.T) { + cfg := validCfg() + cfg.MemstoreEnabled = false + cfg.VerifierConfig.RPCURL = "" + cfg.VerifierConfig.SvcManagerAddr = "" + + err := cfg.Check() + require.Error(t, err) + }) }) }