Commit Graph

12648 Commits

Author SHA1 Message Date
Alexander Block
97ee3015e1 Wakeup select/poll when new nodes are added 2020-04-18 12:41:25 +02:00
Alexander Block
2610e718cd
Don't delete MN list snapshots and diffs from DB when reorgs take place (#3435)
Deleting these from the DB means that future calls to GetListForBlock  for
the reorged/orphaned block will return an empty MN list. At the same time,
GetListForBlock will add the empty list to the internal MN list cache.

This behavior is not acceptable for multiple reasons:
1. A caller of GetListForBlock should always expect a valid list if that
   block was once in the best chain. We might otherwise run into strange
   behavior (e.g. GetAllQuorumMembers returning zero members)
2. If the chain is ever reorged back to the initial chain (that was
   orphaned), GetListForBlock should not return the invalid/empty cache
   entry for the previously orphaned block.

This should also fix test failures seen on Gitlab CI
2020-04-18 12:35:46 +02:00
Alexander Block
6d83b0a053
Merge pull request #3431 from codablock/pr_socketevents_arg
Make socketevents mode (poll vs select) configurable via parameter
2020-04-18 12:34:34 +02:00
PastaPastaPasta
97742a14d8
Merge bitcoin#10762: [wallet] Remove Wallet dependencies from init.cpp (#3412)
* Merge #10762: [wallet] Remove Wallet dependencies from init.cpp

c7ec524 [wallet] Add dummy wallet init class (John Newbery)
49baa4a [wallet] Use global g_wallet_init_interface to init/destroy the wallet. (John Newbery)
caaf972 [wallet] Create wallet init interface. (John Newbery)
5fb5421 [wallet] Move wallet init functions into WalletInit class. (John Newbery)

Pull request description:

  This continues the work of #7965. This PR, along with several others, would remove the remaining dependencies from libbitcoin_server.a on libbitcoin_wallet.a.

  To create the interface, I've just translated all the old init.cpp wallet function calls into an interface class. I've not done any thinking about whether it makes sense to change that interface by combining/splitting those calls. This is a purely internal interface, so there's no problem in changing it later.

Tree-SHA512: 32ea57615229c33fd1a7f2f29ebc11bf30337685f7211baffa899823ef74b65dcbf068289c557a161c5afffb51fdc38a2ee8180720371f64d433b12b0615cf3f
Signed-off-by: Pasta <pasta@dashboost.org>

# Conflicts:
#	src/dashd.cpp
#	src/init.cpp

* a couple of fixes

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

* move privatesend launch options help into wallet/init.cpp

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

* remove ENABLE_WALLET for AutoLockMasternodeCollaterals

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

* move a wallet param interaction into wallet/init.cpp

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

* move PrivateSend init to wallet/init.h

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

* move privatesend scheduler into wallet.cpp

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

* remove unneeded import

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

* move KeePass init and InitAutoBackup into wallet/init.cpp

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

* Fix 10762

Changes:
- Should backup wallets before trying to verify them. This is because `-salvagewallet` is very dangerous and can actually corrupt wallets making them irreparably broken.
- No reason to make `schedulePrivateSendClientMaintenance` a part of the wallet (interface) because `privateSendClient` is a global object not tied to the wallet directly atm.
- Should not run client-side mixing on masternodes.
- Fix `InitAutoBackup` signature in `DummyWalletInit`.

* remove boost dependancy in wallet/init.cpp

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

Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-04-18 12:59:40 +03:00
UdjinM6
20a0f3a51f
Merge pull request #3407 from PastaPastaPasta/backports-0.16-pr17
Backports 0.16 pr17
2020-04-18 12:57:51 +03:00
Alexander Block
ea81ab5af7 Make socketevents mode (poll vs select) configurable via parameter
Instead of selecting the mode at compile time
2020-04-17 22:09:52 +02:00
Alexander Block
9a8caf0986
Remove fix for fNetworkActive vs OpenNetworkConnection race (#3430)
This is not needed anymore due to bitcoin#13212 being backported
2020-04-17 21:46:58 +02:00
Alexander Block
96ed9fae39
Merge pull request #3429 from codablock/pr_remove_optimistic_send
Fix flushing of rejects before disconnecting
2020-04-17 21:46:36 +02:00
Alexander Block
0cb385c567
Merge pull request #3428 from codablock/pr_better_conn_logging
Improve network connections related logging
2020-04-17 21:46:17 +02:00
Alexander Block
08b57c198b Add some linger time between fDisconnect=true and actually closing the socket 2020-04-17 12:42:30 +02:00
Alexander Block
4117579e8f Honor fLogIPs in OpenNetworkConnection 2020-04-17 12:21:00 +02:00
Alexander Block
d8bbdee7c4 Remove support for optimistic send
This was only used in only one remaining place and only to ensure that
reject messages are sent before closing sockets. This is solved by the
previous commit now.
2020-04-17 11:32:18 +02:00
Alexander Block
926beb3406 Handle sockets one last time before closing sockets 2020-04-17 11:10:08 +02:00
Alexander Block
6ca78b601e Introduce NETCONN logging category and NET_NETCONN to log in NET and NETCONN
This allows easier debugging of connection issues, as it produces much less
chatter in the logs when only -debug=mnconn is given.
2020-04-17 08:52:57 +02:00
Alexander Block
71f1181d21 Improve connection logging in net.cpp 2020-04-17 08:52:48 +02:00
Alexander Block
2f1b3a34ab Invoke DisconnectNodes from getconnectioncount/getpeerinfo/getnetworkinfo
This ensures disconnected nodes don't appear for callers
2020-04-17 07:53:07 +02:00
Alexander Block
76d7b17dcd Invoke DisconnectNodes right before checking for duplicate connections 2020-04-17 07:53:07 +02:00
Alexander Block
30e4afae00 Only run DisconnectNodes once per second
This change is quite invasive for integration tests, as they all expect
connections to be dropped ASAP. The next commits all try to fix the upcoming
issues.
2020-04-17 07:53:07 +02:00
Alexander Block
ee995ef02a
Merge pull request #3422 from codablock/pr_speedups7
Implement more reliable wait_for_masternode_probes in test framework
2020-04-17 07:52:34 +02:00
Alexander Block
1e30054b9e
Merge pull request #3420 from codablock/pr_speedups5
Avoid calling SendMessages (and others) for all nodes all the time
2020-04-17 07:34:23 +02:00
Alexander Block
8aa85c084b
Merge pull request #3419 from codablock/pr_deterministic_connections
Deterministically choose which peers to drop on duplicate MNAUTH
2020-04-17 07:33:46 +02:00
Alexander Block
6c1262f1c8 Add "outbound" field to "quorum dkgstatus" connections 2020-04-16 18:18:41 +02:00
Alexander Block
65fb8bc454 Only run InactivityCheck once per second 2020-04-16 18:08:53 +02:00
Alexander Block
9e57c35e82 Don't even try to send/receive blocks for fMasternode connections
This avoids a lot of overhead in SendMessages, which is called very often.
2020-04-16 18:06:59 +02:00
Alexander Block
a808ff3330 Temporary hack for unnecessary invocations of Broadcast signal 2020-04-16 18:06:59 +02:00
Alexander Block
24ead62905 Only call SendMessages when ProcessMessages did some work or when some time passed
Invoking SendMessages for hundreds of peers while we know that there is no
work to do give a lot of overhead on the message handler thread.
2020-04-16 18:06:59 +02:00
Alexander Block
79f0bb1033
Fix crash in validateaddress (#3418)
The only reason this was not detected in integration tests is that
mapHdPubKeys was empty.
2020-04-16 18:01:40 +02:00
Alexander Block
c65d5612de Deterministically choose which peers to drop on duplicate MNAUTH 2020-04-16 18:00:03 +02:00
Pieter Wuille
782ee1a3cf
Merge #10677: RPC Docs: addmultisigaddress is intended for non-watchonly addresses
73041c3c99 RPC Docs: addmultisigaddress is intended for non-watchonly addresses (Gregory Sanders)

Pull request description:

  Spent a couple hours debugging why my p2sh watchonly funds were not appearing in various accounting calls when address was imported via `addmultisigaddress`.

Tree-SHA512: 0673e276e5ca8cdc4c9357bd835a29bd5a994520a78179600944932c700917142930288bf179f5e89b0874beaf1a88bd70129f3a297a46df42a10bab847017bb
2020-04-16 10:24:22 -05:00
MarcoFalke
a13e2f4355
Merge #13123: net: Add Clang thread safety annotations for guarded variables in the networking code
4894133dc5 Add missing lock in CNode::copyStats(...) (practicalswift)
b312cd7707 Add missing locking annotations (practicalswift)

Pull request description:

  Add Clang thread safety annotations for variables guarded by:
  * `cs_addrLocal`
  * `cs_addrName`
  * `cs_feeFilter`
  * `cs_filter`
  * `cs_hSocket`
  * `cs_inventory`
  * `cs_mapLocalHost`
  * `cs_most_recent_block`
  * `cs_proxyInfos`
  * `cs_sendProcessing`
  * `cs_setBanned`
  * `cs_SubVer`
  * `cs_vOneShots`
  * `cs_vProcessMsg`
  * `cs_vRecv`
  * `cs_vSend`

  Changed files:
  * `src/net.{cpp,h}`
  * `src/netbase.cpp`

Tree-SHA512: 319a1574a07d766e81fab19b9cfdcf8b5f0b175034ebef220cd406f1672b4ef2c57f5c456c623456ca7a1f96308de69c73535792e9e4c34b848b55fd4f35fc95
2020-04-16 10:24:22 -05:00
Wladimir J. van der Laan
b215a1f005
Merge #12986: Trivial: Corrected comment array name from pnSeeds6 to pnSeed6
d1b828b correcting the array name from pnSeeds6 to pnSeed6 (okayplanet)

Pull request description:

  After reading this comment, I tried to grep the code base for `pnSeeds6` but couldn't find anything.  After some time wasted, I realized the arrays actually start with `pnSeed6`.

Tree-SHA512: 78a66d96128267278c7b02dbc0c966a7447cb258c71b04be5a00de8ed10ee11437550bbbf7dd4208315a59d19408a31b62774ae6dbc521261818dece4970a602
2020-04-16 10:24:22 -05:00
Wladimir J. van der Laan
bbce45d8bd
Merge #13652: rpc: Fix that CWallet::AbandonTransaction would leave the grandchildren, etc. active
89e70f9d7fe384ef9de4fa3828d4c80523290186 Fix that CWallet::AbandonTransaction would only traverse one level (Ben Woosley)

Pull request description:

  Prior to this change, it would mark only the first layer of
  child transactions abandoned, due to always following the input `hashTx`
  rather than the current `now` tx.

Tree-SHA512: df068b49637d299ad73237c7244005fe5aa966d6beae57aff12e6948f173d9381e1b5d08533f7e3a1416991ed57f9f1f7b834057141d85c07dc60bb1f0872cea
2020-04-16 10:24:22 -05:00
Wladimir J. van der Laan
5aee3ef4e9
Merge bitcoin#12617: gui: Show messages as text not html
Currently, error messages (such as InitError) are displayed as-is, which
means Qt does auto detection on the format.

This means that it's possible to inject HTML from the command line
though e.g. specifying a wallet name with HTML in it. This isn't
a direct security risk because fetching content from internet is
disabled (and as far as I know we never report strings received
from the network this way). However, it can be confusing.

So explicitly force the format as text.
2020-04-16 10:24:22 -05:00
Wladimir J. van der Laan
d7cbaec108
Merge #12432: [qt] send: Clear All also resets coin control options
f506c0a7f [qt] send: Clear All also resets coin control options (Sjors Provoost)

Pull request description:

  This change makes it so that a custom change address and manual input selection are removed if the user clicks Clear All in the send screen.

Tree-SHA512: 78746043a74c9c26ef476eb0df7ce95411683749d9f6b2747222eaac751e241ea7d4d7ce9e4e69ed0b19fa76754d8584e5bef5bba1ad6598f8e39c784b4264d2
2020-04-16 10:24:22 -05:00
Pieter Wuille
e480ae9fa8
Merge #12743: Fix csBestBlock/cvBlockChange waiting in rpc/mining
4a6c0e3dcf Modernize best block mutex/cv/hash variable naming (Pieter Wuille)
45dd135039 Fix csBestBlock/cvBlockChange waiting in rpc/mining (Pieter Wuille)

Pull request description:

  This is an alternative to #11694.

  It reintroduces a uint256 variable with the best block hash, protected by csBestBlock, and only updated while holding it.

  Also rename the involved variable to modern guidelines, as there are very few uses.

Tree-SHA512: 826a86c7d3cee7fe49f99f4398ae99e81cb0563197eaeba77306a3ca6072b67cdb932bc35720fc0f99c2a57b218efa029d0b8bdfb240591a629b2e90efa3199d
2020-04-16 10:24:22 -05:00
Wladimir J. van der Laan
2a3df4d54c
Merge #12573: Fix compilation when compiler do not support __builtin_clz*
18307849b Consensus: Fix bug when compiler do not support __builtin_clz* (532479301)

Pull request description:

  #ifdef is not correct since defination is defined to 0 or 1. Should change to #if

Tree-SHA512: ba13a591d28f4d7d6ebaab081be4304c43766a611226f8d2994c8db415dfcf318e82217d26a8c4af290760c68eded9503b39535b0e6e079ded912e6a8fca5b36
2020-04-16 10:24:22 -05:00
MarcoFalke
7c5319f032
Partial Merge #13545: tests: Fix test case streams_serializedata_xor. Remove Boost dependency.
962d8eed5b Remove boost dependency (boost/assign/std/vector.hpp) (practicalswift)
c6fd0df4ef Fix incorrect tests (practicalswift)

Pull request description:

  * Fix test case `streams_serializedata_xor`.
  * Remove Boost dependency.

Tree-SHA512: 609c4ced1b6a8b86f6a37e4220535f1b3c9f2e80949cd034ecc069a94c55c05cd514f2e132fe7f715161ee29811a0fadb6903635c507411d8dc3e7efe864edeb
2020-04-16 10:24:22 -05:00
Alexander Block
72afaddf72 Introduce new way of deterministic selection of outbound LLMQ connections
The new way does not require the quorum hash to be included in the
calculation, which allows us to have determinism globally and not only
for single LLMQs.
2020-04-16 13:59:02 +02:00
Wladimir J. van der Laan
23704daaf0 Merge #13437: wallet: Erase wtxOrderd wtx pointer on removeprunedfunds
faa18ca046e9043b2cf68cb1bd17cc8c60fe26d9 wallet: Erase wtxOrderd wtx pointer on removeprunedfunds (MarcoFalke)

Pull request description:

  This prevents segfaults, when reading from the freed memory.

Tree-SHA512: 04f8190dea7901cf1cc298d5db98c83b02858f27114c5ef4da738accd176d6647d6b81f3dc39f3d5912b1a981cf0599370fd391c4154ffbde97afc1fac389123
2020-04-15 21:01:44 -05:00
Wladimir J. van der Laan
15fb6dbf05 Merge #13061: Make tests pass after 2020
3ee4be1 Make tests pass after 2020 (Bernhard M. Wiedemann)

Pull request description:

  Make tests pass after 2020
  and also test that 64 bit integers are properly handled

  Without this patch, the failure was
  ```
  unknown location(0): fatal error: in "rpc_tests/rpc_ban": std::runtime_error: JSON value is not an object as expected
  test/rpc_tests.cpp(260): last checkpoint
  ```

  I found this when testing reproducible builds for openSUSE Linux packages, building 15 years from now (this is the expected lifespan of today's software)

  There is 1 other issue in ./src/qt/test/paymentservertests.cpp that fails to verify a cert that expires in 2022 after 10y.

  ```
  QWARN  : PaymentServerTests::paymentServerTests() PaymentRequestPlus::getMerchant: Payment request: certificate expired or not yet active:  QSslCertificate("3", "01", "Ipbt+DxK8RDQd25/5ueXqw==", (), ("Payment Request Test Merchant"), QMap(), QDateTime(2012-12-10 16:37:24.000 UTC Qt::TimeSpec(UTC)), QDateTime(2022-12-08 16:37:24.000 UTC Qt::TimeSpec(UTC)))
  FAIL!  : PaymentServerTests::paymentServerTests() Compared values are not the same
  ```

Tree-SHA512: d6c49879b6abbddbecc1168ac24c2d4f4ee9949b615607b3e6ba350c415136017f32cd112708791b063a2f2dc1b12f295f4ee55a346bd2128aa6480088d8db48
2020-04-15 21:01:44 -05:00
MarcoFalke
424bbc3425 Merge #12837: rpc: fix type mistmatch in listreceivedbyaddress
05c03d1249 rpc: fix type mistmatch in listreceivedbyaddress (joemphilips)

Pull request description:

  `txids` filed in return value is supposed be `string` but it was `numeric` in the help message

Tree-SHA512: 7d860994c2d1d9149b41fd7afefc1a44460eede5a023070fcc18b0a4a19a26c5eec5abd157038c15fe7d50a3390bdaf7a4823279129eb1458b0d3c6141a533ee
2020-04-15 21:01:43 -05:00
Wladimir J. van der Laan
b08a1f9ec1 Merge #12793: qt: Avoid reseting on resetguisettigs=0
342fb80 qt: Avoid resetting on resetguisettigs=0 (MarcoFalke)

Pull request description:

  Shouldn't be affecting anyone, but might still be worth to fix at some point.

Tree-SHA512: af7fe67f1e8b3a0ff041258e3056d2e3e518258b015ee765f291e91fca86a7f7cd43c83844fd83f00a52dac2cf382db5d568aab91db636a031040551bd34172d
2020-04-15 21:01:41 -05:00
Alexander Block
4118b77249 Better clarification for future conflict resolution 2020-04-14 15:16:51 +02:00
Wladimir J. van der Laan
d4065e79ac Merge #15324: test: Make bloom tests deterministic
fae169c95e09ddf068dcaebc8170c4f41b02cf66 test: Make bloom tests deterministic (MarcoFalke)

Pull request description:

  non-deterministic tests are useless, since a failing test could not be reproduced unless the seed is known.

Tree-SHA512: 4f634ff0c6adf663444f1ac504f6dbceaa46b78d697b840531977ba30006453ac559d5c21cc3eaef6d92b87d46008a34b0db6331ea3318001987fcfaec634acf
2020-04-14 15:16:51 +02:00
Alexander Block
d80212c47c Fix use of mocktime when calling PoissonNextSendInbound
This seems to have been wrong already in the backported PR.
2020-04-14 15:16:51 +02:00
Alexander Block
36d909aa30 Fix compilation error 2020-04-14 13:32:50 +02:00
MarcoFalke
c52c1e1ce5 Merge #17243: p2p: add PoissonNextSend method that returns mockable time
1a8f0d5a74d5cc0000456932babf35301f5c1686 [tools] update nNextInvSend to use mockable time (Amiti Uttarwar)
4de630354fc6808b9b13b9e82da1a82f2f50f26a [tools] add PoissonNextSend method that returns mockable time (Amiti Uttarwar)

Pull request description:

  Introduce a Poisson helper method that wraps the existing method to return `std::chrono::duration` type, which is mockable.

  Needed for https://github.com/bitcoin/bitcoin/pull/16698.

ACKs for top commit:
  ajtowns:
    ACK 1a8f0d5a74d5cc0000456932babf35301f5c1686
  MarcoFalke:
    re-ACK 1a8f0d5a74d5cc0000456932babf35301f5c1686
  naumenkogs:
    ACK 1a8f0d5, and let's merge it and come back to it later.

Tree-SHA512: 7e2325d7c55fc0b4357cb86b83e0c218ba269f678c1786342d8bc380bfd9696373bc24ff124b9ff17a6e761c62b2b44ff5247c3911e2afdc7cc5c20417e8290b
2020-04-14 13:32:50 +02:00
Pieter Wuille
ea9f97c53b Merge #13298: Net: Bucketing INV delays (1 bucket) for incoming connections to hide tx time
d45b344ffd Bucket for inbound when scheduling invs to hide tx time (Gleb)

Pull request description:

  It has been brought up to my attention that current random delays mechanism (originally intended to obfuscate transaction metadata) allows to easily estimate the time a transaction was received by a node.

  It may be done by connecting multiple observer nodes to the same node. Each of those nodes will generate its own schedule of delays. Combined metadata regarding those events from different sources allows an observer to estimate transaction time.

  After this patch a spy won't gain additional information by just creating multiple connections to a target.

Tree-SHA512: c71dae5ff350b614cb40a8e201fd0562d3e03e3e72a5099718cd451f0d84c66d5e52bbaf0d5b4b75137514c8efdedcc6ef4df90142b360153f04ad0721545ab1
2020-04-14 13:32:50 +02:00
Alexander Block
8a0f702f39 Use verifiedProRegTxHash.IsNull() instead of fMasternode to check for MN connections
fMasternode connections don't even relay anything anymore.
2020-04-14 13:32:50 +02:00
PastaPastaPasta
8ade2f7957
Merge bitcoin#11281: Avoid permanent cs_main/cs_wallet lock during RescanFromTime (#3411)
* Merge #11281: Avoid permanent cs_main/cs_wallet lock during RescanFromTime

7f81250 Mention that other RPC calls report keys as "imported" while txns are still missing (Jonas Schnelli)
ccd8ef6 Reduce cs_main lock in ReadBlockFromDisk, only read GetBlockPos under the lock (Jonas Schnelli)
bc356b4 Make sure WalletRescanReserver has successfully reserved the rescan (Jonas Schnelli)
dbf8556 Add RAII wallet rescan reserver (Jonas Schnelli)
8d0b610 Avoid pemanent cs_main/cs_wallet lock during wallet rescans (Jonas Schnelli)

Pull request description:

  Right now, we are holding `cs_main`/`cs_wallet` during the whole rescan process (which can take a couple of hours).
  This was probably only done because of laziness and it is an important show-stopper for #11200 (GUI rescan abort).

Tree-SHA512: 0fc3f82d0ee9b2f013e6bacba8d59f7334306660cd676cd64c47bb305c4cb7c7a36219d6a6f76023b74e5fe87f3ab9fc7fd2439e939f71aef653fddb0a1e23b1
Signed-off-by: Pasta <pasta@dashboost.org>

# Conflicts:
#	src/wallet/rpcdump.cpp
#	src/wallet/test/wallet_tests.cpp
#	src/wallet/wallet.h

* remove "LearnAllRelatedScripts"

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

* fix importelectrumwallet

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

Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
2020-04-14 13:01:03 +03:00