diff --git a/ingest/ledgerbackend/testdata/expected-bucketlistdb-core.cfg b/ingest/ledgerbackend/testdata/expected-bucketlistdb-core.cfg new file mode 100644 index 0000000000..9040d6dc57 --- /dev/null +++ b/ingest/ledgerbackend/testdata/expected-bucketlistdb-core.cfg @@ -0,0 +1,22 @@ +# Generated file, do not edit +BUCKETLIST_DB_INDEX_CUTOFF = 20 +BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT = 15 +DATABASE = "sqlite3://stellar.db" +DEPRECATED_SQL_LEDGER_STATE = false +FAILURE_SAFETY = -1 +HTTP_PORT = 11626 +LOG_FILE_PATH = "" +NETWORK_PASSPHRASE = "Public Global Stellar Network ; September 2015" + +[[HOME_DOMAINS]] + HOME_DOMAIN = "testnet.stellar.org" + QUALITY = "MEDIUM" + +[[VALIDATORS]] + ADDRESS = "localhost:123" + HOME_DOMAIN = "testnet.stellar.org" + NAME = "sdf_testnet_1" + PUBLIC_KEY = "GDKXE2OZMJIPOSLNA6N6F2BVCI3O777I2OOC4BV7VOYUEHYX7RTRYA7Y" + +[HISTORY.h0] + get = "curl -sf http://localhost:1170/{0} -o {1}" diff --git a/ingest/ledgerbackend/testdata/expected-default-bucketlistdb-core.cfg b/ingest/ledgerbackend/testdata/expected-default-bucketlistdb-core.cfg new file mode 100644 index 0000000000..12fe5e36a5 --- /dev/null +++ b/ingest/ledgerbackend/testdata/expected-default-bucketlistdb-core.cfg @@ -0,0 +1,21 @@ +# Generated file, do not edit +BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT = 12 +DATABASE = "sqlite3://stellar.db" +DEPRECATED_SQL_LEDGER_STATE = false +FAILURE_SAFETY = -1 +HTTP_PORT = 11626 +LOG_FILE_PATH = "" +NETWORK_PASSPHRASE = "Public Global Stellar Network ; September 2015" + +[[HOME_DOMAINS]] + HOME_DOMAIN = "testnet.stellar.org" + QUALITY = "MEDIUM" + +[[VALIDATORS]] + ADDRESS = "localhost:123" + HOME_DOMAIN = "testnet.stellar.org" + NAME = "sdf_testnet_1" + PUBLIC_KEY = "GDKXE2OZMJIPOSLNA6N6F2BVCI3O777I2OOC4BV7VOYUEHYX7RTRYA7Y" + +[HISTORY.h0] + get = "curl -sf http://localhost:1170/{0} -o {1}" diff --git a/ingest/ledgerbackend/testdata/expected-in-mem-core.cfg b/ingest/ledgerbackend/testdata/expected-in-mem-core.cfg new file mode 100644 index 0000000000..965fa5aaa6 --- /dev/null +++ b/ingest/ledgerbackend/testdata/expected-in-mem-core.cfg @@ -0,0 +1,19 @@ +# Generated file, do not edit +DEPRECATED_SQL_LEDGER_STATE = true +FAILURE_SAFETY = -1 +HTTP_PORT = 11626 +LOG_FILE_PATH = "" +NETWORK_PASSPHRASE = "Public Global Stellar Network ; September 2015" + +[[HOME_DOMAINS]] + HOME_DOMAIN = "testnet.stellar.org" + QUALITY = "MEDIUM" + +[[VALIDATORS]] + ADDRESS = "localhost:123" + HOME_DOMAIN = "testnet.stellar.org" + NAME = "sdf_testnet_1" + PUBLIC_KEY = "GDKXE2OZMJIPOSLNA6N6F2BVCI3O777I2OOC4BV7VOYUEHYX7RTRYA7Y" + +[HISTORY.h0] + get = "curl -sf http://localhost:1170/{0} -o {1}" diff --git a/ingest/ledgerbackend/testdata/sample-appendix-bucketlistdb.cfg b/ingest/ledgerbackend/testdata/sample-appendix-bucketlistdb.cfg new file mode 100644 index 0000000000..e01a92cc61 --- /dev/null +++ b/ingest/ledgerbackend/testdata/sample-appendix-bucketlistdb.cfg @@ -0,0 +1,12 @@ +BUCKETLIST_DB_INDEX_CUTOFF = 20 +BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT = 15 + +[[HOME_DOMAINS]] +HOME_DOMAIN="testnet.stellar.org" +QUALITY="MEDIUM" + +[[VALIDATORS]] +NAME="sdf_testnet_1" +HOME_DOMAIN="testnet.stellar.org" +PUBLIC_KEY="GDKXE2OZMJIPOSLNA6N6F2BVCI3O777I2OOC4BV7VOYUEHYX7RTRYA7Y" +ADDRESS="localhost:123" diff --git a/ingest/ledgerbackend/toml.go b/ingest/ledgerbackend/toml.go index 22c3ea1608..84c5dbdb33 100644 --- a/ingest/ledgerbackend/toml.go +++ b/ingest/ledgerbackend/toml.go @@ -23,6 +23,8 @@ var ( //go:embed configs/captive-core-testnet.cfg TestnetDefaultConfig []byte + + DefaultBucketListDBPageSize uint = 12 ) const ( @@ -541,8 +543,7 @@ func (c *CaptiveCoreToml) setDefaults(params CaptiveCoreTomlParams) { c.DeprecatedSqlLedgerState = true } else { if !c.tree.Has("BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT") { - n := uint(12) - c.BucketListDBPageSizeExp = &n // Set default page size to 4KB + c.BucketListDBPageSizeExp = &DefaultBucketListDBPageSize } c.DeprecatedSqlLedgerState = false } diff --git a/ingest/ledgerbackend/toml_test.go b/ingest/ledgerbackend/toml_test.go index bd7c69e58f..5eceb27af8 100644 --- a/ingest/ledgerbackend/toml_test.go +++ b/ingest/ledgerbackend/toml_test.go @@ -212,13 +212,6 @@ func TestCaptiveCoreTomlValidation(t *testing.T) { PeerPort: testCase.peerPort, LogPath: testCase.logPath, Strict: true, - checkCoreVersion: func(coreBinaryPath string) coreVersion { - return coreVersion{ - major: 21, - minor: 0, - ledgerProtocolVersion: 21, - } - }, } _, err := NewCaptiveCoreTomlFromFile(testCase.appendPath, params) assert.EqualError(t, err, testCase.expectedError) @@ -359,6 +352,22 @@ func TestGenerateConfig(t *testing.T) { expectedPath: filepath.Join("testdata", "expected-online-with-appendix-minimum-persistent-entry.cfg"), logPath: nil, }, + { + name: "default BucketlistDB config", + mode: stellarCoreRunnerModeOnline, + appendPath: filepath.Join("testdata", "sample-appendix.cfg"), + expectedPath: filepath.Join("testdata", "expected-default-bucketlistdb-core.cfg"), + useDB: true, + logPath: nil, + }, + { + name: "BucketlistDB config in appendix", + mode: stellarCoreRunnerModeOnline, + appendPath: filepath.Join("testdata", "sample-appendix-bucketlistdb.cfg"), + expectedPath: filepath.Join("testdata", "expected-bucketlistdb-core.cfg"), + useDB: true, + logPath: nil, + }, } { t.Run(testCase.name, func(t *testing.T) { var err error @@ -399,6 +408,36 @@ func TestGenerateConfig(t *testing.T) { } } +func TestGenerateCoreConfigInMemory(t *testing.T) { + appendPath := filepath.Join("testdata", "sample-appendix.cfg") + expectedPath := filepath.Join("testdata", "expected-in-mem-core.cfg") + var err error + var captiveCoreToml *CaptiveCoreToml + params := CaptiveCoreTomlParams{ + NetworkPassphrase: "Public Global Stellar Network ; September 2015", + HistoryArchiveURLs: []string{"http://localhost:1170"}, + Strict: false, + UseDB: false, + checkCoreVersion: func(coreBinaryPath string) coreVersion { + return coreVersion{ + major: 21, + minor: 0, + ledgerProtocolVersion: 21, + } + }, + } + captiveCoreToml, err = NewCaptiveCoreTomlFromFile(appendPath, params) + assert.NoError(t, err) + + configBytes, err := generateConfig(captiveCoreToml, stellarCoreRunnerModeOnline) + assert.NoError(t, err) + + expectedByte, err := ioutil.ReadFile(expectedPath) + assert.NoError(t, err) + + assert.Equal(t, string(expectedByte), string(configBytes)) +} + func TestHistoryArchiveURLTrailingSlash(t *testing.T) { httpPort := uint(8000) peerPort := uint(8000) @@ -475,6 +514,9 @@ func TestDBConfigDefaultsToSqlite(t *testing.T) { toml := CaptiveCoreToml{} require.NoError(t, toml.unmarshal(configBytes, true)) assert.Equal(t, toml.Database, "sqlite3://stellar.db") + assert.Equal(t, toml.DeprecatedSqlLedgerState, false) + assert.Equal(t, *toml.BucketListDBPageSizeExp, DefaultBucketListDBPageSize) + assert.Equal(t, toml.BucketListDBCutoff, (*uint)(nil)) } func TestNonDBConfigDoesNotUpdateDatabase(t *testing.T) { diff --git a/services/horizon/docker/captive-core-integration-tests.soroban-rpc.cfg b/services/horizon/docker/captive-core-integration-tests.soroban-rpc.cfg index 9a7ad9d769..8d76504de2 100644 --- a/services/horizon/docker/captive-core-integration-tests.soroban-rpc.cfg +++ b/services/horizon/docker/captive-core-integration-tests.soroban-rpc.cfg @@ -1,3 +1,4 @@ +EXPERIMENTAL_BUCKETLIST_DB = true PEER_PORT=11725 ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING=true diff --git a/services/horizon/docker/stellar-core-classic-integration-tests.cfg b/services/horizon/docker/stellar-core-classic-integration-tests.cfg index e27cfe14ed..fe23e94e8d 100644 --- a/services/horizon/docker/stellar-core-classic-integration-tests.cfg +++ b/services/horizon/docker/stellar-core-classic-integration-tests.cfg @@ -1,3 +1,4 @@ +DEPRECATED_SQL_LEDGER_STATE=false ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING=true NETWORK_PASSPHRASE="Standalone Network ; February 2017" diff --git a/services/horizon/docker/stellar-core-integration-tests.cfg b/services/horizon/docker/stellar-core-integration-tests.cfg index 594a35b244..414ad9c1eb 100644 --- a/services/horizon/docker/stellar-core-integration-tests.cfg +++ b/services/horizon/docker/stellar-core-integration-tests.cfg @@ -1,3 +1,4 @@ +DEPRECATED_SQL_LEDGER_STATE=false ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING=true NETWORK_PASSPHRASE="Standalone Network ; February 2017"