Commit Graph

86 Commits

Author SHA1 Message Date
UdjinM6
bfe6c7ca5e
Fix thread names to fit into 15 symbols (#3897) 2020-12-30 13:33:45 -06:00
dustinface
7da706f8e4
bls: Directly assign some aggregation results (#3899) 2020-12-26 19:16:09 -06:00
dustinface
0c28bf4ab8
refactor: Use constructors instead of static initialiser in CBLSId (#3869)
* bls: Add CBLSId(const int64_t n) and CBLSId(const uint256& nHash)

* bench|llmq: Refactor instantiations of CBLSId

* bls: Drop CBLSId::{SetInt, SetHash, FromInt, FromHash}

* Drop `CBLSId(int64_t)` ctor

* Partially Revert "Drop `CBLSId(int64_t)` ctor"

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-12-14 20:13:54 -06:00
dustinface
e90d6ad11c
refactor: Add/Use byte vector constructor for CBLSWrapper (#3868)
* bls: Add CBLSWrapper constructor which accepts a byte vecor

* bls: Bring CBLSWrapper::CBLSWrapper in scope of CBLSId, CBLSSecretKey, CBLSPublicKey

Allow them to access e.g. the new byte vector consructor.

* governance|init|privatesend|test: Refactor some BLS instantiations
2020-12-14 17:26:30 -06:00
dustinface
ec77d85385
bls: Refactor CBLSWrapper::SetBuf and CBLSWrapper::GetBuf (#3867)
* bls: Add CBLSImplicit, a wrapper around uint256

This makes `CBLSImplicit` compatible (related to methods called by
CBLSWrapper) with the other classes from the
bls-signatures library.

* bls: Use CBLSImplicit instead of uint256 as base type of CBLSId

* bls: Use FromBytes directly instead of indirectly through InternalSetBuf

* bls: Use Serialize directly instead of indirectly through InternalGetBuf

* bls: Drop all occurrences of InternalSetBuf and InternalGetBuf

* bls: Use `CBLSIdImplicit` instead of `uint256` in some more places
2020-12-12 10:45:43 +01:00
pasta
80a9746d0a
remove additional FLATDATA
Signed-off-by: pasta <pasta@dashboost.org>
2020-10-27 13:24:34 -04:00
PastaPastaPasta
404014d31a
change argument name to reflect the fact that it's a return value (#3673)
Signed-off-by: pasta <pasta@dashboost.org>
2020-08-27 12:51:31 +03:00
pasta
9d26ad6d8f remove duplicate includes so that ./contrib/devtools/lint-includes.sh is clean
Signed-off-by: pasta <pasta@dashboost.org>
2020-07-01 20:12:03 -05:00
Alexander Block
465af48e83 Improve logging in LLMQ sig handling 2020-04-07 07:29:23 +02: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
UdjinM6
7d39637b02 Bump copyright year to 2020 (#3290)
* Bump _COPYRIGHT_YEAR

* Run copyright update script

./contrib/devtools/copyright_header.py update .

* Update COPYING

* Bump copyright year in dash-cli/qt/tx and dashd map pages
2020-01-17 15:42:55 +01:00
UdjinM6
5857ec7154
More of 10969 2020-01-10 10:34:03 -06:00
Alexander Block
b9aadc071b Fix excessive memory use when flushing chainstate and EvoDB (#3008)
* Specialize Serialize(CSizeComputer&) for BLS objects

Speeds up size computation for BLS objects.

* Track memory usage in CDBTransaction and CEvoDB

* Take memory used by CEvoDB/CDBTransaction into account when flushing

* Implement specialized SerReadWrite for immer maps

This allows to use READWRITE and fixes compilation errors with CSizeComputer

* Log EvoDB memory usage independently

Co-Authored-By: UdjinM6 <UdjinM6@users.noreply.github.com>
2019-07-02 07:16:27 +03:00
Alexander Block
864856688d Multiple speed optimizations for deterministic MN list handling (#2972)
* Generalize CBLSLazyWrapper so that it can be used of pubkeys and secret keys

* Implement == and != operators for CBLSLazyWrapper

* Implement cached hash for CBLSLazyWrapper

* Use CBLSLazyPublicKey for CDeterministicMNState::pubKeyOperator

* Speed up GetProjectedMNPayees by sorting the MN list by last paid

Instead of updating a temporary list for each projected height and calling
GetMNPayee() on it.

* Cache intermediate lists in GetListForBlock

This avoids re-loading and applying diffs again and again.

* Only update masternode list UI max once every 3 seconds

This avoids updating the UI on every block, which turned out to be very
expensive.

* Fix compilation

* Drop time restrictions for mn list update in ClientModel

They are fully handled by MasternodeList now.
2019-06-13 12:01:26 +03:00
PastaPastaPasta
d931cb723e Update copyright date (2019) (#2970)
Signed-off-by: Pasta <Pasta@dash.org>
2019-06-11 14:46:07 +03:00
UdjinM6
cff9f97179
Prefix all bls/quorum threads with dash- (#2865)
Makes it easier to find them. Note: had to s/quorum/q/ to fit into 15 characters.
2019-04-15 17:42:43 +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
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
UdjinM6
9f04855ae0
Fix blsWorker (#2820)
Use a pointer instead of a static variable, start/stop together with other llmq modules.
2019-04-01 14:10:39 +03:00
Alexander Block
02b68885a0 Implement CBLSLazySignature for lazy serialization/deserialization
In some cases it takes too much time to perform full deserialization of
BLS signatures in the message handler thread. Better to just read the
buffer and do the actual deserialization when the signature is needed for
the first time (which is can be in another thread).
2019-02-15 15:44:02 +01:00
Alexander Block
6e8f50aa55 Faster default-initialization of BLS primitives by re-using the null-hash 2019-02-15 15:43:51 +01:00
Alexander Block
67a86091aa Implement and use secure BLS batch verification (#2681)
* Implement secure verification in bls_batchverifier

* Rename CBLSInsecureBatchVerifier to CBLSBatchVerifier

* Add unit tests for simple BLS verifcation and CBLSBatchVerifier
2019-02-04 21:58:28 +03:00
Alexander Block
088525bde3 Multiple fixes for LLMQs and BLS batch verification (#2674)
* Check aggPubKey for IsValid() instead of aggSig

aggSig is not reliable here as it might already be initialized by the
previous message.

* Significantly reduce sleep time for each DKG phase

Turns out the DKG is much faster then expected, and waiting multiple
minutes for each phase in a devnet is not much fun.

* Correctly use SIGN_HEIGHT_OFFSET when checking for out of bound height

* Introduce startBlockHeight to make things more explicit
2019-02-01 12:07:21 +03:00
Alexander Block
18950f923e Optimize DKG debug message processing for performance and lower bandwidth (#2672)
* Allow sub-batch verification in CBLSInsecureBatchVerifier

* Implement batch verification of CDKGDebugStatus messages

* Use uint8_t for statusBitset in CDKGDebugMemberStatus and CDKGDebugSessionStatus

No need to waste one byte per member and per LLMQ type.

* Reserve 4k of buffer for CSerializedNetMsg buffer

Profiling has shown that a lot of time is spent in resizing the data
vector when large messages are involved.

* Remove nHeight from CDKGDebugStatus

This field changes every block and causes all masternodes to propagate
its status for every block, even if nothing DKG related has changed.

* Leave out session statuses when we're not a member of that session

Otherwise MNs which are not members of DKG sessions will spam the network

* Remove receivedFinalCommitment from CDKGDebugSessionStatus

This is not bound to a session and thus is prone to spam the network when
final commitments are propagated in the finalization phase.

* Add "minableCommitments" to "quorum dkgstatus"

* Hold cs_main while calling GetMinableCommitment

* Abort processing of pending debug messages when spork18 gets disabled

* Don't ask for debug messages when we've already seen them

"statuses" only contains the current messages but none of the old messages,
so nodes kept re-requesting old messages.
2019-02-01 10:49:01 +03:00
PastaPastaPasta
f123248f1c update copyright (#2648)
* update copyright

* Update copyright in configure.ac and COPYING
2019-01-29 15:53:14 +01:00
Alexander Block
b6346a2f68 Implement CBLSInsecureBatchVerifier for convenient batch verification 2019-01-18 11:57:40 +01:00
Alexander Block
c6be8cfcd6 Allow to skip malleability check when deserializing BLS primitives
Useful when many sigs need to be deserialized and at the same time the hash
of these is never used.
2019-01-09 12:16:11 +01:00
Alexander Block
88f7bf0d82
Don't delete/add values to the unique property map when it's null (#2538)
* Don't delete/add values to the unique property map when it's null

This happens when revoking operator keys, as the revoked MN will then have
the address and operator keys set to the null representation. We shouldn't
add the null value to the unique property map as otherwise future revokes
crash in an assert.

* Assert that no null values are passed to Add/DeleteUniqueProperty

* Check for null values before calling Add/DeleteUniqueProperty

* Apply suggestions from code review

Co-Authored-By: codablock <ablock84@gmail.com>

* Add user generated default constructors to BLS primitives

Fixes build issues on Mac:

In file included from evo/deterministicmns.cpp:5:
./evo/deterministicmns.h:375:24: error: default initialization of an object of const type 'const CBLSPublicKey' without a user-provided default constructor
        static const T nullValue;
                       ^
2018-12-10 08:31:09 +01:00
Alexander Block
63b58b1e92
Reintroduce BLSInit to correctly set secure alloctor callbacks (#2543)
https://github.com/dashpay/dash/pull/2409 removed the need to call the
Init method of the Chia BLS library, but we also accidently removed the
initialization of the secure allocator.
2018-12-10 06:04:48 +01:00
Alexander Block
5e829a3b1b Update Chia bls-signature to latest version (#2409)
Brings in:
1. https://github.com/Chia-Network/bls-signatures/pull/41
2. https://github.com/Chia-Network/bls-signatures/pull/46
3. A few commits from https://github.com/codablock/bls-signatures are now
   merged into upstream.

This removes the need for manual initialization of the BLS library. This is
now done internally and in a thread-safe way.

Also switch to using tags instead of raw commit hashes. Makes testing
easier and also removes the risk of Github deleting commits due to
cleanup jobs.
2018-11-02 00:59:11 +03:00
Alexander Block
70eb710b12
Undefine DOUBLE after include Chia BLS headers (#2400)
These cause compilation errors on some platforms.
Observed this when I tried to cross compile win32
locally on a Debian Stretch machine.
2018-10-31 10:58:02 +01:00
Alexander Block
052af81b4b
Ensure correct order of destruction for BLS secure allocator (#2401)
Uses the same trick as LockedPoolManager::Instance()
2018-10-31 10:57:14 +01:00
Alexander Block
d1debfc267
Implement mt_pooled_secure_allocator and use it for BLS secure allocation (#2375)
* Add pooled_secure_allocator and mt_pooled_secure_allocator

* Use mt_pooled_secure_allocator for BLS secure allocation

The old solution relied on thread-local-storage and was thus not compatible
to libc6 2.11 (which is the minimum supported version we use).

Also, the old solution turned out to be erroneous. It would have crashed
or memory leaked when ownership of CBLSPrivateKey would be handled over
to another thread.

* Add new header files to Makefile.am

* Fix copyright headers of new files

* Bail out early from secure deallocation

* Clean up global BLS keys when shutting down
2018-10-26 07:04:22 +02:00
Alexander Block
7b76bbb575 Update Chia BLS libs to latest master (#2357)
* Undefine ERROR before including chia BLS stuff to avoid warnings

* Update Chia BLS libs to latest master
2018-10-20 17:08:54 +03:00
Alexander Block
e2de632f8c Move handling of size != SerSize into SetBuf/GetBuf (#2356)
* Move handling of size >= SerSize into SetBuf/GetBuf

Instead of performing this in the individual implementations of
InternalSetBuf and InternalGetBuf

* Assert that size if GetBuf is always SerSize
2018-10-20 17:08:40 +03:00
Alexander Block
9c8e4ac76b Move bls stuff from crypto/ to bls/ 2018-10-12 19:39:26 +02:00