diff --git a/ingest/ledgerbackend/toml.go b/ingest/ledgerbackend/toml.go index a4f61a454d..b8b6634a78 100644 --- a/ingest/ledgerbackend/toml.go +++ b/ingest/ledgerbackend/toml.go @@ -5,9 +5,7 @@ import ( _ "embed" "fmt" "os" - "os/exec" "regexp" - "strconv" "strings" "github.com/stellar/go/support/errors" @@ -346,8 +344,6 @@ type CaptiveCoreTomlParams struct { EnforceSorobanDiagnosticEvents bool // Enfore EnableSorobanTransactionMetaExtV1 when not disabled explicitly EnforceSorobanTransactionMetaExtV1 bool - // used for testing - checkCoreVersion func(coreBinaryPath string) coreVersion } // NewCaptiveCoreTomlFromFile constructs a new CaptiveCoreToml instance by merging configuration @@ -445,104 +441,13 @@ func (c *CaptiveCoreToml) CatchupToml() (*CaptiveCoreToml, error) { return offline, nil } -// coreVersion helper struct identify a core version and provides the -// utilities to compare the version ( i.e. minor + major pair ) to a predefined -// version. -type coreVersion struct { - major int - minor int - ledgerProtocolVersion int -} - -// IsEqualOrAbove compares the core version to a version specific. If unable -// to make the decision, the result is always "false", leaning toward the -// common denominator. -func (c *coreVersion) IsEqualOrAbove(major, minor int) bool { - if c.major == 0 && c.minor == 0 { - return false - } - return (c.major == major && c.minor >= minor) || (c.major > major) -} - -// IsEqualOrAbove compares the core version to a version specific. If unable -// to make the decision, the result is always "false", leaning toward the -// common denominator. -func (c *coreVersion) IsProtocolVersionEqualOrAbove(protocolVer int) bool { - if c.ledgerProtocolVersion == 0 { - return false - } - return c.ledgerProtocolVersion >= protocolVer -} - -func checkCoreVersion(coreBinaryPath string) coreVersion { - if coreBinaryPath == "" { - return coreVersion{} - } - - versionBytes, err := exec.Command(coreBinaryPath, "version").Output() - if err != nil { - return coreVersion{} - } - - // starting soroban, we want to use only the first row for the version. - versionRows := strings.Split(string(versionBytes), "\n") - versionRaw := versionRows[0] - - var version [2]int - - re := regexp.MustCompile(`\D*(\d*)\.(\d*).*`) - versionStr := re.FindStringSubmatch(versionRaw) - if len(versionStr) == 3 { - for i := 1; i < len(versionStr); i++ { - val, err := strconv.Atoi((versionStr[i])) - if err != nil { - break - } - version[i-1] = val - } - } - - re = regexp.MustCompile(`^\s*ledger protocol version: (\d*)`) - var ledgerProtocol int - var ledgerProtocolStrings []string - for _, line := range versionRows { - ledgerProtocolStrings = re.FindStringSubmatch(line) - if len(ledgerProtocolStrings) > 0 { - break - } - } - if len(ledgerProtocolStrings) == 2 { - if val, err := strconv.Atoi(ledgerProtocolStrings[1]); err == nil { - ledgerProtocol = val - } - } - - return coreVersion{ - major: version[0], - minor: version[1], - ledgerProtocolVersion: ledgerProtocol, - } -} - -const MinimalBucketListDBCoreSupportVersionMajor = 19 -const MinimalBucketListDBCoreSupportVersionMinor = 6 -const MinimalSorobanProtocolSupport = 20 - func (c *CaptiveCoreToml) setDefaults(params CaptiveCoreTomlParams) { if params.UseDB && !c.tree.Has("DATABASE") { c.Database = "sqlite3://stellar.db" } - checkCoreVersionF := params.checkCoreVersion - if checkCoreVersionF == nil { - checkCoreVersionF = checkCoreVersion - } - currentCoreVersion := checkCoreVersionF(params.CoreBinaryPath) if def := c.tree.Has("EXPERIMENTAL_BUCKETLIST_DB"); !def && params.UseDB { - // Supports version 19.6 and above - if currentCoreVersion.IsEqualOrAbove(MinimalBucketListDBCoreSupportVersionMajor, MinimalBucketListDBCoreSupportVersionMinor) { - c.UseBucketListDB = true - } + c.UseBucketListDB = true } if c.UseBucketListDB && !c.tree.Has("EXPERIMENTAL_BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT") { @@ -584,14 +489,10 @@ func (c *CaptiveCoreToml) setDefaults(params CaptiveCoreTomlParams) { } if params.EnforceSorobanDiagnosticEvents { - if currentCoreVersion.IsEqualOrAbove(20, 0) { - enforceOption(&c.EnableSorobanDiagnosticEvents) - } - if currentCoreVersion.IsEqualOrAbove(20, 1) { - enforceOption(&c.EnableDiagnosticsForTxSubmission) - } + enforceOption(&c.EnableSorobanDiagnosticEvents) + enforceOption(&c.EnableDiagnosticsForTxSubmission) } - if params.EnforceSorobanTransactionMetaExtV1 && currentCoreVersion.IsEqualOrAbove(20, 4) { + if params.EnforceSorobanTransactionMetaExtV1 { enforceOption(&c.EnableEmitSorobanTransactionMetaExtV1) } } diff --git a/ingest/ledgerbackend/toml_test.go b/ingest/ledgerbackend/toml_test.go index fecf50c8d9..39b8473d4a 100644 --- a/ingest/ledgerbackend/toml_test.go +++ b/ingest/ledgerbackend/toml_test.go @@ -366,13 +366,6 @@ func TestGenerateConfig(t *testing.T) { UseDB: testCase.useDB, EnforceSorobanDiagnosticEvents: testCase.enforceSorobanDiagnosticEvents, EnforceSorobanTransactionMetaExtV1: testCase.enforceEmitMetaV1, - checkCoreVersion: func(coreBinaryPath string) coreVersion { - return coreVersion{ - major: 21, - minor: 0, - ledgerProtocolVersion: 21, - } - }, } if testCase.appendPath != "" { captiveCoreToml, err = NewCaptiveCoreTomlFromFile(testCase.appendPath, params) @@ -497,13 +490,3 @@ func TestNonDBConfigDoesNotUpdateDatabase(t *testing.T) { require.NoError(t, toml.unmarshal(configBytes, true)) assert.Equal(t, toml.Database, "") } - -func TestCheckCoreVersion(t *testing.T) { - coreBin := os.Getenv("HORIZON_INTEGRATION_TESTS_CAPTIVE_CORE_BIN") - if coreBin == "" { - t.SkipNow() - return - } - version := checkCoreVersion(coreBin) - require.True(t, version.IsEqualOrAbove(20, 0)) -} diff --git a/services/horizon/docker/captive-core-classic-integration-tests.cfg b/services/horizon/docker/captive-core-classic-integration-tests.cfg deleted file mode 100644 index 2f95a0ee54..0000000000 --- a/services/horizon/docker/captive-core-classic-integration-tests.cfg +++ /dev/null @@ -1,15 +0,0 @@ -PEER_PORT=11725 -ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING=true - -UNSAFE_QUORUM=true -FAILURE_SAFETY=0 - -EXPERIMENTAL_BUCKETLIST_DB=true - -[[VALIDATORS]] -NAME="local_core" -HOME_DOMAIN="core.local" -# From "SACJC372QBSSKJYTV5A7LWT4NXWHTQO6GHG4QDAVC2XDPX6CNNXFZ4JK" -PUBLIC_KEY="GD5KD2KEZJIGTC63IGW6UMUSMVUVG5IHG64HUTFWCHVZH2N2IBOQN7PS" -ADDRESS="localhost" -QUALITY="MEDIUM" diff --git a/services/horizon/docker/captive-core-reingest-range-classic-integration-tests.cfg b/services/horizon/docker/captive-core-reingest-range-classic-integration-tests.cfg deleted file mode 100644 index 735f58b739..0000000000 --- a/services/horizon/docker/captive-core-reingest-range-classic-integration-tests.cfg +++ /dev/null @@ -1,11 +0,0 @@ -ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING=true - -EXPERIMENTAL_BUCKETLIST_DB=true - -[[VALIDATORS]] -NAME="local_core" -HOME_DOMAIN="core.local" -# From "SACJC372QBSSKJYTV5A7LWT4NXWHTQO6GHG4QDAVC2XDPX6CNNXFZ4JK" -PUBLIC_KEY="GD5KD2KEZJIGTC63IGW6UMUSMVUVG5IHG64HUTFWCHVZH2N2IBOQN7PS" -ADDRESS="localhost" -QUALITY="MEDIUM" diff --git a/services/horizon/internal/flags_test.go b/services/horizon/internal/flags_test.go index 65d1da524c..76ec1ffd8d 100644 --- a/services/horizon/internal/flags_test.go +++ b/services/horizon/internal/flags_test.go @@ -307,7 +307,7 @@ func TestEnvironmentVariables(t *testing.T) { assert.Equal(t, config.AdminPort, uint(6060)) assert.Equal(t, config.Port, uint(8001)) assert.Equal(t, config.CaptiveCoreBinaryPath, os.Getenv("HORIZON_INTEGRATION_TESTS_CAPTIVE_CORE_BIN")) - assert.Equal(t, config.CaptiveCoreConfigPath, "../docker/captive-core-classic-integration-tests.cfg") + assert.Equal(t, config.CaptiveCoreConfigPath, "../docker/captive-core-integration-tests.cfg") assert.Equal(t, config.CaptiveCoreConfigUseDB, true) } @@ -324,7 +324,7 @@ func horizonEnvVars() map[string]string { "ADMIN_PORT": "6060", "PORT": "8001", "CAPTIVE_CORE_BINARY_PATH": os.Getenv("HORIZON_INTEGRATION_TESTS_CAPTIVE_CORE_BIN"), - "CAPTIVE_CORE_CONFIG_PATH": "../docker/captive-core-classic-integration-tests.cfg", + "CAPTIVE_CORE_CONFIG_PATH": "../docker/captive-core-integration-tests.cfg", "CAPTIVE_CORE_USE_DB": "true", } } diff --git a/services/horizon/internal/integration/db_test.go b/services/horizon/internal/integration/db_test.go index 98d584c8e6..331f99ee27 100644 --- a/services/horizon/internal/integration/db_test.go +++ b/services/horizon/internal/integration/db_test.go @@ -12,7 +12,6 @@ import ( "github.com/stellar/go/clients/horizonclient" "github.com/stellar/go/historyarchive" - "github.com/stellar/go/ingest/ledgerbackend" "github.com/stellar/go/keypair" hProtocol "github.com/stellar/go/protocols/horizon" horizoncmd "github.com/stellar/go/services/horizon/cmd" @@ -535,7 +534,7 @@ func TestReingestDB(t *testing.T) { horizonConfig.CaptiveCoreConfigPath = filepath.Join( filepath.Dir(horizonConfig.CaptiveCoreConfigPath), - getCoreConfigFile(itest), + "captive-core-reingest-range-integration-tests.cfg", ) horizoncmd.RootCmd.SetArgs(command(t, horizonConfig, "db", @@ -703,14 +702,6 @@ func TestReingestDBWithFilterRules(t *testing.T) { }, 30*time.Second, time.Second) } -func getCoreConfigFile(itest *integration.Test) string { - coreConfigFile := "captive-core-reingest-range-classic-integration-tests.cfg" - if itest.Config().ProtocolVersion >= ledgerbackend.MinimalSorobanProtocolSupport { - coreConfigFile = "captive-core-reingest-range-integration-tests.cfg" - } - return coreConfigFile -} - func command(t *testing.T, horizonConfig horizon.Config, args ...string) []string { return append([]string{ "--stellar-core-url", @@ -848,7 +839,7 @@ func TestFillGaps(t *testing.T) { horizonConfig.CaptiveCoreConfigPath = filepath.Join( filepath.Dir(horizonConfig.CaptiveCoreConfigPath), - getCoreConfigFile(itest), + "captive-core-reingest-range-integration-tests.cfg", ) horizoncmd.RootCmd.SetArgs(command(t, horizonConfig, "db", "fill-gaps", "--parallel-workers=1")) tt.NoError(horizoncmd.RootCmd.Execute()) diff --git a/services/horizon/internal/test/integration/integration.go b/services/horizon/internal/test/integration/integration.go index e12f77f693..0402301a44 100644 --- a/services/horizon/internal/test/integration/integration.go +++ b/services/horizon/internal/test/integration/integration.go @@ -26,7 +26,6 @@ import ( sdk "github.com/stellar/go/clients/horizonclient" "github.com/stellar/go/clients/stellarcore" - "github.com/stellar/go/ingest/ledgerbackend" "github.com/stellar/go/keypair" proto "github.com/stellar/go/protocols/horizon" horizon "github.com/stellar/go/services/horizon/internal" @@ -184,11 +183,7 @@ func NewTest(t *testing.T, config Config) *Test { func (i *Test) configureCaptiveCore() { composePath := findDockerComposePath() i.coreConfig.binaryPath = os.Getenv("HORIZON_INTEGRATION_TESTS_CAPTIVE_CORE_BIN") - coreConfigFile := "captive-core-classic-integration-tests.cfg" - if i.config.ProtocolVersion >= ledgerbackend.MinimalSorobanProtocolSupport { - coreConfigFile = "captive-core-integration-tests.cfg" - } - i.coreConfig.configPath = filepath.Join(composePath, coreConfigFile) + i.coreConfig.configPath = filepath.Join(composePath, "captive-core-integration-tests.cfg") i.coreConfig.storagePath = i.CurrentTest().TempDir() i.coreConfig.useDB = true @@ -254,13 +249,6 @@ func (i *Test) runComposeCommand(args ...string) { ) } - if i.config.ProtocolVersion < ledgerbackend.MinimalSorobanProtocolSupport { - cmd.Env = append( - cmd.Environ(), - "CORE_CONFIG_FILE=stellar-core-classic-integration-tests.cfg", - ) - } - i.t.Log("Running", cmd.Args) out, innerErr := cmd.Output() if len(out) > 0 {