Commit Graph

15703 Commits

Author SHA1 Message Date
UdjinM6
6350adf1b9
Slightly refactor ProcessInstantSendLock (#2767)
Rewrite `if (var =  func())` in a less confusing way
2019-03-13 18:21:40 +03:00
Alexander Block
3a1aeb000e Multiple fixes/refactorings for ChainLocks (#2765)
* Print which DKG type aborted

* Don't directly call EnforceBestChainLock and instead schedule the call

Calling EnforceBestChainLock might result in switching chains, which in
turn might end up calling signals, so we get into a recursive call chain.

Better to call EnforceBestChainLock from the scheduler.

* Regularly call EnforceBestChainLock and reset error flags on locked chain

* Don't invalidate blocks from CChainLocksHandler::TrySignChainTip

As the name of this method implies, it's trying to sign something and not
enforce/invalidate chains. Invalidating blocks is the job of
EnforceBestChainLock.

* Only call ActivateBestChain when tip != best CL tip

* Fix unprotected access of bestChainLockBlockIndex and bail out if its null

* Fix ChainLocks tests after changes in enforcement handling

* Only invoke NotifyChainLock signal from EnforceBestChainLock

This ensures that NotifyChainLock is not prematurely called before the
block is fully connected.

* Use a mutex to ensure that only one thread executes ActivateBestChain

It might happen that 2 threads enter ActivateBestChain at the same time
start processing block by block, while randomly switching between threads
so that sometimes one thread processed the block and then another one
processes it. A mutex protects ActivateBestChain now against this race.

* Rename local copy of bestChainLockBlockIndex to currentBestChainLockBlockIndex

* Don't call ActivateBestChain when best CL is part of the main chain
2019-03-13 16:00:54 +03:00
UdjinM6
8955eb82ef
Merge pull request #2764 from codablock/pr_activatebestchainrace
Backport PRs from Bitcoin required to make ActivateBestChain cs_main free on entry
2019-03-12 15:41:33 +03:00
Alexander Block
152a78eab2 Add compatibility code to P2PFingerprintTest until we catch up with backports 2019-03-12 10:43:47 +01:00
Alexander Block
72af215a36 Fix CreateNewBlock_validity by not holding cs_main when calling createAndProcessEmptyBlock 2019-03-12 10:43:47 +01:00
Matt Corallo
95192d5b56 Require no cs_main lock for ProcessNewBlock/ActivateBestChain
This requires the removal of some very liberal (incorrect) cs_mains
sprinkled in some tests. It adds some chainActive.Tip() races, but
the tests are all single-threaded anyway.
2019-03-12 10:43:47 +01:00
Matt Corallo
2eb5531747 Avoid cs_main in net_processing ActivateBestChain calls 2019-03-12 10:43:47 +01:00
Matt Corallo
f69c4370d0 Refactor ProcessGetData in anticipation of avoiding cs_main for ABC 2019-03-12 10:43:47 +01:00
Matt Corallo
7f54372bb6 Create new mutex for orphans, no cs_main in PLV::BlockConnected
This should (marginally) speed up validationinterface queue
draining by avoiding a cs_main lock in one client.
2019-03-12 10:43:47 +01:00
Matt Corallo
6085de3781 Add ability to assert a lock is not held in DEBUG_LOCKORDER 2019-03-12 10:43:47 +01:00
Wladimir J. van der Laan
9344dee8aa Merge #11580: Do not send (potentially) invalid headers in response to getheaders
725b79a [test] Verify node doesn't send headers that haven't been fully validated (Russell Yanofsky)
3788a84 Do not send (potentially) invalid headers in response to getheaders (Matt Corallo)

Pull request description:

  Nowhere else in the protocol do we send headers which are for
  blocks we have not fully validated except in response to getheaders
  messages with a null locator. On my public node I have not seen any
  such request (whether for an invalid block or not) in at least two
  years of debug.log output, indicating that this should have minimal
  impact.

Tree-SHA512: c1f6e0cdcdfb78ea577d555f9b3ceb1b4b60eff4f6cf313bfd8b576c9562d797bea73abc23f7011f249ae36dd539c715f3d20487ac03ace60e84e1b77c0c1e1a
2019-03-12 10:43:47 +01:00
Wladimir J. van der Laan
d1a6022605 Merge #11113: [net] Ignore getheaders requests for very old side blocks
eff4bd8 [test] P2P functional test for certain fingerprinting protections (Jim Posen)
a2be3b6 [net] Ignore getheaders requests for very old side blocks (Jim Posen)

Pull request description:

  Sending a getheaders message with an empty locator and a stop hash is a request for a single header by hash. The node will respond with headers for blocks not in the main chain as well as those in the main chain. To avoid fingerprinting, the node should, however, ignore requests for headers on side branches that are too old. This replicates the logic that currently exists for `getdata` requests for blocks.

Tree-SHA512: e04ef61e2b73945be6ec5977b3c5680b6dc3667246f8bfb67afae1ecaba900c0b49b18bbbb74869f7a37ef70b6ed99e78ebe0ea0a1569369fad9e447d720ffc4
2019-03-12 10:43:47 +01:00
Wladimir J. van der Laan
d1db98c67a Merge #9665: Use cached [compact] blocks to respond to getdata messages
b49ad44 Add comment about cs_most_recent_block coverage (Matt Corallo)
c47f5b7 Cache witness-enabled state with recent-compact-block-cache (Matt Corallo)
efc135f Use cached [compact] blocks to respond to getdata messages (Matt Corallo)

Tree-SHA512: ffc478bddbf14b8ed304a3041f47746520ce545bdeffa9652eff2ccb25c8b0d5194abe72568c10f9c1b246ee361176ba217767af834752a2ca7263d292005e87
2019-03-12 10:43:47 +01:00
Alexander Block
0905b911dc Actually use cached most recent compact block
This seems to be backported wrongly. In the Bitcoin code, there is a
condition on requested witness data and we took the other branch which
recreates the compact block. We should have taken the other branch because
we always send with witness data (there is no Segwit in Dash).
2019-03-12 10:43:47 +01:00
Alexander Block
4b5409ab59
Merge pull request #2760 from codablock/pr_llmq_posetests
Move simple PoSe tests into llmq-simplepose.py
2019-03-12 10:42:51 +01:00
Alexander Block
cd0f94fb54 Give wait_for_quorum_phase more time 2019-03-12 09:20:17 +01:00
Alexander Block
4ae52758bd Remove size check in CDKGSessionManager::GetVerifiedContributions
It's actually not true that these should always be the same. In case a
quorum is built and the total number of masternodes in the network is below
the quorum size, we might still end up having a valid quorum as long as
the total number of masternodes is >= minSize.
2019-03-12 07:02:52 +01:00
Alexander Block
e21da2d99b Move simple PoSe tests into llmq-simplepose.py
These tend to fail quite often on Travis due to multiple reasons. One
reason is that establishing intra quorum connections take some time and
the tests in dip3-deterministicmns.py did not sleep long enough. Another
reason is that the individual stages were not really checked for completion
but instead just a hardcoded sleep was used. And another reason was that
with a total of 13 MNs, it's not guaranteed that every DKG results in one
MN to be punished.
2019-03-12 07:02:52 +01:00
Alexander Block
6488135f46 Track index into self.nodes in mninfo 2019-03-12 07:02:52 +01:00
Alexander Block
effcd0ca53
Merge pull request #2756 from codablock/pr_llmq_instantsend_perstency
Implement persistence for LLMQ based InstantSend
2019-03-12 07:02:14 +01:00
Alexander Block
f30ea6dfde Replace BITCOIN_UNORDERED_LRU_CACHE_H with DASH_UNORDERED_LRU_CACHE_H 2019-03-11 15:18:25 +01:00
Alexander Block
e763310b54 Add missing LOCK(cs_main) 2019-03-11 15:18:15 +01:00
UdjinM6
3a5e7c4334
Do not hold cs_vNodes in CSigSharesManager::SendMessages() for too long (#2758) 2019-03-11 16:33:17 +03:00
UdjinM6
fbf0dcb086
Various small cleanups (#2761)
* Fix remaining `print`s in tests

* use AssertLockHeld(cs) instead of relying on comments

* actually use `clsig` in `EnforceBestChainLock()`

* fix log output in `EnforceBestChainLock()`

* drop comments
2019-03-11 16:32:26 +03:00
Alexander Block
588eb30b86 Fix deadlock in CSigSharesManager::SendMessages (#2757)
* Fix deadlock in CSigSharesManager::SendMessages

Locking "cs" at this location caused a (potential) deadlock due to changed
order of cs and cs_vNodes locking. This changes the method to not require
the session object anymore which removes the need for locking.

* Pass size of LLMQ instead of llmqType into CSigSharesInv::Init

This allows use of sizes which are not supported in chainparams.
2019-03-11 16:31:51 +03:00
-k
7b24f9b8b3 Drop --c++11 brew flag in build-osx.md (#2755)
* fix brew flag typo

* drop c++11
2019-03-11 11:16:28 +03:00
UdjinM6
9f40afce86
Merge pull request #2727 from PastaPastaPasta/backports-0.15-pr7
Backports 0.15 pr7
2019-03-11 11:15:51 +03:00
Alexander Block
ac00c66287 Make InstantSend locks persistent 2019-03-11 07:37:08 +01:00
Alexander Block
293c9ad6a1 Use unordered_lru_cache in CRecoveredSigsDb 2019-03-11 07:31:25 +01:00
Alexander Block
9e4aa1f98c Implement unordered_lru_cache 2019-03-11 06:33:46 +01:00
Pasta
609114a803 Code review: re-add string cast in mininode.py 2019-03-08 17:05:10 -06:00
pasta
85ffc1d647 drop swap_outputs_in_rawtx and DecimalEncoder in smartfees.py 2019-03-08 14:28:00 -06:00
Alexander Block
bc593c84b7 Revert "Fix use of missing self.log in blockchain.py"
This reverts commit b06a6a2e74.
2019-03-08 14:22:49 -06:00
Alexander Block
0e91ebcf42 Use logging framework in Dash specific tests 2019-03-08 14:22:40 -06:00
PastaPastaPasta
dd1245c2a9 Update dnsseed-policy.md (#2751)
* Remove irrelevant link in dnsseed-policy

* Link to dash-seeder in dnsseed-policy

instead of bitcoin-seeder
2019-03-08 21:21:20 +03:00
Alexander Block
f351145e60 Use GetVoteForId instead of maintaining votes on inputs 2019-03-08 17:58:59 +01:00
Alexander Block
d4cf78fe25 Add HasVotedOnId/GetVoteForId to CSigningManager
These just pass through to CRecoveredSigsDb
2019-03-08 17:57:53 +01:00
Alexander Block
43e1bf674e Add key prefix to "rs_" for CRecoveredSigsDb keys
This avoids future conflicts with other data stored in llmqDb
2019-03-08 17:57:16 +01:00
Alexander Block
61e10f6512 Use llmqDb for CRecoveredSigsDb
Instead of creating its own CDBWrapper internally.
2019-03-08 17:34:09 +01:00
Alexander Block
b2cd1db406 Don't use CEvoDB in CDKGSessionManager and instead use llmqDb
Contributions are not part of on-chain consensus and shouldn't be stored in
CEvoDB.
2019-03-08 17:34:09 +01:00
Alexander Block
e2cad1bd69 Introduce global llmq::llmqDb instance of CDBWrapper
This DB is for LLMQ related data that is not part of on-chain consensus.
This for example included LLMQ secret key shares and recovered signatures.
2019-03-08 17:34:09 +01:00
Alexander Block
acb52f6ec1 Don't pass CEvoDB to CDKGSessionHandler and CDKGSession
Was never used.
2019-03-08 17:34:09 +01:00
Alexander Block
64ae91268a
Merge pull request #2735 from codablock/pr_llmq_instantsend
Implement LLMQ based InstantSend
2019-03-08 11:32:44 +01:00
Alexander Block
06fc655595 Actually remove from finalInstantSendLocks in CInstantSendManager::RemoveFinalISLock 2019-03-07 21:15:09 +01:00
Alexander Block
041a1c26d0 Move safe TX checks into TestForBlock and TestPackageTransactions
Otherwise we'll miss checks for ancestors.
2019-03-07 21:15:09 +01:00
Alexander Block
4d3365ddb2 Completely disable InstantSend while filling mempool in autoix-mempool.py
Otherwise we overload Travis and tests start to randomly fail.
2019-03-07 21:15:09 +01:00
Alexander Block
fae33e03ae Let ProcessPendingReconstructedRecoveredSigs return void instead of bool
Return value is unused and the method actually never returned something.
2019-03-07 21:15:09 +01:00
Alexander Block
f8f867a6bb Sync blocks after generating in mine_quorum() 2019-03-07 21:15:09 +01:00
Alexander Block
3e60d2d2db Adjust LLMQ based InstantSend tests for new spork20 2019-03-07 21:15:09 +01:00
UdjinM6
41a71fe443 update autoix-mempool.py to test both "old" and "new" InstantSend (and fix CheckCanLock to respect mempool limits) 2019-03-07 21:15:09 +01:00