bitcoin/src/util
Ava Chow 2c7a4231db
Merge bitcoin/bitcoin#30569: node: reduce unsafe uint256S usage
18d65d2772 test: use uint256::FromUserHex for RANDOM_CTX_SEED (stickies-v)
6819e5a329 node: use uint256::FromUserHex for -assumevalid parsing (stickies-v)
2e58fdb544 util: remove unused IsHexNumber (stickies-v)
8a44d7d3c1 node: use uint256::FromUserHex for -minimumchainwork parsing (stickies-v)
70e2c87737 refactor: add uint256::FromUserHex helper (stickies-v)
85b7cbfcbe test: unittest chainstatemanager_args (stickies-v)

Pull request description:

  Since fad2991ba0, `uint256S` has been [deprecated](fad2991ba0 (diff-800776e2dda39116e889839f69409571a5d397de048a141da7e4003bc099e3e2R138)) because it is less robust than the `base_blob::FromHex()` introduced in [the same PR](https://github.com/bitcoin/bitcoin/pull/30482). Specifically, it tries to recover from length-mismatches, recover from untrimmed whitespace, 0x-prefix and garbage at the end, instead of simply requiring exactly 64 hex-only characters. _(see also #30532)_

  This PR carves out the few `uint256S` callsites that may potentially prove a bit more controversial to change because they deal with user input and backwards incompatible behaviour change.

  The main behaviour change introduced in this PR is:
  - `-minimumchainwork` will raise an error when input is longer than 64 hex digits
  - `-assumevalid` will raise an error when input contains invalid hex characters, or when it is longer than 64 hex digits
  - test: the optional RANDOM_CTX_SEED env var will now cause tests to abort when it contains invalid hex characters, or when it is longer than 64 hex digits

  After this PR, the remaining work to remove `uint256S` completely is almost entirely mechanical and/or test related. I will open that PR once #30560 is merged because it builds on that.

ACKs for top commit:
  hodlinator:
    re-ACK 18d65d2772
  l0rinc:
    ACK 18d65d2772
  achow101:
    ACK 18d65d2772
  ryanofsky:
    Code review ACK 18d65d2772. Very nice change that cleans up the API, adds checking for invalid values, makes parsing of values more consistent, and adds test coverage.

Tree-SHA512: ec118ea3d56e1dfbc4c79acdbfc797f65c4d2107b0ca9577c848b4ab9b7cb8d05db9f3c7fe8441a09291aca41bf671572431f4eddc59be8fb53abbea76bbbf86
2024-08-27 16:47:54 -04:00
..
any.h refactor: Split util::AnyPtr into its own file 2023-05-20 12:03:33 +02:00
asmap.cpp crypto: replace CountBits with std::bit_width 2024-02-26 16:13:12 +00:00
asmap.h refactor: Move fs.* to util/fs.* 2023-03-23 12:55:18 +01:00
batchpriority.cpp refactor: Move ScheduleBatchPriority to its own file 2023-05-20 12:03:30 +02:00
batchpriority.h refactor: Move ScheduleBatchPriority to its own file 2023-05-20 12:03:30 +02:00
bip32.cpp Merge bitcoin/bitcoin#26076: Switch hardened derivation marker to h 2023-05-08 13:31:28 -04:00
bip32.h Switch hardened derivation marker to h in descriptors 2023-04-04 18:33:08 +02:00
bitdeque.h refactor: Fix "error C2248: cannot access private member" on MSVC 2024-04-28 07:11:24 +01:00
bitset.h util: add BitSet 2024-06-10 07:54:48 -04:00
bytevectorhash.cpp random: get rid of GetRand by inlining 2024-07-01 12:39:53 -04:00
bytevectorhash.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
chaintype.cpp testnet: Introduce Testnet4 2024-08-06 01:38:10 +02:00
chaintype.h testnet: Introduce Testnet4 2024-08-06 01:38:10 +02:00
check.cpp scripted-diff: Add IWYU pragma keep to bitcoin-config.h includes 2024-05-01 08:33:04 +02:00
check.h Export assert from util/check.h 2023-11-24 13:11:36 +01:00
epochguard.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
exception.cpp refactor: Extract util/exception from util/system 2023-03-13 17:09:47 +01:00
exception.h refactor: Extract util/exception from util/system 2023-03-13 17:09:47 +01:00
fastrange.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
feefrac.cpp Avoid explicitly computing diagram; compare based on chunks 2024-04-22 09:36:36 -04:00
feefrac.h Avoid explicitly computing diagram; compare based on chunks 2024-04-22 09:36:36 -04:00
fs.cpp Add tests for C++20 std::u8string 2023-12-11 17:42:05 +01:00
fs.h refactor: Rename fs::path::u8string() to fs::path::utf8string() 2023-12-14 16:22:40 +01:00
fs_helpers.cpp util: add perm string helper functions 2024-06-27 14:55:10 +01:00
fs_helpers.h util: add perm string helper functions 2024-06-27 14:55:10 +01:00
golombrice.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
hash_type.h move-only: Add util/hash_type 2021-05-11 10:38:18 +02:00
hasher.cpp random: get rid of GetRand by inlining 2024-07-01 12:39:53 -04:00
hasher.h Bump g++ minimum supported version to 10 2023-10-30 15:12:26 +01:00
insert.h refactor: Split util::insert into its own file 2023-05-20 12:03:31 +02:00
macros.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
moneystr.cpp util: Move util/string.h functions to util namespace 2024-05-16 10:16:08 -05:00
moneystr.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
overflow.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
overloaded.h doc: Clarify C++20 comments 2024-01-05 11:22:31 +01:00
rbf.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
rbf.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
readwritefile.cpp refactor: Move fs.* to util/fs.* 2023-03-23 12:55:18 +01:00
readwritefile.h refactor: Move fs.* to util/fs.* 2023-03-23 12:55:18 +01:00
result.h refactor: Avoid copying util::Result values 2024-04-25 16:08:24 -04:00
serfloat.cpp Add platform-independent float encoder/decoder 2021-05-24 16:04:44 -07:00
serfloat.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
signalinterrupt.cpp util: Get rid of uncaught exceptions thrown by SignalInterrupt class 2023-12-04 15:39:15 -04:00
signalinterrupt.h util: Get rid of uncaught exceptions thrown by SignalInterrupt class 2023-12-04 15:39:15 -04:00
sock.cpp sock: change Sock::SendComplete() to take Span 2023-10-31 18:19:22 +01:00
sock.h sock: change Sock::SendComplete() to take Span 2023-10-31 18:19:22 +01:00
strencodings.cpp util: remove unused IsHexNumber 2024-08-23 13:53:40 +01:00
strencodings.h util: remove unused IsHexNumber 2024-08-23 13:53:40 +01:00
string.cpp util: Move util/string.h functions to util namespace 2024-05-16 10:16:08 -05:00
string.h log: Remove NOLINT(bitcoin-unterminated-logprintf) 2024-07-19 15:09:00 +02:00
subprocess.h tidy: modernize-use-equals-default 2024-07-08 11:12:01 +02:00
syserror.cpp scripted-diff: Add IWYU pragma keep to bitcoin-config.h includes 2024-05-01 08:33:04 +02:00
syserror.h Show descriptive error messages when FileCommit fails 2023-06-30 09:48:21 -04:00
task_runner.h tidy: modernize-use-equals-default 2024-07-08 11:12:01 +02:00
thread.cpp refactor: Extract util/exception from util/system 2023-03-13 17:09:47 +01:00
thread.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
threadinterrupt.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
threadinterrupt.h util: Add SignalInterrupt class and use in shutdown.cpp 2023-06-28 09:49:28 +02:00
threadnames.cpp build: remove --enable-threadlocal 2024-05-21 10:29:51 +01:00
threadnames.h util: avoid using thread_local variable that has a destructor 2024-05-16 18:16:46 +02:00
time.cpp refactor: Use chrono type for g_mock_time 2024-04-15 13:34:31 +02:00
time.h Revert "time: add runtime sanity check" 2024-03-18 16:01:08 +01:00
tokenpipe.cpp scripted-diff: Add IWYU pragma keep to bitcoin-config.h includes 2024-05-01 08:33:04 +02:00
tokenpipe.h util: Add RAII TokenPipe 2021-03-04 18:24:00 +01:00
trace.h scripted-diff: Add IWYU pragma keep to bitcoin-config.h includes 2024-05-01 08:33:04 +02:00
transaction_identifier.h refactor: remove TxidFromString 2024-07-31 16:47:39 +01:00
translation.h util: Catch translation string errors at compile time 2024-07-10 09:40:47 +02:00
types.h doc: Clarify C++20 comments 2024-01-05 11:22:31 +01:00
ui_change_type.h wallet: Do not include server symbols 2020-06-27 11:39:09 -04:00
vecdeque.h utils: add missing include 2024-06-11 16:28:11 +00:00
vector.h chainparams: add blockhash to AssumeutxoData 2023-09-30 06:38:47 -04:00