From c4f0baec52bb05222c8741481cfcd87c0497caed Mon Sep 17 00:00:00 2001 From: Urvi Date: Fri, 30 Jun 2023 00:13:45 -0700 Subject: [PATCH 1/3] services/horizon: Consolidate local captive core config steps in single 'if' --- services/horizon/internal/flags.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/services/horizon/internal/flags.go b/services/horizon/internal/flags.go index c2e6cbff4c..be08193c2c 100644 --- a/services/horizon/internal/flags.go +++ b/services/horizon/internal/flags.go @@ -650,18 +650,23 @@ func ApplyFlags(config *Config, flags support.ConfigOptions, options ApplyOption viper.Set(StellarCoreBinaryPathName, binaryPath) config.CaptiveCoreBinaryPath = binaryPath } + } else { + config.CaptiveCoreBinaryPath = binaryPath } + } + + // Create config for local captive core + if config.EnableCaptiveCoreIngestion && config.RemoteCaptiveCoreURL == "" { // NOTE: If both of these are set (regardless of user- or PATH-supplied // defaults for the binary path), the Remote Captive Core URL // takes precedence. - if binaryPath == "" && config.RemoteCaptiveCoreURL == "" { + if config.CaptiveCoreBinaryPath == "" { return fmt.Errorf("Invalid config: captive core requires that either --%s or --remote-captive-core-url is set. %s", StellarCoreBinaryPathName, captiveCoreMigrationHint) } - - config.CaptiveCoreTomlParams.CoreBinaryPath = binaryPath - if config.RemoteCaptiveCoreURL == "" && (binaryPath == "" || config.CaptiveCoreConfigPath == "") { + config.CaptiveCoreTomlParams.CoreBinaryPath = config.CaptiveCoreBinaryPath + if config.CaptiveCoreConfigPath == "" { if options.RequireCaptiveCoreConfig { var err error errorMessage := fmt.Errorf( @@ -707,7 +712,7 @@ func ApplyFlags(config *Config, flags support.ConfigOptions, options ApplyOption return fmt.Errorf("Invalid captive core toml file %v", err) } } - } else if config.RemoteCaptiveCoreURL == "" { + } else { var err error config.CaptiveCoreTomlParams.HistoryArchiveURLs = config.HistoryArchiveURLs config.CaptiveCoreTomlParams.NetworkPassphrase = config.NetworkPassphrase @@ -719,7 +724,7 @@ func ApplyFlags(config *Config, flags support.ConfigOptions, options ApplyOption // If we don't supply an explicit core URL and we are running a local // captive core process with the http port enabled, point to it. - if config.StellarCoreURL == "" && config.RemoteCaptiveCoreURL == "" && config.CaptiveCoreToml.HTTPPort != 0 { + if config.StellarCoreURL == "" && config.CaptiveCoreToml.HTTPPort != 0 { config.StellarCoreURL = fmt.Sprintf("http://localhost:%d", config.CaptiveCoreToml.HTTPPort) viper.Set(StellarCoreURLFlagName, config.StellarCoreURL) } From 8d46da563d581e4105a92a7dfbe192b646356168 Mon Sep 17 00:00:00 2001 From: Urvi Date: Mon, 3 Jul 2023 10:34:39 -0700 Subject: [PATCH 2/3] Remove --remote-captive-core-url flag --- services/horizon/internal/flags.go | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/services/horizon/internal/flags.go b/services/horizon/internal/flags.go index be08193c2c..64982e3068 100644 --- a/services/horizon/internal/flags.go +++ b/services/horizon/internal/flags.go @@ -126,17 +126,9 @@ func Flags() (*Config, support.ConfigOptions) { OptType: types.String, FlagDefault: "", Required: false, - Usage: "path to stellar core binary (--remote-captive-core-url has higher precedence). If captive core is enabled, look for the stellar-core binary in $PATH by default.", + Usage: "path to stellar core binary, look for the stellar-core binary in $PATH by default.", ConfigKey: &config.CaptiveCoreBinaryPath, }, - &support.ConfigOption{ - Name: "remote-captive-core-url", - OptType: types.String, - FlagDefault: "", - Required: false, - Usage: "url to access the remote captive core server", - ConfigKey: &config.RemoteCaptiveCoreURL, - }, &support.ConfigOption{ Name: captiveCoreConfigAppendPathName, OptType: types.String, @@ -649,29 +641,21 @@ func ApplyFlags(config *Config, flags support.ConfigOptions, options ApplyOption binaryPath = result viper.Set(StellarCoreBinaryPathName, binaryPath) config.CaptiveCoreBinaryPath = binaryPath + } else { + return fmt.Errorf("invalid config: captive core requires --%s. %s", + StellarCoreBinaryPathName, captiveCoreMigrationHint) } } else { config.CaptiveCoreBinaryPath = binaryPath } - } - // Create config for local captive core - if config.EnableCaptiveCoreIngestion && config.RemoteCaptiveCoreURL == "" { - - // NOTE: If both of these are set (regardless of user- or PATH-supplied - // defaults for the binary path), the Remote Captive Core URL - // takes precedence. - if config.CaptiveCoreBinaryPath == "" { - return fmt.Errorf("Invalid config: captive core requires that either --%s or --remote-captive-core-url is set. %s", - StellarCoreBinaryPathName, captiveCoreMigrationHint) - } config.CaptiveCoreTomlParams.CoreBinaryPath = config.CaptiveCoreBinaryPath if config.CaptiveCoreConfigPath == "" { if options.RequireCaptiveCoreConfig { var err error errorMessage := fmt.Errorf( - "Invalid config: captive core requires that both --%s and --%s are set. %s", - StellarCoreBinaryPathName, CaptiveCoreConfigPathName, captiveCoreMigrationHint, + "invalid config: captive core requires that --%s is set. %s", + CaptiveCoreConfigPathName, captiveCoreMigrationHint, ) var configFileName string From 8b18dcd969846f0bfe2b58b681fc5031c344abd4 Mon Sep 17 00:00:00 2001 From: Urvi Date: Wed, 5 Jul 2023 14:37:59 -0700 Subject: [PATCH 3/3] Updated CHANGELOG.md --- services/horizon/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/services/horizon/CHANGELOG.md b/services/horizon/CHANGELOG.md index bd535472b8..772fe42af0 100644 --- a/services/horizon/CHANGELOG.md +++ b/services/horizon/CHANGELOG.md @@ -6,6 +6,7 @@ file. This project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased +- The command line flag --remote-captive-core-url has been removed as remote captive core functionality is now deprecated ([4940](https://github.com/stellar/go/pull/4940)). ## 2.26.0 ### Changes