Configuration argument handling improvements.

bitcoin/bitcoin: PR #36861

1 minor finding · 6 suggestions

Earlier concerns neither republished nor resolved: 4 suggestions. See the Run archive for their assessments.

Findings

Link

[minor] · Negated zero-valued options now abort startup without migration guidance

Previously accepted noX settings now abort startup even where X=0 remains valid, without migration guidance; the prevalence of these configurations is unknown.

Location: src/init.cpp:697 (head).

Details and suggested fix

This affects -bytespersigop, -datacarriersize, -mempoolexpiry, -maxtipage, -maxsendbuffer, -maxreceivebuffer, -dbbatchsize, -limitancestorcount and -limitdescendantcount. Ordinary negation previously produced false, which GetIntArg converted to zero. DISALLOW_NEGATION now rejects those spellings before numeric validation in both command-line and bitcoin.conf parsing. Add a release note listing the affected options and the replacement syntax, for example -nobytespersigop becomes -bytespersigop=0, and nodatacarriersize=1 becomes datacarriersize=0. Neither the supplied description nor the commit message mentions this compatibility change.


Optional improvements

Link

[suggestion] · Wallet target rejection lacks upgrade documentation

Targets above the estimator maximum now prevent wallet loading and can abort startup; invalid targets also fail parameter interaction, but these acceptance changes lack release-note guidance.

Location: src/wallet/wallet.cpp:2942 (head).

Details and suggested fix

LoadWalletArgs now returns false for a previously accepted target above the estimator maximum. A selected existing startup wallet propagates that failure and stops node initialization; without a startup wallet, later loadwallet and createwallet operations fail instead. The estimator-dependent maximum is skipped when no estimator runs, including under -blocksonly. Separately, parameter interaction rejects targets outside [1, UINT_MAX] even without a loaded wallet, unless the wallet is disabled. Document these changes and the no-estimator exception in the description and a release note, telling operators to select a target within the supported range.


Link

[suggestion] · The negative-expiry comment reverses the expiration behavior

The new comment says negative expiry prevents expiration, but a future cutoff instead expires normally timestamped transactions when limiting runs and excludes them on reload.

Location: src/node/mempool_args.cpp:90 (head).

Details and suggested fix

LimitMempoolSize passes now - expiry to Expire, which removes entries older than that cutoff. LoadMempool likewise reloads only entries newer than its cutoff. Change the comment to say that a negative expiry prematurely expires normally timestamped transactions, rather than stopping expiration. Zero is a zero-length retention window in these consumers, not a disabled-expiration sentinel. No code change is needed.


Link

[suggestion] · Mempool argument tests discard the values they validate

The new unit test observes only success or failure, so it cannot detect missing assignments or incorrect unit conversions for accepted options.

Location: src/test/mempool_tests.cpp:556 (head).

Details and suggested fix

Keeping the guards but omitting an assignment or using seconds without the hours multiplier would leave these success assertions passing. Return util::Result<kernel::MemPoolOptions>, following SetOptsFromArgs, and inspect accepted results. Check that -mempoolexpiry=1 yields 3600s and an accepted value above INT32_MAX hours converts correctly on MSVC. Also check that -limitclustersize=1 yields 1000 vbytes, -limitclustercount=64 stays 64, and -datacarriersize=0 produces an engaged zero while -datacarrier=0 produces nullopt. Keep the rejection cases.


Link

[suggestion] · Wallet target tests omit both accepting boundary cases

The new wallet test checks only rejection of 1009; it does not protect acceptance of 1008 or wallet loading without a fee estimator.

Location: test/functional/wallet_fallbackfee.py:76 (head).

Details and suggested fix

An accidental >= max_target comparison would still reject 1009 with the expected message while also rejecting 1008. Removing max_target != 0 would likewise leave this assertion unchanged but prevent wallet loading under -blocksonly, where the interface returns zero. Reuse the persisted wallet in this fixture for a successful start with -txconfirmtarget=1008 and a successful start with -blocksonly=1 -txconfirmtarget=1009, checking that the wallet loads in both cases. Keep the existing rejection case.


Link

[suggestion] · The bytes-per-sigop upper bound has no rejection test

The new rejection table exercises only negative -bytespersigop, so removing the positive upper-bound check would leave these assertions passing.

Location: test/functional/feature_config_args.py:234 (head).

Details and suggested fix

Without the > std::numeric_limits<unsigned int>::max() comparison, -bytespersigop=4294967296 narrows to zero and disables sigop-adjusted sizing. The existing -1 case still fails through the sign check, and the explicit-zero acceptance case does not expose this conversion. Add ("-bytespersigop=4294967296", "Error: -bytespersigop must be between 0 and 4294967295 (got 4294967296).") to the rejection table.


Link

[suggestion] · Wallet target validation is hidden in the node-option commit

The single commit omits the estimator-dependent wallet change from its message and bundles it with independent node checks, making that behavior harder to validate or revert separately.

Location: src/wallet/wallet.cpp:2938 at 0ad0c7138778 (commit) (commit).

Details and suggested fix

Commit 0ad0c71387783753356840d17d2b950367257e78 combines node range checks and help changes with independent wallet -txconfirmtarget validation. Move the changes in src/wallet/init.cpp, including its <limits> include, help text and negation flag, and src/wallet/wallet.cpp into a follow-up commit together with the wallet_fallbackfee.py assertion and the wallet-specific rejection block and -notxconfirmtarget entry in feature_config_args.py. Give that commit a message explaining the wallet-load estimator maximum and why the bound is skipped without an estimator, including under -blocksonly. This preserves the final tree while giving the wallet-load behavior its own review and revert boundary.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

Argument negation and argument type validation were deliberately separated to avoid misleading interfaces and unintended compatibility changes. The earlier ALLOW_INT, ALLOW_BOOL and ALLOW_STRING flags did not actually validate types, although they affected whether negation syntax was accepted; DISALLOW_NEGATION made that distinction explicit.

The pinned head adds DISALLOW_NEGATION to several numeric settings while separately checking their numeric ranges. Historically, forbidding '-no...' syntax and validating a supplied number address different aspects of configuration meaning; one does not substitute for the other.

Source 1

UTXO database writes are batched to manage temporary memory consumption during flushing. Larger batches can reduce per-write overhead and improve disk throughput, especially on HDDs, but increase peak memory use and the risk of an out-of-memory interruption.

In pinned src/txdb.cpp, batch_write_bytes controls when the accumulated write batch is written and cleared. The base assigns the configuration integer directly to that limit; the head validates it first. The underlying design question is preserving a meaningful memory-versus-I/O control during chainstate flushing, not enforcing a network consensus rule.

Source 1

Cluster mempool organizes connected transactions so mining selects high-feerate chunks and eviction removes low-feerate chunks using the same linearizations. Its implementation replaces ancestor/descendant admission limits with cluster count and size limits. The historical discussion explicitly balances bounded per-operation latency, bounded aggregate CPU expenditure and good fee-ordering results.

The pinned mempool argument code configures cluster count and virtual-size limits, including the existing maximum count of 64. The head adds lower-bound and conversion checks. These settings constrain the transaction graph on which fee-aware processing operates. The earlier proposal also explains why ancestor/descendant information remains available for compatibility even after those admission limits cease to be enforced; the pinned help identifies the old count options as wallet coin-selection settings.

Source 1 · Source 2

The bytes-per-sigop option was introduced as an additional relay and mining restriction, with explicit historical support for having a mitigation against sigop-spam attacks.

The pinned initialization code loads this numeric policy setting into nBytesPerSigOp, which is consumed by sigop-adjusted transaction-size calculations. Its historical purpose concerns computational resource pressure, not merely serialized transaction bytes. The head's range validation applies to that existing resource-policy input.

Source 1 · Source 2

Ralph's inferences

Taken together, these controls express operator-selected resource policies whose meaning depends on preserving their units and domains. Rejecting an invalid setting before conversion helps distinguish a chosen policy from an accidental machine-representation effect.

This is an interpretation of the pinned base-to-head behavior, rather than a retrieved historical statement about this PR. The affected conversions include kilobytes to bytes, hours to seconds, and signed configuration integers to unsigned limits. The historical batching and cluster discussions supply the underlying memory, I/O and CPU tradeoffs that those numbers represent.

Source 1 · Source 2 · Source 3

Zero should be understood as an option-specific value, not a universal synonym for disabling a limit. Configuration syntax alone cannot determine whether zero is useful for a particular subsystem.

The pinned head permits zero for several affected settings, but requires a positive cluster-size limit, cluster count, connection timeout and default ban duration. This interpretation connects the separation of syntax and semantic validation to the actual option-specific checks without asserting a historical rationale for every individual zero case.

Source 1

Unresolved disagreements

The historical sigop discussion distinguished support for resource protection from justification of the particular default of 20 bytes per sigop. Participants questioned that calibration; the mirrored discussion also records a proposal to treat sigop-heavy transactions as larger rather than simply reject them. The inspected record does not establish a resolution of the default-value justification.

This limits what history can explain about bytespersigop: it documents the attack-mitigation motivation, but does not independently justify every parameter choice. These are historical policy questions, not findings about the current argument-validation changes.

Source 1 · Source 2 · Source 3