Commit Graph

15923 Commits

Author SHA1 Message Date
Alexander Block
7fe1a4a78b Also invoke WriteInstantSendLockMined when IS lock comes after the mined block (#2861) 2019-04-11 23:11:56 +03:00
Alexander Block
f32f9523b9 Use lazy BLS signatures more often and don't always verify self-recovered sigs (#2860)
* Make CBLSLazySignature thread safe

* Perform malleability check in CBLSLazySignature

* Use CBLSLazySignature in CRecoveredSig and CInstantSendLock

* Only sporadically verify self-recovered signatures

* test
2019-04-11 23:11:39 +03:00
Alexander Block
5e8ae2ceb6 Disable optimistic send in PushMessage by default (#2859)
* Automatically wake up select() when optimistic send was not used

But only when we know that we are actually inside select() and that it
currenlty is unlikely for it to have selected the node's socket for
sending. We accept race conditions here as the select() timeout
will ensure that we always send the data.

* Don't manually call WakeSelect() in CSigSharesManager::SendMessages

Not needed anymore

* Disable optimistic send in PushMessage by default
2019-04-11 15:43:22 +03:00
Alexander Block
90b1b71967 Move processing of InstantSend locks into its own worker thread (#2857)
* Let ProcessPendingInstantSendLocks return true when it did some work

* Introduce own worker thread for CInstantSendManager

Instead of using the scheduler.

* Remove scheduler from CInstantSendManager

* Add missing reset() call for workInterrupt
2019-04-11 15:43:00 +03:00
Alexander Block
ae78360e5d Add cache to CQuorumManager::ScanQuorums (#2856) 2019-04-11 15:42:35 +03:00
Alexander Block
241f76f9bf Collection of minor performance optimizations (#2855)
* Merge #13176: Improve CRollingBloomFilter performance: replace modulus with FastMod

9aac9f90d5e56752cc6cbfac48063ad29a01143c replace modulus with FastMod (Martin Ankerl)

Pull request description:

  Not sure if this is optimization is necessary, but anyway I have some spare time so here it is. This replaces the slow modulo operation with a much faster 64bit multiplication & shift. This works when the hash is uniformly distributed between 0 and 2^32-1. This speeds up the benchmark by a factor of about 1.3:

  ```
  RollingBloom, 5, 1500000, 3.73733, 4.97569e-07, 4.99002e-07, 4.98372e-07 # before
  RollingBloom, 5, 1500000, 2.86842, 3.81630e-07, 3.83730e-07, 3.82473e-07 # FastMod
  ```

  Be aware that this changes the internal data of the filter, so this should probably
  not be used for CBloomFilter because of interoperability problems.

Tree-SHA512: 04104f3fb09f56c9d14458a6aad919aeb0a5af944e8ee6a31f00e93c753e22004648c1cd65bf36752b6addec528d19fb665c27b955ce1666a85a928e17afa47a

* Use unordered_map in CSporkManager

In one of my profiling sessions with many InstantSend transactions
happening, calls into CSporkManager added up to about 1% of total CPU time.
This is easily avoidable by using unordered maps.

* Use std::unordered_map instead of std::map in limitedmap

* Use unordered_set for CNode::setAskFor

* Add serialization support for unordered maps and sets

* Use unordered_map for mapArgs and mapMultiArgs

* Let limitedmap prune in batches and use unordered_multimap

Due to the batched pruning, there is no need to maintain an ordered map
of values anymore. Only when nPruneAfterSize, there is a need to create
a temporary ordered vector of values to figure out what can be removed.

* Instead of using a multimap for mapAskFor, use a vector which we sort on demand

CNode::AskFor will now push entries into an initially unordered vector
instead of an ordered multimap. Only when we later want to use vecAskFor in
SendMessages, we sort the vector.

The vector will actually be mostly sorted in most cases as insertion order
usually mimics the desired ordering. Only the last few entries might need
some shuffling around. Doing the sort on-demand should be less wasteful
then trying to maintain correct order all the time.

* Fix compilation of tests

* Fix limitedmap tests

* Rename limitedmap to unordered_limitedmap to ensure backports conflict

This ensures that future backports that depends on limitedmap's ordering
conflict so that we are made aware of needed action.

* Fix compilation error on Travis
2019-04-11 15:42:14 +03:00
Alexander Block
82a47f5432 Allow testing ChainLocks enforcement with spork19 == 1 (#2854)
This is only for testnet.
2019-04-11 15:41:51 +03:00
Nathan Marley
e67618ac5c Clean up a few GUI related items (#2846)
* Remove unused (old) icons

* Remove red line from top/bottom of frame

* Remove red line from about image

* Clean up theme display names

* Remove DASH at the beginning (just redundant)
* Capitalize theme names

* Flip "about" image back on its end

* Fix up about image a bit
2019-04-11 15:41:23 +03:00
Alexander Block
225c3898d8
Don't skip "safe TX" check when ChainLocks are not enforced yet (#2851) 2019-04-10 18:16:33 +02:00
Alexander Block
6fd9e51059
Merge pull request #2849 from codablock/pr_dip3_notifymnlistchanged
Refactor and fix missing calls to NotifyMasternodeListChanged
2019-04-10 18:16:19 +02:00
Alexander Block
27b2cd2cca
Skip required services and port checks when outgoing connections is a MN (#2847)
* Skip required services and port checks when outgoing connections is a MN

* Only relax default port check when AllowMultiplePorts is true

Co-Authored-By: codablock <ablock84@gmail.com>
2019-04-10 18:14:20 +02:00
Alexander Block
2f8440696f
Merge pull request #2848 from codablock/pr_llmq_betterintraquorum
Connect to most recently updated address in ThreadOpenMasternodeConnections
2019-04-09 13:55:04 +02:00
Alexander Block
aeb4c60c8e Reimplement CMNAuth::NotifyMasternodeListChanged to work with new interface 2019-04-09 13:28:53 +02:00
Alexander Block
fa90c0204f Also call NotifyMasternodeListChanged when MNs have been updated
And not only when added/removed.
2019-04-09 13:28:53 +02:00
Alexander Block
db781b32dc Pass oldList and diff instead of newList into NotifyMasternodeListChanged 2019-04-09 13:28:40 +02:00
Alexander Block
b0260e970f Do not maintain CService in masternodeQuorumNodes
Not needed anymore as we retrieve the service/address of a masternode
on-the-fly in ThreadOpenMasternodeConnections.
2019-04-09 12:32:52 +02:00
Alexander Block
60788ce325 Connect to most recently updated address in ThreadOpenMasternodeConnections
It's not a good idea to try to connect to an old address of a masternode.
This will also skip connection attempts when the masternode is not in the
valid set anymore (banned or collateral spent).
2019-04-09 12:32:52 +02:00
Alexander Block
93b1b3d732 Fix shadowing of "addr" 2019-04-09 12:32:52 +02:00
Alexander Block
5bebdda71f Add GetValidMNByService to CDeterministicMNList 2019-04-09 12:32:52 +02:00
Alexander Block
5d94d6bdfd Remove unused CConnman::ForEachQuorumMember 2019-04-09 12:32:52 +02:00
UdjinM6
1ba8694cd7
Various fixes for RemoveInvalidVotes() (#2845)
* Fix crash in RemoveInvalidVotes()

Caused by lock not being held while accessing lastMNListForVotingKeys when RemoveInvalidVotes() is called from DoMaintenance() and UpdatedBlockTip() at the same time.

* No need to call RemoveInvalidVotes() from DoMaintenance()

MN list only changes on new blocks and we already call RemoveInvalidVotes() from UpdatedBlockTip()

* No need to call RemoveInvalidVotes() until we are fully synced
2019-04-08 08:38:13 +03:00
Alexander Block
b5bc7c9dac Call HandleFullyConfirmedBlock when ChainLocks are enabled but not enforced (#2844)
Otherwise IS locks never get removed before DIP8 activates via BIP9.
2019-04-08 08:07:47 +03:00
UdjinM6
9fa09b974b
CBLSWrapper::SetHexStr() should not accept non-hex strings (#2843)
* CBLSWrapper::SetHexStr() should not accept non-hex strings

* Rework to implement suggested behaviour
2019-04-08 08:07:26 +03:00
Nathan Marley
0f0d8eaf48 Add RPC for BLS secret to public key (#2841)
* Add RPC for BLS secret to public key

* Simplify and unify "bls s2pk"

* Reuse "generate"

* Revert "Reuse "generate""

This reverts commit c12388c5b5.

* Rename sk2pk to fromsecret
2019-04-08 08:06:54 +03:00
UdjinM6
2c72c075af
Merge pull request #2842 from UdjinM6/mergemaster133develop
Merge master v0.13.3 into develop
2019-04-08 08:05:42 +03:00
UdjinM6
fa6db6d69b Merge branch 'master' into mergemaster133develop 2019-04-05 20:52:53 +03:00
UdjinM6
6982d98548 Ignore cache files on reindex (#2840) 2019-04-05 14:39:30 +02:00
Alexander Block
565754e019
Merge pull request #2839 from codablock/pr_llmq_scanquorumsfix
Fix invalid results from ScanQuorum
2019-04-05 14:39:17 +02:00
Alexander Block
f8bedba7c4
Don't retry locks when new IS system is disabled (#2837)
Retrying still failed, but this spammed logs quite a bit.
2019-04-05 14:38:58 +02:00
Peter Bushnell
92feade817 Remove unused forward declaration (#2838) 2019-04-05 14:38:45 +02:00
Alexander Block
206e5a1b47 Use big endian inversed height in CInstantSendDb 2019-04-05 13:40:18 +02:00
Alexander Block
4b9f6cd3a9 Use big endian inversed height in BuildInversedHeightKey
Otherwise keys are not properly sorted.
2019-04-05 13:39:29 +02:00
Alexander Block
53656b3e82 Compare CDataStream internal vector with unsigned comparison 2019-04-05 13:37:58 +02:00
Alexander Block
dd21d046f5 Avoid unnecessary calls to parentIt->GetKey 2019-04-05 13:37:25 +02:00
Alexander Block
1caee15425
Merge pull request #2836 from codablock/pr_is_removeconfirmed
Better handle removing of fully confirmed IS locks
2019-04-05 10:13:56 +02:00
Alexander Block
d34ec78664 Update wallet transactions when confirmed IS locks are removed 2019-04-05 08:18:56 +02:00
Alexander Block
b897505f85 Remove the need for maintaining the last ChainLocked block in the DB 2019-04-05 08:05:12 +02:00
Alexander Block
8e7083cb89 Use db.RemoveConfirmedISLocks() in NotifyChainLock to remove confirmed locks
Also move the actual logic into HandleFullyConfirmedBlock and call it
from NotifyChainLock and UpdatedBlockTip.
2019-04-05 08:05:12 +02:00
Alexander Block
4577438e87 Implement RemoveConfirmedInstantSendLocks to prune confirmed IS locks from DB 2019-04-05 08:05:12 +02:00
Alexander Block
d6e7758519 Keep track of when IS locks were mined 2019-04-05 06:36:09 +02:00
Alexander Block
20ec1de4c6
Merge pull request #2833 from codablock/pr_dip4_quorums
Implement quorum merkle roots for DIP4 coinbases and add quorums to MNLISTDIFF
2019-04-05 05:58:05 +02:00
UdjinM6
0a6416e064 Wipe llmq db on reindex (#2835) 2019-04-05 05:57:46 +02:00
Peter Bushnell
4af5ea8a7f Remove netfulfilledman.h duplicate (#2834) 2019-04-05 05:57:33 +02:00
UdjinM6
208406df71 Re-introduce nInstantSendKeepLock check for LLMQ-based IS when spork19 is OFF (#2829) 2019-04-05 05:55:30 +02:00
Alexander Block
7d765a0fce Track best block to later know if a DB upgrade is needed 2019-04-04 17:58:51 +02:00
UdjinM6
1a25c2084c Apply suggestions from code review
Co-Authored-By: codablock <ablock84@gmail.com>
2019-04-04 17:41:30 +02:00
Alexander Block
282cb697aa Use version 2 CCbTx in create_coinbase to fix test failures 2019-04-04 12:27:35 +02:00
Alexander Block
adc101a11a Implement quorum commitment merkle root tests in dip4-coinbasemerkleroots.py 2019-04-04 12:27:35 +02:00
Alexander Block
40ad06e775 Return the fresh quorum hash from mine_quorum 2019-04-04 12:27:35 +02:00
Alexander Block
17b9318a04 Mine SIGN_HEIGHT_OFFSET additional blocks after the quorum commitment
Otherwise the fresh quorum won't be eligable for signing sessions.
2019-04-04 12:27:35 +02:00