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

Subsystems configuration #277

Merged
merged 31 commits into from
Jul 18, 2022
Merged

Subsystems configuration #277

merged 31 commits into from
Jul 18, 2022

Conversation

stanislav-tkach
Copy link
Contributor

@stanislav-tkach stanislav-tkach commented Jul 5, 2022

The goals are the following:

  • Separate configuration parts that are relevant to some subsystem.
  • Load option from the config file with an ability to override them from the command line.
  • Give a possibility to change default values (constants).

p2p/src/config.rs Outdated Show resolved Hide resolved
p2p/src/config.rs Outdated Show resolved Hide resolved
@stanislav-tkach stanislav-tkach changed the title Raw prototype of subsystems configuration Subsystems configuration Jul 12, 2022
@stanislav-tkach
Copy link
Contributor Author

I'm still not sure about what approach would be better here: split the current ChainConfig structure or not, but here is the overview of the current state:

  • The node now takes two sub-commands: create-config and run.
  • Subsystems need both ChainConfig and a config specific to that subsystem for initialization.
  • The version becomes constant.

@stanislav-tkach stanislav-tkach marked this pull request as ready for review July 14, 2022 12:54
@stanislav-tkach
Copy link
Contributor Author

Finally ready to review!

Copy link
Contributor

@TheQuantumPhysicist TheQuantumPhysicist left a comment

Choose a reason for hiding this comment

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

The PR is OK. There are two things that I feel can be improved:

  1. There's no configuration reading for ChainConfig. There has to be a way to configure ChainConfig itself for functional tests. But this can be made in another PR.
  2. The initialization of the config can be improved. All these if lets are very ugly. One solution is to create a wrapper type with a generic trait for a NodeConfigEntry. Then you implement that for all types that can be taken from config (ints, strings, etc). Finally, you can make a method there to load values from Option<T> if a value exists. Maybe you can come up with something else that's simpler.

@stanislav-tkach
Copy link
Contributor Author

@TheQuantumPhysicist

  1. We have a separate test-node, so I see no issues in reading the chain configuration only in functional tests. And yes, I would prefer to do that in a separate pull request.
  2. Ideally it can be fixed in clap itself (Allow adding "external argv"s to be parsed alongside/before command line clap-rs/clap#748 and Layering env, args, and config clap-rs/clap#3113), but I don't expect that it will be done in the nearest future. I don't like if let boilerplate either mostly because it can easily lead to an error (reading a wrong value or forgetting to override one of the options). I'm going to think about a better solution.

Copy link
Contributor

@TheQuantumPhysicist TheQuantumPhysicist left a comment

Choose a reason for hiding this comment

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

I think this looks good now, besides the minor comments I mentioned.

Copy link
Contributor

@iljakuklic iljakuklic left a comment

Choose a reason for hiding this comment

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

Looks good. Rather unfortunate there are separate mechanisms for dealing with options coming from a config file and options coming from the command line with this manual translation, but given that, the solution presented here looks rather nice.

chainstate/src/config.rs Show resolved Hide resolved
chainstate/src/detail/block_index_history_iter.rs Outdated Show resolved Hide resolved
@stanislav-tkach stanislav-tkach merged commit 3b8c69d into master Jul 18, 2022
@stanislav-tkach stanislav-tkach deleted the subsystems-configuration branch July 18, 2022 11:01
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.

5 participants