Skip to content

Conversation

AkioNak
Copy link
Contributor

@AkioNak AkioNak commented Dec 4, 2018

This PR intends to make it easy to understand how the configuration files are interpreted.

  1. Evaluate "includeconf" at the position described in the config file (like #include directive in C/C++), rather than at the end.

  2. If once a section is specified with square brackets like [main], the only way to configure another network is to use square brackets again, e.g. [test].

  3. In the "included" config file, the section is taken over from the "including" file. If no sections are specified yet, using square brackets or section prefix is still possible in the "included" file.

  4. Changing the section in the "included" config file does not affects the including file. The section of the including file is kept.

  5. If the "included" config file is included after the section has been specified by using square brackets or if they are included by using section prefix, any square brackets can not be used in that file.

ex) With Following 3 files, the properties are read as:

    port=8444, main.port=8445, test.port=8442, regtest.port: undefined

bitcoin.conf

test.includeconf=inc1.conf
includeconf=inc2.conf
port=8441   # ignored (2nd appearance of w/o section)

inc1.conf

 port=8442   # test
 [regtest]
 port=8443   # ignored

inc2.conf

 port=8444   # w/o section
 [main]
 port=8445   # main
 [regtest]

@promag
Copy link
Contributor

promag commented Dec 4, 2018

This can break existing configurations correct?

@AkioNak
Copy link
Contributor Author

AkioNak commented Dec 5, 2018

@promag Thanks for your comment.
Yes. Sometimes this may be different from previous results when interpreting existing configurations.
Especially the possibility of interpretation unmatch increases if using "includeconf" and sections are specified with square brackets in the "included" configuration file.
Is it necessary for this change to add a flag to specify how to read the configuration file?

if (key == "includeconf") {
if (depth < 0) {
continue;
} else if (depth < MAX_INCLUDECONF_DEPTH) {
Copy link
Contributor

@practicalswift practicalswift Dec 5, 2018

Choose a reason for hiding this comment

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

Nit: The else here is redundant due to the continue above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@practicalswift Thanks. Indeed!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@promag
Copy link
Contributor

promag commented Dec 5, 2018

You should not break existing configurations, especially if there is no strong reason to do it.

@AkioNak
Copy link
Contributor Author

AkioNak commented Dec 5, 2018

@promag My motivation of this PR is that I think it is very difficult to effectively use sections explicitly specified using prefix or use "includeconf".

For example, If using following 4 config file, bitcoind (build from master 86ff041) never read port.conf and user.conf. Furthermore, it warns these files as nested.
This cause is that the chain may be specipied in the course of processing the "includeconf"s collectively later.

bitcoin.conf 
----
includeconf=global.conf
regtest.includeconf=port.conf
[regtest]
includeconf=user.conf

global.conf 
----
regtest=1
daemon=1

port.conf 
----
[regtest]
rpcport=18443
port=18442

user.conf 
----
[regtest]
rpcuser=user
rpcpassword=pass
$ ./src/bitcoind --version | head -1
Bitcoin Core Daemon version v0.17.99.0-86ff0413b
$ ./src/bitcoind 
warning: -includeconf cannot be used from included files; ignoring -includeconf=port.conf
warning: -includeconf cannot be used from included files; ignoring -includeconf=user.conf
Bitcoin server starting

So I think evaluate "includeconf" step by step is better .

@bitcoin bitcoin deleted a comment from dougstrong77 Dec 6, 2018
@kallewoof
Copy link
Contributor

@promag The includeconf and sections features are both relatively recent. I think this is a bug-fix that should be back-ported, in fact, as the current behavior is completely nonsensical.

@laanwj
Copy link
Member

laanwj commented Dec 13, 2018

@promag The includeconf and sections features are both relatively recent

I think that's a good point, does this only affect use of -includeconf?

@kallewoof
Copy link
Contributor

@laanwj I believe so, yes, except for maybe the minor detail (item 4 in the OP list). @AkioNak?

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 13, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@AkioNak
Copy link
Contributor Author

AkioNak commented Jan 10, 2019

@kallewoof @laanwj I'm so sorry for my late reply.

I believe so, yes, except for maybe the minor detail (item 4 in the OP list).

I think so too.

@AkioNak AkioNak force-pushed the includeconf_eval_at_its_position branch from f63984b to 5c55f9a Compare January 10, 2019 08:42
@AkioNak
Copy link
Contributor Author

AkioNak commented Jan 11, 2019

Rebased but travis failed. Hmm,,, I will check what's going on.

@AkioNak
Copy link
Contributor Author

AkioNak commented Jan 15, 2019

The direct cause of failing travis was potential deadlock detection.
The investigation will continue ...

potential_deadlock_detected() reports following message:

POTENTIAL DEADLOCK DETECTED
Previous lock order was:
 (1) cs_args  util/system.cpp:921
 (2) csPathCached  util/system.cpp:790
Current lock order is:
 (2) csPathCached  util/system.cpp:790
 (1) cs_args  util/system.cpp:531

@AkioNak
Copy link
Contributor Author

AkioNak commented Jan 16, 2019

Addressed to the potential deadlock by narrowing the range of LOCK(cs_args).

@kallewoof
Copy link
Contributor

utACK cca8a9196f491aa8e99d18846578307cd7004c45

@AkioNak AkioNak force-pushed the includeconf_eval_at_its_position branch from cca8a91 to c858ddc Compare January 21, 2019 04:54
@AkioNak
Copy link
Contributor Author

AkioNak commented Jan 21, 2019

squashed and rebased.

@Sjors
Copy link
Member

Sjors commented Feb 21, 2019

Concept ACK, except I think the following example (from the description) should just fail:

[main]
includeconf=inc1.conf
test.includeconf=inc2.conf

Once a network is specified with square brackets like [main], the only way to configure another network should be to use square brackets again, e.g. [testsnet]. That rule should also apply to anything included by includeconf.

I'm also tempted to suggest a rule that square brackets may not exist in both bitcoin.conf and and includeconf files. Or, slightly less strict, that square brackets may not exist in includeconf files if they are included after a square bracket.

It's important to simplify this behavior sufficiently so we stand a chance of one day merging #11082 :-)

@AkioNak
Copy link
Contributor Author

AkioNak commented Feb 22, 2019

@Sjors Thank you for your surggestions.

Once a network is specified with square brackets like [main], the only way to configure another network should be to use square brackets again, e.g. [testsnet]. That rule should also apply to anything included by includeconf.

Good idea. I agree.

Or, slightly less strict, that square brackets may not exist in includeconf files if they are included after a square bracket.

I like this. And I think square brackets may not exist in the files that are included by using "section.includeconf" style, too.

@Sjors
Copy link
Member

Sjors commented Feb 22, 2019

Ok, looking forward to the new version. I think it would be very useful to add a lot more tests to feature_config_args.py, given that you were able to make these changes without breaking any existing test.

@AkioNak AkioNak force-pushed the includeconf_eval_at_its_position branch from c858ddc to 613c62b Compare March 4, 2019 11:32
@AkioNak
Copy link
Contributor Author

AkioNak commented Mar 4, 2019

rebased. (no functional change yet)

@AkioNak AkioNak force-pushed the includeconf_eval_at_its_position branch from 6430f92 to 042eb42 Compare May 11, 2020 07:51
@AkioNak
Copy link
Contributor Author

AkioNak commented May 11, 2020

Rebased.
I am still working on addressing the comments by ryanofsky and Sjors.

@adamjonas
Copy link
Member

Hi @AkioNak - friendly monthly ping.

@AkioNak
Copy link
Contributor Author

AkioNak commented Jun 18, 2020

@adamjonas Thanks. I will do again.

@AkioNak AkioNak force-pushed the includeconf_eval_at_its_position branch from 042eb42 to 12bacf3 Compare July 8, 2020 23:15
@AkioNak AkioNak changed the title Improve property evaluation way in bitcoin.conf [wip] util: Improve evaluation of includeconf lines in network sections of the config file Jul 8, 2020
@AkioNak AkioNak force-pushed the includeconf_eval_at_its_position branch from 12bacf3 to 3b6b025 Compare July 10, 2020 02:20
@AkioNak AkioNak force-pushed the includeconf_eval_at_its_position branch from 3b6b025 to 8b20f4a Compare July 13, 2020 02:19
Improve property evaluation way in bitcoin.conf

This PR intends to make it easy to understand how the configuration
files are interpreted.

1. Evaluate "includeconf" at the position described in the config file
(like #include directive in C/C++), rather than at the end.

2. If once a section is specified with square brackets like [main],
the only way to configure another network is to use square brackets
again, e.g. [test].

3. In the "included" config file, the section is taken over from
the "including" file. If no sections are specified yet, using square
brackets or section prefix is still possible in the "included" file.

4. Changing the section in the "included" config file does not affects
the including file. The section of the including file is kept.

5. If the "included" config file is included after the section has been
specified by using square brackets or if they are included by using
section prefix, any square brackets can not be used in that file.

ex) With Following 3 files, the properties are read as:
port=8444, main.port=8445, test.port=8442, regtest.port: undefined

bitcoin.conf
---
test.includeconf=inc1.conf
includeconf=inc2.conf
port=8441   # ignored (2nd appearance of w/o section)

inc1.conf
---
port=8442   # test
[regtest]
port=8443   # ignored

inc2.conf
---
port=8444   # w/o section
[main]
port=8445   # main
[regtest]
@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase. What is the status here?
  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

@AkioNak
Copy link
Contributor Author

AkioNak commented Dec 16, 2021

I will solve the conflicts.

@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase. What is the status here?
  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

@fanquake
Copy link
Member

Going to close with "Up for Grabs".

@fanquake fanquake closed this Mar 21, 2022
@bitcoin bitcoin locked and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.