Skip to content

Commit 94f0caa

Browse files
05e2091 merge bitcoin#30464: Fix MSVC warning C4101 "unreferenced local variable" (Kittywhiskers Van Gogh) f00dc78 build: drop `-Wdangling-reference` GCC suppression (Kittywhiskers Van Gogh) 6d81d06 merge bitcoin#27605: Replace global find_value function with UniValue::find_value method (Kittywhiskers Van Gogh) 203a1c1 merge bitcoin#26612: pass named argument value as string_view (Kittywhiskers Van Gogh) 41eb3b0 merge bitcoin#25714: Avoid std::string copies (Kittywhiskers Van Gogh) 6f03a13 merge bitcoin#25736: Remove unused and confusing set*() return value (Kittywhiskers Van Gogh) 27cffb1 refactor: shed avoidable casts in Dash-specific UniValue-ret functions (Kittywhiskers Van Gogh) 32958da merge bitcoin#25611: Avoid brittle, narrowing and verbose integral type confusions (Kittywhiskers Van Gogh) 7802752 merge bitcoin#25617: univalue test cleanups (Kittywhiskers Van Gogh) 94bbbf1 partial bitcoin#25551: Throw exception on invalid Univalue pushes over silent ignore (Kittywhiskers Van Gogh) d980870 revert: revert bitcoin#25464 (Reduce Univalue push_backV peak memory usage in listtransactions) (Kittywhiskers Van Gogh) 1e023e5 merge bitcoin#25369: Unsubtree Univalue (Kittywhiskers Van Gogh) 6b9e682 merge bitcoin#25249: Bump univalue subtree (Kittywhiskers Van Gogh) b3443ee Squashed 'src/univalue/' changes from 6c19d050a9..de4f73ddca (Kittywhiskers Van Gogh) 9db7b12 merge bitcoin#25113: Bump univalue subtree (Kittywhiskers Van Gogh) 88f794f Squashed 'src/univalue/' changes from a44caf65fe..6c19d050a9 (Kittywhiskers Van Gogh) b07e550 merge bitcoin#25153: Use getInt<T> over get_int/get_int64 (Kittywhiskers Van Gogh) b1ae6f5 Squashed 'src/univalue/' changes from 2740c4f..a44caf65fe (Kittywhiskers Van Gogh) 1780961 revert: bitcoin#25464 (Reduce Univalue push_backV peak memory usage in listtransactions) (Kittywhiskers Van Gogh) Pull request description: ## Motivation To get rid of the `-Wdangling-reference` suppression ([source](https://github.com/dashpay/dash/blob/f648039258d2192ec5e505721e34edaa0bda568c/configure.ac#L461-L467)) for GCC introduced in [dash#6639](dashpay#6639) by backporting the set of changes needed to backport [bitcoin#27605](bitcoin#27605). ## Additional Information * At some point, the contents on `univalue/` diverged from official repository ([bitcoin-core/univalue-subtree](https://github.com/bitcoin-core/univalue-subtree)), which makes updating the subtree a more difficult prospect. We realign the subtree by updating it to [`a44caf65`](bitcoin-core/univalue-subtree@a44caf65) (last sane commit, taken from [bitcoin#22646](bitcoin#22646), which was backported as [dash#4823](dashpay#4823)) and marking all merge conflicts in favour of the incoming update. This lets us do the final few subtree updates before it's no longer treated as a subtree. * To allow for subtree updates, [bitcoin#25464](bitcoin#25464) (backported as 001d7ba in [dash#6698](dashpay#6698)) was temporarily reverted and then reapplied _after_ the directory was unsubtree'd. * [bitcoin#30464](bitcoin#30464) needed to be backported to keep the whitespace linter happy (failed [build](https://github.com/dashpay/dash/actions/runs/16463979981/job/46536933377#step:5:119)). ## Breaking Changes None expected. ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)** - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation **(note: N/A)** - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK 05e2091 Tree-SHA512: fdd35699defcc24a396fc9746a8eca26a5866666e9ae049f7d9e38fe84021aa49169e48b9408d3c47c6cd41aa9523f0f94a8b91ecc874a962bf5e6005d7eff21
2 parents 1e694a5 + 05e2091 commit 94f0caa

File tree

93 files changed

+619
-2026
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+619
-2026
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ src/obj
4949
share/setup.nsi
5050
share/qt/Info.plist
5151

52-
src/univalue/gen
53-
5452
src/qt/*.moc
5553
src/qt/moc_*.cpp
5654
src/qt/forms/ui_*.h

Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ LCOV_FILTER_PATTERN = \
169169
-p "src/leveldb/" \
170170
-p "src/crc32c/" \
171171
-p "src/bench/" \
172-
-p "src/univalue" \
173172
-p "src/crypto/ctaes" \
174173
-p "src/minisketch" \
175174
-p "src/secp256k1" \

ci/lint/06_script.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export COMMIT_RANGE
2626
test/lint/git-subtree-check.sh src/crypto/ctaes
2727
test/lint/git-subtree-check.sh src/secp256k1
2828
test/lint/git-subtree-check.sh src/minisketch
29-
test/lint/git-subtree-check.sh src/univalue
3029
test/lint/git-subtree-check.sh src/leveldb
3130
test/lint/check-doc.py
3231
test/lint/all-lint.py

ci/test/wrap-wine.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
export LC_ALL=C.UTF-8
88

9-
for b_name in {"${BASE_OUTDIR}/bin"/*,src/secp256k1/*tests,src/minisketch/test{,-verify},src/univalue/{no_nul,test_json,unitester,object}}.exe; do
9+
for b_name in {"${BASE_OUTDIR}/bin"/*,src/secp256k1/*tests,src/minisketch/test{,-verify},src/univalue/{test_json,unitester,object}}.exe; do
1010
# shellcheck disable=SC2044
1111
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name "$(basename "$b_name")"); do
1212
if (file "$b" | grep "Windows"); then

configure.ac

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -450,21 +450,14 @@ if test "$enable_werror" = "yes"; then
450450
fi
451451
ERROR_CXXFLAGS=$CXXFLAG_WERROR
452452

453-
dnl -Warray-bounds and -Wdangling-reference cause problems with GCC. Do not treat these warnings as errors.
453+
dnl -Warray-bounds cause problems with GCC. Do not treat these warnings as errors.
454454
dnl Suppress -Warray-bounds entirely because of noisy output, currently unhappy with immer implementation.
455455
AX_CHECK_COMPILE_FLAG([-Warray-bounds], [NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-array-bounds"], [], [$CXXFLAG_WERROR], [AC_LANG_SOURCE([
456456
#if defined(__clang__) || defined(__INTEL_COMPILER) || !defined(__GNUC__)
457457
#error Non-GCC compiler detected, not setting flag
458458
#endif
459459
int main(void) { return 0; }
460460
])])
461-
dnl TODO: Remove suppression after backporting bitcoin#27605
462-
AX_CHECK_COMPILE_FLAG([-Wdangling-reference], [NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-error=dangling-reference"], [], [$CXXFLAG_WERROR], [AC_LANG_SOURCE([
463-
#if defined(__clang__) || defined(__INTEL_COMPILER) || !defined(__GNUC__)
464-
#error Non-GCC compiler detected, not setting flag
465-
#endif
466-
int main(void) { return 0; }
467-
])])
468461

469462
dnl -Wattributes cause problems with some versions of GCC. Do not treat these warnings as errors.
470463
AX_CHECK_COMPILE_FLAG([-Wattributes], [NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-error=attributes"], [], [$CXXFLAG_WERROR], [AC_LANG_SOURCE([

contrib/devtools/copyright_header.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"src/leveldb/",
4646
"src/minisketch",
4747
"src/secp256k1/",
48-
"src/univalue/",
4948
]
5049

5150
INCLUDE = ['*.h', '*.cpp', '*.cc', '*.c', '*.mm', '*.py', '*.sh', '*.bash-completion']

doc/developer-notes.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,10 +1155,6 @@ Current subtrees include:
11551155
- src/crypto/ctaes
11561156
- Upstream at https://github.com/bitcoin-core/ctaes ; maintained by Core contributors.
11571157

1158-
- src/univalue
1159-
- Subtree at https://github.com/bitcoin-core/univalue-subtree ; maintained by Core contributors.
1160-
- Deviates from upstream https://github.com/jgarzik/univalue.
1161-
11621158
- src/minisketch
11631159
- Upstream at https://github.com/sipa/minisketch ; maintained by Core contributors.
11641160

src/Makefile.test.include

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ endif
411411
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
412412

413413
if ENABLE_TESTS
414-
UNIVALUE_TESTS = univalue/test/object univalue/test/unitester univalue/test/no_nul
414+
UNIVALUE_TESTS = univalue/test/object univalue/test/unitester
415415
noinst_PROGRAMS += $(UNIVALUE_TESTS)
416416
TESTS += $(UNIVALUE_TESTS)
417417

@@ -420,11 +420,6 @@ univalue_test_unitester_LDADD = $(LIBUNIVALUE)
420420
univalue_test_unitester_CPPFLAGS = -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) -DJSON_TEST_SRC=\"$(srcdir)/$(UNIVALUE_TEST_DATA_DIR_INT)\"
421421
univalue_test_unitester_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS)
422422

423-
univalue_test_no_nul_SOURCES = $(UNIVALUE_TEST_NO_NUL_INT)
424-
univalue_test_no_nul_LDADD = $(LIBUNIVALUE)
425-
univalue_test_no_nul_CPPFLAGS = -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)
426-
univalue_test_no_nul_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS)
427-
428423
univalue_test_object_SOURCES = $(UNIVALUE_TEST_OBJECT_INT)
429424
univalue_test_object_LDADD = $(LIBUNIVALUE)
430425
univalue_test_object_CPPFLAGS = -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)

src/bitcoin-cli.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
483483
if (!batch[ID_NETWORKINFO]["error"].isNull()) return batch[ID_NETWORKINFO];
484484

485485
const UniValue& networkinfo{batch[ID_NETWORKINFO]["result"]};
486-
if (networkinfo["version"].get_int() < 200000) {
486+
if (networkinfo["version"].getInt<int>() < 200000) {
487487
throw std::runtime_error("-netinfo requires dashd server to be running v20.0 and up");
488488
}
489489
const int64_t time_now{TicksSinceEpoch<std::chrono::seconds>(CliClock::now())};
@@ -504,16 +504,16 @@ class NetinfoRequestHandler : public BaseRequestHandler
504504
if (conn_type == "manual") ++m_manual_peers_count;
505505
if (DetailsRequested()) {
506506
// Push data for this peer to the peers vector.
507-
const int peer_id{peer["id"].get_int()};
508-
const int mapped_as{peer["mapped_as"].isNull() ? 0 : peer["mapped_as"].get_int()};
509-
const int version{peer["version"].get_int()};
510-
const int64_t addr_processed{peer["addr_processed"].isNull() ? 0 : peer["addr_processed"].get_int64()};
511-
const int64_t addr_rate_limited{peer["addr_rate_limited"].isNull() ? 0 : peer["addr_rate_limited"].get_int64()};
512-
const int64_t conn_time{peer["conntime"].get_int64()};
513-
const int64_t last_blck{peer["last_block"].get_int64()};
514-
const int64_t last_recv{peer["lastrecv"].get_int64()};
515-
const int64_t last_send{peer["lastsend"].get_int64()};
516-
const int64_t last_trxn{peer["last_transaction"].get_int64()};
507+
const int peer_id{peer["id"].getInt<int>()};
508+
const int mapped_as{peer["mapped_as"].isNull() ? 0 : peer["mapped_as"].getInt<int>()};
509+
const int version{peer["version"].getInt<int>()};
510+
const int64_t addr_processed{peer["addr_processed"].isNull() ? 0 : peer["addr_processed"].getInt<int64_t>()};
511+
const int64_t addr_rate_limited{peer["addr_rate_limited"].isNull() ? 0 : peer["addr_rate_limited"].getInt<int64_t>()};
512+
const int64_t conn_time{peer["conntime"].getInt<int64_t>()};
513+
const int64_t last_blck{peer["last_block"].getInt<int64_t>()};
514+
const int64_t last_recv{peer["lastrecv"].getInt<int64_t>()};
515+
const int64_t last_send{peer["lastsend"].getInt<int64_t>()};
516+
const int64_t last_trxn{peer["last_transaction"].getInt<int64_t>()};
517517
const double min_ping{peer["minping"].isNull() ? -1 : peer["minping"].get_real()};
518518
const double ping{peer["pingtime"].isNull() ? -1 : peer["pingtime"].get_real()};
519519
const std::string addr{peer["addr"].get_str()};
@@ -534,7 +534,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
534534
}
535535

536536
// Generate report header.
537-
std::string result{strprintf("%s client %s%s - server %i%s\n\n", PACKAGE_NAME, FormatFullVersion(), ChainToString(), networkinfo["protocolversion"].get_int(), networkinfo["subversion"].get_str())};
537+
std::string result{strprintf("%s client %s%s - server %i%s\n\n", PACKAGE_NAME, FormatFullVersion(), ChainToString(), networkinfo["protocolversion"].getInt<int>(), networkinfo["subversion"].get_str())};
538538

539539
// Report detailed peer connections list sorted by direction and minimum ping time.
540540
if (DetailsRequested() && !m_peers.empty()) {
@@ -623,7 +623,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
623623
max_addr_size = std::max(addr["address"].get_str().length() + 1, max_addr_size);
624624
}
625625
for (const UniValue& addr : local_addrs) {
626-
result += strprintf("\n%-*s port %6i score %6i", max_addr_size, addr["address"].get_str(), addr["port"].get_int(), addr["score"].get_int());
626+
result += strprintf("\n%-*s port %6i score %6i", max_addr_size, addr["address"].get_str(), addr["port"].getInt<int>(), addr["score"].getInt<int>());
627627
}
628628
}
629629

@@ -876,8 +876,8 @@ static UniValue ConnectAndCallRPC(BaseRequestHandler* rh, const std::string& str
876876
try {
877877
response = CallRPC(rh, strMethod, args, rpcwallet);
878878
if (fWait) {
879-
const UniValue& error = find_value(response, "error");
880-
if (!error.isNull() && error["code"].get_int() == RPC_IN_WARMUP) {
879+
const UniValue& error = response.find_value("error");
880+
if (!error.isNull() && error["code"].getInt<int>() == RPC_IN_WARMUP) {
881881
throw CConnectionFailed("server in warmup");
882882
}
883883
}
@@ -904,21 +904,21 @@ static void ParseResult(const UniValue& result, std::string& strPrint)
904904
static void ParseError(const UniValue& error, std::string& strPrint, int& nRet)
905905
{
906906
if (error.isObject()) {
907-
const UniValue& err_code = find_value(error, "code");
908-
const UniValue& err_msg = find_value(error, "message");
907+
const UniValue& err_code = error.find_value("code");
908+
const UniValue& err_msg = error.find_value("message");
909909
if (!err_code.isNull()) {
910910
strPrint = "error code: " + err_code.getValStr() + "\n";
911911
}
912912
if (err_msg.isStr()) {
913913
strPrint += ("error message:\n" + err_msg.get_str());
914914
}
915-
if (err_code.isNum() && err_code.get_int() == RPC_WALLET_NOT_SPECIFIED) {
915+
if (err_code.isNum() && err_code.getInt<int>() == RPC_WALLET_NOT_SPECIFIED) {
916916
strPrint += "\nTry adding \"-rpcwallet=<filename>\" option to dash-cli command line.";
917917
}
918918
} else {
919919
strPrint = "error: " + error.write();
920920
}
921-
nRet = abs(error["code"].get_int());
921+
nRet = abs(error["code"].getInt<int>());
922922
}
923923

924924
/**
@@ -931,15 +931,15 @@ static void GetWalletBalances(UniValue& result)
931931
{
932932
DefaultRequestHandler rh;
933933
const UniValue listwallets = ConnectAndCallRPC(&rh, "listwallets", /* args=*/{});
934-
if (!find_value(listwallets, "error").isNull()) return;
935-
const UniValue& wallets = find_value(listwallets, "result");
934+
if (!listwallets.find_value("error").isNull()) return;
935+
const UniValue& wallets = listwallets.find_value("result");
936936
if (wallets.size() <= 1) return;
937937

938938
UniValue balances(UniValue::VOBJ);
939939
for (const UniValue& wallet : wallets.getValues()) {
940940
const std::string wallet_name = wallet.get_str();
941941
const UniValue getbalances = ConnectAndCallRPC(&rh, "getbalances", /* args=*/{}, wallet_name);
942-
const UniValue& balance = find_value(getbalances, "result")["mine"]["trusted"];
942+
const UniValue& balance = getbalances.find_value("result")["mine"]["trusted"];
943943
balances.pushKV(wallet_name, balance);
944944
}
945945
result.pushKV("balances", balances);
@@ -975,7 +975,7 @@ static void GetProgressBar(double progress, std::string& progress_bar)
975975
*/
976976
static void ParseGetInfoResult(UniValue& result)
977977
{
978-
if (!find_value(result, "error").isNull()) return;
978+
if (!result.find_value("error").isNull()) return;
979979

980980
std::string RESET, GREEN, BLUE, YELLOW, MAGENTA, CYAN;
981981
bool should_colorize = false;
@@ -1191,9 +1191,9 @@ static int CommandLineRPC(int argc, char *argv[])
11911191
rh.reset(new NetinfoRequestHandler());
11921192
} else if (gArgs.GetBoolArg("-generate", false)) {
11931193
const UniValue getnewaddress{GetNewAddress()};
1194-
const UniValue& error{find_value(getnewaddress, "error")};
1194+
const UniValue& error{getnewaddress.find_value("error")};
11951195
if (error.isNull()) {
1196-
SetGenerateToAddressArgs(find_value(getnewaddress, "result").get_str(), args);
1196+
SetGenerateToAddressArgs(getnewaddress.find_value("result").get_str(), args);
11971197
rh.reset(new GenerateToAddressRequestHandler());
11981198
} else {
11991199
ParseError(error, strPrint, nRet);
@@ -1215,8 +1215,8 @@ static int CommandLineRPC(int argc, char *argv[])
12151215
const UniValue reply = ConnectAndCallRPC(rh.get(), method, args, wallet_name);
12161216

12171217
// Parse reply
1218-
UniValue result = find_value(reply, "result");
1219-
const UniValue& error = find_value(reply, "error");
1218+
UniValue result = reply.find_value("result");
1219+
const UniValue& error = reply.find_value("error");
12201220
if (error.isNull()) {
12211221
if (gArgs.GetBoolArg("-getinfo", false)) {
12221222
if (!gArgs.IsArgSet("-rpcwallet")) {

src/bitcoin-tx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
569569
throw std::runtime_error("txid must be hexadecimal string (not '" + prevOut["txid"].get_str() + "')");
570570
}
571571

572-
const int nOut = prevOut["vout"].get_int();
572+
const int nOut = prevOut["vout"].getInt<int>();
573573
if (nOut < 0)
574574
throw std::runtime_error("vout cannot be negative");
575575

0 commit comments

Comments
 (0)