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

common: Disallow calling IsArgSet() on ALLOW_LIST options #17783

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
20a9986
common: Grammar / formatting tweaks
ryanofsky Sep 25, 2024
30385f2
doc: Add detailed ArgsManager type flag documention
ryanofsky Jul 30, 2024
a7a35ed
common: Implement ArgsManager flags to parse and validate settings on…
ryanofsky Aug 4, 2019
225ab2b
common: Update ArgManager GetArg helper methods to work better with A…
ryanofsky Sep 21, 2022
350c715
test: Add tests to demonstrate usage of ArgsManager flags
ryanofsky Jul 30, 2024
b5ef854
test: Add test for settings.json parsing with type flags
ryanofsky Jun 5, 2024
afaf226
Merge remote-tracking branch 'origin/pull/16545/head'
ryanofsky Dec 5, 2024
f6d6383
test: Add test to make sure -noconnect disables -dnsseed and -listen …
ryanofsky Jul 29, 2024
da3bdd5
common: Add support for combining ArgsManager flags
ryanofsky Aug 19, 2024
0a954ce
refactor: Clarify handling of -noconnect option
ryanofsky Dec 19, 2019
603423e
scripted-diff: Add ALLOW_LIST flag to arguments retrieved with GetArgs
ryanofsky Nov 15, 2019
f6c966e
refactor: Clarify handling of -nodebug option
ryanofsky Dec 19, 2019
8f6aa85
refactor: Fix more ALLOW_LIST arguments
ryanofsky Nov 15, 2019
594acdb
Fix nonsensical -norpcwhitelist, -norpcallowip and related behavior
ryanofsky Dec 19, 2019
7a75635
Always reject empty -blockfilterindex="" arguments
ryanofsky Sep 22, 2022
54ad580
Fix nonsensical bitcoin-cli -norpcwallet behavior
ryanofsky Dec 19, 2019
d2edef6
refactor: Always enforce ALLOW_LIST in CheckArgFlags
ryanofsky Jul 19, 2024
f173d66
Merge remote-tracking branch 'origin/pull/30529/head'
ryanofsky Dec 5, 2024
f5aa87f
Merge remote-tracking branch 'origin/pull/17580/head'
ryanofsky Dec 5, 2024
e74d730
common: Disallow calling IsArgSet() on ALLOW_LIST options
ryanofsky Dec 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Always reject empty -blockfilterindex="" arguments
Previous behavior was inconsistent: if -blockfilterindex or
-blockfilterindex="" arguments were specified they would normally enable all
block filter indexes, but could also trigger "Unknown -blockfilterindex value"
errors if followed by later -blockfilterindex arguments.

It was confusing that the same -blockfilterindex options could sometime trigger
errors and sometimes not depending on option position. It was also confusing
that an empty -blockfilterindex="" setting could enable all indexes even though
indexes are disabled by default.

New behavior is more straightforward:

- -blockfilterindex and -blockfilterindex=1 always enable indexes
- -noblockfilterindex and -blockfilterindex=0 always disable indexes
- -blockfilterindex="" is always an unknown value error

The meaning of these options no longer changes based on option position.
  • Loading branch information
ryanofsky committed Dec 5, 2024
commit 7a756355c1de57e0dc7ef66ff016dc0c7bc14ed1
15 changes: 8 additions & 7 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
argsman.AddArg("-blockfilterindex=<type>",
strprintf("Maintain an index of compact filters by block (default: %s, values: %s).", DEFAULT_BLOCKFILTERINDEX, ListBlockFilterTypes()) +
" If <type> is not supplied or if <type> = 1, indexes for all known types are enabled.",
ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
ArgsManager::ALLOW_BOOL | ArgsManager::ALLOW_STRING | ArgsManager::ALLOW_LIST, OptionsCategory::OPTIONS);

argsman.AddArg("-addnode=<ip>", strprintf("Add a node to connect to and attempt to keep the connection open (see the addnode RPC help for more info). This option can be specified multiple times to add multiple nodes; connections are limited to %u at a time and are counted separately from the -maxconnections limit.", MAX_ADDNODE_CONNECTIONS), ArgsManager::ALLOW_ANY | ArgsManager::ALLOW_LIST | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
argsman.AddArg("-asmap=<file>", strprintf("Specify asn mapping used for bucketing of the peers (default: %s). Relative paths will be prefixed by the net-specific datadir location.", DEFAULT_ASMAP_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
Expand Down Expand Up @@ -913,12 +913,13 @@ bool AppInitParameterInteraction(const ArgsManager& args)
}

// parse and validate enabled filter types
std::string blockfilterindex_value = args.GetArg("-blockfilterindex", DEFAULT_BLOCKFILTERINDEX);
if (blockfilterindex_value == "" || blockfilterindex_value == "1") {
g_enabled_filter_types = AllBlockFilterTypes();
} else if (blockfilterindex_value != "0") {
const std::vector<std::string> names = args.GetArgs("-blockfilterindex");
for (const auto& name : names) {
for (const auto& value : args.GetSettingsList("-blockfilterindex")) {
if (value.isTrue() || value.get_str() == "1") {
g_enabled_filter_types = AllBlockFilterTypes();
} else if (value.get_str() == "0") {
g_enabled_filter_types.clear();
} else {
const std::string& name = value.get_str();
BlockFilterType filter_type;
if (!BlockFilterTypeByName(name, filter_type)) {
return InitError(strprintf(_("Unknown -blockfilterindex value %s."), name));
Expand Down