From 13ac7c7562da02de8b2c7ac05d1f7883ff15190b Mon Sep 17 00:00:00 2001 From: pasta Date: Fri, 13 Nov 2026 00:12:33 -0600 Subject: [PATCH 1/5] fix(rpc): reject an out-of-range verifyislock maxHeight When the transaction is unknown or mined above maxHeight, the height is looked up on the active chain. A height below -1 or above the tip hit CHECK_NONFATAL and was reported as an internal bug. Co-Authored-By: Claude Fable 5.2 --- src/rpc/quorums.cpp | 4 +++- test/functional/rpc_verifyislock.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rpc/quorums.cpp b/src/rpc/quorums.cpp index 7d16a4618d62..f837cf248d99 100644 --- a/src/rpc/quorums.cpp +++ b/src/rpc/quorums.cpp @@ -1340,7 +1340,9 @@ static RPCHelpMan verifyislock() } } - CHECK_NONFATAL(pBlockIndex != nullptr); + if (pBlockIndex == nullptr) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); + } CBLSSignature sig; const bool use_bls_legacy{!DeploymentActiveAfter(pBlockIndex, chainman.GetConsensus(), Consensus::DEPLOYMENT_V19)}; diff --git a/test/functional/rpc_verifyislock.py b/test/functional/rpc_verifyislock.py index efdb3d73f9d1..2e65a8bdf7fd 100755 --- a/test/functional/rpc_verifyislock.py +++ b/test/functional/rpc_verifyislock.py @@ -52,6 +52,8 @@ def run_test(self): assert node.verifyislock(request_id, txid, rec_sig) # Not mined, should use maxHeight assert not node.verifyislock(request_id, txid, rec_sig, 1) + for height in (-2, node.getblockcount() + 1): + assert_raises_rpc_error(-8, "Block height out of range", node.verifyislock, request_id, txid, rec_sig, height) self.generate(node, 1, sync_fun=self.no_op) assert txid not in node.getrawmempool() # Mined but at higher height, should use maxHeight From e1f8795d3bf81e54a501406c4cb03e238642ae08 Mon Sep 17 00:00:00 2001 From: pasta Date: Fri, 13 Nov 2026 00:45:07 -0600 Subject: [PATCH 2/5] fix(rpc): reject a negative masternode winners count A count of INT_MIN overflowed the signed start-height subtraction, which is undefined behavior and aborts builds that use -ftrapv. Co-Authored-By: Claude Fable 5.2 --- src/rpc/masternode.cpp | 3 +++ test/functional/feature_llmq_evo.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index a8290fd5cd7e..a5c587f2c92b 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -308,6 +308,9 @@ static RPCHelpMan masternode_winners() if (!request.params[0].isNull()) { nCount = request.params[0].getInt(); + if (nCount < 0) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative count"); + } } if (!request.params[1].isNull()) { diff --git a/test/functional/feature_llmq_evo.py b/test/functional/feature_llmq_evo.py index aa63a63478da..c417d4266acd 100755 --- a/test/functional/feature_llmq_evo.py +++ b/test/functional/feature_llmq_evo.py @@ -20,7 +20,7 @@ MasternodeInfo, ) from test_framework.util import ( - assert_equal, assert_greater_than_or_equal, + assert_equal, assert_greater_than_or_equal, assert_raises_rpc_error, ) @@ -180,6 +180,7 @@ def test_masternode_count(self, expected_mns_count, expected_evo_count): assert_equal(detailed_count['evo']['total'], expected_evo_count) def test_masternode_winners(self, mn_rr_active=False): + assert_raises_rpc_error(-8, "Negative count", self.nodes[0].masternode, 'winners', -1) # ignore recent winners, test future ones only # we get up to 21 entries here: tip + up to 20 future payees winners = self.nodes[0].masternode('winners', 0) From 7a4325d5f73ddd53e49eec63dd196715473ff9bc Mon Sep 17 00:00:00 2001 From: pasta Date: Fri, 13 Nov 2026 00:12:33 -0600 Subject: [PATCH 3/5] test: fix the tx_pool_standard supply invariant The fixture mines Dash regtest coinbases of 500 DASH, not 50, and the backport of bitcoin#21142 dropped the mempool fee term that Bitcoin Core's check starts from. Co-Authored-By: Claude Fable 5.2 --- src/test/fuzz/tx_pool.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/fuzz/tx_pool.cpp b/src/test/fuzz/tx_pool.cpp index 176318a4a212..0bf6a31b6497 100644 --- a/src/test/fuzz/tx_pool.cpp +++ b/src/test/fuzz/tx_pool.cpp @@ -147,7 +147,7 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool) outpoints_rbf = outpoints_supply; // The sum of the values of all spendable outpoints - constexpr CAmount SUPPLY_TOTAL{COINBASE_MATURITY * 50 * COIN}; + constexpr CAmount SUPPLY_TOTAL{COINBASE_MATURITY * 500 * COIN}; SetMempoolConstraints(*node.args, fuzzed_data_provider); CTxMemPool tx_pool_{MakeMempool(fuzzed_data_provider, node)}; @@ -166,8 +166,8 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool) LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 300) { { - // Total supply is all outpoints - CAmount supply_now{0}; + // Total supply is the mempool fee + all outpoints + CAmount supply_now{WITH_LOCK(tx_pool.cs, return tx_pool.GetTotalFee())}; for (const auto& op : outpoints_supply) { supply_now += GetAmount(op); } From a34ad94b7573018e952babca56bc6ad17a5f6785 Mon Sep 17 00:00:00 2001 From: pasta Date: Fri, 13 Nov 2026 00:12:33 -0600 Subject: [PATCH 4/5] test: complete the rpc fuzz command tables The target terminated during initialization because registered Dash commands were in neither table. Compound names such as "quorum info" are dispatched as the parent method with a fixed first argument, and the fixture constructs the governance manager those commands dereference. Co-Authored-By: Claude Fable 5.2 --- src/test/fuzz/rpc.cpp | 92 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/src/test/fuzz/rpc.cpp b/src/test/fuzz/rpc.cpp index c8a8de622f1c..047b2e29721d 100644 --- a/src/test/fuzz/rpc.cpp +++ b/src/test/fuzz/rpc.cpp @@ -3,6 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include +#include #include #include #include @@ -41,6 +42,9 @@ namespace { struct RPCFuzzTestingSetup : public TestingSetup { RPCFuzzTestingSetup(const ChainType chain_type, const std::vector& extra_args) : TestingSetup{chain_type, extra_args} { + m_node.govman = std::make_unique(m_args.GetDataDirNet(), *m_node.mn_metaman, + *m_node.chainman, *m_node.sbman, *m_node.dmnman, + *m_node.mn_sync, /*collateral=*/nullptr); } void CallRPC(const std::string& rpc_method, const std::vector& arguments) @@ -49,7 +53,15 @@ struct RPCFuzzTestingSetup : public TestingSetup { request.context = m_node; request.strMethod = rpc_method; try { - request.params = RPCConvertValues(rpc_method, arguments); + const auto subcommand_pos = rpc_method.find(' '); + if (subcommand_pos == std::string::npos) { + request.params = RPCConvertValues(rpc_method, arguments); + } else { + request.strMethod = rpc_method.substr(0, subcommand_pos); + std::vector subcommand_arguments{rpc_method.substr(subcommand_pos + 1)}; + subcommand_arguments.insert(subcommand_arguments.end(), arguments.begin(), arguments.end()); + request.params = RPCConvertValues(request.strMethod, subcommand_arguments); + } } catch (const std::runtime_error&) { return; } @@ -72,25 +84,42 @@ const std::vector RPC_COMMANDS_NOT_SAFE_FOR_FUZZING{ "addconnection", // avoid DNS lookups "addnode", // avoid DNS lookups "addpeeraddress", // avoid DNS lookups + "debug", // changes global log categories "dumptxoutset", // avoid writing to disk "dumpwallet", // avoid writing to disk "enumeratesigners", "echoipc", // avoid assertion failure (Assertion `"EnsureAnyNodeContext(request.context).init" && check' failed.) + "evodb repair", // avoid repairing/rewriting EvoDB state "generatetoaddress", // avoid prohibitively slow execution (when `num_blocks` is large) "generatetodescriptor", // avoid prohibitively slow execution (when `nblocks` is large) "gettxoutproof", // avoid prohibitively slow execution + "gobject", // may dispatch to gobject submit + "gobject submit", // changes governance state "importmempool", // avoid reading from disk "importwallet", // avoid reading from disk "loadwallet", // avoid reading from disk + "masternode", // may dispatch to masternode connect + "masternode connect", // avoid network activity / DNS lookups + "mnauth", // changes peer authentication state + "mnsync", // changes masternode sync state + "quorum", // may dispatch to quorum dkgsimerror + "quorum dkgsimerror", // changes global DKG error rates "savemempool", // disabled as a precautionary measure: may take a file path argument in the future "setban", // avoid DNS lookups + "sporkupdate", // changes spork state "stop", // avoid shutdown state + "submitchainlock", // changes ChainLock state + "voteraw", // changes governance votes }; // RPC commands which are safe for fuzzing. const std::vector RPC_COMMANDS_SAFE_FOR_FUZZING{ "analyzepsbt", + "bls", + "bls fromsecret", + "bls generate", "clearbanned", + "cleardiscouraged", "combinepsbt", "combinerawtransaction", "converttopsbt", @@ -107,33 +136,49 @@ const std::vector RPC_COMMANDS_SAFE_FOR_FUZZING{ "echojson", "estimaterawfee", "estimatesmartfee", + "evodb verify", "finalizepsbt", "generate", "generateblock", "getaddednodeinfo", + "getaddressbalance", + "getaddressdeltas", + "getaddressmempool", + "getaddresstxids", + "getaddressutxos", "getaddrmaninfo", + "getassetunlockstatuses", "getbestblockhash", + "getbestchainlock", "getblock", "getblockchaininfo", "getblockcount", "getblockfilter", + "getblockfrompeer", "getblockhash", + "getblockhashes", "getblockheader", + "getblockheaders", "getblockstats", "getblocktemplate", + "getchainlockbyheight", "getchaintips", "getchaintxstats", + "getcoinjoininfo", "getconnectioncount", + "getcreditpoolinfo", "getdeploymentinfo", "getdescriptorinfo", "getdifficulty", + "getgovernanceinfo", "getindexinfo", + "getislocks", "getmemoryinfo", "getmempoolancestors", "getmempooldescendants", "getmempoolentry", - "gettxspendingprevout", "getmempoolinfo", + "getmerkleblocks", "getmininginfo", "getnettotals", "getnetworkhashps", @@ -141,23 +186,62 @@ const std::vector RPC_COMMANDS_SAFE_FOR_FUZZING{ "getnodeaddresses", "getpeerinfo", "getprioritisedtransactions", + "getquorumproofchain", "getrawaddrman", "getrawmempool", "getrawtransaction", + "getrawtransactionmulti", "getrpcinfo", + "getspecialtxes", + "getspentinfo", + "getsuperblockbudget", + "gettxchainlocks", "gettxout", "gettxoutsetinfo", "gettxspendingprevout", + "gobject check", + "gobject count", + "gobject deserialize", + "gobject diff", + "gobject get", + "gobject getcurrentvotes", + "gobject list", "help", "invalidateblock", "joinpsbts", "listbanned", "logging", + "masternode count", + "masternode list", + "masternode payments", + "masternode status", + "masternode winners", + "masternodelist", "mockscheduler", "ping", "preciousblock", "prioritisetransaction", + "protx", + "protx diff", + "protx info", + "protx list", + "protx listdiff", "pruneblockchain", + "quorum dkginfo", + "quorum dkgstatus", + "quorum getdata", + "quorum getrecsig", + "quorum hasrecsig", + "quorum info", + "quorum isconflicting", + "quorum list", + "quorum listextended", + "quorum memberof", + "quorum platformsign", + "quorum rotationinfo", + "quorum selectquorum", + "quorum sign", + "quorum verify", "reconsiderblock", "scanblocks", "scantxoutset", @@ -168,6 +252,7 @@ const std::vector RPC_COMMANDS_SAFE_FOR_FUZZING{ "setnetworkactive", "signmessagewithprivkey", "signrawtransactionwithkey", + "spork", "submitblock", "submitheader", "submitpackage", @@ -177,7 +262,10 @@ const std::vector RPC_COMMANDS_SAFE_FOR_FUZZING{ "utxoupdatepsbt", "validateaddress", "verifychain", + "verifychainlock", + "verifyislock", "verifymessage", + "verifyquorumproofchain", "verifytxoutproof", "waitforblock", "waitforblockheight", From 83c1f02d7d773d32040dd4ebc41657c0a658ea49 Mon Sep 17 00:00:00 2001 From: pasta Date: Fri, 13 Nov 2026 00:12:33 -0600 Subject: [PATCH 5/5] bench: cycle parallel BLS verification inputs Co-Authored-By: Claude Fable 5.2 --- src/bench/bls.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bench/bls.cpp b/src/bench/bls.cpp index 4e4cf76bda47..15deecc1a47c 100644 --- a/src/bench/bls.cpp +++ b/src/bench/bls.cpp @@ -327,10 +327,10 @@ static void BLS_Verify_BatchedParallel(benchmark::Bench& bench) blsWorker.Start(llmq::DEFAULT_WORKER_COUNT); // Benchmark. + size_t i = 0; bench.minEpochIterations(bench.output() ? 1000 : 1).run([&] { if (futures.size() < 100) { while (futures.size() < 10000) { - size_t i = 0; auto f = blsWorker.AsyncVerifySig(sigs[i], pubKeys[i], msgHashes[i], cancelCond); futures.emplace_back(i, std::move(f)); i = (i + 1) % pubKeys.size();