From d58b15a1405920f3ca39dfc14fdd72bd1eb13cdd Mon Sep 17 00:00:00 2001 From: Shawn Reuland Date: Wed, 28 Aug 2024 15:47:57 -0700 Subject: [PATCH] #4538: enabled captive core full config option from reingest cmd flag parsing as it's needed now since captive core does run mode --- ingest/ledgerbackend/toml.go | 14 +++++++------- services/horizon/cmd/db.go | 4 ++-- services/horizon/cmd/db_test.go | 1 + services/horizon/cmd/ingest.go | 2 +- services/horizon/internal/flags.go | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ingest/ledgerbackend/toml.go b/ingest/ledgerbackend/toml.go index b64138e318..40328761de 100644 --- a/ingest/ledgerbackend/toml.go +++ b/ingest/ledgerbackend/toml.go @@ -421,27 +421,27 @@ func (c *CaptiveCoreToml) clone() (*CaptiveCoreToml, error) { // the run command on captive core with some defaults to ensure startup // and disabling optional services like the http port. func (c *CaptiveCoreToml) PassiveToml() (*CaptiveCoreToml, error) { - offline, err := c.clone() + passiveToml, err := c.clone() if err != nil { return nil, errors.Wrap(err, "could not clone toml") } - offline.UnsafeQuorum = true - offline.PublicHTTPPort = false - offline.HTTPPort = 0 - offline.FailureSafety = 0 + passiveToml.UnsafeQuorum = true + passiveToml.PublicHTTPPort = false + passiveToml.HTTPPort = 0 + passiveToml.FailureSafety = 0 if !c.QuorumSetIsConfigured() { // Add a fictional quorum -- necessary to convince core to start up; // but not used at all for our purposes. Pubkey here is just random. - offline.QuorumSetEntries = map[string]QuorumSet{ + passiveToml.QuorumSetEntries = map[string]QuorumSet{ "QUORUM_SET": { ThresholdPercent: 100, Validators: []string{"GCZBOIAY4HLKAJVNJORXZOZRAY2BJDBZHKPBHZCRAIUR5IHC2UHBGCQR"}, }, } } - return offline, nil + return passiveToml, nil } func (c *CaptiveCoreToml) setDefaults(params CaptiveCoreTomlParams) { diff --git a/services/horizon/cmd/db.go b/services/horizon/cmd/db.go index 92a732e002..b5ad89e809 100644 --- a/services/horizon/cmd/db.go +++ b/services/horizon/cmd/db.go @@ -481,7 +481,7 @@ func DefineDBCommands(rootCmd *cobra.Command, horizonConfig *horizon.Config, hor var err error var storageBackendConfig ingest.StorageBackendConfig - options := horizon.ApplyOptions{RequireCaptiveCoreFullConfig: false} + options := horizon.ApplyOptions{RequireCaptiveCoreFullConfig: true} if ledgerBackendType == ingest.BufferedStorageBackend { if storageBackendConfig, err = loadStorageBackendConfig(storageBackendConfigPath); err != nil { return err @@ -543,7 +543,7 @@ func DefineDBCommands(rootCmd *cobra.Command, horizonConfig *horizon.Config, hor var err error var storageBackendConfig ingest.StorageBackendConfig - options := horizon.ApplyOptions{RequireCaptiveCoreFullConfig: false} + options := horizon.ApplyOptions{RequireCaptiveCoreFullConfig: true} if ledgerBackendType == ingest.BufferedStorageBackend { if storageBackendConfig, err = loadStorageBackendConfig(storageBackendConfigPath); err != nil { return err diff --git a/services/horizon/cmd/db_test.go b/services/horizon/cmd/db_test.go index 6a00576bd3..dcf66a71fc 100644 --- a/services/horizon/cmd/db_test.go +++ b/services/horizon/cmd/db_test.go @@ -121,6 +121,7 @@ func (s *DBCommandsTestSuite) TestDbReingestAndFillGapsCmds() { "1", "100", "--network-passphrase", "passphrase", "--history-archive-urls", "[]", + "--captive-core-config-path", "core-test.cfg", }, expectError: false, }, diff --git a/services/horizon/cmd/ingest.go b/services/horizon/cmd/ingest.go index f6b94a8f52..02c08341e5 100644 --- a/services/horizon/cmd/ingest.go +++ b/services/horizon/cmd/ingest.go @@ -95,7 +95,7 @@ var ingestVerifyRangeCmd = &cobra.Command{ co.SetValue() } - if err := horizon.ApplyFlags(globalConfig, globalFlags, horizon.ApplyOptions{RequireCaptiveCoreFullConfig: false}); err != nil { + if err := horizon.ApplyFlags(globalConfig, globalFlags, horizon.ApplyOptions{RequireCaptiveCoreFullConfig: true}); err != nil { return err } diff --git a/services/horizon/internal/flags.go b/services/horizon/internal/flags.go index 38fca67576..12d21b452d 100644 --- a/services/horizon/internal/flags.go +++ b/services/horizon/internal/flags.go @@ -898,7 +898,7 @@ func setCaptiveCoreConfiguration(config *Config, options ApplyOptions) error { } } else if !options.RequireCaptiveCoreFullConfig { // Creates a minimal captive-core config (without quorum information), just enough to run captive core. - // This is used by certain database commands, such as `reingest and fill-gaps, to reingest historical data. + // This is used by certain commands that don't depend on captive core 'run' which does live network peer connection. config.CaptiveCoreToml, err = ledgerbackend.NewCaptiveCoreToml(config.CaptiveCoreTomlParams) if err != nil { return errors.Wrap(err, "invalid captive core toml file")