diff --git a/cmd/root.go b/cmd/root.go index c04053b..3871ac8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -43,6 +43,7 @@ func init() { rootCmd.PersistentFlags().String("rewards-coordinator-address", "0x56c119bD92Af45eb74443ab14D4e93B7f5C67896", "Ethereum address of the rewards coordinator contract") rootCmd.PersistentFlags().String("proof-store-base-url", "", "HTTP base url where data is stored") rootCmd.PersistentFlags().String("sidecar-rpc-url", "", "Sidecar RPC URL") + rootCmd.PersistentFlags().Bool("sidecar-insecure-rpc", false, "Use insecure gRPC connection to sidecar") rootCmd.PersistentFlags().Bool("pushgateway-enabled", false, "Enable/disable pushgateway metrics collection") rootCmd.PersistentFlags().String("pushgateway-url", "", "URL to use for Pushgateway. This option is ignored if pushgateway-enable is not set.") diff --git a/cmd/updater.go b/cmd/updater.go index c510b12..6514ae5 100644 --- a/cmd/updater.go +++ b/cmd/updater.go @@ -37,7 +37,7 @@ func runUpdater(ctx context.Context, cfg *config.UpdaterConfig, logger *zap.Logg return err } - sidecarClient, err := sidecar.NewSidecarClient(cfg.SidecarRpcUrl) + sidecarClient, err := sidecar.NewSidecarClient(cfg.SidecarRpcUrl, cfg.SidecarInsecureRpc) if err != nil { logger.Sugar().Errorf("Failed to create sidecar client", zap.Error(err)) return err diff --git a/pkg/config/config.go b/pkg/config/config.go index 2dc4ea8..3b0e755 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -33,8 +33,8 @@ type UpdaterConfig struct { RPCUrl string `mapstructure:"rpc_url"` PrivateKey string `mapstructure:"private_key"` RewardsCoordinatorAddress string `mapstructure:"rewards_coordinator_address"` - ProofStoreBaseUrl string `mapstructure:"proof_store_base_url"` SidecarRpcUrl string `mapstructure:"sidecar_rpc_url"` + SidecarInsecureRpc bool `mapstructure:"sidecar_insecure_rpc"` } type DistributionConfig struct { @@ -138,6 +138,7 @@ func NewUpdaterConfig() *UpdaterConfig { PrivateKey: viper.GetString("private_key"), RewardsCoordinatorAddress: viper.GetString("rewards_coordinator_address"), SidecarRpcUrl: viper.GetString("sidecar_rpc_url"), + SidecarInsecureRpc: viper.GetBool("sidecar_insecure_rpc"), } return updaterConfig } diff --git a/pkg/sidecar/client.go b/pkg/sidecar/client.go index 475e63f..1e50d1a 100644 --- a/pkg/sidecar/client.go +++ b/pkg/sidecar/client.go @@ -19,9 +19,9 @@ type SidecarClient struct { Rewards IRewardsClient } -func NewSidecarClient(url string) (*SidecarClient, error) { +func NewSidecarClient(url string, insecureConn bool) (*SidecarClient, error) { var creds grpc.DialOption - if strings.Contains(url, "localhost:") || strings.Contains(url, "127.0.0.1:") { + if strings.Contains(url, "localhost:") || strings.Contains(url, "127.0.0.1:") || insecureConn { creds = grpc.WithTransportCredentials(insecure.NewCredentials()) } else { creds = grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{InsecureSkipVerify: false}))