Skip to content

Commit

Permalink
fix: Disable SERVICE_MANAGER_ADDR & ETH_RPC as mandatory (#205)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
epociask authored Dec 3, 2024
1 parent 64cac16 commit 5b2c4e8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions flags/eigendaflags/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
16 changes: 16 additions & 0 deletions server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
23 changes: 23 additions & 0 deletions server/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})

}

0 comments on commit 5b2c4e8

Please sign in to comment.