Commit Graph

12668 Commits

Author SHA1 Message Date
Alexander Block
6d93b33f48 Fix compilation of util_time.cpp 2020-04-08 18:01:20 +02:00
Alexander Block
6b32192bdc Fix compilation 2020-04-08 14:55:27 +02:00
UdjinM6
775e4ba823 transactions -> objects
+ corresponding changes in comments
2020-04-08 14:51:42 +02:00
Alexander Block
a7b38efb98 Fix GetObjectInterval and EraseObjectRequest 2020-04-08 14:51:20 +02:00
Alexander Block
8e5fbedf21 net: Use mockable time for tx download
# Conflicts:
#	src/net_processing.cpp
#	src/random.cpp
#	src/random.h
2020-04-08 14:51:14 +02:00
Wladimir J. van der Laan
a76bafb98c Merge #16046: util: Add type safe GetTime
fa013664ae23d0682a195b9bded85bc19c99536e util: Add type safe GetTime (MarcoFalke)

Pull request description:

  There are basically two ways to get the time in Bitcoin Core:
  * get the system time (via `GetSystemTimeInSeconds` or `GetTime{Millis,Micros}`)
  * get the mockable time (via `GetTime`)

  Both return the same type (a plain int). This can lead to (test-only) bugs such as 99464bc38e.

  Fix that by deprecating `GetTime` and adding a `GetTime<>` that returns the mockable time in a non-int type. The new util function is currently unused, but new code should it where possible.

ACKs for commit fa0136:
  promag:
    utACK fa013664.

Tree-SHA512: efab9c463f079fd8fd3030c479637c7b1e8be567a881234bd0f555c8f87e518e3b43ef2466128103db8fc40295aaf24e87ad76d91f338c631246fc703477e95c
2020-04-08 14:50:07 +02:00
Alexander Block
2d4cc8a19e More logging for object request handling 2020-04-07 13:26:47 +02:00
Alexander Block
81503598b9 No inbound delay for non-TX objects and masternodes 2020-04-07 13:26:34 +02:00
Alexander Block
26fcd3f0bf Also remove m_tx_announced and m_tx_in_flight entries when EraseObjectRequest is called
Otherwise they'll run into false-positive timeouts.
2020-04-07 13:25:29 +02:00
Alexander Block
4bfc20cb67 Force re-requesting of IS locked TXs 2020-04-07 13:23:29 +02:00
Alexander Block
ef14b19f05 Don't re-request erased object requests 2020-04-07 10:33:31 +02:00
Alexander Block
f142fff881 Skip verification of recovered sigs that were reconstructed in InstantSend
Also don't request them via getdata
2020-04-07 07:30:00 +02:00
Alexander Block
454fae3bda Only process 32 IS locks at a time in ProcessPendingInstantSendLocks 2020-04-07 07:29:51 +02:00
Alexander Block
d856fd1407 Use salted hasher for pendingInstantSendLocks 2020-04-07 07:29:32 +02:00
Alexander Block
465af48e83 Improve logging in LLMQ sig handling 2020-04-07 07:29:23 +02:00
Alexander Block
fd1875b61f Reserve vector size in CopyNodeVector 2020-04-07 07:27:23 +02:00
Alexander Block
122b740e2d Optimize deletion of vNodes entries
Iterate through the vectors with iterators and use them for .erase().
This avoids an expensive lookup when erasing.
2020-04-07 07:27:07 +02:00
Alexander Block
481339355d Don't hold cs_vNodes in ReleaseNodeVector
We're not touching this->vNodes here, so there is no need to hold the lock.
2020-04-07 07:25:14 +02:00
Alexander Block
201f8eea1a Optimize vInv.reserve in SendMessages
1. Don't call it while holding cs_invetory
2. Also take setInventoryTxToSend.size() into account
2020-04-07 07:25:02 +02:00
Alexander Block
027a852a77 Use std::list for vSendMsg
std::deque is indexed internally, which gives some unnecessary overhead
when removing the front element.
2020-04-07 07:24:42 +02:00
Alexander Block
a3bc3fd0f0 Use std::chrono for GetTimeMillis/GetTimeMicros
It's slightly faster then the boost variant as it has less overhead.
2020-04-07 07:24:21 +02:00
Alexander Block
2443c8f582 Replace uses of CNode::AskFor with RequestObject 2020-04-07 07:14:53 +02:00
Alexander Block
004d9224c4 Replace uses of CConnman::RemoveAskFor with EraseObjectRequest 2020-04-07 07:14:42 +02:00
Alexander Block
414943b611 Make interval and timeout dependend on INV type 2020-04-07 07:14:32 +02:00
Alexander Block
56da433bd9 Fix governance.cpp 2020-04-07 07:14:19 +02:00
Alexander Block
29d3b75f28 Generalize TX request code 2020-04-07 07:14:16 +02:00
Alexander Block
8c11a8e698 Remove MSG_WITNESS_TX 2020-04-07 07:14:12 +02:00
MarcoFalke
74eabc23e5 Merge #15834: Fix transaction relay bugs introduced in #14897 and expire transactions from peer in-flight map
308b76732f Fix bug around transaction requests (Suhas Daftuar)
f635a3ba11 Expire old entries from the in-flight tx map (Suhas Daftuar)
e32e08407e Remove NOTFOUND transactions from in-flight data structures (Suhas Daftuar)
23163b7593 Add an explicit memory bound to m_tx_process_time (Suhas Daftuar)
218697b645 Improve NOTFOUND comment (Suhas Daftuar)

Pull request description:

  #14897 introduced several bugs that could lead to a node no longer requesting transactions from one or more of its peers.  Credit to ajtowns for originally reporting many of these bugs along with an originally proposed fix in #15776.

  This PR does a few things:

  - Fix a bug in NOTFOUND processing, where the in-flight map for a peer was keeping transactions it shouldn't

  - Eliminate the possibility of a memory attack on the CNodeState `m_tx_process_time` data structure by explicitly bounding its size

  - Remove entries from a peer's in-flight map after 10 minutes, so that we should always eventually resume transaction requests even if there are other bugs like the NOTFOUND one

  - Fix a bug relating to the coordination of request times when multiple peers announce the same transaction

  The expiry mechanism added here is something we'll likely want to remove in the future, but is belt-and-suspenders for now to try to ensure we don't have other bugs that could lead to transaction relay failing due to some unforeseen conditions.

ACKs for commit 308b76:
  ajtowns:
    utACK 308b76732f97020c86977e29c854e8e27262cf7c
  morcos:
    light ACK 308b767
  laanwj:
    Code review ACK 308b76732f97020c86977e29c854e8e27262cf7c
  jonatack:
    Light ACK 308b76732f97020c86977e29c854e8e27262cf7c.
  jamesob:
    ACK 308b76732f
  MarcoFalke:
    ACK 308b76732f97020c86977e29c854e8e27262cf7c (Tested two of the three bugs this pull fixes, see comment above)
  jamesob:
    Concept ACK 308b76732f
  MarcoFalke:
    ACK 308b76732f

Tree-SHA512: 8865dca5294447859d95655e8699085643db60c22f0719e76e961651a1398251bc932494b68932e33f68d4f6084579ab3bed7d0e7dd4ac6c362590eaf9414eda
2020-04-07 07:14:06 +02:00
Pieter Wuille
8c0ff34ccd Merge #14897: randomize GETDATA(tx) request order and introduce bias toward outbound
1cff3d6cb0 Change in transaction pull scheduling to prevent InvBlock-related attacks (Gleb Naumenko)

Pull request description:

  This code makes executing two particular (and potentially other) attacks harder.

  ### InvBlock
  This behavior was described well [here](https://www.cs.umd.edu/projects/coinscope/coinscope.pdf) (page 11).

  Per current implementation, if node A receives _INV_ (tx) from node B, node A sends _GETDATA_ to B and waits for _TX_ message back.

  Node A is likely to receive more _INVs_ (regarding the same tx) from other peers. But node A would not send another _GETDATA_ unless it does not hear _TX_ back from node B for next 2 minutes (to save bandwidth)

  Thus, if B is a malicious node, it can prevent node A from getting the transaction (even if all A’s peers have it) for 2 minutes.

  This behavior seems to be an inherent limitation of the current P2P relay protocol, and I don’t see how it can be fundamentally changed (I can see workarounds which involve rewriting a lot of P2P code though).

  ### What does this PR fix?

  The attacks I’m looking at involve preventing A from learning the transaction for 2*N minutes. To do that, an attacker has to spin up N nodes and send N _INVs_ simultaneously to node A (then InvBlocks will be queued with an interval of 2 minutes according to current implementation)

  More precisely, 2 scenarios I’m looking at are:
  1. An attacker censors a particular transaction. By performing InvBlock from different nodes, an attacker can execute a network-wide censorship of a particular transaction (or all transactions). The earlier an attacker founds the transaction he wants to censor, the easier it is to perform an attack. As it was pointed out by @gwillen, this is even more dangerous in the case of lightning, where transactions are known in advance.
  2. Topology inference described in papers [1](https://www.cs.umd.edu/projects/coinscope/coinscope.pdf), [2](https://arxiv.org/pdf/1812.00942.pdf) involve network-wide InvBlock. This fix would not mitigate this type of inference, but I believe it will make it more expensive to perform (an attacker would have to create more transactions and perform more rounds to learn the topology, the second paper itself notes that InvBlock isolation is important for the attack).

  ### How does it work
  This PR introduces bias toward outbound connections (they have higher priority when a node chooses from whom it should request a transaction) and randomizes the order.
  As per @gmaxwell suggestion, GETDATA requests queue is created after processing all incoming messages from all nodes.

  After this fix, if the incoming messages were [I1, I2, I3, O1, O2, O3, O4], the queue for _GETDATA_ may look like [O2, O1, O3, O4, I1, I3, I2, ….].

  If {I1, I2, I3} were significantly earlier (but the difference is less than TX_TIMEOUT=60 s) than others, the queue for _GETDATA_ may look like [I2, O2, O1, O3, O4, I1, I3, ….].

  ### Other comments:
  1. This mitigation works better if the connectivity is higher (especially outbound, because it would be less likely that 2 _GETDATAs_ for inbound malicious nodes queued together)

Tree-SHA512: 2ad1e80c3c7e16ff0f2d1160aa7d9a5eaae88baa88467f156b987fe2a387f767a41e11507d7f99ea02ab75e89ab93b6a278d138cb1054f1aaa2df336e9b2ca6a
2020-04-07 07:14:00 +02:00
UdjinM6
af1dc378cd
More of 11220 2020-04-06 11:55:59 -05:00
Wladimir J. van der Laan
b25eec73ed
Merge #11220: Check specific validation error in miner tests
12781db [Tests] check specific validation error in miner tests (Sjors Provoost)

Pull request description:

  ## Problem

  `BOOST_CHECK_THROW` merely checks that some `std::runtime_error` is
  thrown, but not which one.

  Here's an example of how this can cause a test to pass when a developer
  introduces a consensus bug. The test for the sigops limit assumes
  that `CreateNewBlock` fails with `bad-blk-sigops`. However it can
  also fail with bad-txns-vout-negative, if a naive developer lowers
  `BLOCKSUBSIDY` to `1*COIN`.

  ## Solution

  `BOOST_CHECK_EXCEPTION` allows an additional predicate function. This
  commit uses this for all exceptions that are checked for in
  `miner_tets.cpp`:
  * `bad-blk-sigops`
  * `bad-cb-multiple`
  * `bad-txns-inputs-missingorspent`
  * `block-validation-failed`

  If the function throws a different error, the test will fail. Although the message produced by Boost is a bit [confusing](http://boost.2283326.n4.nabble.com/Test-BOOST-CHECK-EXCEPTION-error-message-still-vague-tt4683257.html#a4683554), it does show which error was actually thrown. Here's what the above `1*COIN` bug would result in:

  <img width="1134" alt="schermafbeelding 2017-09-02 om 23 42 29" src="https://user-images.githubusercontent.com/10217/29998976-815cabce-9038-11e7-9c46-f5f6cfb0ca7d.png">

  ## Other considerations

  A more elegant solution in my opinion would be to subclass `std::runtime_error` for each `INVALID_TRANSACTION` type, but this would involve touching consensus code.

  I put the predicates in `test_bitcoin.h` because I assume they can be reused in other test files. However [serialize_tests.cpp](https://github.com/bitcoin/bitcoin/blob/v0.15.0rc3/src/test/serialize_tests.cpp#L245) also uses `BOOST_CHECK_EXCEPTION` and it defines the predicate in the test file itself.

  Instead of four `IsRejectInvalidReasonX(std::runtime_error const& e)` functions, I'd prefer something reusable like `bool IsRejectInvalidReason(String reason)(std::runtime_error const& e)`, which would be used like `BOOST_CHECK_EXCEPTION(functionThatThrows(), std::runtime_error, IsRejectInvalidReason("bad-blk-sigops")`. I couldn't figure out how to do that in C++.

Tree-SHA512: e364f19b4ac19f910f6e8d6533357f57ccddcbd9d53dcfaf923d424d2b9711446d6f36da193208b35788ca21863eadaa7becd9ad890334d334bccf8c2e63dee1
2020-04-05 11:06:14 -05:00
Pasta
61d12fd5bb
remove witness
Signed-off-by: Pasta <pasta@dashboost.org>
2020-04-05 11:06:13 -05:00
Wladimir J. van der Laan
5757e0d9e3
Merge #10699: Make all script validation flags backward compatible
01013f5 Simplify tx validation tests (Pieter Wuille)
2dd6f80 Add a test that all flags are softforks (Pieter Wuille)
2851b77 Make all script verification flags softforks (Pieter Wuille)

Pull request description:

  This change makes `SCRIPT_VERIFY_UPGRADABLE_NOPS` not apply to `OP_CHECKLOCKTIMEVERIFY` and `OP_CHECKSEQUENCEVERIFY`. This is a no-op as `UPGRADABLE_NOPS` is only set for mempool transactions, and those always have `SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY` and `SCRIPT_VERIFY_CHECKSEQUENCEVERIFY` set as well. The advantage is that setting more flags now always results in a reduction in acceptable scripts (=softfork).

  This results in a nice and testable property for validation, for which a new test is added.

  This also means that the introduction of a new definition for a NOP or witness version will likely need the following procedure (example OP_NOP8 here)
  * Remove OP_NOP8 from being affected by `SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS`.
  * Add a `SCRIPT_VERIFY_DISCOURAGE_NOP8`, which only applies to `OP_NOP8`.
  * Add a `SCRIPT_VERIFY_NOP8` which implements the new consensus logic.
  * Before activation, add `SCRIPT_VERIFY_DISCOURAGE_NOP8` to the mempool flags.
  * After activation, add `SCRIPT_VERIFY_NOP8` to both the mempool and consensus flags.

Tree-SHA512: d3b4538986ecf646aac9dba13a8d89318baf9e308e258547ca3b99e7c0509747f323edac6b1fea4e87e7d3c01b71193794b41679ae4f86f6e11ed6be3fd62c72
2020-04-05 11:06:13 -05:00
Wladimir J. van der Laan
7c79c480d7
Merge #11804: [docs] Fixed outdated link with archive.is
bf20a7d [docs] Fixed outdated link with archive.is (Tim Shimmin)

Tree-SHA512: 7d316aa4c462213578a9a1e71b06a459924ed3bb681a0469cc3719b21a871a6350fff4656696057e362561ee10dc10e933fe1328ef454ab7e133ecf05549ec1c
2020-04-05 11:06:12 -05:00
Pasta
af2cf2028e
fix
Signed-off-by: Pasta <pasta@dashboost.org>
2020-04-05 11:06:11 -05:00
Jonas Schnelli
625142bfa0
Merge #12327: [gui] Defer coin control instancing
6558f8acc [gui] Defer coin control instancing (João Barbosa)

Pull request description:

  Defer the GUI coin control instancing so that argument processing
  is taken into account for the default coin control values.

  Fixes #12312

Tree-SHA512: ecda28b94f4709319e9484b01afe763c7c3569097d2afb89db79da8a195c46d20ea77166df7edce0c8ab77627b295def01c072148714503436d27675d5e75d99
2020-04-05 11:06:11 -05:00
Wladimir J. van der Laan
7fb5b5b3a5
Merge #12173: [Qt] Use flexible font size for QRCode image address
59f9e2a Use flexible font size for QRCode image address (Jonas Schnelli)

Pull request description:

  Bech32 addresses are currently cut off in the QRCode image in the GUI receive tab.
  This adds a simple font size calculation logic that "must" (down to 4pt) fix into the given image width.

  Examples OSX HiDPI:
  <img width="332" alt="bildschirmfoto 2018-01-12 um 11 25 40" src="https://user-images.githubusercontent.com/178464/34896144-c0c65d76-f78c-11e7-93e1-94dc8e203269.png">
  <img width="322" alt="bildschirmfoto 2018-01-12 um 11 25 46" src="https://user-images.githubusercontent.com/178464/34896145-c0edfe1c-f78c-11e7-8c09-c15155e2160e.png">

  Examples Ubuntu non HIDPI:
  <img width="314" alt="bildschirmfoto 2018-01-12 um 11 27 51" src="https://user-images.githubusercontent.com/178464/34896151-c88347f4-f78c-11e7-8a03-df8049dcfed6.png">
  <img width="322" alt="bildschirmfoto 2018-01-12 um 11 27 42" src="https://user-images.githubusercontent.com/178464/34896152-c8bb881c-f78c-11e7-89d2-6f04ec608a19.png">

Tree-SHA512: d749763fb748b146f77fd8d88fb7d29b07a46cde0b0f303a4006ae9cc3521b3c2e8ab43b828e243514109379898b198552e17b8f316c5a869b0cc8246b054b86
2020-04-05 11:06:05 -05:00
MarcoFalke
3567f7b399 Merge #13184: RPC Docs: gettxout*: clarify bestblock and unspent counts
f30e9be4c1 RPC Docs: gettxout*: clarify bestblock and unspent counts (David A. Harding)

Pull request description:

  Expounds on two things I've seen confuse inexperienced users:

  - transactions/outputs in `gettxoutsetinfo`: a user thought this was the total number of transactions or outputs ever seen on the chain, whereas it's only the number in the UTXO.

  - bestblock in `gettxout`: a user thought this was the block that included the output, not realizing it was the tip of the current best block chain.  I also copied this text to `gettxoutsetinfo` for congruency.  I skimmed other uses of "bestblock" in the RPC docs and they seemed clear to me.

Tree-SHA512: c2161c497bef5fe15ee9f1e2a4413fa099b5baa36205ba1ba4b3822885b3ccd1badb9c118a0334f47ba6fa7fff5818ac359cfac6a1108c6847a876b1a251bb7c
2020-04-03 04:15:47 -05:00
Wladimir J. van der Laan
232bd29936 Merge #12999: qt: Show the Window when double clicking the taskbar icon
67bf2aa qt:Show the entire Window when double clicking on taskbar (Chun Kuan Lee)

Pull request description:

  fix #12838

Tree-SHA512: 4498bc1fe52efeed3768d6bdd7941e4b036d52ae80d9c1b6679c6daa3a62aeda4cff0c91fe1c65afaea6049c59cb0296fdcbff63ecb342d518615a92361fda7f
2020-04-03 04:11:11 -05:00
Wladimir J. van der Laan
f6bbb2c16a Merge #12998: Default to defining endian-conversion DECLs in compat w/o config
150b2f0 Default to defining endian-conversion DECLs in compat w/o config (Matt Corallo)

Pull request description:

  While this isn't a supported build configuration, some build
  systems need to build without going through our autotools steps,
  so defaulting to something sane may make it easier to build.

  Specifically, this fixes the inability to build
  rust-bitcoinconsensus on some non-x86 platforms. It needs to build
  without our autotools/configure steps to ensure correct compile
  args are passed from the rust build system to gcc. Converting the
  args from the rust build system to gcc would be a lot of
  unmaintainable work.

Tree-SHA512: 776fdb8c91b66f421fc751cb281c99c53c47e496f46b26c9f49bb6fdb6da3d2dda5dcc1c5bf413206bdd9ff3cbe5cef2823455900462519a4944631d9c48b54c
2020-04-03 04:10:53 -05:00
Wladimir J. van der Laan
547aef1b0b Merge #12650: gui: Fix issue: "default port not shown correctly in settings dialog"
40c5886 Fix illegal default `addProxy` and `addrSeparateProxyTor` settings. (251)

Pull request description:

  In f05d349 the value of the `addrProxy` and `addrSeparateProxyTor` settings is set to an illegal default value, because the value of `DEFAULT_GUI_PROXY_PORT ` is passed to the `fieldWidth` parameter of the `QString QString::arg(const QString &a, int fieldWidth = 0, QChar fillChar = QLatin1Char( ' ' )) const` method:

  29fad97c32/src/qt/optionsmodel.cpp (L129)

  29fad97c32/src/qt/optionsmodel.cpp (L139)

  This will create a default proxy setting that consists of 9053 characters and ends with the string `127.0.0.1:%2`.

  This PR attempts to resolve #12623 by setting the correct value for the `addrProxy` and `addrSeparateProxyTor` settings (i) if the proxy setting does not exist; or (ii) if the proxy setting has an illegal value caused by to the aforementioned bug.

  The second condition is *only* relevant if we don't want Bitcoin Core 0.16.0 users to explicitly reset their settings to see the correct default proxy port value.

Tree-SHA512: 3dc3de2eb7da831f6e318797df67341ced2076b48f9b561c73677bf6beb67b259d8e413095f290356fb92e32e4e8162d48accbc575c4e612060fd5d6dde7ac8d
2020-04-03 04:08:11 -05:00
Wladimir J. van der Laan
89bc82625b test: Add missing signal.h header
util_tests.cpp needs to include the signal.h header on FreeBSD.

Reported by denis2342 on IRC.

Github-Pull: #12447
Rebased-From: dd7e42cbb4
Tree-SHA512: 10ead029bb59f5d69e37b5679c710f22d64051de26e1ec8342eec4e4dec4d76249e16dff78d192972bcb8d139d99c7555a7cb2fe43b2b911103eab6d6f943b79
2020-04-03 04:02:01 -05:00
Wladimir J. van der Laan
40e4a1a45c Merge #12422: util: Make LockDirectory thread-safe, consistent, and fix OpenBSD 6.2 build
1d4cbd2 test: Add unit test for LockDirectory (Wladimir J. van der Laan)
fc888bf util: Fix multiple use of LockDirectory (Wladimir J. van der Laan)

Pull request description:

  Wrap the `boost::interprocess::file_lock` in a `std::unique_ptr` inside the map that keeps track of per-directory locks.

  This fixes a build issue with the clang 4.0.0+boost-1.58.0p8 version combo on OpenBSD 6.2, and should have no effect otherwise.

  Also add a unit test, make the function thread-safe, and fix Linux versus Windows behavior inconsistency.

  Meant to fix #12413.

Tree-SHA512: 1a94c714c932524a51212c46e8951c129337d57b00fd3da5a347c6bcf6a947706cd440f39df935591b2079995136917f71ca7435fb356f6e8a128c509a62ec32
2020-04-03 04:00:42 -05:00
UdjinM6
3e072bed89
Merge pull request #3387 from PastaPastaPasta/backports-0.16-pr13
Backports 0.16 pr13
2020-04-03 02:31:23 +03:00
Alexander Block
c7b6eb851d
Merge pull request #3389 from codablock/pr_concentrated_recovery
Implement "concentrated recovery" of LLMQ signatures
2020-04-02 13:59:05 +02:00
Alexander Block
e518ce4e13
Increase DIP0008 bip9 window by 10 years (#3391) 2020-04-02 08:19:41 +02:00
UdjinM6
f4d6d370f0 Fix 11854 2020-04-01 12:43:18 -05:00
Wladimir J. van der Laan
9bedb900a9 Merge #11904: Add a lock to the wallet directory
2f3bd47 Abstract directory locking into util.cpp (MeshCollider)
5260a4a Make .walletlock distinct from .lock (MeshCollider)
64226de Generalise walletdir lock error message for correctness (MeshCollider)
c9ed4bd Add a test for wallet directory locking (MeshCollider)
e60cb99 Add a lock to the wallet directory (MeshCollider)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/issues/11888, needs a 0.16 milestone

  Also adds a test that the lock works.

  https://github.com/bitcoin/bitcoin/pull/11687 will probably rework this to a per-wallet lock instead of just the walletdir, but this fixes the current issue

Tree-SHA512: 98e52d67f820e3b8f919cf361ffbb7d928f1bd67603e0ed26c5076ea02d9b3a90c3535ddf7329f3b88171396fa28dd3c87adab3577a8a217bd1e4247bda99138
2020-04-01 12:43:18 -05:00
Wladimir J. van der Laan
9d3c7c3ca6 Merge #11854: Split up key and script metadata for better type safety
9c8eca7 Split up key and script metadata for better type safety (Russell Yanofsky)

Pull request description:

  Suggested by @TheBlueMatt
  https://github.com/bitcoin/bitcoin/pull/11403#discussion_r155599383

  Combining the maps was probably never a good arrangement but is more
  problematic now in presence of WitnessV0ScriptHash and WitnessV0KeyHash types.

Tree-SHA512: 9263e9c01090fb49221e91d88a88241a9691dda3e92d86041c8e284306a64d3af5e2438249f9dcc3e6e4a5c11c1a89f975a86d55690adf95bf2636f15f99f92a
2020-04-01 12:43:18 -05:00
Wladimir J. van der Laan
02ab2efe4a Merge #11667: Add scripts to dumpwallet RPC
656fde5 Add script birthtime metadata to dump and import wallet (MeshCollider)
1bab9b2 Add script dump note to RPC help text and release notes (MeshCollider)
68c1e00 Add test for importwallet (MeshCollider)
9e1184d Add dumpwallet scripts test (MeshCollider)
ef0c730 Add scripts to importwallet RPC (MeshCollider)
b702ae8 Add CScripts to dumpwallet RPC (MeshCollider)
cdc260a Add GetCScripts to CBasicKeyStore (MeshCollider)

Pull request description:

  As discussed in https://github.com/bitcoin/bitcoin/pull/11289#issuecomment-334600457, adds the CScripts from the wallet to the `dumpwallet` RPC and then allows them to be imported with the `importwallet` RPC. Includes a basic test, and modifies the helptext of the dumpwallet RPC.

  Notes:
  - Reviewers: use `?w=1` to avoid the indentation-only change in commit `Add scripts to importwallet RPC `
  - currently the scripts are followed with `# addr=` comments just as the other keys are, unsure if this might confuse users into thinking all the scripts are for valid P2SH addresses though, but I don't think that should be an issue.
  - there are no birthtimes for scripts, so script imports don't affect rescans
  - `importwallet` imports the CScripts but I'm not sure how to approach specifying whether scripts are for P2SH addresses, BIP173 addresses, etc. whether that matters or not. Otherwise the RPC helptext might just need modification.

  Fixes #11715

Tree-SHA512: 36c55837b3a58b9d3499d4c0c2ae82153d62aa71919e751574651b63a1d2b8ecc83796db4553cc65dad9b5341c3a42ae2fcf4d62598c30af267f8e1461ba8272
2020-04-01 12:43:18 -05:00
MarcoFalke
adec6e262e Merge #11997: [tests] util_tests.cpp: actually check ignored args
c99a3c32c8 [tests] util_tests.cpp: actually check ignored args (Anthony Towns)

Pull request description:

  An array with 7 elements was setup for checking argument parsing, but
  was passed to ParseParamaeters with argc=5, meaning the interpretation
  of the last two arguments was never actually checked.

Tree-SHA512: 7b81fde49742e524f1bb67e2ec084f5909ae36125f237f0210df4587c62e5a5a8f277f13543f0a85ad145c4bb80d62339a7d50d7ed41659df318c8198ea7f428
2020-04-01 12:43:18 -05:00
Wladimir J. van der Laan
58422516d0 Merge #10874: [RPC] getblockchaininfo: Loop through the bip9 soft fork deployments instead of hard coding
e4d0af4 Loop through the bip9 soft fork deployments instead of hard coding (Andrew Chow)

Pull request description:

  Instead of hard coding which deployment statistics should be listed in the `getblockchaininfo` output, loop through the available deployments (except testdummy) when displaying their deployment info.

Tree-SHA512: 87e503bcf5e0fd379940d5e53320b9cbb4b47d647c66246d46f47c09a941f135e6ce1e8b75dad441ed4c22c3f41992dfde7717414be1d71c771d4ff8fe0e1936
2020-04-01 12:43:18 -05:00
Wladimir J. van der Laan
fe8c18ca77 Merge #10574: Remove includes in .cpp files for things the corresponding .h file already included
a720b92 Remove includes in .cpp files for things the corresponding .h file already included (practicalswift)

Pull request description:

  Remove includes in .cpp files for things the corresponding .h file already included.

  Example case:
  * `addrdb.cpp` includes `addrdb.h` and `fs.h`
  * `addrdb.h` includes `fs.h`

  Then remove the direct inclusion of `fs.h` in `addrman.cpp` and rely on the indirect inclusion of `fs.h` via the included `addrdb.h`.

  In line with the header include guideline (see #10575).

Tree-SHA512: 8704b9de3011a4c234db336a39f7d2c139e741cf0f7aef08a5d3e05197e1e18286b863fdab25ae9638af4ff86b3d52e5cab9eed66bfa2476063aa5c79f9b0346
2020-04-01 12:43:18 -05:00
MarcoFalke
a98db86ada Merge #10493: Use range-based for loops (C++11) when looping over map elements
680bc2cbb Use range-based for loops (C++11) when looping over map elements (practicalswift)

Pull request description:

  Before this commit:

  ```c++
  for (std::map<T1, T2>::iterator x = y.begin(); x != y.end(); ++x) {
      T1 z = (*x).first;
      …
  }
  ```

  After this commit:

  ```c++
  for (auto& x : y) {
      T1 z = x.first;
      …
  }
  ```

Tree-SHA512: 954b136b7f5e6df09f39248a6b530fd9baa9ab59d7c2c7eb369fd4afbb591b7a52c92ee25f87f1745f47b41d6828b7abfd395b43daf84a55b4e6a3d45015e3a0
2020-04-01 12:43:18 -05:00
Pieter Wuille
306390abac Merge #11746: trivial: Fix unsuccessful typo
d2ea2bcb5 trivial: Fix unsuccessful typo (practicalswift)

Pull request description:

  Fix unsuccessful typo.

Tree-SHA512: 48dde6764603b91cdd698fd9b5ea200961009df07f5a024430aaf81c50d889ed72681d76ac0832cdafaa2fd2be32ef3637ba641308de5eea6146f3b1074e9b19
2020-04-01 12:43:17 -05:00
Wladimir J. van der Laan
3f16ebd70a Merge #11738: Fix sendrawtransaction hang when sending a tx already in mempool
d9340ce Fix sendrawtransaction hang when sending a tx already in mempool (Matt Corallo)

Pull request description:

  I assume this is what #11721 actually hit.

Tree-SHA512: 1da4088bbda64c5527233de9ec4d03f9e0c1eacddb2ed3deab3cb99eac0293ee6fb846830f97b5e10e230307b6d7fd18013043173aa4f27ef171d9da626e2c88
2020-04-01 12:43:17 -05:00
Alexander Block
148bbdd5cf
Use GetTime instead of GetAdjustedTime
Co-Authored-By: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-04-01 18:05:44 +02:00
Alexander Block
76b6614fe5 Use auto keyword in CollectSigSharesToSend 2020-03-31 19:58:07 +02:00
Alexander Block
900ee0f194 Use range based for loop in SelectMemberForRecovery 2020-03-31 19:58:07 +02:00
Alexander Block
80533f6c0d Implement "quorum selectquorum" RPC 2020-03-31 19:58:07 +02:00
Alexander Block
b212f21c15 Implement new way of concentrated signature recovery
Instead of propagating all sig shares to all LLMQ members, this will now
make all members send their individual sig share to a single member, which
is then responsible for the recovery and propagation of the recovered
signature. This process is repeated by all members every second for another
target/recovering member, until a recovered signature appears.
2020-03-31 19:58:07 +02:00
Alexander Block
45064d8dc9 Rename sigSharesToSend to sigShareBatchesToSend 2020-03-31 19:58:07 +02:00
Alexander Block
97ffcd369d Use !fMasternode to disable restart of mnsync instead of checking for regtest 2020-03-31 19:53:46 +02:00
Alexander Block
19e3e8733d Use Params().RequireRoutableExternalIP() wherever possible 2020-03-31 07:21:12 +02:00
Alexander Block
99414ed754 Fix fRequireRoutableExternalIP for devnets 2020-03-31 07:16:35 +02:00
Alexander Block
88d4f551c9 Move spork21 condition into VerifyConnectionAndMinProtoVersions 2020-03-31 07:11:27 +02:00
Alexander Block
3e3eba63e2 Fix LLMQ dkgBadVotesThreshold parameter in regtest and devnet 2020-03-31 07:07:52 +02:00
Alexander Block
d3586e1df0 Immediately close connections again when fNetworkActive==false 2020-03-31 07:07:52 +02:00
Alexander Block
cace76d07f Actually use LLMQConnectionRetryTimeout for probing 2020-03-31 07:07:52 +02:00
Alexander Block
38bf1a31fb Allow masternode mode and -listen=0 in regtest mode 2020-03-31 07:07:52 +02:00
Alexander Block
bb63327623 Don't restart mnsync in regtest when nothing happens for too long
This kept conflicting with the way we use mocktime and causes many DKG
failures.
2020-03-31 07:07:52 +02:00
Alexander Block
d16b7dbcb5 Implement hidden "-pushversion" parameter for PoSe testing 2020-03-31 07:07:52 +02:00
Alexander Block
32c83b432b Verify min proto version and open ports of LLMQ members and vote on bad ones 2020-03-31 07:07:52 +02:00
UdjinM6
f43cdbc586
Gradually bump mocktime in wait_for_quorum_connections (#3388)
* Gradually bump mocktime in wait_for_quorum_connections

* Lower nLLMQConnectionRetryTimeout to 1 sec for regtest
2020-03-31 07:06:41 +02:00
Alexander Block
b0668028b6
Implement more randomized behavior in GetQuorumConnections (#3385)
When taking the proTxHash naively, we might end up with a few unlucky MNs
which always have to perform most of the outbound connections while other
unlucky MNs would always have to wait for inbound connections. Hashing
the proTxHash with the quorum hash makes this more random.
2020-03-28 00:59:32 +03:00
UdjinM6
3c90da86b3
Merge pull request #3371 from PastaPastaPasta/backports-0.16-pr12
Backports 0.16 pr12
2020-03-28 00:58:08 +03:00
Alexander Block
a09e36106e Fix onlyOutbound handling 2020-03-27 15:12:20 +01:00
Alexander Block
f82204db95 Move intra-quorum connection calculation into local func 2020-03-27 15:12:20 +01:00
Alexander Block
882b58c990 Use <> instead of "" for #include 2020-03-27 15:12:20 +01:00
Alexander Block
dbaf13848d Include inbound connections in output of "quorum dkgstatus" 2020-03-27 15:12:20 +01:00
Alexander Block
e8bbbec259 Don't try to open masternode connections when network is disabled 2020-03-27 15:12:20 +01:00
Alexander Block
c9608bf930 Only add wallet info to protx list/info when wallet is enabled 2020-03-27 15:12:20 +01:00
Alexander Block
9ef2b05884 Add masternode meta info to protx list/info 2020-03-27 15:12:20 +01:00
Alexander Block
8f644d18d7 Implement probing of public ip/port of LLMQ members 2020-03-27 15:12:20 +01:00
Alexander Block
14bb62ac8e Connect all LLMQ members to all other members 2020-03-27 15:12:20 +01:00
Alexander Block
486463d622 Add SPORK_21_QUORUM_ALL_CONNECTED 2020-03-27 15:12:20 +01:00
Alexander Block
6c95518807 Bump proto version 2020-03-27 15:12:20 +01:00
Alexander Block
c68b5f68aa
Hold CEvoDB lock while iterating mined commitments (#3379) 2020-03-27 15:11:42 +01:00
Alexander Block
17ece14f40
Better/more logging for DKGs (#3381)
* Better/more logging for DKGs

* Use type name instead of type number in CDKGLogger
2020-03-26 13:25:01 +01:00
Alexander Block
80be2520a2
Call FlushBackgroundCallbacks before resetting CConnman (#3378) 2020-03-26 13:24:31 +01:00
Alexander Block
b6bdb8be9e
Faster opening of masternode connections (#3375)
Only sleep 100ms when we previously tried to connect a MN. The back-off
logic in ThreadOpenMasternodeConnections will prevent too many unsuccessful
connects to offline/bad nodes.
2020-03-26 13:24:06 +01:00
Alexander Block
fa9b91b50f
Merge pull request #3376 from UdjinM6/merge_11824
Merge remaining bits of #11824: Block ActivateBestChain to empty validationinterface queue
2020-03-26 13:23:44 +01:00
UdjinM6
b1dff227cb Apply some review suggestions 2020-03-25 17:51:42 +03:00
Wladimir J. van der Laan
d94dd15de7
Merge #11718: tests: move pwalletMain to wallet test fixture
49bd659 tests: move pwalletMain to wallet test fixture (Wladimir J. van der Laan)

Pull request description:

  Scope the variable instead of using an external global; this is how test fixtures are intended to be used.

  Followup to #11713.

Tree-SHA512: 7d5bda93cdfe1329c8fe39bd72965906e36dad72fbb5d344ebedf26e66b1857510d01a3c2872d7f718fdeb23365e6ba71991aafe68e82781c6767a086b6d1590
2020-03-24 11:43:10 -05:00
Wladimir J. van der Laan
d3e5f8ead7
Merge #12518: [0.16] Bump leveldb subtree
835a21b Squashed 'src/leveldb/' changes from c521b3ac65..64052c76c5 (MarcoFalke)

Pull request description:

  The leveldb bump is the same branch/commit as in #12451

Tree-SHA512: 585a55747c75e990c9fd73399e98e548c01bef8b960c0a99844326de43663d004d2211b4689518f2d3e51cc48a732e9c92082939c356793143db411224fa75fa
2020-03-24 11:43:10 -05:00
Wladimir J. van der Laan
1e41cf9f3d
Merge #11722: Switched sync.{cpp,h} to std threading primitives.
f7f7e2c threads: add a thread_local autoconf check (Cory Fields)
bba9bd0 Switched sync.{cpp,h} to std threading primitives. (Thomas Snider)

Pull request description:

  Replaced boost threading primitives with the std equivalents.

Tree-SHA512: 72d10f9e48bfcf1db87e4a88bc698ef98eba0b29fe904570391b34a6ea1ffad474b7f192e70e3588a30e448f70f244eb4ddc5f24412a0bde2b564e76274160a5
2020-03-24 11:43:10 -05:00
Wladimir J. van der Laan
411c57995b
Merge #11884: Remove unused include in hash.cpp
3f09e03 Remove unused include in hash.cpp (Karl-Johan Alm)

Pull request description:

Tree-SHA512: 543a72656460fba1c5498a0b85c49601d9b0399a4ecc49f4acf4715c258918da729df388e3be724c3161438e903ee16ad3c50626a71483aa6d85ffdbb827742d
2020-03-24 11:43:10 -05:00
Alexander Block
8211ff0a8a
Merge pull request #3368 from codablock/pr_fmasternode
Don't relay anything to inbound/outbound fMasternode connections
2020-03-24 17:40:51 +01:00
Pieter Wuille
871b8585ca Merge #11824: Block ActivateBestChain to empty validationinterface queue
97d2b09c12 Add helper to wait for validation interface queue to catch up (Matt Corallo)
36137497f1 Block ActivateBestChain to empty validationinterface queue (Matt Corallo)
5a933cefcc Add an interface to get the queue depth out of CValidationInterface (Matt Corallo)
a99b76f269 Require no cs_main lock for ProcessNewBlock/ActivateBestChain (Matt Corallo)
a734896038 Avoid cs_main in net_processing ActivateBestChain calls (Matt Corallo)
66aa1d58a1 Refactor ProcessGetData in anticipation of avoiding cs_main for ABC (Matt Corallo)
818075adac Create new mutex for orphans, no cs_main in PLV::BlockConnected (Matt Corallo)

Pull request description:

  This should fix #11822.

  It ended up bigger than I hoped for, but its not too gnarly. Note that "
  Require no cs_main lock for ProcessNewBlock/ActivateBestChain" is mostly pure code-movement.

Tree-SHA512: 1127688545926f6099449dca6a4e6609eefc3abbd72f1c66e03d32bd8c7b31e82097d8307822cfd1dec0321703579cfdd82069cab6e17b1024e75eac694122cb
2020-03-24 17:21:59 +03:00
Alexander Block
94bcf85347
Merge pull request #3367 from codablock/pr_refactor_llmq_conns
Refactor and unify quorum connection handling
2020-03-24 11:20:45 +01:00
Alexander Block
4e8f4ea202
Merge pull request #3374 from codablock/pr_fix_scheduler_shutdown
Backport bitcoin#12266 and bitcoin#13894 to fix shutdown issues
2020-03-24 11:20:12 +01:00
Alexander Block
d8121bba29
Apply suggestions from code review
Co-Authored-By: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-03-24 11:07:26 +01:00
Alexander Block
7f1f1d12f5 Make EnsureQuorumConnections re-set connections in every iteration
Instead of only doing it the first time. This is a preparation for
the new intra-quorum connection system (which connects all members to all
other members)
2020-03-24 10:58:29 +01:00
Alexander Block
9ef1e7cb51 Only log new quorum connections when it's actually new 2020-03-24 10:58:16 +01:00
Alexander Block
364d6c37f7 Move and unify logic for quorum connection establishment into CLLMQUtils 2020-03-24 10:58:16 +01:00
Alexander Block
c0bb06e766
Merge pull request #3366 from codablock/pr_fix_mnconns
Multiple fixes for masternode connection handling
2020-03-24 10:57:42 +01:00
Alexander Block
f2ece1031f
Remove logging for waking of select() (#3370)
This was always quite spammy and so far never useful in debugging.
2020-03-24 10:55:24 +01:00
Wladimir J. van der Laan
35b041ed14 Merge #13894: shutdown: Stop threads before resetting ptrs
faab63111d8f27335aa1f09c1a48da3be45135de shutdown: Stop threads before resetting ptrs (MarcoFalke)

Pull request description:

  On shutdown some threads would continue to run after or during a pointer reset. This leads to occasional segfaults on shutdown.

  Fix this by resetting the smart pointers after all threads that might read from them have been stopped.

  This should fix:
  * A segfault in the txindex thread, that occurs when the txindex destructor is done, but the thread was not yet stopped (as this is done in the base index destructor)
  * A segfault in the scheduler thread, which dereferences conman. (e.g. CheckForStaleTipAndEvictPeers)

Tree-SHA512: abbcf67fadd088e10fe8c384fadfb90bb115d5317145ccb5363603583b320efc18131e46384f55a9bc574969013dfcbd08c49e0d42c004ed7212eca193858ab2
2020-03-23 12:42:58 +01:00
Wladimir J. van der Laan
c01e39d610 Merge #12266: Move scheduler/threadGroup into common-init instead of per-app
082a61c Move scheduler/threadGroup into common-init instead of per-app (Matt Corallo)

Pull request description:

  This resolves #12229 which pointed out a shutdown deadlock due to
  scheduler/checkqueue having been shut down while network message
  processing is still running.

Tree-SHA512: 0c0a76113996b164b0610d3b8c40b396f3e384d165bf098768e31fe3701b00763d0d810ef24702387e2e936fefb9fb900a6225f7417bb0175b585f365d542660
2020-03-23 12:42:14 +01:00
Alexander Block
f7ddee13a1
Fix possible segfault (#3365)
When CheckActiveState is called very early, there might be no chain yet.
2020-03-21 13:31:09 +01:00
Alexander Block
2a6465a6fb Move LLMQ connection retry timeout into chainparams 2020-03-21 12:21:09 +01:00
Alexander Block
40cdfe8662
Add peer id to "socket send error" logs (#3363) 2020-03-21 11:33:37 +01:00
Alexander Block
71e57a25fa Add masternode flag to result of getpeerinfo 2020-03-20 17:16:49 +01:00
Alexander Block
31825146a3 Don't relay anything to fMasternode connections
This reduces traffic on these connections to PS and DKG/LLMQ traffic only.
2020-03-20 17:16:49 +01:00
Alexander Block
f4f57fbb63 Pass fMasternode variable in VERSION so that the other end knows about it 2020-03-20 17:16:49 +01:00
Alexander Block
458a63736d Track last outbound connection attempts in CMasternodeMetaMan
Instead of relying on CAddrMan, which only works well for addresses
announced in P2P networking (and not with MNs).
2020-03-20 17:16:24 +01:00
Alexander Block
93ed22b239 Logging for outgoing masternode connections 2020-03-20 17:16:24 +01:00
Alexander Block
35d75b19e6 Make pending masternode queue proTxHash based
Instead of CService
2020-03-20 17:16:24 +01:00
Alexander Block
0adef2cf7a Fix ThreadOpenMasternodeConnections to not drop pending MN connections
The way it was implemented caused vPendingMasternodes entries to be popped
but not necessarily connected to when at the same time quorum connections
were pending.
2020-03-20 17:16:24 +01:00
Alexander Block
0fa2e14065
Fix issues introduced with asynchronous signal handling (#3369)
* Introduce SynchronousUpdatedBlockTip signal

This version of UpdatedBlockTip mirrors the asynchronous behavior that we
had before the introduction of asynchronous signal handling.

* Fix tab spacing in validationinterface.cpp

* Invoke CDeterministicMNManager::UpdatedBlockTip from validation thread

It must be invoked synchronously as otherwise things become inconsistent.

* Call CActiveMasternodeManager::Init with block index

pindexNew in UpdatedBlockTip is not necessarily the current tip, so we
shouldn't rely on it in Init(). This is due to the async nature of the
UpdatedBlockTip invocation.
2020-03-20 19:11:54 +03:00
Wladimir J. van der Laan
791719ea3d Merge #11839: don't attempt mempool entry for wallet transactions on startup if alr…
6697a70 add test for unconfirmed balance between restarts (Gregory Sanders)
6ba8f30 don't attempt mempool entry for wallet transactions on startup if already in mempool (Gregory Sanders)

Pull request description:

  …eady in mempool

  Mempool loads first, wallet second. Second attempt fails, marking that transaction !fInMempool. Those funds will disappear until confirmation is reached.

Tree-SHA512: 955f0565ec1dc1ba395e0b803a98c07b7cd00c8cac5ec618ed832fed259a856fb7bbbe41310cf6a4e43c0435e09b156109d2a4467d403811dc8379d2caebeede
2020-03-19 17:51:25 -05:00
UdjinM6
b188c5c25e
Refactor some PrivateSend related code to use WalletModel instead of accessing the wallet directly from qt (#3345)
* Use item data to figure out PS rounds for the input selected in CoinControl dialog

* Access GetRealOutpointPrivateSendRounds through WalletModel in CoinControl dialog

Instead of accessing the walet directly

* Make OverviewPage::privateSendStatus() mockable

GetTimeMillis() -> GetTime()

* Refactor PS related code in overviewpage to access wallet via wallet model
2020-03-20 01:48:24 +03:00
UdjinM6
9efa0e3d82
Merge pull request #3361 from PastaPastaPasta/backports-0.16-pr11
Backports 0.16 pr11
2020-03-20 01:47:53 +03:00
UdjinM6
7334888122
Merge pull request #3360 from PastaPastaPasta/backport-upstream
Backport upstream
2020-03-20 01:47:23 +03:00
PastaPastaPasta
8a1ec935a0
Backport 11651 (#3358)
* scripted-diff: Replace #include "" with #include <> (ryanofsky)

-BEGIN VERIFY SCRIPT-
for f in \
  src/*.cpp \
  src/*.h \
  src/bench/*.cpp \
  src/bench/*.h \
  src/compat/*.cpp \
  src/compat/*.h \
  src/consensus/*.cpp \
  src/consensus/*.h \
  src/crypto/*.cpp \
  src/crypto/*.h \
  src/crypto/ctaes/*.h \
  src/policy/*.cpp \
  src/policy/*.h \
  src/primitives/*.cpp \
  src/primitives/*.h \
  src/qt/*.cpp \
  src/qt/*.h \
  src/qt/test/*.cpp \
  src/qt/test/*.h \
  src/rpc/*.cpp \
  src/rpc/*.h \
  src/script/*.cpp \
  src/script/*.h \
  src/support/*.cpp \
  src/support/*.h \
  src/support/allocators/*.h \
  src/test/*.cpp \
  src/test/*.h \
  src/wallet/*.cpp \
  src/wallet/*.h \
  src/wallet/test/*.cpp \
  src/wallet/test/*.h \
  src/zmq/*.cpp \
  src/zmq/*.h
do
  base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f
done
-END VERIFY SCRIPT-

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

* scripted-diff: Replace #include "" with #include <> (Dash Specific)

-BEGIN VERIFY SCRIPT-
for f in \
  src/bls/*.cpp \
  src/bls/*.h \
  src/evo/*.cpp \
  src/evo/*.h \
  src/governance/*.cpp \
  src/governance/*.h \
  src/llmq/*.cpp \
  src/llmq/*.h \
  src/masternode/*.cpp \
  src/masternode/*.h \
  src/privatesend/*.cpp \
  src/privatesend/*.h
do
  base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f
done
-END VERIFY SCRIPT-

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

* build: Remove -I for everything but project root

Remove -I from build system for everything but the project root,
and built-in dependencies.

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

# Conflicts:
#	src/Makefile.test.include

* qt: refactor: Use absolute include paths in .ui files

* qt: refactor: Changes to make include paths absolute

This makes all include paths in the GUI absolute.

Many changes are involved as every single source file in
src/qt/ assumes to be able to use relative includes.

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

# Conflicts:
#	src/qt/dash.cpp
#	src/qt/optionsmodel.cpp
#	src/qt/test/rpcnestedtests.cpp

* test: refactor: Use absolute include paths for test data files

* Recommend #include<> syntax in developer notes

* refactor: Include obj/build.h instead of build.h

* END BACKPORT #11651 Remove trailing whitespace causing travis failure

* fix backport 11651

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

* More of 11651

* fix blockchain.cpp

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

* Add missing "qt/" in includes

* Add missing "test/" in includes

* Fix trailing whitespaces

Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
Co-authored-by: MeshCollider <dobsonsa68@gmail.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-03-20 01:46:56 +03:00
Pasta
b46693eaf7
Apply the same fix to evoDb and deterministicMNManager as pblocktree
Signed-off-by: Pasta <pasta@dashboost.org>
2020-03-16 16:35:45 -05:00
PastaPastaPasta
9a2fa43455
Remove "> 0" from IsArgSet call
Co-Authored-By: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-03-16 16:35:45 -05:00
MarcoFalke
75f32fb50f
Merge #11309: Minor cleanups for AcceptToMemoryPool
bf64c3cb3 Ignore transactions added to mempool during a reorg for fee estimation purposes. (Alex Morcos)
04f78ab5b Do not reject based on mempool min fee when bypass_limits is set. (Alex Morcos)
fd849e1b0 Change AcceptToMemoryPool function signature (Alex Morcos)

Pull request description:

  First commit just removes default arguments from `AcceptToMemoryPool` and consolidates two arguments, it does not change behavior.

  Second commit finally fixes the fact that we're not meant to reject based on mempool min fee when adding a transaction from a disconnected block during a reorg as mentioned [here](https://github.com/bitcoin/bitcoin/pull/9602#issue-202197849)

  Third commit makes fee estimation ignore transactions added from a disconnected block during a reorg. I think this was another source of fee estimates returning estimates below 1000 sat/kB as in #11303.

Tree-SHA512: 30925ca8b341915bb214f1d2590b36b7931f2e125b7660150e38ae70338f00db5aa7f1608546dddb181446924177eb7cf62ea8bd2583068acc074d6c3f86bc0c

fix 11309

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

fix &

Signed-off-by: Pasta <pasta@dashboost.org>
2020-03-16 16:35:43 -05:00
Wladimir J. van der Laan
ce08ccec2c
Merge #12556: [Trivial] fix version typo in getpeerinfo RPC call help
d16bfaa fix version typo (Tamas Blummer)

Pull request description:

  RPC getpeeerinfo help output uses non-existent protocol version 7001. Changed to 70001.

Tree-SHA512: aea634d739b51bf26e3f871e8bf2bf812eb62a5d87008ead3ed27ec8bd9b753ad0a958eb21f580e505d7f2b36d60e5d9901dc8e0d25f34b7ef9533fddc898844
2020-03-14 22:01:59 -05:00
Wladimir J. van der Laan
b447c5a0c6
Merge #12349: shutdown: fix crash on shutdown with reindex-chainstate
ceaefdd fix possible shutdown assertion with -reindex-shutdown (Cory Fields)

Pull request description:

  Fixes the assertion error reported here: https://github.com/bitcoin/bitcoin/pull/12349#issuecomment-365095741

Tree-SHA512: db8e2a275f92a99df7f17852d00eba6df996e412aa3ed3853a9ea0a8cb9800760677532efd52f92abbf2cdcc4210957a87a5f919ac998d46c205365a7a7dffca
2020-03-14 22:01:59 -05:00
Wladimir J. van der Laan
99caed29f1
Merge #12415: Interrupt loading thread after shutdown request
2e9406c Interrupt loading thread after shutdown request (João Barbosa)

Pull request description:

  This change (currently) avoids loading the mempool if shutdown is requested.

Tree-SHA512: 3dca3a6ea5b09bd71db0974584d93dfe81819bc0bdbb4d9b6fa0474755306d1403f6c058ecb8211384493a8f7ca3a9134173db744b7344043cfc7d79286c8fd4
2020-03-14 22:01:59 -05:00
Wladimir J. van der Laan
5e19f32b6b
Merge #12401: Reset pblocktree before deleting LevelDB file
a8b5d20 Reset pblocktree before deleting LevelDB file (Sjors Provoost)

Pull request description:

  #11043 repaced:

  ```
  delete pblocktree;
  pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReset);
  ```

  With:

  ```
  pblocktree.reset(new CBlockTreeDB(nBlockTreeDBCache, false, fReset));
  ```

  This is problematic because `new CBlockTreeDB` tries to delete the existing file, which will fail with `LOCK: already held by process` if it's still open. That's the case for QT.

  When QT finds a problem with the index it will ask the user if they want to reindex. At that point it has already opened `blocks/index`.  It then runs this [while loop](https://github.com/bitcoin/bitcoin/blob/v0.16.0rc3/src/init.cpp#L1415) again with `fReset = 1`, resulting in the above error.

  This change makes that error go away, presumably because `reset()` without an argument closes the file.

Tree-SHA512: fde8b546912f6773ac64da8476673cc270b125aa2d909212391d1a2001b35c8260a8772126b99dfd76b39faaa286feb7c43239185fe584bd4dc2bc04a64044ce
2020-03-14 22:01:59 -05:00
Wladimir J. van der Laan
78d303c3fd
Merge #12368: Hold mempool.cs for the duration of ATMP.
02fc886 Add braces to meet code style on line-after-the-one-changed. (Matt Corallo)
85aa839 Hold mempool.cs for the duration of ATMP. (Matt Corallo)

Pull request description:

  This resolves an issue where getrawmempool() can race mempool
  notification signals. Intuitively we use mempool.cs as a "read
  lock" on the mempool with cs_main being the write lock, so holding
  the read lock intermittently while doing write operations is
  somewhat strange.

  This also avoids the introduction of cs_main in getrawmempool()
  which reviewers objected to in the previous fix in #12273

Tree-SHA512: 29464b9ca3890010ae13b7dc1c53487cc2bc9c3cf3d32a14cb09c8aa33848f57959d8991ea096beebcfb72f062e4e1962f104aefe4252c7db87633bbfe4ab317
2020-03-14 22:01:59 -05:00
Wladimir J. van der Laan
aa34483efd
Merge #12374: qt: Make sure splash screen is freed on AppInitMain fail
1e5d14b qt: Clarify some comments (Wladimir J. van der Laan)
f5a4c3d qt: Make sure splash screen is freed on AppInitMain fail (Wladimir J. van der Laan)

Pull request description:

  The `splashFinished` event was never sent if AppInitMain fails, causing the splash screen to stick around, causing problems later.

  This bug has existed for a while but is now trigging potential crashed because the splash screen subscribes to wallet events.

  Meant to fix #12372.

Tree-SHA512: 192a7e3a528015e771d7860dd95fd7b772292fd8064abf2a3cf3a8ea0d375cd43a6e8ed37ca1a38962fe1410c934599e557adf6a8ef9d87ec7f61b6e5fd8db7e
2020-03-14 22:01:59 -05:00
Wladimir J. van der Laan
7e5c5d40d1
Merge #12377: qt: Poll ShutdownTimer after init is done
2222bf0 qt: Poll ShutdownTimer after init is done (MarcoFalke)

Pull request description:

  The shutdown process has started in `requestShutdown`, but initialize will happily continue with `initializeResult` and start threads late in the shutdown progess. Deleting this running thread will crash the application according to the qt docs:
  e5033a5c9b/src/corelib/thread/qthread.cpp (L412-L415)

  Potential fix for https://github.com/bitcoin/bitcoin/issues/12372#issuecomment-363642332

  This reverts #11831 for now and hopefully restores the previous behaviour.

Tree-SHA512: 8e1706afe90ddf2d972aca12c12d4cb2a9a4f38646c59c5466fe5a1a67361896b93c43917d5ac283841ee2bcc62e6bb8dc2bc81dea9129c899b354e9a4ef241b
2020-03-14 22:01:59 -05:00
Wladimir J. van der Laan
8095699575
Merge #12367: Fix two fast-shutdown bugs
dd2de47 Fix fast-shutdown crash if genesis block was not loaded (Matt Corallo)
1c9394a Fix fast-shutdown hang on ThreadImport+GenesisWait (Matt Corallo)

Pull request description:

  The second commit is a much simpler alternative fix for the issue fixed in #12349. To test I made ShutdownRequested() always StartShutdown() after a certain number of calls, which turned up one other hang, fixed in the first commit.

Tree-SHA512: 86bde6ac4b8b4e2cb99fff87dafeed02c0d9514acee6d94455637fb2da9ffc274b5ad31b0a6b9f5bd7b700ae35395f28ddb14ffc65ddda3619aa28df28a5607d
2020-03-14 22:01:59 -05:00
MarcoFalke
a4dfd54ecf
Merge #17324: Update univalue subtree
fa0b3da36cd7cf0aada22f2d459296b81274c2f9 Squashed 'src/univalue/' changes from 7890db99d6..5a58a46671 (MarcoFalke)

Pull request description:

  Only change is a performance improvement. See https://github.com/bitcoin-core/univalue/pull/21#issue-333858474 and https://github.com/bitcoin-core/univalue/pull/15#issue-186748173

ACKs for top commit:
  jnewbery:
    ACK fa439e88af944082875e1fdb1cd8bb5a74b88b56
  laanwj:
    ACK fa439e88af944082875e1fdb1cd8bb5a74b88b56

Tree-SHA512: 35ea8f76ea4806182949c8eb5a8b652d1aaeec03ee023838e7cb29abcb81c61d59b38f15708564a78574722df57d13f61ef17d0f670a4056819705ef892321e0
2020-03-14 11:03:02 -05:00
Wladimir J. van der Laan
0d49c6fa00
Merge #15703: Update secp256k1 subtree to latest upstream
54245985fb3c89d72e285c4db39d38ed2f5fb0de Squashed 'src/secp256k1/' changes from 0b70241850..b19c000063 (Pieter Wuille)

Pull request description:

  It's been 1.5 years since our secp256k1 subtree was updated, while the upstream project has undergone a number of incremental improvements (performance, tests, build system fixes), plus gained the groundwork for batch verification.

  As we're early in the 0.19 window, this seems like a good time to get these merged.

ACKs for commit 99df27:
  fanquake:
    utACK 99df276 the subtree merge, still need to test the actual changes.
  laanwj:
    utACK 99df276da

Tree-SHA512: 769a699366321635068ebfbd9d3f30f6e72401c4fcdc1fdc84e5b3fd888c3f01437748f6cd23a507ab47cf04c226cd504fd48aee654457c34bb106c9db7e5c09
2020-03-14 11:01:03 -05:00
Wladimir J. van der Laan
139108aba5
Merge #15270: Pull leveldb subtree
4f2e6c8b881b7ccda36233332dfd1bd231389a8e Squashed 'src/leveldb/' changes from 524b7e36a8..f545dfabff (MarcoFalke)

Pull request description:

  Some windows-related fixes.

  Sanity check with:

  ```
  git fetch https://github.com/bitcoin-core/leveldb
  ./test/lint/git-subtree-check.sh src/leveldb

Tree-SHA512: ff94907ff3075b81cffb733129673a9bfd2abbe84240686b29274382b64b4e5845880236458043d6db0332bf70d12942d9c0e68b4fffab43931103d224cb59d4
2020-03-14 10:50:13 -05:00
MarcoFalke
d8d18d6657
Merge #11714: [tests] Test that mempool rejects coinbase transactions
65e91f5ed [tests] Test that mempool rejects coinbase transactions (James O'Beirne)

Pull request description:

  ![selection_063](https://user-images.githubusercontent.com/73197/32978622-b0fa9d70-cbfa-11e7-9a72-1997409e5ba8.png)

  Neither the unit nor functional tests appear to cover rejecting a transaction from acceptance to the mempool on the basis of it being a coinbase. Seems like a decent thing to have a test for.

Tree-SHA512: 53af53c975cad5d7a21c443d71a1c0ced5c70a7799b75bb44d9b7dd6ab2afbcdcaab14571540efeb848f3a1daee5e1dd856530d8f2b50582595219a1c17555ff
2020-03-14 00:57:48 -05:00
Pasta
e2c7d1f55a
add include 2020-03-14 00:57:41 -05:00
Wladimir J. van der Laan
62987bee8c
Merge #11191: RPC: Improve help text and behavior of RPC-logging.
c60c49b Improve help text and behavior of RPC-logging (Akio Nakamura)

Pull request description:

  1. It is allowed `libevent` logging to be updated during runtime,
    but still described that restriction in the help text.
    So we delete these text.
  2. Add a descrption about the evaluation order of `<include>` and
    `<exclude>` to clarify how debug loggig categories to be set.
  3. Add a description about the available logging category `"all"`
    which is not explained.
  4. Add `"optional"` to the help text of `<include>` and `<exclude>`.
  5. Add missing new lines before `"Argument:"`.
  6. `"0"`,`"1"` are allowed in both array of `<include>` and `<exclude>`.
    `"0"` is **ignored** and `"1"` is treated **same as** `"all"`.
    It is confusing, so forbid them.
  7. It always returns all logging categories with status.
    Fix the help text to match this behavior.

Tree-SHA512: c2142da1a9bf714af8ebc38ac0d82394e2073fc0bd56f136372e3db7b2af3b6746f8d6b0241fe66c1698c208c124deb076be83f07dec0d0a180ad150593af415
2020-03-14 00:57:35 -05:00
Wladimir J. van der Laan
26281c023a
Merge #10154: init: Remove redundant logging code
faafa80 init: Remove redundant logging code (MarcoFalke)

Tree-SHA512: 5ad0e9aba0e25a36025dd4ee5e5fddd2c0039f95bafd0f33300ea59e2f9bba807da6a1a8b4311d6aad5a360b99163edf4a4f161cb13f0f38580d8d6b504c94ad
2020-03-14 00:57:24 -05:00
Wladimir J. van der Laan
0c97cd5cee
Merge #11710: cli: Reject arguments to -getinfo
dcfef27 cli: Reject arguments to -getinfo (Wladimir J. van der Laan)

Pull request description:

  Currently it's possible to accidentally type e.g.

      bitcoin-cli -getinfo getbalance

  and get an answer which can be confusing; the trailing arguments are just ignored.

  To avoid this, throw an error if the user provides arguments to
  `-getinfo`.

Tree-SHA512: 3603e8fa852b884d1dd3b7462db40b092fe8b3390fd4384b4ee330315d797aff711e9f62990012fd4b5a55c8678734ba8497a5488a09ee6b65cf8a99017d6eb4
2020-03-14 00:56:23 -05:00
UdjinM6
05c134c783
Fix litemode vs txindex check (#3355) 2020-03-12 13:32:49 +03:00
UdjinM6
c9881d0fc7
Masternodes must have required services enabled (#3350)
* Masternodes must have required services enabled

* Add a comment about missing bits

* Refactor *InitParameterInteraction parts to follow surrounding code logic

Changes:
- move all related param interactions to appropriate places;
- try to softly set required params, complain and fail to start later if smth is not ok.

* Drop redundant code
2020-03-12 13:32:39 +03:00
UdjinM6
c6911354a1
Few tweaks for MakeCollateralAmounts (#3347)
* Few tweaks for MakeCollateralAmounts

Fail early, avoid creating non-usable change outputs

* Adjust wallet logic to display "make collaterals" txes correctly when we create one using non-max amount
2020-03-12 13:32:12 +03:00
UdjinM6
56b8e97ab0
Refactor and simplify PrivateSend based on the fact that we only mix one single denom at a time now (#3346)
* Split GetDenominationsToString into DenominationToAmount/DenominationToString

* Refactor SelectPrivateCoins into SelectDenominatedAmounts and drop ConvertList

* Refactor SelectPSInOutPairsByDenominations

* Drop GetDenominationsBits

* Drop GetDenominations

* Address review comments

* Fix/bring back session denom randomization in StartNewQueue

Note: no need to randomize if there is only one single option
2020-03-12 13:31:55 +03:00
UdjinM6
73258b363b
Merge pull request #3354 from PastaPastaPasta/backports-0.16-pr10
Backports 0.16 pr10
2020-03-10 14:57:35 +03:00
UdjinM6
ff5540bf73
Fix walletpassphrase
Let it update unlock time unless user tries to downgrade from "fuly unlocked" mode to "mixing only" one.
2020-03-04 10:14:17 -06:00