diff --git a/cmd/geth/forgecmd.go b/cmd/geth/forgecmd.go index 962f09405..e195a71ec 100644 --- a/cmd/geth/forgecmd.go +++ b/cmd/geth/forgecmd.go @@ -36,9 +36,9 @@ var ( Name: "whitelist", Usage: `The whitelist external endpoints to call`, } - dnsRegistryForgeFlag = &cli.StringSliceFlag{ - Name: "dns-registry", - Usage: `The DNS registry to resolve aliases to endpoints`, + serviceAliasForgeFlag = &cli.StringSliceFlag{ + Name: "service-alias", + Usage: `The list of alias to endpoint mappings.`, } ethBackendForgeFlag = &cli.StringFlag{ Name: "eth-backend", @@ -51,9 +51,9 @@ var ( ) type suaveForgeConfig struct { - Whitelist []string `toml:"whitelist"` - DnsRegistry map[string]string `toml:"dns_registry"` - EthBackend string `toml:"eth_backend"` + Whitelist []string `toml:"whitelist"` + ServiceAlias map[string]string `toml:"service_alias"` + EthBackend string `toml:"eth_backend"` } func readContext(ctx *cli.Context) (*vm.SuaveContext, error) { @@ -95,18 +95,18 @@ func readContext(ctx *cli.Context) (*vm.SuaveContext, error) { if ctx.IsSet(whiteListForgeFlag.Name) { cfg.Whitelist = ctx.StringSlice(whiteListForgeFlag.Name) } - if ctx.IsSet(dnsRegistryForgeFlag.Name) { - dnsRegistry := make(map[string]string) - for _, endpoint := range ctx.StringSlice(dnsRegistryForgeFlag.Name) { + if ctx.IsSet(serviceAliasForgeFlag.Name) { + registry := make(map[string]string) + for _, endpoint := range ctx.StringSlice(serviceAliasForgeFlag.Name) { parts := strings.Split(endpoint, "=") if len(parts) != 2 { return nil, fmt.Errorf("invalid value for remote backend endpoint: %s", endpoint) } name := parts[0] domain := parts[1] - dnsRegistry[name] = domain + registry[name] = domain } - cfg.DnsRegistry = dnsRegistry + cfg.ServiceAlias = registry } // create the suave context @@ -130,7 +130,7 @@ func readContext(ctx *cli.Context) (*vm.SuaveContext, error) { backend := &vm.SuaveExecutionBackend{ ExternalWhitelist: cfg.Whitelist, ConfidentialEthBackend: suaveEthBackend, - DnsRegistry: cfg.DnsRegistry, + ServiceAliasRegistry: cfg.ServiceAlias, EthBlockSigningKey: blsKey, EthBundleSigningKey: ecdsaKey, } @@ -149,7 +149,7 @@ var ( Flags: []cli.Flag{ isLocalForgeFlag, whiteListForgeFlag, - dnsRegistryForgeFlag, + serviceAliasForgeFlag, ethBackendForgeFlag, tomlConfigForgeFlag, }, diff --git a/cmd/geth/forgecmd_test.go b/cmd/geth/forgecmd_test.go index ae16c1bd4..1c7986d43 100644 --- a/cmd/geth/forgecmd_test.go +++ b/cmd/geth/forgecmd_test.go @@ -48,20 +48,20 @@ func TestForgeReadConfig(t *testing.T) { sCtx, err = readContext(ctx) require.NoError(t, err) - require.Equal(t, sCtx.Backend.ExternalWhitelist, []string{"a", "b"}) - require.Equal(t, sCtx.Backend.DnsRegistry, map[string]string{"a": "b", "c": "d"}) - require.Equal(t, sCtx.Backend.ConfidentialEthBackend.(*suave_backends.RemoteEthBackend).Endpoint(), "suave") + require.Equal(t, []string{"a", "b"}, sCtx.Backend.ExternalWhitelist) + require.Equal(t, map[string]string{"a": "b", "c": "d"}, sCtx.Backend.ServiceAliasRegistry) + require.Equal(t, "suave", sCtx.Backend.ConfidentialEthBackend.(*suave_backends.RemoteEthBackend).Endpoint()) // override the config if the flags are set ctx.Set("eth-backend", "http://localhost:8545") ctx.Set("whitelist", "c,d") - ctx.Set("dns-registry", "e=f,g=h") + ctx.Set("service-alias", "e=f,g=h") sCtx, err = readContext(ctx) require.NoError(t, err) - require.Equal(t, sCtx.Backend.ExternalWhitelist, []string{"c", "d"}) - require.Equal(t, sCtx.Backend.DnsRegistry, map[string]string{"e": "f", "g": "h"}) - require.Equal(t, sCtx.Backend.ConfidentialEthBackend.(*suave_backends.RemoteEthBackend).Endpoint(), "http://localhost:8545") + require.Equal(t, []string{"c", "d"}, sCtx.Backend.ExternalWhitelist) + require.Equal(t, map[string]string{"e": "f", "g": "h"}, sCtx.Backend.ServiceAliasRegistry) + require.Equal(t, "http://localhost:8545", sCtx.Backend.ConfidentialEthBackend.(*suave_backends.RemoteEthBackend).Endpoint()) // set flags to null and use default values ctx = cli.NewContext(nil, flagSet(t, forgeCommand.Flags), nil) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 485e7fe31..93e9a6b0e 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -192,7 +192,7 @@ var ( suaveFlags = []cli.Flag{ utils.SuaveEthRemoteBackendEndpointFlag, - utils.SuaveDnsFlag, + utils.SuaveServiceAlias, utils.SuaveConfidentialTransportRedisEndpointFlag, utils.SuaveConfidentialStoreRedisEndpointFlag, utils.SuaveConfidentialStorePebbleDbPathFlag, diff --git a/cmd/geth/testdata/forge.toml b/cmd/geth/testdata/forge.toml index 2f5c03fae..113433f1d 100644 --- a/cmd/geth/testdata/forge.toml +++ b/cmd/geth/testdata/forge.toml @@ -1,6 +1,6 @@ [profile.suave] whitelist = ["a", "b"] -dns_registry = { a = "b", c = "d" } +service_alias = { a = "b", c = "d" } eth_backend = "suave" [profile.ci.fuzz] runs = 10_000 diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 1ab08383d..cd377db3d 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -530,8 +530,8 @@ var ( Category: flags.SuaveCategory, } - SuaveDnsFlag = &cli.StringSliceFlag{ - Name: "suave.dns", + SuaveServiceAlias = &cli.StringSliceFlag{ + Name: "suave.service-alias", Usage: "Suave domain name resolver settings. (format: alias=url)", Category: flags.SuaveCategory, } @@ -1730,18 +1730,18 @@ func SetSuaveConfig(ctx *cli.Context, stack *node.Node, cfg *suave.Config) { cfg.SuaveEthRemoteBackendEndpoint = ctx.String(SuaveEthRemoteBackendEndpointFlag.Name) } - if ctx.IsSet(SuaveDnsFlag.Name) { - dnsRegistry := make(map[string]string) - for _, endpoint := range ctx.StringSlice(SuaveDnsFlag.Name) { + if ctx.IsSet(SuaveServiceAlias.Name) { + registry := make(map[string]string) + for _, endpoint := range ctx.StringSlice(SuaveServiceAlias.Name) { parts := strings.Split(endpoint, "=") if len(parts) != 2 { Fatalf("invalid value for remote backend endpoint: %s", endpoint) } name := parts[0] domain := parts[1] - dnsRegistry[name] = domain + registry[name] = domain } - cfg.DnsRegistry = dnsRegistry + cfg.AliasRegistry = registry } if ctx.IsSet(SuaveConfidentialTransportRedisEndpointFlag.Name) { diff --git a/core/vm/contracts_suave.go b/core/vm/contracts_suave.go index fbbced3a2..12409fe6a 100644 --- a/core/vm/contracts_suave.go +++ b/core/vm/contracts_suave.go @@ -225,7 +225,7 @@ func (s *suaveRuntime) doHTTPRequest(request types.HttpRequest) ([]byte, error) var allowed bool // resolve dns if possible - if endpoint, ok := s.suaveContext.Backend.DnsRegistry[request.Url]; ok { + if endpoint, ok := s.suaveContext.Backend.ServiceAliasRegistry[request.Url]; ok { request.Url = endpoint } else { // decode the url and check if the domain is allowed diff --git a/core/vm/contracts_suave_test.go b/core/vm/contracts_suave_test.go index fb285995b..cc0c0d3fb 100644 --- a/core/vm/contracts_suave_test.go +++ b/core/vm/contracts_suave_test.go @@ -199,8 +199,8 @@ func TestSuave_HttpRequest_Basic(t *testing.T) { s := &suaveRuntime{ suaveContext: &SuaveContext{ Backend: &SuaveExecutionBackend{ - ExternalWhitelist: []string{"127.0.0.1"}, - DnsRegistry: map[string]string{"goerli": srv.URL}, + ExternalWhitelist: []string{"127.0.0.1"}, + ServiceAliasRegistry: map[string]string{"goerli": srv.URL}, }, }, } diff --git a/core/vm/suave.go b/core/vm/suave.go index ab7349bd8..044f1bdeb 100644 --- a/core/vm/suave.go +++ b/core/vm/suave.go @@ -36,7 +36,7 @@ type SuaveExecutionBackend struct { EthBundleSigningKey *ecdsa.PrivateKey EthBlockSigningKey *bls.SecretKey ExternalWhitelist []string - DnsRegistry map[string]string + ServiceAliasRegistry map[string]string ConfidentialStore ConfidentialStore ConfidentialEthBackend suave.ConfidentialEthBackend } diff --git a/eth/api_backend.go b/eth/api_backend.go index a1ed3c317..ddc278b1a 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -50,16 +50,16 @@ import ( // EthAPIBackend implements ethapi.Backend for full nodes type EthAPIBackend struct { - extRPCEnabled bool - allowUnprotectedTxs bool - eth *Ethereum - gpo *gasprice.Oracle - suaveEthBundleSigningKey *ecdsa.PrivateKey - suaveEthBlockSigningKey *bls.SecretKey - suaveEngine *cstore.CStoreEngine - suaveEthBackend suave.ConfidentialEthBackend - suaveExternalWhitelist []string - suaveDnsRegistry map[string]string + extRPCEnabled bool + allowUnprotectedTxs bool + eth *Ethereum + gpo *gasprice.Oracle + suaveEthBundleSigningKey *ecdsa.PrivateKey + suaveEthBlockSigningKey *bls.SecretKey + suaveEngine *cstore.CStoreEngine + suaveEthBackend suave.ConfidentialEthBackend + suaveExternalWhitelist []string + suaveServiceAliasRegistry map[string]string } // For testing purposes @@ -446,7 +446,7 @@ func (b *EthAPIBackend) SuaveContext(requestTx *types.Transaction, ccr *types.Co EthBundleSigningKey: b.suaveEthBundleSigningKey, EthBlockSigningKey: b.suaveEthBlockSigningKey, ExternalWhitelist: b.suaveExternalWhitelist, - DnsRegistry: b.suaveDnsRegistry, + ServiceAliasRegistry: b.suaveServiceAliasRegistry, ConfidentialStore: storeTransaction, ConfidentialEthBackend: b.suaveEthBackend, }, diff --git a/eth/backend.go b/eth/backend.go index 85a503592..d79c3f3a3 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -290,7 +290,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { confidentialStoreEngine := cstore.NewEngine(confidentialStoreBackend, confidentialStoreTransport, suaveDaSigner, types.LatestSigner(chainConfig)) eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil, - suaveEthBundleSigningKey, suaveEthBlockSigningKey, confidentialStoreEngine, suaveEthBackend, config.Suave.ExternalWhitelist, config.Suave.DnsRegistry} + suaveEthBundleSigningKey, suaveEthBlockSigningKey, confidentialStoreEngine, suaveEthBackend, config.Suave.ExternalWhitelist, config.Suave.AliasRegistry} if eth.APIBackend.allowUnprotectedTxs { log.Info("Unprotected transactions allowed") } diff --git a/suave/core/config.go b/suave/core/config.go index e68f3a4a3..34605ba2a 100644 --- a/suave/core/config.go +++ b/suave/core/config.go @@ -8,7 +8,7 @@ type Config struct { EthBundleSigningKeyHex string EthBlockSigningKeyHex string ExternalWhitelist []string - DnsRegistry map[string]string + AliasRegistry map[string]string } var DefaultConfig = Config{} diff --git a/suave/e2e/workflow_test.go b/suave/e2e/workflow_test.go index 7b2f218bc..633cb3efd 100644 --- a/suave/e2e/workflow_test.go +++ b/suave/e2e/workflow_test.go @@ -1490,7 +1490,7 @@ func WithWhitelist(whitelist []string) frameworkOpt { func WithDnsRegistry(registry map[string]string) frameworkOpt { return func(c *frameworkConfig) { - c.suaveConfig.DnsRegistry = registry + c.suaveConfig.AliasRegistry = registry } }