Skip to content

Commit

Permalink
stellar#4538: enabled captive core full config option from reingest c…
Browse files Browse the repository at this point in the history
…md flag parsing as it's needed now since captive core does run mode
  • Loading branch information
sreuland committed Aug 28, 2024
1 parent 3d23723 commit d58b15a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
14 changes: 7 additions & 7 deletions ingest/ledgerbackend/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions services/horizon/cmd/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions services/horizon/cmd/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion services/horizon/cmd/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion services/horizon/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit d58b15a

Please sign in to comment.