Commit Graph

489 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
Wladimir J. van der Laan
93f168eee3 Merge #15894: Remove duplicated "Error: " prefix in logs
f724f31401b963c75bd64f5e2c5b9d9561a9a9dd Make AbortNode() aware of MSG_NOPREFIX flag (Hennadii Stepanov)
96fd4ee02f6c3be21cade729b95a85c60634b0f8 Add MSG_NOPREFIX flag for user messages (Hennadii Stepanov)
f0641f274ffe94fbe7cae43c07a9373013739df2 Prepend the error/warning prefix for GUI messages (Hennadii Stepanov)

Pull request description:

  The "Error" prefix/title is set already in the next functions:
  - `noui_ThreadSafeMessageBox()`2068f089c8/src/noui.cpp (L17)
  - `ThreadSafeMessageBox()`a720a98301/src/qt/bitcoingui.cpp (L1351)

  Currently on master:
  ![Screenshot from 2019-04-25 22-08-54](https://user-images.githubusercontent.com/32963518/56763092-25ee8280-67aa-11e9-86c8-6a029dd9ab08.png)

  With this PR:
  ![Screenshot from 2019-04-25 22-26-36](https://user-images.githubusercontent.com/32963518/56763107-30108100-67aa-11e9-9021-683cbd7e2aaa.png)

ACKs for top commit:
  laanwj:
    concept and code-review ACK f724f31401b963c75bd64f5e2c5b9d9561a9a9dd

Tree-SHA512: 218a179b81cc2ac64239d833c02b4c4d4da9b976728a2dcd645966726c4c660b6f1fe43aa28f33d1cb566785a4329e7f93bf5a502bf202316db79d2ff5fce0f8
2021-11-18 15:30:54 -05:00
Kittywhiskers Van Gogh
d978259654
merge bitcoin#15638: Pull wallet code out of libbitcoin_server (#4560)
* merge 15638: Move CheckTransaction from lib_server to lib_consensus

* merge 15638: Move policy settings to new src/policy/settings unit

* merge 15638: Move rpc utility methods to rpc/util

* merge 15638: Move rpc rawtransaction util functions to rpc/rawtransaction_util.cpp

* merge 15638: Move several units into common libraries

* merge 15638: Move wallet load functions to wallet/load unit

* merge 15638: Document src subdirectories and different libraries

* [build] Add several util units (cleanup)

* build: resolve missing declarations by re-specifying headers
2021-11-16 10:19:47 -05:00
PastaPastaPasta
085dbc2649
Merge pull request #4573 from humbleDasher/backport15615
Backport 15615, 16774, and 16793
2021-11-13 15:02:28 -05:00
MarcoFalke
4bf53b1931 Merge #16793: refactor: Avoid locking cs_main in ProcessNewBlockHeaders
3109a1f948f3c8fd500defbdc4e59bfb2953c30b refactor: Avoid locking cs_main in ProcessNewBlockHeaders (João Barbosa)

Pull request description:

  Builds on #16774, this change avoids locking `cs_main` in `ProcessNewBlockHeaders` when the tip has changed - in this case the removed lock was necessary to just log a message.

Top commit has no ACKs.

Tree-SHA512: 31be6d319fa122804f72fa813cec5ed041dd7e4aef3c1921124a1f03016925c43cd4d9a272d80093e77fa7600e3506ef47b7bb821afcbffe01e6be9bceb6dc00
2021-11-12 18:19:27 -05:00
MarcoFalke
2996f593ef Merge #16774: Avoid unnecessary "Synchronizing blockheaders" log messages
dcc448e3d2b97f7e4e23f5ed174762cec3530306 Avoid unnecessary "Synchronizing blockheaders" log messages (Jonas Schnelli)

Pull request description:

  Fixes #16773

  I'm not entirely sure why 16773 happend, but probably due to headers fallback in a compact block.

  However, this PR should fix it and should have been included in #15615.

ACKs for top commit:
  ajtowns:
    ACK dcc448e3d2b97f7e4e23f5ed174762cec3530306 ; code review only, haven't compiled or tested.
  promag:
    ACK dcc448e3d2b97f7e4e23f5ed174762cec3530306.
  TheBlueMatt:
    utACK dcc448e3d2b97f7e4e23f5ed174762cec3530306. Went and read how pindexBestHeader is handled and this code looks correct (worst case it breaks a LogPrint, so whatever). I also ran into this on #16762.
  fanquake:
    ACK dcc448e3d2b97f7e4e23f5ed174762cec3530306

Tree-SHA512: f8cac3b6eb9d4e8fab53a535b55f9ea9b058e3ab6ade64801ebc56439ede4f54b5fee36d5d2b316966ab987b65b13ab9dc18849f345d08b81ecdf2722a3f5f5a
2021-11-12 18:17:18 -05:00
Wladimir J. van der Laan
07af856ef1 Merge #15615: Add log output during initial header sync
d75e704ac08fb43320e3ebcdde0d2a5392fdec9f Add log output during initial header sync (Jonas Schnelli)

Pull request description:

  The non debug log output is completely quiet during the header sync. I see two main reasons to add infos about the state of the initial header sync...
  * users may think the node did fail to start sync
  * it's a little complicate to check if your getting throttled during header sync (repeatedly calling `getchaintips` or similar)

ACKs for top commit:
  fanquake:
    Concept ACK d75e704ac0
  practicalswift:
    utACK d75e704ac08fb43320e3ebcdde0d2a5392fdec9f
  laanwj:
    Tested ACK d75e704ac08fb43320e3ebcdde0d2a5392fdec9f

Tree-SHA512: 2e738571b703d7251290864603c3a829729645962c2fa3187250bab0585e66a5f01fce892e9b5b98da451fab2b40a2e4784f9b2e5a9cad75ff62c535affe7430
2021-11-12 18:15:34 -05: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
Kittywhiskers Van Gogh
0a760bb809
merge bitcoin#8365: Treat high-sigop transactions as larger rather than rejecting them (#4562) 2021-11-08 21:43:24 +03:00
MarcoFalke
bdb1a55c0b
Merge #19088: validation: use std::chrono throughout some validation functions
789e9dd3aa727176797529c35b2848f994630a82 validation: use std::chrono in IsCurrentForFeeEstimation() (fanquake)
47be28c8bc475eafeebd4fc58ea92f0d3df0d8c6 validation: use std::chrono in CChainState::FlushStateToDisk() (fanquake)

Pull request description:

  Probably up for debate as to which type is used for the constants. Personally, swapping these to hours is more readable.

ACKs for top commit:
  MarcoFalke:
    ACK 789e9dd3aa727176797529c35b2848f994630a82
  jonatack:
    ACK 789e9dd3aa727176797529c35b2848f994630a82

Tree-SHA512: f4a25cbd00a49a54b7783a1f588be83706dd2a475cecb5c2e8b97b2d4b27c0955a7454d7486f2454e96351c44f233b300c4f4b9ca62fc7336277f10da34dd5c3
2021-11-03 12:24:06 -04:00
MarcoFalke
847a75ba4a
Merge #15971: validation: Add compile-time checking for negative locking requirement in LimitValidationInterfaceQueue
62d50ef308 Add LOCKS_EXCLUDED(cs_main) to LimitValidationInterfaceQueue(...) which does AssertLockNotHeld(cs_main) (practicalswift)

Pull request description:

  This PR adds compile-time checking for negative locking requirements that follow from the run-time locking requirement `AssertLockNotHeld(cs_main)` in `LimitValidationInterfaceQueue(...)`.

  Changes:
  * Add `LOCKS_EXCLUDED(cs_main)` to `LimitValidationInterfaceQueue(...)` which does `AssertLockNotHeld(cs_main)`
  * Add `LOCKS_EXCLUDED(cs_main)` to `CChainState::ActivateBestChain(…)`, `CChainState:: InvalidateBlock(…)` and `CChainState::RewindBlockIndex(…)` which all call `LimitValidationInterfaceQueue(...)` which does `AssertLockNotHeld(cs_main)`
  * Add `LOCKS_EXCLUDED(cs_main)` to `InvalidateBlock(…)` which calls `CChainState::InvalidateBlock(...)` which in turn calls `LimitValidationInterfaceQueue(...)` which  does `AssertLockNotHeld(cs_main)`
  * Add `LOCKS_EXCLUDED(cs_main)` to `RewindBlockIndex(…)` which calls `CChainState::RewindBlockIndex(...)` which in turn calls `LimitValidationInterfaceQueue(...)` which does `AssertLockNotHeld(cs_main)`

ACKs for commit 62d50e:
  MarcoFalke:
    utACK 62d50ef308

Tree-SHA512: 73d092ccd08c851ae3c5d60370c369fc030c5793f5507e2faccb6f91c851ddc0ce059fbea3899f2856330d7a8c78f2ac6a2988e8268b03154f946be9e60e3be1
2021-10-29 16:29:53 +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
fba2a546f6
Merge #16849: Fix block index inconsistency in InvalidateBlock()
2a4e60b48261d3f0ec3d85f97af998ef989134e0 Fix block index inconsistency in InvalidateBlock() (Suhas Daftuar)

Pull request description:

  Previously, we could release `cs_main` while leaving the block index in a state
  that would fail `CheckBlockIndex()`, because `setBlockIndexCandidates` was not being
  fully populated before releasing `cs_main`.

ACKs for top commit:
  TheBlueMatt:
    utACK 2a4e60b48261d3f0ec3d85f97af998ef989134e0. I also discovered another issue in InvalidateBlock while reviewing, see #16856.
  Sjors:
    ACK 2a4e60b. Tested on top of #16899. Also tested `invalidateblock` with `-checkblockindex=1`.
  fjahr:
    ACK 2a4e60b. Ran tests, reviewed code, inspected behavior while manually testing `invalidateblock`.

Tree-SHA512: ced12f9dfff0d413258c709921543fb154789898165590b30d1ee0cdc72863382f189744f7669a7c924d3689a1cc623efdf4e5ae3efc60054572c1e6826de612
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
UdjinM6
c20eccab44
Fix ResetBlockFailureFlags (#4545) 2021-10-28 15:42:11 +03:00
MarcoFalke
02c6ecb02f
Merge #15655: Resolve the checkpoints <-> validation circular dependency
418d3230f8 Resolve the checkpoints <-> validation CD. (251)

Pull request description:

  This pull request attempts to resolve the `checkpoints -> validation -> checkpoints` circular dependency.

  The circular dependency is resolved by moving the `CheckPoints::GetLastCheckpoint(const CCheckpointData& data)` function to `validation.cpp` where it used exclusively by the private function `ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& state, const CChainParams& params, const CBlockIndex* pindexPrev, int64_t nAdjustedTime)`.

ACKs for commit 418d32:
  promag:
    utACK 418d323, only `GetLastCheckpoint` usage is in `validation.cpp` and so makes sense to move it there.
  practicalswift:
    utACK 418d3230f86f77dde6e817f502baff8a54b707fa
  MarcoFalke:
    utACK 418d3230f86f77dde6e817f502baff8a54b707fa
  sipa:
    utACK 418d3230f86f77dde6e817f502baff8a54b707fa

Tree-SHA512: 03c3556bc192e65f5e3fa76fd545d4ee7d63d3fb06b132f7a1fa6131aa21ddd2e5b2d19e2222dfe524f422daaca30efde219bed188db8c74ff4b088876b5bc16
2021-10-25 12:22:06 -04: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
2da416a664 mutex: lock mempool.cs before calling LimitMempoolSize() 2021-10-22 08:15:38 +05:30
Kittywhiskers Van Gogh
692928d618 trivial: make linter happy 2021-10-22 08:15:38 +05:30
Kittywhiskers Van Gogh
f9c4b85575 merge bitcoin#16945: introduce CChainState::GetCoinsCacheSizeState 2021-10-22 08:15:38 +05:30
Kittywhiskers Van Gogh
510ee3581a merge bitcoin#16743: move LoadChainTip/RelayBlocks under CChainState 2021-10-22 08:15:38 +05:30
Kittywhiskers Van Gogh
80d08bb487 merge bitcoin#16757: CChainState return values 2021-10-22 08:15:38 +05:30
Kittywhiskers Van Gogh
84339a4b84 merge bitcoin#16443: have CCoins* data managed under CChainState 2021-10-22 08:15:38 +05:30
Kittywhiskers Van Gogh
51f73b558f merge bitcoin#15999: Remove dead code in LoadChainTip 2021-10-22 08:15:38 +05:30
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
900c0100eb merge bitcoin#16092: Don't use global (external) symbols for symbols that are used in only one translation unit 2021-10-22 08:15:38 +05:30
Kittywhiskers Van Gogh
1bb1cea5c9 merge bitcoin#15976: move methods under CChainState
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
Vijay Das Manikpuri
2366480563
Merge #15267: doc: explain AcceptToMemoryPoolWorker's coins_to_uncache 2021-10-20 07:17:36 +05:30
Kittywhiskers Van Gogh
f22be5a16b refactor: llmq/quorums_*[cpp/h] --> llmq/*.[cpp/h] 2021-10-06 09:04:45 +05:30
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
8fb5e07c4e
Add more descriptive logging in case of CL overriding islock (#4460) 2021-09-29 00:08:02 +03:00
UdjinM6
2d1b13bd90
Merge pull request #4435 from PastaPastaPasta/backport-trivial-pr20
Backport trivial pr20
2021-09-24 23:10:10 +03:00
MarcoFalke
4d8f035207
Merge #20519: Handle rename failure in DumpMempool(...) by using the RenameOver(...) return value. Add [[nodiscard]] to RenameOver(...).
ce9dd45422e1f4ecce6df68da086b8bfc2100756 Add [[nodiscard]] to RenameOver(...) (practicalswift)
9429a398e291a1b5edcfc657b94fcaf52cd1d8f9 Handle rename failure in DumpMempool(...) by using RenameOver(...) return value (practicalswift)

Pull request description:

  Handle rename failure in `DumpMempool(...)` by using the `RenameOver(...)` return value.

  Add `[[nodiscard]]` to `RenameOver(...)` to reduce the risk of similar rename issues in the future.

ACKs for top commit:
  vasild:
    ACK ce9dd454
  theStack:
    ACK ce9dd45422e1f4ecce6df68da086b8bfc2100756 🏷️

Tree-SHA512: 1e63d7f3061e1f6ea2df5750dbc1547a39bd50b6c529812a0c8a0c11d3100c241afdf14094e69b69a38bade7e54a12b2a42888545874398eaf5d02421b57e874
2021-09-24 13:26:41 -04:00
UdjinM6
6ac3b30107
Merge pull request #4433 from PastaPastaPasta/backport-trivial-pr19
Backport trivial pr19
2021-09-19 10:34:12 +03:00
Wladimir J. van der Laan
480fc90ef7
Merge #17994: validation: flush undo files after last block write
ac94141af0c16161afa68de1c3720f254ae4e12c validation: delay flushing undo files in syncing node case (Karl-Johan Alm)

Pull request description:

  Fixes #17890. Replaces #17892.

  Data files (`{blk|rev}<number>.dat`) pre-allocate space as they are written, and then trims down to the final size once they move on to the next sequence ("finalized flush"). The code currently assumes (incorrectly) that blk and rev files finish at the same time, but because blk files are written as blocks come in, and rev files are written in block height order, rev files end up being written to for awhile after moving on to the next block file, resulting in pre-allocation and waste of up to 1 MB of space per rev file.

  The exact point at which rev file writing finishes is the highest height block found inside the corresponding block file, which is already available in the CBlockFileInfo vector. This PR moves finalized flushing of undo files to to directly after the undo data for the previous block file has been written.

  There is a branch with annotation that demonstrates how this is handling flushing here: https://github.com/kallewoof/bitcoin/tree/200124-rev-files-annotated

ACKs for top commit:
  vasild:
    ACK ac94141af (no changes in the code since ed34e00da).
  fjahr:
    Code review re-ACK ac94141af0c16161afa68de1c3720f254ae4e12c
  jonatack:
    Code review ACK ac94141af0c16

Tree-SHA512: 1d4e3b3d1d99bd7ebe7a2f632b1231146dd4f9f993c54db3a4090d9c086d95d2e4c327fd936066392b3afc6277b8f3a908d5c5993d4c8e49f72b92a417716dd2
2021-09-18 21:46:23 -04:00
Wladimir J. van der Laan
d0b0f08432
Merge #18410: Docs: Improve commenting for coins.cpp|h
21fa0a44abe8c1b5c452e097eab20cf0ae988805 [docs] use consistent naming for possible_overwrite (John Newbery)
2685c214cce4b07695273503e60350e3f05fe3e2 [tests] small whitespace fixup (John Newbery)
e9936966c08bd8a6ac02828131f619ddaa1ced13 scripted-diff: Rename PRUNED to SPENT in coins tests (John Newbery)
c205979031ff4e8e32a5f05bae813405f233fccd [docs] Improve commenting in coins.cpp|h (John Newbery)

Pull request description:

  - Add full commenting for spentness / DIRTYness / FRESHness and which combinations are valid
  - Remove the 'pruned' terminology, which doesn't make sense since per-txout chainstate db was merged (#10195).
  - Rename `potential_overwrite` to `possible_overwrite` to standardize terminology (there were previously examples of both, which made searching the codebase difficult).
  - Make other minor improvements to the comments

ACKs for top commit:
  jonatack:
    Re-ACK 21fa0a4 per `git diff 98bee55 21fa0a4` the only change since my previous review is the following code commenting diff in `src/coins.cpp::L177-179`;  rebuilt/ran unit tests anyway as a sanity check on the unit test changes.

Tree-SHA512: 391e01588ef5edb417250080cec17361f982c4454bc5f8c6d78bbd528c68a2bb94373297760691295c24660ce1022ad3ef7599762f736c8eed772ce096d38c3d
2021-09-18 17:15:47 -04: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
Wladimir J. van der Laan
67893ff277
Merge #14841: consensus: Move CheckBlock() call to critical section
c5ed6e73d Move CheckBlock() call to critical section (Hennadii Stepanov)

Pull request description:

  This is an alternative to #14803.

  Refs:
  - #14058
  - #14072
  - https://github.com/bitcoin/bitcoin/pull/14803#issuecomment-442233211 by @gmaxwell
  > It doesn't support multithreaded validation and there are lot of things that prevent that, which is why I was concerned. Why doesn't the lock on the block index or even cs main prevent concurrency here?

  - https://github.com/bitcoin/bitcoin/pull/14803#issuecomment-442237566 by @MarcoFalke

Tree-SHA512: 2152e97106e11da5763b2748234ecd2982daadab13a0da04215f4db60af802a44ab5700f32249137d122eb13fc2a02e0f2d561d364607d727d8c6ab879339afb
2021-09-06 18:01:57 +05:30
MarcoFalke
283a4b8c71
Merge #15471: rpc/gui: Remove 'Unknown block versions being mined' warning
ef362f2773 rpc/gui: Remove 'Unknown block versions being mined' warning (Wladimir J. van der Laan)

Pull request description:

  Due to miners inserting garbage into the version numbers causing false positives, the current version signalling has become completely useless. This removes the "unknown block versions" warning which has the tendency to scare users unnecessarily (and might get them to "update" to something bad).

  It preserves the warning in the logs. Whether this is desirable can be a point of discussion.

Tree-SHA512: 51407ccd24a571462465d9c7180f0f28307c50b82a03284abe783e181d8ab7e0638dbb710698d883f28de8a609db70763e39be2470d956e67c833da0768e43e9
2021-09-06 18:01:57 +05:30
rkarthik2k21
f456edb07e
merge bitcoin#13311: Don't edit Chainparams after initialization (#4362)
* Merge #13311: Don't edit Chainparams after initialization

6fa901fb47 Don't edit Chainparams after initialization (Jorge Timón)
980b38f8a1 MOVEONLY: Move versionbits info out of versionbits.o (Jorge Timón)

Pull request description:

  This encapsulates the "-vbparams" option, which is only meant for regtest, directly on CRegTestParams.

  This is a refactor and doesn't change functionality.

  Related to https://github.com/bitcoin/bitcoin/pull/8994

Tree-SHA512: 79771d729a63a720e743a9c77d5e2d80369f072d66202a43c1304e83a7d0ef7c6103d4968a03aea9666cc89a7203c618da972124a677b38cfe62ddaeb28f9f5d

* Resolve Merge with #13311

* Incorporated review changes

* Apply suggestions from code review

* Update src/chainparams.cpp

* Update src/chainparams.cpp

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

Co-authored-by: MarcoFalke <falke.marco@gmail.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
2021-09-03 01:36:11 +03:00
UdjinM6
8eafd332c3
Add missing cs_main locks/checks 2021-09-02 03:04:40 +03:00
MarcoFalke
8c64eec579
Merge #14772: refactor: Convert comments to thread safety annotations
fa71eb5196 Convert comments to thread safety annotations (MarcoFalke)

Pull request description:

  Convert human-only-readable annotations to human-and-machine-readable annotations.

Tree-SHA512: 98a97b32b50e8ec816626ed853d56c9afb31065eb14f058cda8f22a16ddd2b0c02911f9e30478aa347f466891f972496d89a828eb6e4662fb712d7d9e7643d49
2021-09-02 03:04:40 +03:00
Vijay Manikpuri
c417db87c9
Merge #17519: rpc: Remove unused COINBASE_FLAGS (#4377)
* Merge #17519: rpc: Remove unused COINBASE_FLAGS

e9a27cf338dc618b8ecab8984abc54d588de8a05 refactor: Remove unused COINBASE_FLAGS (Neha Narula)

Pull request description:

  Commit d449772cf6 stopped setting
  COINBASE_FLAGS, and it looks like it hasn't been used since P2SH.

  Following up on #17489, remove COINBASE_FLAGS which is unused. I verified that removing this did not change the contents of the coinbase's scriptSig.

ACKs for top commit:
  laanwj:
    ACK e9a27cf338dc618b8ecab8984abc54d588de8a05
  MarcoFalke:
    ACK e9a27cf338dc618b8ecab8984abc54d588de8a05 💻

Tree-SHA512: f9dac124ce7e3edcae974137764bb5039387b1b123b86af44486e398aa4a8d91a9ecf640e207b364ae303acbbaee7cca300d303ea3d6869ba9cae2bf555a6334

* Update src/rpc/mining.cpp

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

Co-authored-by: Wladimir J. van der Laan <laanwj@protonmail.com>
Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
2021-08-31 12:51:34 -04:00
MarcoFalke
d5f50c3df8 Merge #14963: mempool, validation: Explain cs_main locking semantics
fa5e373365 validation: Add cs_main locking annotations (MarcoFalke)
fa5c346c5a doc: Add comment to cs_main and mempool::cs (MarcoFalke)
fafe941bdd test: Add missing validation locks (MarcoFalke)
fac4558462 sync: Add RecursiveMutex type alias (MarcoFalke)

Pull request description:

  Both the chain state and the transaction pool are validation specific, but access to them is protected by two locks. The two locks have the following semantics:

  * Writing to the chain state or adding transactions to the transaction pool -> Take both `cs_main` and `mempool::cs`
  * Reading either or removing transactions from the the transaction pool -> Take only the appropriate lock

Tree-SHA512: 6f6e612ffc391904c6434a79a4f3f8de1b928bf0a3e3434b73561037b395e2b40a70a5a4bd8472dd230e9eacc8e5d5374c904a3c509910cf3971dd7ff59a626c
2021-08-24 19:14:50 -04: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
PastaPastaPasta
592cd0a939
Merge pull request #4333 from Munkybooty/backports-0.18-pr13
Backports 0.18 pr13
2021-08-16 14:24:51 -05:00
Wladimir J. van der Laan
36efb7ec0d Merge #14863: refactor: Add and use HaveTxsDownloaded() where appropriate
fa4fc8856b239059421a8e507b3e3e7f4b379a72 validation: Add and use HaveTxsDownloaded where appropriate (MarcoFalke)

Pull request description:

  `nChainTx` is an implementation detail that shouldn't be exposed without a wrapper that comes with appropriate documentation.

Tree-SHA512: 56ab7378c2ce97794498724c271f861de982de69099e90ec09632a26230ae6fded3c59668adb378bd64dcb8ef714769b970210977b88a53fc7550774ddba3d59
2021-08-15 11:08:08 -04:00
UdjinM6
297cdf92b5
Merge pull request #4328 from 5tefan/backports_018_e0a4f9de7
Merge bitcoin#13793, #14208
2021-08-13 23:24:05 +03:00