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

feat : provider config file #320

Merged
merged 6 commits into from
Jan 14, 2025
Merged

feat : provider config file #320

merged 6 commits into from
Jan 14, 2025

Conversation

undercover-cactus
Copy link
Contributor

In this PR, we add the possibility to specify a provider config file by using the argument --provider-config-file=./config.toml.

Expected behaviors when a provider config file is specified :

  • we check that the config file exists if it doesn't we print a message and return None as provider options.
  • we try to pass the file as a Toml file and make sure we have the required values.
  • --provider-config-file agrument cannot be used with any others of the provider configurations argument. The CLI will throw an error. It will avoid any conflict between the parameters and make sure the provider configurations are explicit.

Error message example :

error: the argument '--provider-type <PROVIDER_TYPE>' cannot be used with '--provider-config-file <PROVIDER_CONFIG_FILE>'

Usage: storage-hub-node --provider-type <PROVIDER_TYPE> [-- <RELAY_CHAIN_ARGS>...]

For more information, try '--help'.

Error message example in case of missing parameters in config file :

Fail to parse config file : TOML parse error at line 13, column 1
   |
13 | [provider]
   | ^^^^^^^^^^
missing field `extrinsic_retry_timeout`

@undercover-cactus undercover-cactus requested review from ffarall and a team January 10, 2025 12:59
@ffarall ffarall marked this pull request as ready for review January 11, 2025 01:09
Copy link
Contributor

@ffarall ffarall left a comment

Choose a reason for hiding this comment

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

Great job! Approved with some comments, but I trust you'll take care of it.

.gitignore Outdated Show resolved Hide resolved
node/src/config.rs Outdated Show resolved Hide resolved

let config = match toml::from_str(&contents) {
Err(err) => {
println!("Fail to parse config file : {}", err);
Copy link
Contributor

Choose a reason for hiding this comment

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

Use log::error if possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also everywhere else in this file

node/src/cli.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@snowmead snowmead left a comment

Choose a reason for hiding this comment

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

lgtm mod @ffarall's comments

@undercover-cactus undercover-cactus merged commit d00d38d into main Jan 14, 2025
25 checks passed
@undercover-cactus undercover-cactus deleted the feat/config-file branch January 14, 2025 10:15
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.

3 participants