Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/bench/bls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ static RPCHelpMan masternode_winners()

if (!request.params[0].isNull()) {
nCount = request.params[0].getInt<int>();
if (nCount < 0) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative count");
}
}

if (!request.params[1].isNull()) {
Expand Down
4 changes: 3 additions & 1 deletion src/rpc/quorums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)};
Expand Down
92 changes: 90 additions & 2 deletions src/test/fuzz/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <base58.h>
#include <governance/governance.h>
#include <key.h>
#include <key_io.h>
#include <primitives/block.h>
Expand Down Expand Up @@ -41,6 +42,9 @@ namespace {
struct RPCFuzzTestingSetup : public TestingSetup {
RPCFuzzTestingSetup(const ChainType chain_type, const std::vector<const char*>& extra_args) : TestingSetup{chain_type, extra_args}
{
m_node.govman = std::make_unique<CGovernanceManager>(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<std::string>& arguments)
Expand All @@ -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<std::string> 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;
}
Expand All @@ -72,25 +84,42 @@ const std::vector<std::string> 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<std::string> RPC_COMMANDS_SAFE_FOR_FUZZING{
"analyzepsbt",
"bls",
"bls fromsecret",
"bls generate",
"clearbanned",
"cleardiscouraged",
"combinepsbt",
"combinerawtransaction",
"converttopsbt",
Expand All @@ -107,57 +136,112 @@ const std::vector<std::string> 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",
"getnetworkinfo",
"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",
Comment thread
PastaPastaPasta marked this conversation as resolved.
Resolved
"protx listdiff",
"pruneblockchain",
"quorum dkginfo",
"quorum dkgstatus",
"quorum getdata",
"quorum getrecsig",
"quorum hasrecsig",
"quorum info",
"quorum isconflicting",
"quorum list",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
"quorum listextended",
"quorum memberof",
"quorum platformsign",
"quorum rotationinfo",
"quorum selectquorum",
"quorum sign",
"quorum verify",
"reconsiderblock",
"scanblocks",
"scantxoutset",
Expand All @@ -168,6 +252,7 @@ const std::vector<std::string> RPC_COMMANDS_SAFE_FOR_FUZZING{
"setnetworkactive",
"signmessagewithprivkey",
"signrawtransactionwithkey",
"spork",
"submitblock",
"submitheader",
"submitpackage",
Expand All @@ -177,7 +262,10 @@ const std::vector<std::string> RPC_COMMANDS_SAFE_FOR_FUZZING{
"utxoupdatepsbt",
"validateaddress",
"verifychain",
"verifychainlock",
"verifyislock",
"verifymessage",
"verifyquorumproofchain",
"verifytxoutproof",
"waitforblock",
"waitforblockheight",
Expand Down
6 changes: 3 additions & 3 deletions src/test/fuzz/tx_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)};
Expand All @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion test/functional/feature_llmq_evo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)


Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions test/functional/rpc_verifyislock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading