Skip to content
Closed
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: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ BITCOIN_CORE_H = \
netmessagemaker.h \
node/coin.h \
node/coinstats.h \
node/context.h \
node/transaction.h \
noui.h \
optional.h \
Expand Down Expand Up @@ -420,6 +421,7 @@ libdash_server_a_SOURCES = \
net_processing.cpp \
node/coin.cpp \
node/coinstats.cpp \
node/context.cpp \
node/transaction.cpp \
noui.cpp \
policy/fees.cpp \
Expand Down
11 changes: 10 additions & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ FUZZ_TARGETS = \
test/fuzz/partial_merkle_tree_deserialize \
test/fuzz/partially_signed_transaction_deserialize \
test/fuzz/prefilled_transaction_deserialize \
test/fuzz/process_message \
test/fuzz/psbt_input_deserialize \
test/fuzz/psbt_output_deserialize \
test/fuzz/pub_key_deserialize \
Expand Down Expand Up @@ -108,7 +109,9 @@ FUZZ_SUITE = \
test/fuzz/fuzz.cpp \
test/fuzz/fuzz.h \
test/fuzz/FuzzedDataProvider.h \
test/fuzz/util.h
test/fuzz/util.h \
test/util.cpp \
test/util.h

FUZZ_SUITE_LD_COMMON = \
$(LIBBITCOIN_SERVER) \
Expand Down Expand Up @@ -570,6 +573,12 @@ test_fuzz_prefilled_transaction_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAG
test_fuzz_prefilled_transaction_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(LDFLAGS_WRAP_EXCEPTIONS)
test_fuzz_prefilled_transaction_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)

test_fuzz_process_message_SOURCES = $(FUZZ_SUITE) test/fuzz/process_message.cpp
test_fuzz_process_message_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
test_fuzz_process_message_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
test_fuzz_process_message_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(LDFLAGS_WRAP_EXCEPTIONS)
test_fuzz_process_message_LDADD = $(FUZZ_SUITE_LD_COMMON)

test_fuzz_psbt_input_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
test_fuzz_psbt_input_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DPSBT_INPUT_DESERIALIZE=1
test_fuzz_psbt_input_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
Expand Down
1 change: 0 additions & 1 deletion src/banman.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,4 @@ class BanMan
const int64_t m_default_ban_time;
};

extern std::unique_ptr<BanMan> g_banman;
#endif
1 change: 1 addition & 0 deletions src/bench/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <regex>

const std::function<void(const std::string&)> G_TEST_LOG_FUN{};

namespace {

void GenerateTemplateResults(const std::vector<ankerl::nanobench::Result>& benchmarkResults, const std::string& filename, const char* tpl)
Expand Down
6 changes: 4 additions & 2 deletions src/bench/block_assemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <consensus/validation.h>
#include <script/standard.h>
#include <test/util.h>
#include <test/util/setup_common.h>
#include <txmempool.h>
#include <validation.h>

Expand All @@ -15,6 +16,7 @@

static void AssembleBlock(benchmark::Bench& bench)
{
RegTestingSetup test_setup;
const CScript redeemScript = CScript() << OP_DROP << OP_TRUE;
const CScript SCRIPT_PUB =
CScript() << OP_HASH160 << ToByteVector(CScriptID(redeemScript))
Expand All @@ -28,7 +30,7 @@ static void AssembleBlock(benchmark::Bench& bench)
std::array<CTransactionRef, NUM_BLOCKS - COINBASE_MATURITY + 1> txs;
for (size_t b{0}; b < NUM_BLOCKS; ++b) {
CMutableTransaction tx;
tx.vin.push_back(MineBlock(SCRIPT_PUB));
tx.vin.push_back(MineBlock(test_setup.m_node, SCRIPT_PUB));
tx.vin.back().scriptSig = scriptSig;
tx.vout.emplace_back(1337, SCRIPT_PUB);
if (NUM_BLOCKS - b >= COINBASE_MATURITY)
Expand All @@ -45,7 +47,7 @@ static void AssembleBlock(benchmark::Bench& bench)
}

bench.minEpochIterations(700).run([&] {
PrepareBlock(SCRIPT_PUB);
PrepareBlock(test_setup.m_node, SCRIPT_PUB);
});
}

Expand Down
4 changes: 4 additions & 0 deletions src/bench/ccoins_caching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ SetupDummyInputs(CBasicKeyStore& keystoreRet, CCoinsViewCache& coinsRet)
// (https://github.com/bitcoin/bitcoin/issues/7883#issuecomment-224807484)
static void CCoinsCaching(benchmark::Bench& bench)
{
const ECCVerifyHandle verify_handle;
ECC_Start();

CBasicKeyStore keystore;
CCoinsView coinsDummy;
CCoinsViewCache coins(&coinsDummy);
Expand Down Expand Up @@ -83,6 +86,7 @@ static void CCoinsCaching(benchmark::Bench& bench)
CAmount value = coins.GetValueIn(tx_1);
assert(value == (50 + 21 + 22) * COIN);
});
ECC_Stop();
}

BENCHMARK(CCoinsCaching);
8 changes: 7 additions & 1 deletion src/bench/checkqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
#include <bench/bench.h>
#include <util/system.h>
#include <checkqueue.h>
#include <key.h>
#include <prevector.h>
#include <vector>
#include <pubkey.h>
#include <random.h>

#include <vector>

static const size_t BATCHES = 101;
static const size_t BATCH_SIZE = 30;
Expand All @@ -20,6 +22,9 @@ static const unsigned int QUEUE_BATCH_SIZE = 128;
// and there is a little bit of work done between calls to Add.
static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
{
const ECCVerifyHandle verify_handle;
ECC_Start();

struct PrevectorJob {
prevector<PREVECTOR_SIZE, uint8_t> p;
PrevectorJob(){
Expand Down Expand Up @@ -59,5 +64,6 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
control.Wait();
});
queue.StopWorkerThreads();
ECC_Stop();
}
BENCHMARK(CCheckQueueSpeedPrevectorJob);
11 changes: 7 additions & 4 deletions src/bench/coin_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <bench/bench.h>
#include <interfaces/chain.h>
#include <node/context.h>
#include <wallet/coinselection.h>
#include <wallet/wallet.h>

Expand All @@ -28,8 +29,9 @@ static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<st
// (https://github.com/bitcoin/bitcoin/issues/7883#issuecomment-224807484)
static void CoinSelection(benchmark::Bench& bench)
{
auto chain = interfaces::MakeChain();
const CWallet wallet(*chain, WalletLocation(), CreateDummyWalletDatabase());
NodeContext node;
auto chain = interfaces::MakeChain(node);
const CWallet wallet(chain.get(), WalletLocation(), CreateDummyWalletDatabase());
std::vector<std::unique_ptr<CWalletTx>> wtxs;
LOCK(wallet.cs_wallet);

Expand Down Expand Up @@ -59,8 +61,9 @@ static void CoinSelection(benchmark::Bench& bench)
}

typedef std::set<CInputCoin> CoinSet;
static auto testChain = interfaces::MakeChain();
static const CWallet testWallet(*testChain, WalletLocation(), CreateDummyWalletDatabase());
static NodeContext testNode;
static auto testChain = interfaces::MakeChain(testNode);
static const CWallet testWallet(testChain.get(), WalletLocation(), CreateDummyWalletDatabase());
std::vector<std::unique_ptr<CWalletTx>> wtxn;

// Copied from src/wallet/test/coinselector_tests.cpp
Expand Down
3 changes: 3 additions & 0 deletions src/bench/duplicate_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
#include <consensus/validation.h>
#include <policy/policy.h>
#include <pow.h>
#include <test/util/setup_common.h>
#include <txmempool.h>
#include <validation.h>



static void DuplicateInputs(benchmark::Bench& bench)
{
RegTestingSetup test_setup;

const CScript SCRIPT_PUB{CScript(OP_TRUE)};

const CChainParams& chainparams = Params();
Expand Down
3 changes: 3 additions & 0 deletions src/bench/mempool_eviction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <bench/bench.h>
#include <policy/policy.h>
#include <test/util/setup_common.h>
#include <txmempool.h>


Expand All @@ -24,6 +25,8 @@ static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& po
// unique transactions for a more meaningful performance measurement.
static void MempoolEviction(benchmark::Bench& bench)
{
RegTestingSetup test_setup;

CMutableTransaction tx1 = CMutableTransaction();
tx1.vin.resize(1);
tx1.vin[0].scriptSig = CScript() << OP_1;
Expand Down
2 changes: 2 additions & 0 deletions src/bench/mempool_stress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <bench/bench.h>
#include <policy/policy.h>
#include <test/util/setup_common.h>
#include <txmempool.h>

#include <vector>
Expand Down Expand Up @@ -82,6 +83,7 @@ static void ComplexMemPool(benchmark::Bench& bench)
ordered_coins.emplace_back(MakeTransactionRef(tx));
available_coins.emplace_back(ordered_coins.back(), tx_counter++);
}
TestingSetup test_setup;
CTxMemPool pool;
LOCK2(cs_main, pool.cs);
bench.run([&]() NO_THREAD_SAFETY_ANALYSIS {
Expand Down
12 changes: 8 additions & 4 deletions src/bench/wallet_balance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@

#include <bench/bench.h>
#include <interfaces/chain.h>
#include <node/context.h>
#include <test/util.h>
#include <test/util/setup_common.h>
#include <validationinterface.h>
#include <wallet/wallet.h>

#include <optional>

static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const bool add_watchonly, const bool add_mine, const uint32_t epoch_iters)
{
RegTestingSetup test_setup;
const auto& ADDRESS_WATCHONLY = ADDRESS_B58T_UNSPENDABLE;

std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain();
CWallet wallet{*chain.get(), WalletLocation(), CreateMockWalletDatabase()};
NodeContext node;
std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain(node);
CWallet wallet{chain.get(), WalletLocation(), CreateMockWalletDatabase()};
{
bool first_run;
if (wallet.LoadWallet(first_run) != DBErrors::LOAD_OK) assert(false);
Expand All @@ -27,8 +31,8 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
if (add_watchonly) importaddress(wallet, ADDRESS_WATCHONLY);

for (int i = 0; i < 100; ++i) {
generatetoaddress(address_mine.value_or(ADDRESS_WATCHONLY));
generatetoaddress(ADDRESS_WATCHONLY);
generatetoaddress(test_setup.m_node, address_mine.value_or(ADDRESS_WATCHONLY));
generatetoaddress(test_setup.m_node, ADDRESS_WATCHONLY);
}
SyncWithValidationInterfaceQueue();

Expand Down
4 changes: 4 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ class CMainParams : public CChainParams {
fAllowMultipleAddressesFromGroup = false;
fAllowMultiplePorts = false;
nLLMQConnectionRetryTimeout = 60;
m_is_mockable_chain = false;

nPoolMinParticipants = 3;
nPoolMaxParticipants = 20;
Expand Down Expand Up @@ -528,6 +529,7 @@ class CTestNetParams : public CChainParams {
fAllowMultipleAddressesFromGroup = false;
fAllowMultiplePorts = true;
nLLMQConnectionRetryTimeout = 60;
m_is_mockable_chain = false;

nPoolMinParticipants = 2;
nPoolMaxParticipants = 20;
Expand Down Expand Up @@ -727,6 +729,7 @@ class CDevNetParams : public CChainParams {
fAllowMultipleAddressesFromGroup = true;
fAllowMultiplePorts = true;
nLLMQConnectionRetryTimeout = 60;
m_is_mockable_chain = false;

nPoolMinParticipants = 2;
nPoolMaxParticipants = 20;
Expand Down Expand Up @@ -912,6 +915,7 @@ class CRegTestParams : public CChainParams {
fAllowMultipleAddressesFromGroup = true;
fAllowMultiplePorts = true;
nLLMQConnectionRetryTimeout = 1; // must be lower then the LLMQ signing session timeout so that tests have control over failing behavior
m_is_mockable_chain = true;

nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes
nPoolMinParticipants = 2;
Expand Down
3 changes: 3 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class CChainParams
bool RequireStandard() const { return fRequireStandard; }
/** Require addresses specified with "-externalip" parameter to be routable */
bool RequireRoutableExternalIP() const { return fRequireRoutableExternalIP; }
/** If this chain allows time to be mocked */
bool IsMockableChain() const { return m_is_mockable_chain; }
/** If this chain is exclusively used for testing */
bool IsTestChain() const { return m_is_test_chain; }
uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
Expand Down Expand Up @@ -133,6 +135,7 @@ class CChainParams
bool m_is_test_chain;
bool fAllowMultipleAddressesFromGroup;
bool fAllowMultiplePorts;
bool m_is_mockable_chain;
int nLLMQConnectionRetryTimeout;
CCheckpointData checkpointData;
ChainTxData chainTxData;
Expand Down
17 changes: 9 additions & 8 deletions src/dashd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <compat.h>
#include <init.h>
#include <interfaces/chain.h>
#include <node/context.h>
#include <noui.h>
#include <shutdown.h>
#include <util/system.h>
Expand All @@ -24,13 +25,13 @@

const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;

static void WaitForShutdown()
static void WaitForShutdown(NodeContext& node)
{
while (!ShutdownRequested())
{
UninterruptibleSleep(std::chrono::milliseconds{200});
}
Interrupt();
Interrupt(node);
}

//////////////////////////////////////////////////////////////////////////////
Expand All @@ -39,8 +40,8 @@ static void WaitForShutdown()
//
static bool AppInit(int argc, char* argv[])
{
InitInterfaces interfaces;
interfaces.chain = interfaces::MakeChain();
NodeContext node;
node.chain = interfaces::MakeChain(node);

bool fRet = false;

Expand Down Expand Up @@ -161,18 +162,18 @@ static bool AppInit(int argc, char* argv[])
// If locking the data directory failed, exit immediately
return false;
}
fRet = AppInitMain(interfaces);
fRet = AppInitMain(node);
} catch (...) {
PrintExceptionContinue(std::current_exception(), "AppInit()");
}

if (!fRet)
{
Interrupt();
Interrupt(node);
} else {
WaitForShutdown();
WaitForShutdown(node);
}
Shutdown(interfaces);
Shutdown(node);

return fRet;
}
Expand Down
4 changes: 2 additions & 2 deletions src/dsnotificationinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ void CDSNotificationInterface::BlockDisconnected(const std::shared_ptr<const CBl
CCoinJoin::BlockDisconnected(pblock, pindexDisconnected);
}

void CDSNotificationInterface::NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff)
void CDSNotificationInterface::NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff, CConnman& connman)
{
CMNAuth::NotifyMasternodeListChanged(undo, oldMNList, diff);
CMNAuth::NotifyMasternodeListChanged(undo, oldMNList, diff, connman);
governance.UpdateCachesAndClean();
}

Expand Down
2 changes: 1 addition & 1 deletion src/dsnotificationinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CDSNotificationInterface : public CValidationInterface
void TransactionRemovedFromMempool(const CTransactionRef& ptx, MemPoolRemovalReason reason) override;
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted) override;
void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected) override;
void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff) override;
void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff, CConnman& connman) override;
void NotifyChainLock(const CBlockIndex* pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion src/dummywallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DummyWalletInit : public WalletInitInterface {
bool HasWalletSupport() const override {return false;}
void AddWalletOptions() const override;
bool ParameterInteraction() const override {return true;}
void Construct(InitInterfaces& interfaces) const override {LogPrintf("No wallet support compiled in!\n");}
void Construct(NodeContext& node) const override {LogPrintf("No wallet support compiled in!\n");}

// Dash Specific WalletInitInterface InitCoinJoinSettings
void AutoLockMasternodeCollaterals() const override {}
Expand Down
Loading