Commit graph

15925 commits

Author SHA1 Message Date
Vasil Dimov fbacad1880
util: simplify the interface of serviceFlagToStr()
Don't take two redundant arguments in `serviceFlagToStr()`.

As a side effect this fixes an issue introduced in
https://github.com/bitcoin/bitcoin/pull/18165 due to which the GUI could
print something like `UNKNOWN[1033] & UNKNOWN[1033] & UNKNOWN[2^10]`
instead of `NETWORK & WITNESS`.
2020-05-29 18:49:26 +02:00
practicalswift c571ecb071 tests: Add fuzzing helper functions ConsumeDataStream, ConsumeTxDestination and ConsumeUInt160 2020-05-29 16:44:22 +00:00
Anthony Towns 5cb7ee67a5 net: improve code documentation for dns seed behaviour 2020-05-30 02:07:48 +10:00
João Barbosa 4f49d5222e gui, refactor: Register Qt meta types in application constructor 2020-05-29 16:05:47 +01:00
Jonas Schnelli e4bfd51acc
Merge #18452: qt: Fix shutdown when waitfor* cmds are called from RPC console
da73f1513a qt: Fix shutdown when waitfor* cmds are called from RPC console (Hennadii Stepanov)

Pull request description:

  On master (7eed413e72), if the GUI has been started with`-server=1`, `bitcoin-qt` hangs on shutdown during calling any of the `waitfor*` commands in the GUI RPC console.

  This PR suggests minimal changes to fix this bug.

  Fix #17495

ACKs for top commit:
  jonasschnelli:
    utACK da73f1513a

Tree-SHA512: 469f5332945a5f2c57d19336cda5df79b123ccc494aea6d58a85eb1293be52708b2b9c5bb6bc2c402a90b7b4e9e8d7ab8fe84cf201cf7ce612c9290c57e43681
2020-05-29 15:49:46 +02:00
Jonas Schnelli f2e2c5ebcc
Merge #14988: wallet: Fix for confirmed column in csv export for payment to self transactions
9760293ce6 wallet: Fix for exported confirmation field in payment to self transactions (Ben Carman)

Pull request description:

  Closes #3455

ACKs for top commit:
  jonasschnelli:
    Tested ACK 9760293ce6

Tree-SHA512: 8207768771ad787f716b966c4aa7aeef2da8a602e32e3510e41c7b49ec5ec679a3835d248be5016d4b37764f9914846f7c41c11cf48cddb617cb7ef831318fd7
2020-05-29 14:42:48 +02:00
fanquake 73407ff65c
Merge #16939: p2p: Delay querying DNS seeds
96954d1794 DNS seeds: don't query DNS while network is inactive (Anthony Towns)
fa5894f7f5 DNS seeds: wait for 5m instead of 11s if 1000+ peers are known (Anthony Towns)

Pull request description:

  Changes the logic for querying DNS seeds: after this PR, if there's less than 1000 entries in addrman, it will still usually query DNS seeds after 11s (unless the first few peers tried mostly succeed), but if there's more than 1000 entries it won't try DNS seeds until 5 minutes have passed without getting multiple outbound peers. (If there's 0 entries in addrman, it will still immediately query the DNS seeds). Additionally, delays querying DNS seeds while the p2p network is not active.

  Fixes #15434

ACKs for top commit:
  fanquake:
    ACK 96954d1794 - Ran some tests of different scenarios. More documentation is being added in #19084.
  ariard:
    Tested ACK 96954d1, on Debian 9.1. Both MANY_PEERS/FEW_PEERS cases work.
  Sjors:
    tACK 96954d1 (rebased on master) on macOS 10.15.4. It found it useful to run with `-debug=addrman` and change `DNSSEEDS_DELAY_MANY_PEERS` to something lower to test the behaviour, as well as renaming `peers.dat` to test the peer threshold.
  naumenkogs:
    utACK 96954d1794

Tree-SHA512: 73693db3da73bf8e76c3df9e9c82f0a7fb08049187356eac2575c4ffa455f76548dd1c86a11fc6beea8a3baf0ba020e047bebe927883c731383ec72442356005
2020-05-29 18:24:09 +08:00
Jonas Schnelli d7f5e01e30
Merge #18424: qt: Use parent-child relation to manage lifetime of OptionsModel object
8e08d00598 qt: Use parent-child relation to manage lifetime of OptionsModel object (Hennadii Stepanov)

Pull request description:

  Both `BitcoinApplication` and `OptionsModel` classes are derived from the `QObject` class, therefore a parent-child relation could be established to manage the lifetime of an `OptionsModel` object:
  5236b2e267/src/qt/optionsmodel.cpp (L29-L30)

  This PR does not change behavior.

ACKs for top commit:
  jonasschnelli:
    utACK 8e08d00598
  promag:
    ACK 8e08d00598.

Tree-SHA512: 0223dddf5ba28b0bfaefeda1b03b4ff95bf7e7d0c1e7b32368171e561813e22129f2a664f09279fa3b4fa63259b7680d55aa3fe66db9c7ae0039b7f529777ec3
2020-05-29 11:09:09 +02:00
Jonas Schnelli de369c7ea5
Merge #18165: Consolidate service flag bit-to-name conversion to a shared serviceFlagToStr function
c31bc5bcfd Consolidate service flag bit-to-name conversion to a shared serviceFlagToStr function (Luke Dashjr)
cea91a1e40 Bugfix: GUI: Use unsigned long long type to avoid implicit conversion of MSB check (Luke Dashjr)

Pull request description:

  Side effect: this results in the RPC showing unknown service bits as "UNKNOWN[n]" like the GUI.

  Note that there is no common mask-to-`vector<string>` function because both GUI and RPC would need to iterate through it to convert to their desired target formats.

ACKs for top commit:
  jonasschnelli:
    utACK ~~cea91a1e40e12029140ebfba969ce3ef2965029c~~ c31bc5bcfd

Tree-SHA512: 32c7ba8ac7ef2d4087f4f317447ae93a328ec9fb9ad81301df2fbaeeb21a3db7a503187a369552b05a9414251b7cf8e15bcde74c1ea2ef36591ea7ffb6721f60
2020-05-29 11:06:08 +02:00
Jonas Schnelli f4b603cff6
Merge #17993: gui: Balance/TxStatus polling update based on last block hash.
a06e845e82 BlockTip struct created and connected to notifyHeaderTip and notifyBlockTip signals. (furszy)
2f867203b0 Added best block hash to the NotifyHeaderTip and NotifyBlockTip signals. (furszy)

Pull request description:

  Rationale:

  The height based polling in the GUI is an issue on chain reorgs. Any new tip signal with the same height as the one that it's cached in the model was not triggering the GUI update (interpreting it as the same same block when it could receive a different one). Ending up with bad information presented in the GUI.

  This PR essentially changes the last cached height to be a last cached block hash.

  ---

  Old historical information of this PR.

  As the tip height is cached and updated via signaling in clientModel, there is no need to continue locking `cs_main` on every balance poll (`m_node.getNumBlocks()` method call).

  Extra topic:

  Would suggest to change the `cachedNumBlocks` field inside `walletModel` to a more understandable name, maybe `nLastBalanceUpdateHeight`.

  And finally, this will have the equal height reorg issue mentioned [here](https://github.com/bitcoin/bitcoin/pull/17905#issuecomment-577324304), whatever is presented to fix it, this should use the same flow too.

  **[Edit - 24/01/2020]**

  Have added #[17905](https://github.com/bitcoin/bitcoin/pull/17905#issuecomment-577324304) comment fix here too.

ACKs for top commit:
  jonasschnelli:
    utACK a06e845e82 - it would be great to have QT unit tests  (in this case for a reorg) that either automatically inspect the window content based on accessibility and tests for expected values or at least allow for quick manual re-testing (screenshots, automatically create UI situations).
  hebasto:
    re-ACK a06e845e82, suggested style changes implemented since the [previous](https://github.com/bitcoin/bitcoin/pull/17993#pullrequestreview-417249705) review.
  ryanofsky:
    Code review ACK a06e845e82. A lot of changes since the last review: rebase after sync_state introduction #18152 and tryGetBalances revert #18587, reverting getLastBlockTime change, fixing spacing and initializations and renaming some variables

Tree-SHA512: 835e587a8296df9899cccd7b3e598a5970942b640e432e6a32de0b4eaea5b40f9271258f089ec033595311707b74a0f7187ecf8ed397c713e1153e2714072975
2020-05-29 11:01:09 +02:00
Jonas Schnelli beb3844c45
Merge #17968: qt: Ensure that ModalOverlay is resized properly
4fc1df41d5 qt: Track QEvent::Resize during animation (Hennadii Stepanov)

Pull request description:

  In certain circumstances the `ModalOverlay` widget is not sized properly:
  - #17269
  - #17967
  - https://github.com/bitcoin/bitcoin/pull/17968#pullrequestreview-350753107

  On master (f018d0c9cd) this bug looks like this:
  ![DeepinScreenshot_bitcoin-qt_20200120193402](https://user-images.githubusercontent.com/32963518/72748165-298b2a80-3bbf-11ea-810d-2966f08e496a.png)

  With this PR the wallet frame looks ok:
  ![DeepinScreenshot_bitcoin-qt_20200120195241](https://user-images.githubusercontent.com/32963518/72748388-c64dc800-3bbf-11ea-8875-1ba1899b3513.png)

  Fix #17269
  Fix #17967

ACKs for top commit:
  promag:
    Code review ACK 4fc1df41d5.
  jonasschnelli:
    utACK 4fc1df41d5

Tree-SHA512: b5d303fbc139c9383cd22edecba05e51b0d6115631aeb7d4474e973e7250a84019c11c0e41b5200e4d9ab10e17908774b45234317535857dc5314c3c28614ad4
2020-05-29 10:30:36 +02:00
Jonas Schnelli 0d5c18204b
Merge #17956: gui: Disable unavailable context menu items in transactions tab
2b18fd2242 Disable unavailable context menu items in transactions tab (Kristaps Kaupe)

Pull request description:

  Fixes #9192.

ACKs for top commit:
  jonatack:
    Re-ACK 2b18fd2242
  jonasschnelli:
    codereview utACK 2b18fd2242

Tree-SHA512: 4ea19c7b5976f1f0b1baecccb3077cf82f078af7257f92162686bcce2188efe49511a5f557853bc5fe0b10616708957d61c006944babbe60b8105e78751e865f
2020-05-29 10:29:14 +02:00
Jonas Schnelli a9024a42fc
Merge #17918: qt: Hide non PKHash-Addresses in signing address book
c4ea501e96 qt: Hide non PKHash-Addresses in signing address book (Emil Engler)

Pull request description:

  [Video Demo](https://www.youtube.com/watch?v=T-Rp2pFRmzY)

  This PR hides all non PKHash addresses in the signing GUI in the Address Book when it is opened through the signing dialog, as non PKHash addresses are useless there.

ACKs for top commit:
  jonasschnelli:
    Code Review ACK c4ea501e96

Tree-SHA512: e321d45e15534b2d68da5a1297b1c7551cdd784f03203f54c9385c2ce0bb2b7316c09f9e8c3eb41bfa1e7207ecc94c8ed08f012e2d6c117b803996ade26feb2f
2020-05-29 10:23:08 +02:00
Jonas Schnelli c2c15ea54e
Merge #17908: qt: Remove QFont warnings with QT_QPA_PLATFORM=minimal
1122817c19 qt: Remove QFont warnings with QPA=minimal (Hennadii Stepanov)

Pull request description:

  This PR removes massive warnings like:
  ```
  QWARN  : ... QFont::setPointSizeF: Point size <= 0 (...), must be greater than 0
  ```

  from `test_bitcoin-qt` output.

  On master (e258ce792a):
  ```
  $ ./src/qt/test/test_bitcoin-qt | grep QFont | wc -l
  ~BitcoinApplication : Stopping thread
  ~BitcoinApplication : Stopped thread
  57
  ```

  With this PR:
  ```
  $ ./src/qt/test/test_bitcoin-qt | grep QFont | wc -l
  ~BitcoinApplication : Stopping thread
  ~BitcoinApplication : Stopped thread
  0
  ```

ACKs for top commit:
  promag:
    Code review ACK 1122817c19.
  jonasschnelli:
    utACK 1122817c19

Tree-SHA512: 32fa72a5d3db1d4c73a2a324aa9cad807ee46f23fc5319f7d71202987dc73ea7c90082904489b323a432e1afaebd9976b7dd0374236a16153162aa75fe368723
2020-05-29 10:19:44 +02:00
Jonas Schnelli 3431699981
Merge #17597: qt: Fix height of QR-less ReceiveRequestDialog
73529f0859 qt: Rename slot to updateDisplayUnit() (Hennadii Stepanov)
68288ef0c1 qt: Overhaul ReceiveRequestDialog (Hennadii Stepanov)

Pull request description:

  If master (89a1f7a250) is compiled without QR support, the "Request payment to..." dialog looks ugly:

  ![Screenshot from 2019-11-25 19-58-59](https://user-images.githubusercontent.com/32963518/69566647-3d9c1c80-0fc0-11ea-8ff6-183cea9372c5.png)

  With this PR:

  ![Screenshot from 2019-12-26 00-42-46](https://user-images.githubusercontent.com/32963518/71451226-221c6100-277a-11ea-94ae-c19a5c6256f7.png)

  ![Screenshot from 2019-12-26 00-44-34](https://user-images.githubusercontent.com/32963518/71451228-29436f00-277a-11ea-8ac5-1bafe6d73b5c.png)

  ![Screenshot from 2019-12-26 00-48-51](https://user-images.githubusercontent.com/32963518/71451230-2e082300-277a-11ea-8c4c-726ca7b776e7.png)

  Other minor changes:
  - "URI" abbreviation is not translated now
  - wallet name is shown if available

ACKs for top commit:
  jonasschnelli:
    Tested ACK 73529f0859

Tree-SHA512: 45f9a41d3c72978d78eb2e8ca98e274b8be5abf5352fd3e1f4f49514ce744994545fb3012e80600ded936ae41c6be4d4825a0c5f7bcb3db671d69e0299f0f65b
2020-05-29 10:02:26 +02:00
Jonas Schnelli 5f75c5e7df
Merge #16432: qt: Add privacy to the Overview page
8d75115844 qt: Add privacy feature to Overview page (Hennadii Stepanov)
73d8ef7274 qt: Add BitcoinUnits::formatWithPrivacy() function (Hennadii Stepanov)

Pull request description:

  This PR allows to hide/reveal values on the Overviewpage by checking/unchecking Menu->Settings-> Mask Values

  Closes #16407

  Privacy mode is OFF (the default behavior):
  ![Screenshot from 2020-01-02 15-08-28](https://user-images.githubusercontent.com/32963518/71669074-28ab6980-2d74-11ea-8e54-4973aa307192.png)

  Privacy mode is ON:
  ![Screenshot from 2020-01-02 15-10-23 cropped](https://user-images.githubusercontent.com/32963518/71669082-2d701d80-2d74-11ea-9df5-d4acc4982dbe.png)

ACKs for top commit:
  jonatack:
    Tested ACK 8d75115
  jonasschnelli:
    Tested ACK 8d75115844

Tree-SHA512: 42f396d5bf0d343b306fb7e925f86f66b3fc3a257af370a812f4be181b5269298f9b23bd8a3ce25ab61de92908c4018d8c2dc8591d11bc58d79c4eb7206fc6ec
2020-05-29 08:55:16 +02:00
Andrew Chow 79b0a69e09 Add missing QPainterPath include
This is needed to compile with Qt 5.15.
2020-05-28 14:56:47 -04:00
Wladimir J. van der Laan ea3e9e0b84
Merge #18700: Fix locking on WSL using flock instead of fcntl
e8fa0a3d20 Fix WSL file locking by using flock instead of fcntl (Samuel Dobson)

Pull request description:

  Fixes #18622

  A bug in WSL means that fcntl does not exclusively lock files, allowing multiple instances of bitcoin to use the same datadir. If we instead use flock, it works correctly. Passes Travis, but testing on some OS variety would be sensible.

  From what I can tell, flock and fcntl don't work with each other on linux, so it would still be possible to run a node with this code change and a node before it with the same datadir (this isn't true for Mac/FreeBSD). flock also doesn't support NFS on MacOS and linux<2.6.12 while fcntl did. See here for example: https://gavv.github.io/articles/file-locks/

  If changing to flock for all systems is inadvisable, it would also be possible to just detect WSL and use flock when on that platform to avoid the bug.

ACKs for top commit:
  laanwj:
    Code review ACK e8fa0a3d20

Tree-SHA512: ca1009e171970101f1dc2332c5e998717aee00eebc80bb586b826927a74bd0d4c94712e46d1396821bc30533d76deac391b6e1c406c406865661f57fa062c702
2020-05-28 17:55:20 +02:00
fanquake 789e9dd3aa
validation: use std::chrono in IsCurrentForFeeEstimation() 2020-05-28 21:43:36 +08:00
fanquake 47be28c8bc
validation: use std::chrono in CChainState::FlushStateToDisk() 2020-05-28 21:39:41 +08:00
glowang f871f15c9d scripted-diff: replace gArgs with argsman
-BEGIN VERIFY SCRIPT-
sed -i 's/\<gArgs\>/m_args/g' src/test/getarg_tests.cpp
-END VERIFY SCRIPT-
2020-05-28 06:22:19 -07:00
glowang 357f02bf29 Create a local class inherited from BasicTestingSetup with a localized args manager
and put it into the getarg_tests namespace
2020-05-28 06:21:43 -07:00
Hennadii Stepanov 9cc6eb3c9e
Get rid of -Wthread-safety-precise warnings 2020-05-28 09:55:39 +03:00
Hennadii Stepanov 971a468ccf
Use template function instead of void* parameter
This change gets rid of -Wthread-safety-attributes warning spam.
2020-05-28 09:55:04 +03:00
Hennadii Stepanov dfb75ae49d
refactor: Rename LockGuard to StdLockGuard for consistency with StdMutex 2020-05-28 09:54:24 +03:00
Hennadii Stepanov 79be487420
Add thread safety annotated wrapper for std::mutex
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2020-05-28 09:54:09 +03:00
Russell Yanofsky 4a7253ab6c Remove g_rpc_chain global
Replace with RPC request reference to new WalletContext struct similar to the
existing NodeContext struct and reference.

This PR is a followup to 25ad2c623a
https://github.com/bitcoin/bitcoin/pull/18740 removing the g_rpc_node global.

Some later PRs will follow this up and move more wallet globals to the
WalletContext struct.

Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
2020-05-28 02:13:19 -04:00
Russell Yanofsky e783197bf0 refactor: replace RegisterWalletRPCCommands with GetWalletRPCCommands 2020-05-28 02:13:19 -04:00
MarcoFalke 55b4c65bd1
Merge #16127: More thread safety annotation coverage
5478d6c099 logging: thread safety annotations (Anthony Towns)
e685ca1992 util/system.cpp: add thread safety annotations for dir_locks (Anthony Towns)
a788789948 test/checkqueue_tests: thread safety annotations (Anthony Towns)
479c5846f7 rpc/blockchain.cpp: thread safety annotations for latestblock (Anthony Towns)
8b5af3d4c1 net: fMsgProcWake use LOCK instead of lock_guard (Anthony Towns)
de7c5f41ab wallet/wallet.h: Remove mutexScanning which was only protecting a single atomic bool (Anthony Towns)
c3cf2f5501 rpc/blockchain.cpp: Remove g_utxosetscan mutex that is only protecting a single atomic variable (Anthony Towns)

Pull request description:

  In a few cases we need to use `std::mutex` rather than the sync.h primitives. But `std::lock_guard<std::mutex>` doesn't include the clang thread safety annotations unless you also use clang's C library, which means you can't indicate when variables should be guarded by `std::mutex` mutexes.

  This adds an annotated version of `std::lock_guard<std::mutex>` to threadsafety.h to fix that, and modifies places where `std::mutex` is used to take advantage of the annotations.

  It's based on top of #16112, and turns the thread safety comments included there into annotations.

  It also changes the RAII classes in wallet/wallet.h and rpc/blockchain.cpp to just use the atomic<bool> flag for synchronisation rather than having a mutex that doesn't actually guard anything as well.

ACKs for top commit:
  MarcoFalke:
    ACK 5478d6c099 🗾
  hebasto:
    re-ACK 5478d6c099, only renamed s/`MutexGuard`/`LockGuard`/, and dropped the commit "test/util_threadnames_tests: add thread safety annotations" since the [previous](https://github.com/bitcoin/bitcoin/pull/16127#pullrequestreview-414184113) review.
  ryanofsky:
    Code review ACK 5478d6c099. Thanks for taking suggestions! Only changes since last review are dropping thread rename test commit d53072ec730d8eec5a5b72f7e65a54b141e62b19 and renaming mutex guard to lock guard

Tree-SHA512: 7b00d31f6f2b5a222ec69431eb810a74abf0542db3a65d1bbad54e354c40df2857ec89c00b4a5e466c81ba223267ca95f3f98d5fbc1a1d052a2c3a7d2209790a
2020-05-27 19:31:33 -04:00
MarcoFalke fa7b885f51
walletdb: Remove unsed boost/thread 2020-05-27 13:41:56 -04:00
MarcoFalke fab893e0ca
doc: Fix unrelated typos reported by codespell 2020-05-27 12:37:08 -04:00
MarcoFalke 9ccaee1d5e
Merge #19004: refactor: Replace const char* to std::string
c57f03ce17 refactor: Replace const char* to std::string (Calvin Kim)

Pull request description:

  Rationale: Addresses #19000
  Some functions should be returning std::string instead of const char*.
  This commit changes that.

  Main benefits/reasoning:

  1.  The functions never return nullptr, so returning a string makes code at call sites easier to review (reviewers don't have to read the source code to verify that a nullptr is never returned)
  2. All call sites convert to string anyway

ACKs for top commit:
  MarcoFalke:
    re-ACK c57f03ce17 (no changes since previous review) 🚃
  Empact:
    Fair enough, Code Review ACK c57f03ce17
  practicalswift:
    ACK c57f03ce17 -- patch looks correct
  hebasto:
    re-ACK c57f03ce17

Tree-SHA512: 9ce99bb38fe399b54844315048204cafce0f27fd8f24cae357fa7ac6f5d8094d57bbf5f5c1f5878a65f2d35e4a3f95d527eb17f49250b690c591c0df86ca84fd
2020-05-27 07:16:10 -04:00
fanquake cffbf1eb9a
Merge #19073: Remove outdated comment about DER encoding
4c825792dd Remove outdated comment about DER encoding (Elichai Turkel)

Pull request description:

  This comment got me confused about the status of BIP66 (Thanks jnewbery for explaining)
  The comment was added in: https://github.com/bitcoin/bitcoin/pull/3843
  But in https://github.com/bitcoin/bitcoin/pull/5713 strict DER encoding was enforced in consensus,
  and is now it's buried and enforced by the height of the block here: 4af01b37d4/src/validation.cpp (L1889)

  P.S. This is also quite confusing: 4af01b37d4/src/validation.cpp (L1560-L1563) But seems to be intentional: 4af01b37d4/src/validation.cpp (L1510-L1511)

ACKs for top commit:
  laanwj:
    ACK 4c825792dd

Tree-SHA512: 7afbbae84ed4ecfaa0a273ae024b14f2b7ffe65307f078086fe0b5b645c57722bc2952fb15d167d9e4fa5b052d1d0ac6e5e33f57e8fc881c0ea611d352bccc1e
2020-05-27 18:35:54 +08:00
Hennadii Stepanov 8d75115844
qt: Add privacy feature to Overview page 2020-05-27 11:55:44 +03:00
Samuel Dobson 520e435b5e
Merge #18918: wallet: Move salvagewallet into wallettool
84ae0578b6 Add release notes about salvage changes (Andrew Chow)
ea337f2d03 Move RecoverKeysOnlyFilter into RecoverDataBaseFile (Andrew Chow)
9ea2d258b4 Move RecoverDatabaseFile and RecoverKeysOnlyFilter into salvage.{cpp/h} (Andrew Chow)
b426c7764d Make BerkeleyBatch::Recover and WalletBatch::RecoverKeysOnlyFilter standalone (Andrew Chow)
2741774214 Expose a version of ReadKeyValue and use it in RecoverKeysOnlyFilter (Andrew Chow)
ced95d0e43 Move BerkeleyEnvironment::Salvage into BerkeleyBatch::Recover (Andrew Chow)
07250b8dce walletdb: remove fAggressive from Salvage (Andrew Chow)
8ebcbc85c6 walletdb: don't automatically salvage when corruption is detected (Andrew Chow)
d321046f4b wallet: remove -salvagewallet (Andrew Chow)
cdd955e580 Add basic test for bitcoin-wallet salvage (Andrew Chow)
c87770915b wallettool: Add a salvage command (Andrew Chow)

Pull request description:

  Removes the `-salvagewallet` startup option and adds a `salvage` command to the `bitcoin-wallet` tool. As such, `-salvagewallet` is removed. Additionally, the automatic salvage that is done if the wallet file fails to load is removed.

  Lastly the salvage code entirely is moved out entirely into `bitcoin-wallet` from `walletdb.{cpp/h}` and `db.{cpp/h}`.

ACKs for top commit:
  jonatack:
    ACK 84ae0578b6 feedback taken, and compared to my previous review, the bitcoin-wallet salvage command now seems to run and it exits without raising. The new test passes at both 9454105 and 84ae057 so as a sanity check I'd agree there is room for improvement, if possible.
  MarcoFalke:
    re-ACK 84ae0578b6 🏉
  Empact:
    Code Review ACK 84ae0578b6
  ryanofsky:
    Code review ACK 84ae0578b6. Lot of small changes since previous review: added verify step before salvage, added basic test in new commit, removed unused scanstate variable and warnings parameter, tweaked various comments and strings, moved fsuccess variable declaration
  meshcollider:
    Concept / light code review ACK 84ae0578b6

Tree-SHA512: 05be116b56ecade1c58faca1728c8fe4b78f0a082dbc2544a3f7507dd155f1f4f39070bd1fe90053444384337bc48b97149df5c1010230d78f8ecc08e69d93af
2020-05-27 14:51:49 +12:00
MarcoFalke 5555d978b0
wallet: Make PeriodicFlush uninterruptible 2020-05-26 19:56:43 -04:00
Jim Posen 11106a4722 [net processing] Message handling for getcfilters.
Handle getcfilters request if -peercfilter is configured.
2020-05-26 17:38:20 -04:00
Jim Posen e535670726 [indexes] Fix default [de]serialization of BlockFilter.
This only changes network serialization. Disk serialization does not
include the filter_type and is defined in
ReadFilterFromDisk()/WriteFilterToDisk().
2020-05-26 17:27:15 -04:00
John Newbery bb911ae7f5 [refactor] Pass CNode and CConnman by reference
Pass CNode and CConnman by reference instead of by pointer to
ProcessGetCFCheckPt() and ProcessGetCFHeaders().
2020-05-26 17:24:17 -04:00
Elichai Turkel 4c825792dd
Remove outdated comment about DER encoding 2020-05-26 18:39:01 +03:00
Anthony Towns 5478d6c099 logging: thread safety annotations
Adds LockGuard helper in threadsafety.h to replace lock_guard<mutex>
when LOCK(Mutex) isn't available for use.
2020-05-27 01:31:51 +10:00
Wladimir J. van der Laan dcacea096e
Merge #19032: Serialization improvements: final step
71f016c6eb Remove old serialization primitives (Pieter Wuille)
92beff15d3 Convert LimitedString to formatter (Pieter Wuille)
ef17c03e07 Convert wallet to new serialization (Pieter Wuille)
65c589e45e Convert Qt to new serialization (Pieter Wuille)

Pull request description:

  This is the final step 🥳 of the serialization improvements extracted from #10785.

  It converts the LimitedString wrapper to a new-style formatter, and updates the wallet and Qt code to use the new serialization framework. Finally all remaining old primitives are removed.

ACKs for top commit:
  jonatack:
    ACK 71f016c6eb reviewed diff, builds/tests/re-fuzzed.
  laanwj:
    Code review ACK 71f016c6eb

Tree-SHA512: d952194bc73259f6510bd4ab1348a1febbbf9862af30f905991812fb0e1f23f15948cdb3fc662be54d648e8f6d95b11060055d2e7a8c2cb5bf008224870b1ea1
2020-05-26 15:45:50 +02:00
Anthony Towns e685ca1992 util/system.cpp: add thread safety annotations for dir_locks 2020-05-26 23:23:15 +10:00
MarcoFalke fe1357a03a
Merge #18881: Prevent UB in DeleteLock() function
90eb027204 doc: Add and fix comments about never destroyed objects (Hennadii Stepanov)
26c093a995 Replace thread_local g_lockstack with a mutex-protected map (Hennadii Stepanov)
58e6881bc5 refactor: Refactor duplicated code into LockHeld() (Hennadii Stepanov)
f511f61dda refactor: Add LockPair type alias (Hennadii Stepanov)
8d8921abd3 refactor: Add LockStackItem type alias (Hennadii Stepanov)
458992b06d Prevent UB in DeleteLock() function (Hennadii Stepanov)

Pull request description:

  Tracking our instrumented mutexes (`Mutex` and `RecursiveMutex` types) requires that all involved objects should not be destroyed until after their last use. On master (ec79b5f86b) we have two problems related to the object destroying order:
  - the function-local `static` `lockdata` object that is destroyed at [program exit](https://en.cppreference.com/w/cpp/utility/program/exit)
  - the `thread_local` `g_lockstack` that is destroyed at [thread exit](https://en.cppreference.com/w/cpp/language/destructor)

  Both cases could cause UB at program exit in so far as mutexes are used in other static object destructors.

  Fix #18824

ACKs for top commit:
  MarcoFalke:
    re-ACK 90eb027204, only change is new doc commit 👠
  ryanofsky:
    Code review ACK 90eb027204 because all the changes look correct and safe. But I don't know the purpose of commit  26c093a995 "Replace thread_local g_lockstack with a mutex-protected map (5/6)." It seems like it could have a bad impact on debug performance, and the commit message and PR description don't give a reason for the change.

Tree-SHA512: 99f29157fd1278994e3f6eebccedfd9dae540450f5f8b980518345a89d56b635f943a85b20864cef087027fd0fcdb4880b659ef59bfe5626d110452ae22031c6
2020-05-26 08:14:57 -04:00
MarcoFalke 13397dc78f
Merge #19056: rpc: Make gettxoutsetinfo/GetUTXOStats interruptible
fa756928c3 rpc: Make gettxoutsetinfo/GetUTXOStats interruptible (MarcoFalke)
fa7fc5a8e0 rpc: factor out RpcInterruptionPoint from dumptxoutset (MarcoFalke)

Pull request description:

  Make it interruptible, so that shutdown doesn't block for up to one hour.

  Fixes (partially) #13217

ACKs for top commit:
  Empact:
    Code Review ACK fa756928c3
  laanwj:
    Code review ACK fa756928c3

Tree-SHA512: 298261e0ff7d79fab542b8f6828cc0ac451cbafe396d5f0816c9d36437faba1330f5c4cb2a25c5540e202bfb9783da6ec858bd453056ce488d21e36335d3d42c
2020-05-26 07:33:43 -04:00
MarcoFalke d3b0ef80f6
Merge #18867: tests: Add fuzzing harness for CCoinsViewCache
f9b22e3bdb tests: Add fuzzing harness for CCoinsViewCache (practicalswift)

Pull request description:

  Add fuzzing harness for `CCoinsViewCache`.

  See [`doc/fuzzing.md`](https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md) for information on how to fuzz Bitcoin Core. Don't forget to contribute any coverage increasing inputs you find to the [Bitcoin Core fuzzing corpus repo](https://github.com/bitcoin-core/qa-assets).

  Happy fuzzing :)

ACKs for top commit:
  MarcoFalke:
    ACK f9b22e3bdb 📫

Tree-SHA512: 4fa79aab683875eef128b672cf199909c86e4d2ed7c406f006fa27a546dafc9cb0061c4de5e660e622458072f1dab69dbf6b6b03d5b863f81c5710bf4cee6c0c
2020-05-26 07:29:44 -04:00
MarcoFalke 7d32cce3e7
Merge #19010: net processing: Add support for getcfheaders
5308c97cca [test] Add test for cfheaders (Jim Posen)
f6b58c1506 [net processing] Message handling for getcfheaders. (Jim Posen)
3bdc7c2d39 [doc] Add comment for m_headers_cache (John Newbery)

Pull request description:

  Support `getcfheaders` requests when `-peerblockfilters` is set.

  Does not advertise compact filter support in version messages.

ACKs for top commit:
  jkczyz:
    ACK 5308c97cca
  MarcoFalke:
    re-ACK 5308c97cca , only change is doc related 🗂
  theStack:
    ACK 5308c97cca 🚀

Tree-SHA512: 240fc654f6f634c191d9f7628b6c4801f87ed514a1dd55c7de5d454d4012d1c09509a2d5a246bc7da445cd920252b4cd56a493c060cdb207b04af4ffe53b95f7
2020-05-26 07:27:00 -04:00
Amiti Uttarwar 9e1cb1adf1 [trivial/doc] Fix comment type 2020-05-25 11:27:07 -07:00
Amiti Uttarwar 8f30260a67 [doc] Update unbroadcast description in RPC results 2020-05-25 11:27:07 -07:00
Amiti Uttarwar 750456d6f2 [trivial] Remove misleading 'const'
Returning by const value is only meaningful in a specific circumstance around
user defined types. In this case, the const is not enforcing any restrictions
on the call site, so is misleading.
2020-05-25 11:27:07 -07:00
Amiti Uttarwar 1f94bb0c74 [doc] Provide rationale for randomization in scheduling. 2020-05-25 11:27:07 -07:00
Amiti Uttarwar 9c8a55d9cb [mempool] Don't throw expected error message when upgrading 2020-05-25 11:27:07 -07:00
Andrew Chow ea337f2d03 Move RecoverKeysOnlyFilter into RecoverDataBaseFile 2020-05-25 12:59:29 -04:00
Andrew Chow 9ea2d258b4 Move RecoverDatabaseFile and RecoverKeysOnlyFilter into salvage.{cpp/h} 2020-05-25 12:59:29 -04:00
Andrew Chow b426c7764d Make BerkeleyBatch::Recover and WalletBatch::RecoverKeysOnlyFilter standalone
Instead of having these be class static functions, just make them be
standalone. Also removes WalletBatch::Recover which just passed through
to BerkeleyBatch::Recover.
2020-05-25 12:59:29 -04:00
Andrew Chow 2741774214 Expose a version of ReadKeyValue and use it in RecoverKeysOnlyFilter
We need this exposed for BerkeleyBatch::Recover to be moved out.
2020-05-25 12:59:29 -04:00
Andrew Chow ced95d0e43 Move BerkeleyEnvironment::Salvage into BerkeleyBatch::Recover 2020-05-25 12:59:29 -04:00
Andrew Chow 07250b8dce walletdb: remove fAggressive from Salvage
The only call to Salvage set fAggressive = true so remove that parameter
and always use DB_AGGRESSIVE
2020-05-25 12:59:29 -04:00
Andrew Chow 8ebcbc85c6 walletdb: don't automatically salvage when corruption is detected 2020-05-25 12:59:22 -04:00
Andrew Chow d321046f4b wallet: remove -salvagewallet 2020-05-25 12:39:40 -04:00
Andrew Chow c87770915b wallettool: Add a salvage command 2020-05-25 12:36:48 -04:00
practicalswift f9b22e3bdb tests: Add fuzzing harness for CCoinsViewCache 2020-05-25 10:05:06 +00:00
Pieter Wuille 71f016c6eb Remove old serialization primitives 2020-05-24 10:35:00 -07:00
Pieter Wuille 92beff15d3 Convert LimitedString to formatter 2020-05-24 10:35:00 -07:00
Pieter Wuille ef17c03e07 Convert wallet to new serialization 2020-05-24 10:34:52 -07:00
furszy a06e845e82
BlockTip struct created and connected to notifyHeaderTip and notifyBlockTip signals. 2020-05-23 20:02:10 -03:00
furszy 2f867203b0
Added best block hash to the NotifyHeaderTip and NotifyBlockTip signals.
[ClientModel] best header/block hash cached.
2020-05-23 20:02:04 -03:00
Hennadii Stepanov 73d8ef7274
qt: Add BitcoinUnits::formatWithPrivacy() function 2020-05-23 16:47:10 +03:00
Samuel Dobson 24f7029064
Merge #18594: cli: display multiwallet balances in -getinfo
5edad5ce5d test: add -getinfo multiwallet functional tests (Jon Atack)
903b6c117f rpc: drop unused JSONRPCProcessBatchReply size arg, refactor (Jon Atack)
afce85eb99 cli: use GetWalletBalances() functionality for -getinfo (Jon Atack)
9f01849a49 cli: create GetWalletBalances() to fetch multiwallet balances (Jon Atack)
743077544b cli: lift -rpcwallet logic up to CommandLineRPC() (Jon Atack)
29f2cbdeb7 cli: extract connection exception handler, -rpcwait logic (Jon Atack)

Pull request description:

  This PR is a client-side version of #18453, per review feedback there and [review club discussions](https://bitcoincore.reviews/18453#meeting-log). It updates `bitcoin-cli -getinfo` on the client side to display wallet name and balance for the loaded wallets when more than one is loaded (e.g. you are in "multiwallet mode") and `-rpcwallet=` is not passed; otherwise, behavior is unchanged.

  before
  ```json
  $ bitcoin-cli -getinfo -regtest
  {
    "version": 199900,
    "blocks": 15599,
    "headers": 15599,
    "verificationprogress": 1,
    "timeoffset": 0,
    "connections": 0,
    "proxy": "",
    "difficulty": 4.656542373906925e-10,
    "chain": "regtest",
    "balance": 0.00001000,
    "relayfee": 0.00001000
  }

  ```
  after
  ```json
  $ bitcoin-cli -getinfo -regtest
  {
    "version": 199900,
    "blocks": 15599,
    "headers": 15599,
    "verificationprogress": 1,
    "timeoffset": 0,
    "connections": 0,
    "proxy": "",
    "difficulty": 4.656542373906925e-10,
    "chain": "regtest",
    "balances": {
      "": 0.00001000,
      "Encrypted": 0.00003500,
      "day-to-day": 0.00000120,
      "side project": 0.00000094
    }
  }
  ```
  -----

  `Review club` discussion about this PR is here: https://bitcoincore.reviews/18453

  This PR can be manually tested by building, creating/loading/unloading several wallets with `bitcoin-cli createwallet/loadwallet/unloadwallet` and running `bitcoin-cli -getinfo` and `bitcoin-cli -rpcwallet=<wallet-name> -getinfo`.

  `wallet_multiwallet.py --usecli` provides regression test coverage on this change, along with `interface_bitcoin_cli.py` where this PR adds test coverage.

  Credit to Wladimir J. van der Laan for the idea in https://github.com/bitcoin/bitcoin/issues/17314 and https://github.com/bitcoin/bitcoin/pull/18453#issuecomment-605431806.

ACKs for top commit:
  promag:
    Tested ACK 5edad5ce5d.
  jnewbery:
    utACK 5edad5ce5d
  meshcollider:
    Code review ACK 5edad5ce5d

Tree-SHA512: 4ca36c5f6c49936b40afb605c44459c1d5b80b5bd84df634007ca276b3f6c102a0cb382f9d528370363ee32c94b0d7ffa15184578eaf8de74179e566c5c5cee5
2020-05-24 00:17:38 +12:00
MarcoFalke 793e0ff22c
Merge #18698: Make g_chainman internal to validation
fab6b9d18f validation: Mark g_chainman DEPRECATED (MarcoFalke)
fa1d97b256 validation: Make ProcessNewBlock*() members of ChainstateManager (MarcoFalke)
fa24d49098 validation: Make PruneOneBlockFile() a member of ChainstateManager (MarcoFalke)
fa84b1cd84 validation: Make LoadBlockIndex() a member of ChainstateManager (MarcoFalke)
fa05fdf0f1 net: Pass chainman into PeerLogicValidation (MarcoFalke)
fa7b626d7a node: Add chainman alias for g_chainman (MarcoFalke)

Pull request description:

  The global `g_chainman` has recently been introduced in #17737. The chainstate manager is primarily needed for the assumeutxo feature, but it can also simplify testing in the future.

  The goal of this pull is to make the global chainstate manager internal to validation, so that all external code does not depend on globals and that unit or fuzz tests can pass in their (potentially mocked) chainstate manager.

  I suggest reviewing the pull request commit-by-commit. It should be relatively straightforward refactoring that does not change behavior at all.

ACKs for top commit:
  ryanofsky:
    Code review ACK fab6b9d18f. Had to be rebased but still looks good

Tree-SHA512: dcbf114aeef4f8320d466369769f22ce4dd8f46a846870354df176c3de9ff17c64630fbd777e7121d7470d7a8564ed8d37b77168746e8df7489c6877e55d7b4f
2020-05-23 07:58:13 -04:00
Russell Yanofsky 7eaf86d3bf trivial: Suggested cleanups to surrounding code
https://github.com/bitcoin/bitcoin/pull/18982#pullrequestreview-416974841
2020-05-22 16:30:07 -04:00
MarcoFalke fa756928c3
rpc: Make gettxoutsetinfo/GetUTXOStats interruptible
Also, add interruption points to scantxoutset
2020-05-22 15:53:50 -04:00
MarcoFalke fa7fc5a8e0
rpc: factor out RpcInterruptionPoint from dumptxoutset 2020-05-22 15:52:37 -04:00
Jim Posen f6b58c1506 [net processing] Message handling for getcfheaders.
if -peerblockfilters is configured, handle requests for cfheaders.
2020-05-22 11:59:58 -04:00
John Newbery 3bdc7c2d39 [doc] Add comment for m_headers_cache 2020-05-22 11:59:58 -04:00
practicalswift 6a239e72eb tests: Don't limit fuzzing inputs to 1 MB for afl-fuzz (now: ∞ ∀ fuzzers) 2020-05-22 15:15:46 +00:00
Hennadii Stepanov 90eb027204
doc: Add and fix comments about never destroyed objects 2020-05-22 15:45:21 +03:00
Samuel Dobson df303ceb65
Merge #18787: wallet: descriptor wallet release notes and cleanups
ca2a09640f Change SetType to SetInternal and remove m_address_type (Andrew Chow)
89b1ce1140 Remove unimplemented SetCrypted from DescriptorScriptPubKeyMan (Andrew Chow)
b9073c8f13 rpc: createwallet warning that descriptor wallets are experimental (Andrew Chow)
610030d95c docs: Add release notes for descriptor wallets (Andrew Chow)

Pull request description:

  Some docs and cleanup following #16528.

  * Added release notes to explain a bit of motivation for descriptor wallets, what was changed, and how users will be effected by it. Also mentions the caveats regarding multsigs and watchonly that we have discussed on IRC.
  * Adds a warning to `createwallet` that descriptor wallets are experimental.
  * Removed unused `SetCrypted` as suggestioned: https://github.com/bitcoin/bitcoin/pull/16528#discussion_r415300916
  * Removed `m_address_type` as mentioned in https://github.com/bitcoin/bitcoin/pull/18782#issuecomment-620167077

ACKs for top commit:
  Sjors:
    tACK ca2a09640f
  instagibbs:
    utACK ca2a09640f
  meshcollider:
    utACK ca2a09640f

Tree-SHA512: 987188a912c191430e5d3f89bcef54ba6773692fc2d95b16a3ec11d9007ded210466ed980a3857e8b7196beef6422f07f9c85cc157f996c02d16f4dbde2e7b2a
2020-05-22 14:21:56 +12:00
Samuel Dobson ccd85b57af
Merge #17681: wallet: Keep inactive seeds after sethdseed and derive keys from them as needed
1ed52fbb4d Remove IBD check in sethdseed (Andrew Chow)
b1810a145a Test that keys from inactive seeds are generated (Andrew Chow)
c93082ece4 Generate new keys for inactive seeds after marking used (Andrew Chow)
45f2f6a0e8 Determine inactive HD seeds from key metadata and track them in LegacyScriptPubKeyMan (Andrew Chow)
b59b4504ab have GenerateNewKey and DeriveNewChildKey take a CHDChain as an argument (Andrew Chow)

Pull request description:

  Largely implements the suggestion from https://github.com/bitcoin/bitcoin/pull/17484#issuecomment-560845316.

  After `sethdseed` is called, the CHDChain for the old seed is kept in the wallet. It is kept on the file as a new `inactivehdseed` record and in memory in a map `m_inactive_hd_seeds`. In `LegacyScriptPubKeyMan::MarkUnusedAddresses` we check each used key's metadata for whether it was derived from an inactive seed. If it is, we then check to see how many keys after that key were derived from the inactive seed. If that number does not match the keypool parameter, we derive more keys from the inactive seed until it does match. This way we won't miss transactions belonging to keys outside of the range of the keypool initially.

  The indexes and internal-ness of a key is gotten by checking it's key origin data.

  Because of this change, we no longer need to wait for IBD to finish before `sethdseed` can work so that check is also removed.

  A test case for this is added as well which fails on master.

ACKs for top commit:
  ryanofsky:
    Code review ACK 1ed52fbb4d. Changes since last review: various commit message, code comment, log message, error checking improvements, and fix for topping up inactive seeds if wallet isn't reloaded after calling sethdseed and test for this
  ariard:
    Code Review ACK 1ed52fb
  jonatack:
    ACK 1ed52fbb4d thanks for addressing the previous review feedback; would be happy to see the new review questions answered and feedback addressed and re-ack.

Tree-SHA512: e658ae0e1dab94be55d2b62cdda506c94815e73a6881533fd30d41cc77477f82fee2095144957a3a1df0c129e256bdd7b7abe3737d515f393610446cae4edf1c
2020-05-22 13:48:26 +12:00
fanquake ad3a61c5f5
Merge #18895: p2p: unbroadcast followups: rpcs, nLastResend, mempool sanity check
651f1d816f [test] wait for inital broadcast before comparing mempool entries (gzhao408)
9d3f7eb986 [mempool] sanity check that all unbroadcast txns are in mempool (gzhao408)
a7ebe48b94 [rpc] add unbroadcast info to mempool entries and getmempoolinfo (gzhao408)
d160069604 [wallet] remove nLastResend logic (gzhao408)

Pull request description:

  Followup to #18038 by amitiuttarwar which introduces the unbroadcast set: "a mechanism for the mempool to track locally submitted transactions" and decreases the frequency of rebroadcast from 10-15 minutes to 12-36 hours.

  This PR addresses some of the outstanding TODOs building on top of it:
  - remove `nLastResend` logic, which is used to ensure rebroadcast doesn't happen again if no new block has been mined (makes sense in 10-15 min period, but not necessary for 12-36 hour period). (#18038 [comment](https://github.com/bitcoin/bitcoin/pull/18038#discussion_r416826914))
  - expose unbroadcast info via RPCs, for more informative queries and testing (#18038 [comment](https://github.com/bitcoin/bitcoin/pull/18038#discussion_r416837980))
  - add sanity check to verify unbroadcast transactions still exist in mempool before rebroadcasting (#18038 [comment](https://github.com/bitcoin/bitcoin/pull/18038#discussion_r416861609))

ACKs for top commit:
  naumenkogs:
    Code review ACK 651f1d816f
  amitiuttarwar:
    ACK 651f1d816f 🎉
  MarcoFalke:
    Review ACK 651f1d816f

Tree-SHA512: d5327e95ef39d44152b48df5c610502ae11c168f43dbbfb2885340c93d1ba9426eb3a5794573f5fc843502109cb3ffb63efa3f2db4f8f112efcde8f76d9a8845
2020-05-22 07:51:51 +08:00
Wladimir J. van der Laan 9abed46871
Merge #16946: wallet: include a checksum of encrypted private keys
d67055e00d Upgrade or rewrite encrypted key checksums (Andrew Chow)
c9a9ddb414 Set fDecryptionThoroughlyChecked based on whether crypted key checksums are valid (Andrew Chow)
a8334f7ac3 Read and write a checksum for encrypted keys (Andrew Chow)

Pull request description:

  Adds a checksum to the encrypted key record in the wallet database so that encrypted keys can be checked for corruption on wallet loading, in the same way that unencrypted keys are. This allows for us to skip the full decryption of keys upon the first unlocking of the wallet in that session as any key corruption will have already been detected. The checksum is just the double SHA256 of the encrypted key and it is appended to the record after the encrypted key itself.

  This is backwards compatible as old wallets will be able to read the encrypted key and ignore that there is more data in the stream. Additionally, old wallets will be upgraded upon their first unlocking (so that key decryption is checked before we commit to a checksum of the encrypted key) and a wallet flag set indicating that. The presence of the wallet flag lets us skip the full decryption as if `fDecryptionThoroughlyChecked` were true.

  This does mean that the first time an old wallet is unlocked in a new version will take much longer, but subsequent unlocks will be instantaneous. Furthermore, corruption will be detected upon loading rather than on trying to send so wallet corruption will be detected sooner.

  Fixes #12423

ACKs for top commit:
  laanwj:
    code review ACK d67055e00d
  jonatack:
    Code review ACK d67055e00d
  meshcollider:
    Code review ACK d67055e00d

Tree-SHA512: d5c1c10cfcb5db9e10dcf2326423565a9f499290b81f3155ec72254ed5bd7491e2ff5c50e98590eb07842c20d7797b4efa1c3475bae64971d500aad3b4e711d4
2020-05-21 20:50:25 +02:00
Wladimir J. van der Laan 4479eb04d9
Merge #18960: indexes: Add compact block filter headers cache
0187d4c118 [indexes] Add compact block filter headers cache (John Newbery)

Pull request description:

  Cache block filter headers at heights of multiples of 1000 in memory.

  Block filter headers at height 1000x are checkpointed, and will be the most frequently requested. Cache them in memory to avoid costly disk reads.

ACKs for top commit:
  jkczyz:
    ACK 0187d4c118
  theStack:
    ACK 0187d4c118 🎉
  fjahr:
    re-utACK 0187d4c118
  laanwj:
    code review ACK 0187d4c118
  ariard:
    Code Review ACK 0187d4c.

Tree-SHA512: 2075ae36901ebcdc4a217eae5203ebc8582181a0831fb7a53a119f031c46bca960a610a38a3d0636a9a405f713efcf4200c85f10c8559fd80139036d89473c56
2020-05-21 19:34:29 +02:00
Calvin Kim c57f03ce17 refactor: Replace const char* to std::string
Some functions should be returning std::string instead of const char*.
This commit changes that.
2020-05-22 01:40:31 +09:00
Wladimir J. van der Laan fed1a9043f
Merge #19020: net: Use C++11 member initialization in protocol
fa8bbb1368 net: Use C++11 member initialization in protocol (MarcoFalke)

Pull request description:

  This change removes `Init` from the constructors and instead uses C++11 member initialization. This removes a bunch of boilerplate, makes the code easier to read. Also, C++11 member initialization avoids accidental uninitialized members.

ACKs for top commit:
  laanwj:
    ACK fa8bbb1368

Tree-SHA512: f89f6c2fe1bbfccd92acd72c0129d43e464339ed17e95384a81ed33a1a4257dba7ecc1534c6fc8c4668f0d9ade7ba0807b57066c6c763c1b72f74fc51f40907a
2020-05-21 17:44:03 +02:00
MarcoFalke 7418169364
Merge #18997: gui: Remove un-actionable TODO
4444dbf4d5 gui: Remove un-actionable TODO (MarcoFalke)

Pull request description:

  With encryption turned on by default for all wallets in consideration (#18889), I believe that wallet decryption will not be implemented ever or at least any time soon. So remove that TODO comment for now. If deemed important, a brainstorming issue can be opened instead.

  Also remove some TODOs in the RPC console, which I don't understand. Maybe the gui was meant to show the debug log interactively? In any case, if deemed important, this should be filed as a brainstorming feature request, so that trade-offs of different solutions can be discussed.

ACKs for top commit:
  laanwj:
    Thanks. ACK 4444dbf4d5
  achow101:
    ACK 4444dbf4d5

Tree-SHA512: f7ddb37a14178f575da5409ea1c34e34bde37d79b2b56eaaf606a069e2b91c9d7b734529f5c68664b2fa5aa831117c8d19cce823743671cd6c31b81d68b8c70c
2020-05-21 10:58:28 -04:00
MarcoFalke fab6b9d18f
validation: Mark g_chainman DEPRECATED 2020-05-21 09:56:25 -04:00
MarcoFalke fa1d97b256
validation: Make ProcessNewBlock*() members of ChainstateManager 2020-05-21 09:56:16 -04:00
MarcoFalke fa24d49098
validation: Make PruneOneBlockFile() a member of ChainstateManager 2020-05-21 09:56:16 -04:00
MarcoFalke fa84b1cd84
validation: Make LoadBlockIndex() a member of ChainstateManager 2020-05-21 09:55:59 -04:00
MarcoFalke fa05fdf0f1
net: Pass chainman into PeerLogicValidation 2020-05-21 09:55:58 -04:00
MarcoFalke fa7b626d7a
node: Add chainman alias for g_chainman 2020-05-21 09:55:51 -04:00
MarcoFalke cfe22a5f9e
Merge #18530: Add test for -blocksonly and -whitelistforcerelay param interaction
0ea5d70b47 Updated comment for the condition where a transaction relay is denied (glowang)
be01449cc8 Add test for param interaction b/w -blocksonly and -whitelistforcerelay (glowang)

Pull request description:

  Related to: #18428

  When -blocksonly is turned on, a node would still relay transactions from whitelisted peers. This funcitonality has not been tested.

ACKs for top commit:
  MarcoFalke:
    ACK 0ea5d70b47

Tree-SHA512: 4e99c88281cb518cc67f5f3be7171a7b413933047b5d24a04bb3ff2210a82e914d69079f64cd5bac9206ec435e21a622c8e69cedbc2ccb39d2328ac5c01668e5
2020-05-21 09:00:25 -04:00
MarcoFalke 25ad2c623a
Merge #18740: Remove g_rpc_node global
b3f7f375ef refactor: Remove g_rpc_node global (Russell Yanofsky)
ccb5059ee8 scripted-diff: Remove g_rpc_node references (Russell Yanofsky)
6fca33b2ed refactor: Pass NodeContext to RPC and REST methods through util::Ref (Russell Yanofsky)
691c817b34 Add util::Ref class as temporary alternative for c++17 std::any (Russell Yanofsky)

Pull request description:

  This PR removes the `g_rpc_node` global, to get same benefits we see removing other globals and make RPC code more testable, modular, and reusable.

  This uses a hybrid of the approaches suggested in #17548. Instead of using `std::any`, which isn't available in c++11, or `void*`, which isn't type safe, it uses a small new `util::Ref` helper class, which acts like a simplified `std::any` that only holds references, not values.

  Motivation for writing this was to provide an simpler alternative to #18647 by Harris Brakmić (brakmic) which avoids some shortcomings of that PR (https://github.com/bitcoin/bitcoin/pull/18647#issuecomment-617878826)

ACKs for top commit:
  MarcoFalke:
    re-ACK b3f7f375ef, only change is adding back const and more tests 🚾
  ajtowns:
    ACK b3f7f375ef

Tree-SHA512: 56292268a001bdbe34d641db1180c215351503966ff451e55cc96c9137f1d262225d7d7733de9c9da7ce7d7a4b34213a98c2476266b58c89dbbb0f3cb5aa5d70
2020-05-21 06:53:39 -04:00
Jon Atack 903b6c117f
rpc: drop unused JSONRPCProcessBatchReply size arg, refactor 2020-05-21 10:24:26 +02:00
Jon Atack afce85eb99
cli: use GetWalletBalances() functionality for -getinfo
and replace GetBoolArg with IsArgSet as we only want
to know if the arg is passed; we do not need the value.
2020-05-21 10:24:23 +02:00
Jon Atack 9f01849a49
cli: create GetWalletBalances() to fetch multiwallet balances 2020-05-21 10:24:20 +02:00
Jon Atack 743077544b
cli: lift -rpcwallet logic up to CommandLineRPC()
to allow passing rpcwallet independently from the -rpcwallet user option, and to
move the logic to the top-level layer where most of the other option args are
handled.
2020-05-21 10:24:17 +02:00
Jon Atack 29f2cbdeb7
cli: extract connection exception handler, -rpcwait logic
to ConnectAndCallRPC() to be callable for individual connections.

This is needed for RPCs that need to be called and handled sequentially, rather
than alone or in a batch.

For example, when fetching the balances for each loaded wallet, -getinfo will
call RPC listwallets, and then, depending on the result, RPC getbalances.

It may be somewhat helpful to review this commit with `git show -w`.
2020-05-21 10:23:48 +02:00
fanquake 97b21b302a
Merge #18677: Multiprocess build support
e2bab2aa16 multiprocess: add multiprocess travis configuration (Russell Yanofsky)
603fd6a2e7 depends: add MULTIPROCESS depends option (Russell Yanofsky)
5d1377b52b build: multiprocess autotools changes (Russell Yanofsky)

Pull request description:

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10).

  ---

  This PR consists of build changes only. It adds an `--enable-multiprocess` autoconf option (off by default and marked experimental), that builds new `bitcoin-node` and `bitcoin-gui` binaries. These currently function the same as existing `bitcoind` and `bitcoin-qt` binaries, but are extended in #10102 with IPC features to execute node, wallet, and gui functions in separate processes.

  In addition to adding the `--enable-multiprocess` config flag, it also adds a depends package and autoconf rules to build with the [libmultiprocess](https://github.com/chaincodelabs/libmultiprocess) library, and it adds new travis configuration to exercise the build code and run functional tests with the new binaries.

  The changes in this PR were originally part of #10102 but were moved into #16367 to be able to develop and review the multiprocess build changes independently of the code changes. #16367 was briefly merged and then reverted in #18588. Only change since #16367 has been dropping the `native_boost.mk` depends package which was pointed out to be no longer necessary in https://github.com/bitcoin/bitcoin/pull/16367#issuecomment-596484337 and https://github.com/bitcoin/bitcoin/pull/18588#pullrequestreview-391765649

ACKs for top commit:
  practicalswift:
    ACK e2bab2aa16
  Sjors:
    tACK e2bab2aa16 on macOS 10.15.4
  hebasto:
    ACK e2bab2aa16, tested on Linux Mint 19.3 (x86_64):

Tree-SHA512: b5a76eab5abf63d9d8b6d628cbdff4cc1888eef15cafa0a5d56369e2f9d02595fed623f4b74b2cf2830c42c05a774f0943e700f9c768a82d9d348cad199e135c
2020-05-21 15:34:25 +08:00
Pieter Wuille 65c589e45e Convert Qt to new serialization 2020-05-20 10:16:41 -07:00