From d01e38dfd8333644b6345a37bbf237789a4a7ffb Mon Sep 17 00:00:00 2001 From: Urvi Date: Wed, 12 Jun 2024 11:03:55 -0700 Subject: [PATCH] Add validation for DEPRECATED_SQL_LEDGER_STATE parameter --- ingest/ledgerbackend/configs/captive-core-pubnet.cfg | 2 -- ingest/ledgerbackend/configs/captive-core-testnet.cfg | 2 -- .../sample-appendix-deprecated_sql_ledger_state.cfg | 11 +++++++++++ ingest/ledgerbackend/toml.go | 4 ++++ ingest/ledgerbackend/toml_test.go | 7 +++++++ 5 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 ingest/ledgerbackend/testdata/sample-appendix-deprecated_sql_ledger_state.cfg diff --git a/ingest/ledgerbackend/configs/captive-core-pubnet.cfg b/ingest/ledgerbackend/configs/captive-core-pubnet.cfg index 6d23046f56..5af59efaf9 100644 --- a/ingest/ledgerbackend/configs/captive-core-pubnet.cfg +++ b/ingest/ledgerbackend/configs/captive-core-pubnet.cfg @@ -5,8 +5,6 @@ FAILURE_SAFETY=1 HTTP_PORT=11626 PEER_PORT=11725 -EXPERIMENTAL_BUCKETLIST_DB=true - [[HOME_DOMAINS]] HOME_DOMAIN="publicnode.org" QUALITY="HIGH" diff --git a/ingest/ledgerbackend/configs/captive-core-testnet.cfg b/ingest/ledgerbackend/configs/captive-core-testnet.cfg index 3f0dec5095..9abeecc8f5 100644 --- a/ingest/ledgerbackend/configs/captive-core-testnet.cfg +++ b/ingest/ledgerbackend/configs/captive-core-testnet.cfg @@ -2,8 +2,6 @@ NETWORK_PASSPHRASE="Test SDF Network ; September 2015" UNSAFE_QUORUM=true FAILURE_SAFETY=1 -EXPERIMENTAL_BUCKETLIST_DB=true - [[HOME_DOMAINS]] HOME_DOMAIN="testnet.stellar.org" QUALITY="HIGH" diff --git a/ingest/ledgerbackend/testdata/sample-appendix-deprecated_sql_ledger_state.cfg b/ingest/ledgerbackend/testdata/sample-appendix-deprecated_sql_ledger_state.cfg new file mode 100644 index 0000000000..3ca36b223b --- /dev/null +++ b/ingest/ledgerbackend/testdata/sample-appendix-deprecated_sql_ledger_state.cfg @@ -0,0 +1,11 @@ +DEPRECATED_SQL_LEDGER_STATE = true + +[[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 e23a771748..e08d7d3cb6 100644 --- a/ingest/ledgerbackend/toml.go +++ b/ingest/ledgerbackend/toml.go @@ -641,6 +641,10 @@ func (c *CaptiveCoreToml) validate(params CaptiveCoreTomlParams) error { ) } + if def := c.tree.Has("DEPRECATED_SQL_LEDGER_STATE"); def && params.UseDB && *c.DeprecatedSqlLedgerState == true { + return fmt.Errorf("CAPTIVE_CORE_USE_DB parameter is set to true, indicating stellar-core on-disk mode, in which DEPRECATED_SQL_LEDGER_STATE must be set to false") + } + homeDomainSet := map[string]HomeDomain{} for _, hd := range c.HomeDomains { if _, ok := homeDomainSet[hd.HomeDomain]; ok { diff --git a/ingest/ledgerbackend/toml_test.go b/ingest/ledgerbackend/toml_test.go index 4fc61f1133..1c51068c44 100644 --- a/ingest/ledgerbackend/toml_test.go +++ b/ingest/ledgerbackend/toml_test.go @@ -203,6 +203,12 @@ func TestCaptiveCoreTomlValidation(t *testing.T) { appendPath: filepath.Join("testdata", "appendix-with-bucket-dir-path.cfg"), expectedError: "could not unmarshal captive core toml: setting BUCKET_DIR_PATH is disallowed for Captive Core, use CAPTIVE_CORE_STORAGE_PATH instead", }, + { + name: "invalid DEPRECATED_SQL_LEDGER_STATE", + appendPath: filepath.Join("testdata", "sample-appendix-deprecated_sql_ledger_state.cfg"), + expectedError: "invalid captive core toml: CAPTIVE_CORE_USE_DB parameter is set to true, indicating " + + "stellar-core on-disk mode, in which DEPRECATED_SQL_LEDGER_STATE must be set to false", + }, } { t.Run(testCase.name, func(t *testing.T) { params := CaptiveCoreTomlParams{ @@ -212,6 +218,7 @@ func TestCaptiveCoreTomlValidation(t *testing.T) { PeerPort: testCase.peerPort, LogPath: testCase.logPath, Strict: true, + UseDB: true, } _, err := NewCaptiveCoreTomlFromFile(testCase.appendPath, params) assert.EqualError(t, err, testCase.expectedError)