Commit Graph

463 Commits

Author SHA1 Message Date
PastaPastaPasta
40c259bdf3
fix: resolve numerous compilation warnings under -Wall (#4599)
* fix: compilation warnings

./validation.h:266:13: warning: ‘bool AcceptToMemoryPoolWithTime(const CChainParams&, CTxMemPool&, CValidationState&, const CTransactionRef&, bool*, int64_t, bool, CAmount, bool)’ declared ‘static’ but never defined [-Wunused-function]
 static bool AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPool& pool, CValidationState &state, const CTransactionRef &tx,
             ^~~~~~~~~~~~~~~~~~~~~~~~~~

* fix: compilation warnings

./coinjoin/client.h: In constructor ‘CCoinJoinClientManager::CCoinJoinClientManager(CWallet&)’:
./coinjoin/client.h:199:10: warning: ‘CCoinJoinClientManager::fCreateAutoBackups’ will be initialized after [-Wreorder]
     bool fCreateAutoBackups; // builtin support for automatic backups
          ^~~~~~~~~~~~~~~~~~
./coinjoin/client.h:187:14: warning:   ‘CWallet& CCoinJoinClientManager::mixingWallet’ [-Wreorder]
     CWallet& mixingWallet;
              ^~~~~~~~~~~~
./coinjoin/client.h:205:14: warning:   when initialized here [-Wreorder]
     explicit CCoinJoinClientManager(CWallet& wallet) :
              ^~~~~~~~~~~~~~~~~~~~~~

* fix: compilation warnings

interfaces/wallet.cpp: In constructor ‘interfaces::{anonymous}::WalletImpl::WalletImpl(const std::shared_ptr<CWallet>&)’:
interfaces/wallet.cpp:594:30: warning: ‘interfaces::{anonymous}::WalletImpl::m_wallet’ will be initialized after [-Wreorder]
     std::shared_ptr<CWallet> m_wallet;
                              ^~~~~~~~
interfaces/wallet.cpp:191:18: warning:   ‘interfaces::{anonymous}::CoinJoinImpl interfaces::{anonymous}::WalletImpl::m_coinjoin’ [-Wreorder]
     CoinJoinImpl m_coinjoin;
                  ^~~~~~~~~~
interfaces/wallet.cpp:193:14: warning:   when initialized here [-Wreorder]
     explicit WalletImpl(const std::shared_ptr<CWallet>& wallet) : m_wallet(wallet), m_coinjoin(wallet) {}
              ^~~~~~~~~~

* fix: compilation warnings

validation.cpp:165:13: warning: ‘void CheckBlockIndex(const Consensus::Params&)’ declared ‘static’ but never defined [-Wunused-function]
 static void CheckBlockIndex(const Consensus::Params& consensusParams);
             ^~~~~~~~~~~~~~~

* fix: compilation warnings

bls/bls_worker.cpp: In constructor ‘ContributionVerifier::ContributionVerifier(CBLSId, const std::vector<std::shared_ptr<std::vector<CBLSPublicKey> > >&, const BLSSecretKeyVector&, size_t, bool, bool, ctpl::thread_pool&, std::function<void(const std::vector<bool>&)>)’:
bls/bls_worker.cpp:425:51: warning: ‘ContributionVerifier::doneCallback’ will be initialized after [-Wreorder]
     std::function<void(const std::vector<bool>&)> doneCallback;
                                                   ^~~~~~~~~~~~
bls/bls_worker.cpp:420:12: warning:   ‘size_t ContributionVerifier::batchCount’ [-Wreorder]
     size_t batchCount;
            ^~~~~~~~~~
bls/bls_worker.cpp:427:5: warning:   when initialized here [-Wreorder]
     ContributionVerifier(CBLSId _forId, const std::vector<BLSVerificationVectorPtr>& _vvecs,
     ^~~~~~~~~~~~~~~~~~~~

* fix: compilation warnings

bls/bls_worker.cpp:342:10: warning: ‘VectorAggregator<CBLSPublicKey>::parallel’ will be initialized after [-Wreorder]
     bool parallel;
          ^~~~~~~~
bls/bls_worker.cpp:340:12: warning:   ‘size_t VectorAggregator<CBLSPublicKey>::start’ [-Wreorder]
     size_t start;
            ^~~~~
bls/bls_worker.cpp:350:5: warning:   when initialized here [-Wreorder]
     VectorAggregator(const VectorVectorType& _vecs,
     ^~~~~~~~~~~~~~~~
bls/bls_worker.cpp:343:24: warning: ‘VectorAggregator<CBLSPublicKey>::workerPool’ will be initialized after [-Wreorder]
     ctpl::thread_pool& workerPool;
                        ^~~~~~~~~~
bls/bls_worker.cpp:337:18: warning:   ‘VectorAggregator<CBLSPublicKey>::DoneCallback VectorAggregator<CBLSPublicKey>::doneCallback’ [-Wreorder]
     DoneCallback doneCallback;
                  ^~~~~~~~~~~~
bls/bls_worker.cpp:350:5: warning:   when initialized here [-Wreorder]
     VectorAggregator(const VectorVectorType& _vecs,
     ^~~~~~~~~~~~~~~~

* fix: compilation warnings

bls/bls_worker.cpp:494:235:   required from here
bls/bls_worker.cpp:136:24: warning: ‘Aggregator<CBLSSecretKey>::workerPool’ will be initialized after [-Wreorder]
     ctpl::thread_pool& workerPool;
                        ^~~~~~~~~~
bls/bls_worker.cpp:135:10: warning:   ‘bool Aggregator<CBLSSecretKey>::parallel’ [-Wreorder]
     bool parallel;
          ^~~~~~~~
bls/bls_worker.cpp:152:5: warning:   when initialized here [-Wreorder]
     Aggregator(const std::vector<TP>& _inputVec,
     ^~~~~~~~~~

* fix: compilation warnings

bench/string_cast.cpp: In lambda function:
bench/string_cast.cpp:22:13: warning: statement has no effect [-Wunused-value]
         atoi("1");
         ~~~~^~~~~

* fix: compilation warnings

./llmq/dkgsessionhandler.h: In constructor ‘llmq::CDKGPendingMessages::CDKGPendingMessages(size_t, int)’:
./llmq/dkgsessionhandler.h:48:12: warning: ‘llmq::CDKGPendingMessages::maxMessagesPerNode’ will be initialized after [-Wreorder]
     size_t maxMessagesPerNode GUARDED_BY(cs);
            ^~~~~~~~~~~~~~~~~~
./llmq/dkgsessionhandler.h:47:15: warning:   ‘const int llmq::CDKGPendingMessages::invType’ [-Wreorder]
     const int invType;
               ^~~~~~~
llmq/dkgsessionhandler.cpp:23:1: warning:   when initialized here [-Wreorder]
 CDKGPendingMessages::CDKGPendingMessages(size_t _maxMessagesPerNode, int _invType) :
 ^~~~~~~~~~~~~~~~~~~

* fix: compilation warnings

Not sure this one is correct, but I believe so. Seems like the `!= 0` is completely not needed

rpc/masternode.cpp: In function ‘UniValue masternode_payments(const JSONRPCRequest&)’:
rpc/masternode.cpp:442:31: warning: suggest parentheses around comparison in operand of ‘!=’ [-Wparentheses]
     while (vecPayments.size() < std::abs(nCount) != 0 && pindex != nullptr) {
            ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~

* fix: compilation warnings

test/cachemultimap_tests.cpp:14:13: warning: ‘void cachemultimap_tests::DumpMap(const CacheMultiMap<int, int>&)’ defined but not used [-Wunused-function]
 static void DumpMap(const CacheMultiMap<int,int>& cmmap)
             ^~~~~~~

* fix: compilation warnings

In file included from qt/appearancewidget.cpp:11:
./qt/appearancewidget.h: In constructor ‘AppearanceWidget::AppearanceWidget(QWidget*)’:
./qt/appearancewidget.h:52:25: warning: ‘AppearanceWidget::prevFontFamily’ will be initialized after [-Wreorder]
     GUIUtil::FontFamily prevFontFamily;
                         ^~~~~~~~~~~~~~
./qt/appearancewidget.h:51:9: warning:   ‘int AppearanceWidget::prevScale’ [-Wreorder]
     int prevScale;
         ^~~~~~~~~
qt/appearancewidget.cpp:21:1: warning:   when initialized here [-Wreorder]
 AppearanceWidget::AppearanceWidget(QWidget* parent) :
 ^~~~~~~~~~~~~~~~

* fix: compilation warnings

In file included from qt/bitcoingui.cpp:6:
./qt/bitcoingui.h: In constructor ‘BitcoinGUI::BitcoinGUI(interfaces::Node&, const NetworkStyle*, QWidget*)’:
./qt/bitcoingui.h:212:31: warning: ‘BitcoinGUI::m_network_style’ will be initialized after [-Wreorder]
     const NetworkStyle* const m_network_style;
                               ^~~~~~~~~~~~~~~
./qt/bitcoingui.h:172:34: warning:   ‘const std::unique_ptr<QMenu> BitcoinGUI::trayIconMenu’ [-Wreorder]
     const std::unique_ptr<QMenu> trayIconMenu;
                                  ^~~~~~~~~~~~
qt/bitcoingui.cpp:81:1: warning:   when initialized here [-Wreorder]
 BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle, QWidget* parent) :
 ^~~~~~~~~~

* fix: compilation warnings

In file included from qt/masternodelist.cpp:1:
./qt/masternodelist.h: In constructor ‘MasternodeList::MasternodeList(QWidget*)’:
./qt/masternodelist.h:66:18: warning: ‘MasternodeList::walletModel’ will be initialized after [-Wreorder]
     WalletModel* walletModel;
                  ^~~~~~~~~~~
./qt/masternodelist.h:61:10: warning:   ‘bool MasternodeList::fFilterUpdatedDIP3’ [-Wreorder]
     bool fFilterUpdatedDIP3;
          ^~~~~~~~~~~~~~~~~~
qt/masternodelist.cpp:45:1: warning:   when initialized here [-Wreorder]
 MasternodeList::MasternodeList(QWidget* parent) :
 ^~~~~~~~~~~~~~
In file included from qt/masternodelist.cpp:1:
./qt/masternodelist.h:61:10: warning: ‘MasternodeList::fFilterUpdatedDIP3’ will be initialized after [-Wreorder]
     bool fFilterUpdatedDIP3;
          ^~~~~~~~~~~~~~~~~~
./qt/masternodelist.h:59:13: warning:   ‘int64_t MasternodeList::nTimeFilterUpdatedDIP3’ [-Wreorder]
     int64_t nTimeFilterUpdatedDIP3;
             ^~~~~~~~~~~~~~~~~~~~~~
qt/masternodelist.cpp:45:1: warning:   when initialized here [-Wreorder]
 MasternodeList::MasternodeList(QWidget* parent) :
 ^~~~~~~~~~~~~~

* fix: compilation warnings

In file included from qt/paymentserver.cpp:10:
./qt/paymentserver.h: In constructor ‘PaymentServer::PaymentServer(QObject*, bool)’:
./qt/paymentserver.h:156:28: warning: ‘PaymentServer::netManager’ will be initialized after [-Wreorder]
     QNetworkAccessManager* netManager;  // Used to fetch payment requests
                            ^~~~~~~~~~
./qt/paymentserver.h:147:19: warning:   ‘OptionsModel* PaymentServer::optionsModel’ [-Wreorder]
     OptionsModel *optionsModel;
                   ^~~~~~~~~~~~
qt/paymentserver.cpp:197:1: warning:   when initialized here [-Wreorder]
 PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) :
 ^~~~~~~~~~~~~
2021-12-01 22:59:34 +03:00
UdjinM6
3b8b3e254a
instantsend: Do not consider islocks with unknown txes as complete (#4147)
* instantsend: Avoid writing IS locks for unknown txes

* instantsend: Allow a competing tx into mempool if there is an islock waiting for it

* use try_emplace

* Hold cs_main while calling ResetBlockFailureFlags
2021-11-30 14:14:08 +03:00
PastaPastaPasta
b9e1d3cb11
fix: add missing optional include (#4595) 2021-11-30 08:03:17 +03:00
PastaPastaPasta
b8c560479e
refactor: misc refactoring prefer std algorithm, range for loops; fix broken loop (#4593)
* fix: replace seemingly buggy loop with std::adjacent_find

* Remove redundant variable declaration

* use std::fill instead of a loop

* remove a few raw for loops
2021-11-30 08:03:08 +03:00
PastaPastaPasta
5cf97c1b07
refactor: Misc LLMQ refactoring (#4590)
* use unique_ptr instead of shared

Signed-off-by: pasta <pasta@dashboost.org>

* unique_ptr over shared_ptr

Signed-off-by: pasta <pasta@dashboost.org>

* remove unneeded ptr

Signed-off-by: pasta <pasta@dashboost.org>

* Adjust IsTxSafeForMining checks

Signed-off-by: pasta <pasta@dashboost.org>

* use const ref

Signed-off-by: pasta <pasta@dashboost.org>

* add a todo

Signed-off-by: pasta <pasta@dashboost.org>

* use optional instead of magic max value

fixes a hypothetical bug where myIdx is not "initialized" (ie max), and we sleep forever

Signed-off-by: pasta <pasta@dashboost.org>

* simplify relay check

Signed-off-by: pasta <pasta@dashboost.org>

* use count_if instead of a loop

Signed-off-by: pasta <pasta@dashboost.org>

* add a few vector reserves

Signed-off-by: pasta <pasta@dashboost.org>
2021-11-29 08:12:09 +03:00
PastaPastaPasta
850806e6e7
chainlocks: fix atomicity in chainlock signing scheduler (#4589)
Signed-off-by: pasta <pasta@dashboost.org>
2021-11-29 08:06:50 +03:00
PastaPastaPasta
fec2d25094
Simplify the interface for CRecoveredSig (#4587)
Signed-off-by: pasta <pasta@dashboost.org>
2021-11-29 08:00:47 +03:00
UdjinM6
35f8ed4d80
instantsend: various fixes (#4553)
* Handle attempts to read non-existent records from isdb properly

* Do not reject blocks that conflict with islocks while still syncing

Otherwise you can stuck with no new blocks/headers which means you won't be able to verify new chainlocks that might override stored islocks

* Handle duplicates/conflicting islocks better

* More constness
2021-11-11 16:15:18 +03:00
UdjinM6
42fb46d470
Fix block index inconsistency in MarkConflictingBlock()
Same idea as in 16849
2021-10-29 16:29:53 +03:00
Wladimir J. van der Laan
6f0646a262
Merge #15402: Granular invalidateblock and RewindBlockIndex
519b0bc5dc5155b6f7e2362c2105552bb7618ad0 Make last disconnected block BLOCK_FAILED_VALID, even when aborted (Pieter Wuille)
8d220417cd7bc34464e28a4861a885193ec091c2 Optimization: don't add txn back to mempool after 10 invalidates (Pieter Wuille)
9ce9c37004440d6a329874dbf66b51666d497dcb Prevent callback overruns in InvalidateBlock and RewindBlockIndex (Pieter Wuille)
9bb32eb571a846b66ed3bac493f55cee11a3a1b9 Release cs_main during InvalidateBlock iterations (Pieter Wuille)
9b1ff5c742dec0a6e0d6aab29b0bb771ad6d8135 Call InvalidateBlock without cs_main held (Pieter Wuille)
241b2c74ac8c4c3000e778554da1271e3f293e5d Make RewindBlockIndex interruptible (Pieter Wuille)
880ce7d46b51835c00d77a366ec28f54a05239df Call RewindBlockIndex without cs_main held (Pieter Wuille)
436f7d735f1c37e77d42ff59d4cbb1bd76d5fcfb Release cs_main during RewindBlockIndex operation (Pieter Wuille)
1d342875c21b5d0a17cf4d176063bb14b35b657e Merge the disconnection and erasing loops in RewindBlockIndex (Pieter Wuille)
32b2696ab4b079db736074b57bbc24deaee0b3d9 Move erasure of non-active blocks to a separate loop in RewindBlockIndex (Pieter Wuille)
9d6dcc52c6cb0cdcda220fddccaabb0ffd40068d Abstract EraseBlockData out of RewindBlockIndex (Pieter Wuille)

Pull request description:

  This PR makes a number of improvements to the InvalidateBlock (`invalidateblock` RPC) and RewindBlockIndex functions, primarily around breaking up their long-term cs_main holding. In addition:
  * They're made safely interruptible (`bitcoind` can be shutdown, and no progress in either will be lost, though if incomplete, `invalidateblock` won't continue after restart and will need to be called again)
  * The validation queue is prevented from overflowing (meaning `invalidateblock` on a very old block will not drive bitcoind OOM) (see #14289).
  * `invalidateblock` won't bother to move transactions back into the mempool after 10 blocks (optimization).

  This is not an optimal solution, as we're relying on the scheduler call sites to make sure the scheduler doesn't overflow. Ideally, the scheduler would guarantee this directly, but that needs a few further changes (moving the signal emissions out of cs_main) to prevent deadlocks.

  I have manually tested the `invalidateblock` changes (including interrupting, and running with -checkblockindex and -checkmempool), but haven't tried the rewinding (which is probably becoming increasingly unnecessary, as very few pre-0.13.1 nodes remain that would care to upgrade).

Tree-SHA512: 692e42758bd3d3efc2eb701984a8cb5db25fbeee32e7575df0183a00d0c2c30fdf72ce64c7625c32ad8c8bdc56313da72a7471658faeb0d39eefe39c4b8b8474
2021-10-29 16:29:49 +03:00
PastaPastaPasta
5781bd5ee3
refactor: more llmq refactoring (#4552)
* replace raw owning ptr with unique ptr

Signed-off-by: pasta <pasta@dashboost.org>

* Add GUARDED_BY annotation to llmq_versionbitscache

Signed-off-by: pasta <pasta@dashboost.org>

* limit scope of locking cs_llmq_vbc

Signed-off-by: pasta <pasta@dashboost.org>

* use llmq_versionbitscache instead of versionbitscache in UpdatedBlockTip to avoid cs_main locking

Signed-off-by: pasta <pasta@dashboost.org>

* drop unneeded cs_main ::mempool.cs

* lock cs_main and mempool.cs in Db::Upgrade
2021-10-28 22:11:34 +03:00
PastaPastaPasta
a0b68ca856
refactor: minimize passing around llmqType just to search for LLMQParams (#4551)
* minimize passing around llmqType just to search for LLMQParams

* more

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-10-28 22:10:43 +03:00
UdjinM6
95262de6b1
Fix potential deadlock in CInstantSendDb::Upgrade() (#4548) 2021-10-26 22:50:09 +03:00
Odysseas Gabrielides
c151ccaf1a
Rename variables for better clarity (#4544)
* Rename variables for better clarity

* Various changes

* Update src/llmq/blockprocessor.cpp

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-10-26 12:08:38 -04:00
PastaPastaPasta
7b78390015
refactor: Include adjustments (#4526)
* include adjustments

* fix macOs build failure

Signed-off-by: pasta <pasta@dashboost.org>

* expcitly include array in spork.h

* sort includes in most files
2021-10-25 16:55:34 +03:00
Kittywhiskers Van Gogh
f1a2cdb680
merge bitcoin#15855: Add missing LockAnnotation for cs_main (#4530)
* merge bitcoin#15855: Add missing LockAnnotation for cs_main

* mutex: update cs_main locks, assertions and annotations

This commit is a squash between 8c98823 and 90d0535
2021-10-25 16:14:34 +03:00
Kittywhiskers Van Gogh
a620d941d3 merge bitcoin#16194: share blockmetadata with BlockManager
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-10-22 08:15:38 +05:30
Kittywhiskers Van Gogh
1f436f8aee merge bitcoin#15948: rename chainActive
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-10-22 08:15:22 +05:30
Wladimir J. van der Laan
d0724b5ee1
Merge #13258: uint256: Remove unnecessary crypto/common.h dependency
bf2e01097 uint256: Remove unnecessary crypto/common.h use (Karl-Johan Alm)

Pull request description:

  This is an alternative to #13242 which keeps the `ReadLE64` part, but moves the `crypto/common.h` dependency into `crypto/common.h` as a function outside of `uint256`.

  **Reason:** this change will remove dependencies for `uint256` to `crypto/common.h`, `compat/endian.h`, and `compat/byteswap.h`.

  This PR removes the need to update tests to be endian-aware/-independent, but keeps the (arguably dubious) `ReadLE64` part (which was only introduced to fix the tests, not for any functionality).

Tree-SHA512: 78b35123cdb185b3b3ec59aba5ca8a5db72624d147f2d6a5484ffa5ce626a72f782a01dc6893fc8f5619b03e2eae7b5a03b0df5d43460f3bda428e719e188aec
2021-10-21 17:41:33 +05:30
PastaPastaPasta
1d457affaa
refactor: misc refactoring in signing_shares.* (#4522)
* refactor: introduce PendingSignatureData

* refactor: explicitly capture in lambdas

* refactor: use structured bindings

* refactor: use more const

* refactor: remove unused include header

* refactor: use if-init

* refactor: add nodiscard

* refactor: initialize llmqType

* refactor: add override

* refactor: remove redundant specifiers

* refactor: prevent shadowing

* refactor: use try_emplace where possible

* refactor: use more accurate name
2021-10-15 21:38:56 +03:00
UdjinM6
ea8d4c26b6
refactor: more LLMQ params related refactoring (#4517)
* refactor: Turn LLMQType into `enum class`

* refactor: Simplify/make LLMQ additions safer

* refactor: Move `is_serializable_enum<Consensus::LLMQType>` to `src/llmq/params.h`

* refactor: Add missing include

* refactor: Add missing comment

* Use `static_cast`

* make available_llmqs constexpr array

Signed-off-by: pasta <pasta@dashboost.org>

* cleanup/fixes

Co-authored-by: pasta <pasta@dashboost.org>
2021-10-15 13:28:19 +03:00
PastaPastaPasta
89e0ccc3dd
llmq: move more llmq params into llmq/params.h remove llmq/params.cpp, use string_view and constexpr (#4500)
string_view is needed for compile time interpretation (constexpr) of the LLMQParams

constexpr is good to add such that we aren't initializing in static scope, but instead at compile time

Sadly using string_view will require that we construct a std::string when passing into univalue, however, this isn't in a performance important section (rpc) and as such another allocation is an okay trade off for the benefits of constexpr

Also, now we aren't having extern variables, which should make the linker mildly happier

Signed-off-by: pasta <pasta@dashboost.org>
2021-10-11 20:11:08 +03:00
PastaPastaPasta
501cdaa91b
refac: use make_unique and constexpr (#4493)
* use make_unique

* use constexpr everywhere possible in dash code
2021-10-11 00:41:53 +03:00
Kittywhiskers Van Gogh
9747f12401 docs: elaborate llmq parameter uses, tidy up 2021-10-09 22:28:13 +05:30
Kittywhiskers Van Gogh
af7cae777b move-only: move llmq parameters to their own file 2021-10-09 22:28:13 +05:30
Kittywhiskers Van Gogh
f22be5a16b refactor: llmq/quorums_*[cpp/h] --> llmq/*.[cpp/h] 2021-10-06 09:04:45 +05:30
PastaPastaPasta
8d5c586477
refactor: replace instances of typedef with using in dash code (#4488) 2021-10-06 00:26:29 +03:00
gabriel-bjg
b4d001a602
instantsend: deterministic lock using the same msg hash as islock (#4381)
When receiving an islock, propagate it as islock.
When creating/receiving and isdlock, propagate it as isdlock to peers which support it and as islock to peers which don't.
Functional tests to cover both islock and isdlock scenarios.
2021-10-05 20:42:34 +03:00
Kittywhiskers Van Gogh
cb1d4766f5
refactor: remove redundant filename prefixes for Dash-specific logic (#4475)
* refactor: coinjoin/coinjoin-*[cpp/h] --> coinjoin/*.[cpp/h]

* refactor: governance/governance-*[cpp/h] --> governance/*.[cpp/h]

* refactor: masternode/masternode-*[cpp/h] --> masternode/*.[cpp/h]

* fix linter

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-10-01 22:19:08 +03:00
PastaPastaPasta
9da186bb61
refactor: Various small improvements (#4471)
* bls: use constexpr int instead of #define

* lint: bump c++ version to 17

* test: use BOOST_CHECK_EQUAL instead of BOOST_ASSERT, call boost assert in another location

* coinjoin: fix typo

* drop redundant LLMQType cast

* use numeric_limits instead of magic value

* net_processing.cpp whitespace fixes

* Add some const

* use std::all_of instead of raw for loop

* Introduce UNINITIALIZED_SESSION_ID and use it instead of a magic number

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-10-01 14:44:40 +03:00
PastaPastaPasta
94959c9adc
Adjust dkgsession CS usage (#4461) 2021-09-30 21:51:55 +03:00
UdjinM6
6eeb1520aa
Merge pull request #4458 from PastaPastaPasta/chainlocks-boost-thread
backport 18234, 19090 and remove usage of boost thread in chainlocks code
2021-09-29 19:22:35 +03:00
PastaPastaPasta
c8da431c13
instantsend: Introduce ISDB specific CCriticalSection, avoid locking IS cs where possible (#4454)
* Don't lock instantsend cs where not needed (db interactions)

* Introduce cs_db to CInstantSendDb

All private members are GUARDED_BY or EXCLUSIVE_LOCKS_REQUIRED w/ cs_db

All public functions lock cs_db immediately

* adjust cs usage a bit more in CInstantSendManager

* Use WITH_LOCK in a few spots

* Make AddNonLockedTx lock internally instead of externally

* instantsend adjust formatting

* instantsend move IsInstantSendEnabled enabled check up
2021-09-29 19:22:02 +03:00
Pasta
ac9a07c863
Remove usage of boost thread in chainlocks code 2021-09-28 19:42:44 -04:00
Wladimir J. van der Laan
9b8884b430
partial Merge #18234: refactor: Replace boost::mutex,condition_var,chrono with std equivalents in scheduler
This backport does not include changes that depend on bitcoin pr 18037

70a6b529f306ff72ea1badf25e970a92b2b17ab3 lint-cppcheck: Remove -DHAVE_WORKING_BOOST_SLEEP_FOR (Anthony Towns)
294937b39de5924e772f8ed90d35c53290c8acab scheduler_tests: re-enable mockforward test (Anthony Towns)
cea19f685915be8affb2203184a549576194413f Drop unused reverselock.h (Anthony Towns)
d0ebd93270758ea97ea956b8821e17a2d001ea94 scheduler: switch from boost to std (Anthony Towns)
b9c426012770d166e6ebfab27689be44e6e89aa5 sync.h: add REVERSE_LOCK (Anthony Towns)
306f71b4eb4a0fd8e64f47dc008bc235b80b13d9 scheduler: don't rely on boost interrupt on shutdown (Anthony Towns)

Pull request description:

  Replacing boost functionality with C++11 stuff.

  Motivated by #18227, but should stand alone. Changing from `boost::condition_var` to `std::condition_var` means `threadGroup.interrupt_all` isn't enough to interrupt `serviceQueue` anymore, so that means calling `stop()` before `join_all()` is needed. And the existing reverselock.h code doesn't work with sync.h's DebugLock code (because the reversed lock won't be removed from `g_lockstack` which then leads to incorrect potential deadlock warnings), so I've replaced that with a dedicated class and macro that's aware of our debug lock behaviour.

  Fixes #16027, Fixes #14200, Fixes #18227

ACKs for top commit:
  laanwj:
    ACK 70a6b529f306ff72ea1badf25e970a92b2b17ab3

Tree-SHA512: d1da13adeabcf9186d114e2dad9a4fdbe2e440f7afbccde0c13dfbaf464efcd850b69d3371c5bf8b179d7ceb9d81f4af3cc22960b90834e41eaaf6d52ef7d331

# Conflicts:
#	src/reverselock.h
#	src/rpc/misc.cpp
#	src/scheduler.cpp
#	src/scheduler.h
#	src/sync.cpp
#	src/sync.h
#	src/test/reverselock_tests.cpp
#	src/test/scheduler_tests.cpp
#	src/test/test_dash.cpp
#	test/lint/extended-lint-cppcheck.sh
2021-09-28 19:42:22 -04:00
PastaPastaPasta
19fcc10d7a
Various cs_main / thread saftey adjustments (#4455)
* Avoid locking cs_main before logging, instead log, then lock where possible

* use WITH_LOCK in a number of locations as a replacement of simple scopes

* add EXCLUSIVE_LOCKS_REQUIRED

* minimize locked scope in rpc

* fix macOS build error

Signed-off-by: pasta <pasta@dashboost.org>

* add missing EXCLUSIVE_LOCKS_REQUIRED(cs_main)

Signed-off-by: pasta <pasta@dashboost.org>

* revert an rpc scope reduction

* revert an rpc scope reduction
2021-09-29 00:40:32 +03:00
PastaPastaPasta
fdcfb25b98
Add some thread annotations (#4464)
* Add some thread annotations

* spork cs adjustments
2021-09-29 00:23:34 +03:00
PastaPastaPasta
24378a7a57
chainlocks: Use std::atomic<bool> for a number of bools previously guarded by cs (#4459)
Adjust cs usage accordingly
2021-09-29 00:07:01 +03:00
PastaPastaPasta
78e04b92f2
Merge pull request #4420 from vijaydasmp/backport_v18_vijay_batch3_1
Merge #15334, #13076, #15266, #13128
2021-09-16 18:29:41 -04:00
MarcoFalke
15f14806a8
Merge #15266: memory: Construct globals on first use
77777c5624 log: Construct global logger on first use (MarcoFalke)

Pull request description:

  The (de)initialization order is not well defined in C++, so generally it is not safe to use globals as the (de/con)structor of one global could use the (de/con)structor of another global before/after it has been (con/de)structed.

  Specifically this fixes:
  * `g_logger` might not be initialized on the first use, so do that. (Fixes #15111)

Tree-SHA512: eb9c22f4baf31ebc5b0b9ee6a51d1354bae1f0df186cc0ce818b4483c7b5a7f90268d2b549ee96b4c57f8ef36ab239dc6497f74f3e2ef166038f7437c368297d
2021-09-16 07:41:45 +05:30
UdjinM6
43183f6aab
instantsend: Add islocks created from recovered sigs to the queue (#4422)
Processing them asap can lead to a race condition
2021-09-14 14:03:26 +03:00
UdjinM6
2723fd13a5
refactor: More constness and thread safety for LLMQ modules (#4392)
* refactor: Add `const` qualifier to various llmq related functions

* refactor: Add thread safety annotations to various llmq related functions

And around them where it's required
2021-09-08 01:33:02 +03:00
UdjinM6
4b4b675d6d
instantsend: Fix potential deadlock (#4390)
Fixes
```
POTENTIAL DEADLOCK DETECTED
Previous lock order was:
 (1) cs llmq/quorums_instantsend.cpp:1071 (in thread )
 (2) cs_main llmq/quorums_instantsend.cpp:1405 (in thread )
Current lock order is:
 (2) cs_main net_processing.cpp:2535 (in thread )
 (1) cs llmq/quorums_instantsend.cpp:1559 (in thread )
```
2021-09-07 03:22:30 +03:00
UdjinM6
b57970a70d
Fix thread names for threads started via pools (#4349)
`RenameThreadPool` calls `ThreadRename` which adds `dash-` prefix internally
2021-08-24 19:18:52 +03:00
Dzutte
4b603e64e4
Backports v0.18: PR 13743: refactor: Replace boost::bind with std::bind (#4343)
* Merge #13743: refactor: Replace boost::bind with std::bind

cb53b825c2 scripted-diff: Replace boost::bind with std::bind (Chun Kuan Lee)
2196c51821 refactor: Use boost::scoped_connection in signal/slot, also prefer range-based loop instead of std::transform (Chun Kuan Lee)

Pull request description:

  Replace boost::bind with std::bind

  - In `src/rpc/server.cpp`, replace `std::transform` with simple loop.
  - In `src/validation.cpp`, store the `boost::signals2::connection` object and use it to disconnect.
  - In `src/validationinterface.cpp`, use 2 map to store the `boost::signals2::scoped_connection` object.

Tree-SHA512: 6653cbe00036fecfc495340618efcba6d7be0227c752b37b81a27184433330f817e8de9257774e9b35828026cb55f11ee7f17d6c388aebe22c4a3df13b5092f0

* Replace boost::bind with std::bind and remove Boost.Bind includes

Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2021-08-17 23:31:09 +03:00
UdjinM6
ef52a8f345
llmq: Split "llmq" db (#4141)
* llmq: Split "isdb" out of "llmq" db

We write and erase islocks a lot. It probably makes sense to have a standalone db with a larger cache for this.

* llmq: Split "recsigdb" out of "llmq" db

* llmq: Migrate recovered sigs

* llmq: Split "dkgdb" out of "llmq" db

* llmq: Migrate DKG db

* llmq: Wipe llmq
2021-08-11 19:58:03 +03:00
Munkybooty
db274ffee5
qt: Add chainlock info (#4252) 2021-08-10 22:41:00 +03:00
PastaPastaPasta
121c838b8d
refactor: adjust cs_main usage in llmq code (#4324) 2021-08-10 22:37:27 +03:00
UdjinM6
7aebf156e9
Merge pull request #4229 from kittywhiskers/auxports
merge #16117, #18358, #17383, #21052, #14424, #15159, #14689, #14978, partial #16908, #14978, #13932: Auxillary Backports
2021-08-10 22:34:17 +03:00
Kittywhiskers Van Gogh
e8e48b33bb merge #15159: Remove lookup to UTXO set from GetTransaction
No need for extra `-txindex` in Dash-specific tests, it's `true` by default
2021-08-09 12:38:04 +05:30