Skip to content

Commit

Permalink
Add validation for DEPRECATED_SQL_LEDGER_STATE parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
urvisavla committed Jun 12, 2024
1 parent 6ece57b commit d01e38d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 0 additions & 2 deletions ingest/ledgerbackend/configs/captive-core-pubnet.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions ingest/ledgerbackend/configs/captive-core-testnet.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 4 additions & 0 deletions ingest/ledgerbackend/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Check failure on line 644 in ingest/ledgerbackend/toml.go

View workflow job for this annotation

GitHub Actions / check (ubuntu-22.04, 1.22.1)

should omit comparison to bool constant, can be simplified to *c.DeprecatedSqlLedgerState (S1002)
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 {
Expand Down
7 changes: 7 additions & 0 deletions ingest/ledgerbackend/toml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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)
Expand Down

0 comments on commit d01e38d

Please sign in to comment.