bitcoin/src/wallet
MarcoFalke f3d27d126b
Merge #16033: Hold cs_main when reading chainActive via getTipLocator(). Remove assumeLocked().
9402ef0739 Remove temporary method assumeLocked(). Remove LockingStateImpl. Remove redundant cs_main locks. (practicalswift)
593a8e8a2c wallet: Use chain.lock() instead of temporary chain.assumeLocked() (practicalswift)

Pull request description:

  Fixes #16028.

  Problem description:

  `LockAnnotation lock(::cs_main)` is a guarantee to the compiler thread analysis that `::cs_main` is locked (when it couldn't be determined otherwise).

  Despite being annotated with the locking guarantee ...

  65526fc866/src/interfaces/chain.cpp (L134-L138)

  ... `getTipLocator()` reads `chainActive` (via `::ChainActive()`) without holding `cs_main`.

  This can be verified by adding the following `AssertLockHeld(cs_main)`:

  ```
  $ git diff
  diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp
  index 59623284d..9fc693a0f 100644
  --- a/src/interfaces/chain.cpp
  +++ b/src/interfaces/chain.cpp
  @@ -134,6 +134,7 @@ class LockImpl : public Chain::Lock
       CBlockLocator getTipLocator() override
       {
           LockAnnotation lock(::cs_main);
  +        AssertLockHeld(::cs_main);
           return ::ChainActive().GetLocator();
       }
       Optional<int> findLocatorFork(const CBlockLocator& locator) override
  $ make check
  ../build-aux/test-driver: line 107: 12881 Aborted                 "$@" > $log_file 2>&1
  FAIL: qt/test/test_bitcoin-qt
  ```

ACKs for commit 9402ef:
  MarcoFalke:
    utACK 9402ef0739
  ryanofsky:
    utACK 9402ef0739. Changes are consolidating commits and removing redundant lock2 cs_main calls

Tree-SHA512: 0a030bf0c07eb53194ecc246f973ef389dd42a0979f51932bf94bdf7e90c52473ae03be49718ee1629582b05dd8e0dc020b5a210318c93378ea4ace90c0f9f72
2019-05-17 07:17:41 -04:00
..
test Merge #16033: Hold cs_main when reading chainActive via getTipLocator(). Remove assumeLocked(). 2019-05-17 07:17:41 -04:00
coincontrol.cpp scripted-diff: Move util files to separate directory. 2018-11-04 22:46:07 -08:00
coincontrol.h scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
coinselection.cpp Introduce a Shuffle for FastRandomContext and use it in wallet and coinselection 2018-12-12 14:22:12 -08:00
coinselection.h amount: Move CAmount CENT to unit test header 2018-09-17 14:34:56 -04:00
crypter.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
crypter.h [tools] Add wallet inspection and modification tool 2019-01-30 16:26:52 -05:00
db.cpp Merge #15870: wallet: Only fail rescan when blocks have actually been pruned 2019-05-16 11:18:27 -04:00
db.h scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
feebumper.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
feebumper.h scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
fees.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
fees.h Remove uses of fee globals in wallet code 2019-02-22 15:43:02 -04:00
init.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
load.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
load.h scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
psbtwallet.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
psbtwallet.h Remove unused TransactionError constants 2019-02-14 10:32:02 -05:00
rpcdump.cpp Merge #15870: wallet: Only fail rescan when blocks have actually been pruned 2019-05-16 11:18:27 -04:00
rpcwallet.cpp Add option to create an encrypted wallet 2019-05-13 22:49:34 -04:00
rpcwallet.h Merge #15870: wallet: Only fail rescan when blocks have actually been pruned 2019-05-16 11:18:27 -04:00
wallet.cpp Merge #16033: Hold cs_main when reading chainActive via getTipLocator(). Remove assumeLocked(). 2019-05-17 07:17:41 -04:00
wallet.h Merge #15870: wallet: Only fail rescan when blocks have actually been pruned 2019-05-16 11:18:27 -04:00
walletdb.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
walletdb.h Store key origin info in key metadata 2019-02-14 17:58:25 -05:00
wallettool.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
wallettool.h scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
walletutil.cpp Merge #15870: wallet: Only fail rescan when blocks have actually been pruned 2019-05-16 11:18:27 -04:00
walletutil.h wallet: Add WalletLocation utility class 2018-10-25 11:53:17 +01:00