Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move permanent flags to config file #1609

Merged
merged 8 commits into from
Feb 27, 2024

Conversation

sgillespie
Copy link
Contributor

@sgillespie sgillespie commented Jan 19, 2024

Description

Fixes #1576. Move configuration flags that can't be changed (disable-ledger, prune-tx-out, disable-shelley, and so on) and add them to the main configuration file.

Checklist

  • Commit sequence broadly makes sense
  • Commits have useful messages
  • New tests are added if needed and existing tests are updated
  • Any changes are noted in the changelog
  • Code is formatted with fourmolu on version 0.10.1.0 (which can be run with scripts/fourmolize.sh)
  • Self-reviewed the diff

Migrations

  • The pr causes a breaking change of type a,b or c
  • If there is a breaking change, the pr includes a database migration and/or a fix process for old values, so that upgrade is possible
  • Resyncing and running the migrations provided will result in the same database semantically

If there is a breaking change, especially a big one, please add a justification here. Please elaborate
more what the migration achieves, what it cannot achieve or why a migration is not possible.

@sgillespie sgillespie force-pushed the feature/flags->config branch 2 times, most recently from 77a4d86 to 57dd896 Compare January 26, 2024 17:35
@sgillespie sgillespie force-pushed the feature/flags->config branch 8 times, most recently from 52ee6bb to 5bfab2e Compare February 14, 2024 21:40
"insert_options": {
"tx_out": "bootstrap"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsure if you are already doing this but could these not be a single file with updated value, here is a simple example:

where
-- an example of how we will pass our custom configs overwriting the init file
mkSynNodeConfig :: IO SyncNodeConfig
mkSynNodeConfig = do
initConfigFile <- mkSyncNodeConfig conwayConfigDir
pure $ initConfigFile {dncEnableLogging = True}

but for this scenarios it would be:

  where
    mkSynNodeConfig :: IO SyncNodeConfig
    mkSynNodeConfig = do
      -- have 1 init file that is read and parsed
      initConfigFile <- mkSyncNodeConfig conwayConfigDir
      -- update the results with required values for the specific test in above tests 
      -- it's "tx_out": "bootstrap" so that is reflected as so
      pure $ 
        initConfigFile 
          { dncInsertConfig = initInsertConfig { spcTxOut = TxOutBootstrap } }

-- have an init for specific set of tests or all tests if required 
initInsertConfig :: SyncInsertConfig
initInsertConfig = 
  SyncInsertConfig
    { spcTxOut = TxOutEnable
    , spcLedger = LedgerEnable
    , spcShelley = ShelleyDisable
    ...
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've written a couple new tests in this style, but the majority I've kept unchanged

cardano-db-sync/src/Cardano/DbSync/Api.hs Show resolved Hide resolved
Disables fetching pool offchain metadata.
**Only UTxO**

This is the equivalent of using `--dont-use-ledger` `--disable-shelley`,
Copy link
Contributor

@Cmdv Cmdv Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to mention that this refers to command line flags we previously had.

This equates to the following deprecated flags: --dont-use-ledger --disable-shelley...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the docs should basically be finished now.

@sgillespie sgillespie force-pushed the feature/flags->config branch 13 times, most recently from 4ea34de to 1c5b202 Compare February 22, 2024 21:46
@sgillespie sgillespie force-pushed the feature/flags->config branch 4 times, most recently from d1c61df to 49a5723 Compare February 23, 2024 19:34
@sgillespie sgillespie force-pushed the feature/flags->config branch from 49a5723 to 722d5a8 Compare February 23, 2024 19:37
@sgillespie sgillespie marked this pull request as ready for review February 23, 2024 20:22
@kderme
Copy link
Contributor

kderme commented Feb 24, 2024

I had this error, which I think used to be a warning

cardano-db-sync -- --config ../cardano-configs/sanchonet/db-sync-config-new.json --socket-path ../db-paths/sancho.socket --state-dir ../ledger-state/sancho-4-0-0-config --schema-dir schema 
cardano-db-sync: Error: If not using --state-dir then make sure to have ledger disabled. For more details view https://github.com/IntersectMBO/cardano-db-sync/blob/master/doc/syncing-and-rollbacks.md#ledger-state

This seems to hapen with "ledger" : "disable" or with some preset values.

, enpSnEveryFollowing :: !Word64
, enpSnEveryLagging :: !Word64
, enpMaybeRollback :: !(Maybe SlotNo)
, enpForceTxIn :: !Bool -- TODO[sgillespie]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be removed, since it's moved to TxOutConfig

Just "disable_all" -> pure DisableAllInsertOptions
Just other -> fail $ "unexpected preset: " <> show other

instance ToJSON SyncInsertConfig where
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these ToJSON necessary or used anywhere?

Copy link
Contributor Author

@sgillespie sgillespie Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These ToJSON instances are used in Hedgehog roundtrip tests

disableAllInsertOptions =
SyncInsertOptions
{ sioTxOut = TxOutDisable
, sioLedger = LedgerDisable
Copy link
Contributor

@kderme kderme Feb 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For onlyGovInsertOptions the ledger should be enabled by default.
Ideally the ledger should remain an option even with preset insert configuration. For this pr it would be enough to change the only gov to have LedgerEnable.


void $ case (maybeLedgerStateDir, ledgerCfg) of
-- It's an error to disable ledger and specify the state dir
(Just _, LedgerDisable) -> error stateDirErrorMsg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this case should just give a warning

Update docs to use the config file, rather than CLI args.
 * Validate state-dir/ledger config
 * Lookup in/out from config
 * Disable rewards in some presets
@sgillespie sgillespie force-pushed the feature/flags->config branch from 8cafde8 to 9bc14a3 Compare February 26, 2024 15:46
Copy link
Contributor

@kderme kderme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@kderme kderme merged commit 59f8eed into IntersectMBO:master Feb 27, 2024
7 of 10 checks passed
@sgillespie sgillespie deleted the feature/flags->config branch February 27, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move flags to config file
3 participants