Commit Graph

50 Commits

Author SHA1 Message Date
rkarthik2k21
13cb92e27f
Add virtual destructors for CBLSWrapper and CBLSLazyWrapper (#4298)
* Fixes issue #3759

Add virtual destructors for CBLSWrapper and CBLSLazyWrapper

* Fix linter errors

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-07-28 23:13:26 +03:00
gabriel-bjg
ee6d2f5b0d
Fix data races in bls_worker and use ctpl_stl queue. (#4240)
Change ctpl implementation to use STL queue & mutex.

Use ctpl synchronized queue instead of boost lockfree queue in bls worker aggregator.

Use smart pointers for memory management of Aggregator and VectorAggregator. With 'delete this;' the objects are prone to data race on the delete operator.

Use smart pointers for memory management of ContributionVerifier.

Pass shared_ptr by value to other threads via worker pool.
2021-07-11 22:25:27 -05:00
Kittywhiskers Van Gogh
ef4dfa8524 merge bitcoin#14555: Move util files to directory
(script modified to account for Dash backports, doesn't account for rebasing)

------------- BEGIN SCRIPT ---------------
mkdir -p src/util
git mv src/util.h src/util/system.h
git mv src/util.cpp src/util/system.cpp
git mv src/utilmemory.h src/util/memory.h
git mv src/utilmoneystr.h src/util/moneystr.h
git mv src/utilmoneystr.cpp src/util/moneystr.cpp
git mv src/utilstrencodings.h src/util/strencodings.h
git mv src/utilstrencodings.cpp src/util/strencodings.cpp
git mv src/utiltime.h src/util/time.h
git mv src/utiltime.cpp src/util/time.cpp
git mv src/utilasmap.h src/util/asmap.h
git mv src/utilasmap.cpp src/util/asmap.cpp
git mv src/utilstring.h src/util/string.h
git mv src/utilstring.cpp src/util/string.cpp

gsed -i 's/<util\.h>/<util\/system\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')
gsed -i 's/<utilmemory\.h>/<util\/memory\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')
gsed -i 's/<utilmoneystr\.h>/<util\/moneystr\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')
gsed -i 's/<utilstrencodings\.h>/<util\/strencodings\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')
gsed -i 's/<utiltime\.h>/<util\/time\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')
gsed -i 's/<utilasmap\.h>/<util\/asmap\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')
gsed -i 's/<utilstring\.h>/<util\/string\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')

gsed -i 's/BITCOIN_UTIL_H/BITCOIN_UTIL_SYSTEM_H/g' src/util/system.h
gsed -i 's/BITCOIN_UTILMEMORY_H/BITCOIN_UTIL_MEMORY_H/g' src/util/memory.h
gsed -i 's/BITCOIN_UTILMONEYSTR_H/BITCOIN_UTIL_MONEYSTR_H/g' src/util/moneystr.h
gsed -i 's/BITCOIN_UTILSTRENCODINGS_H/BITCOIN_UTIL_STRENCODINGS_H/g' src/util/strencodings.h
gsed -i 's/BITCOIN_UTILTIME_H/BITCOIN_UTIL_TIME_H/g' src/util/time.h
gsed -i 's/BITCOIN_UTILASMAP_H/BITCOIN_UTIL_ASMAP_H/g' src/util/asmap.h
gsed -i 's/BITCOIN_UTILSTRING_H/BITCOIN_UTIL_STRING_H/g' src/util/string.h

gsed -i 's/ util\.\(h\|cpp\)/ util\/system\.\1/g' src/Makefile.am
gsed -i 's/utilmemory\.\(h\|cpp\)/util\/memory\.\1/g' src/Makefile.am
gsed -i 's/utilmoneystr\.\(h\|cpp\)/util\/moneystr\.\1/g' src/Makefile.am
gsed -i 's/utilstrencodings\.\(h\|cpp\)/util\/strencodings\.\1/g' src/Makefile.am
gsed -i 's/utiltime\.\(h\|cpp\)/util\/time\.\1/g' src/Makefile.am
gsed -i 's/utilasmap\.\(h\|cpp\)/util\/asmap\.\1/g' src/Makefile.am
gsed -i 's/utilstring\.\(h\|cpp\)/util\/string\.\1/g' src/Makefile.am

gsed -i 's/-> util ->/-> util\/system ->/' test/lint/lint-circular-dependencies.sh
gsed -i 's/src\/util\.cpp/src\/util\/system\.cpp/g' test/lint/lint-format-strings.py test/lint/lint-locale-dependence.sh
gsed -i 's/src\/utilmoneystr\.cpp/src\/util\/moneystr\.cpp/g' test/lint/lint-locale-dependence.sh
gsed -i 's/src\/utilstrencodings\.\(h\|cpp\)/src\/util\/strencodings\.\1/g' test/lint/lint-locale-dependence.sh
------------- END   SCRIPT ---------------
2021-06-27 12:03:13 +05:30
PastaPastaPasta
55be0003e2
Continued refactoring in bls to resolve clang tidy warnings (#4189)
* refac/bls: use default for default constructor

* refac/bls: initialize doneCount via default member initializer

* refac/bls: initialize batchCount and verifyCount via default member initializer

* refac/bls: remove unused parameter

* refac/bls: add __attribute__((unused)) where functions are unused

* refac/bls: remove unused lambda this capture

* refac/bls: Move assignment operators should be marked noexcept

* refac/bls: Single-argument constructors must be marked explicit to avoid unintentional implicit conversions

* refac/bls: fix compilation due to explicit constructor
2021-06-06 23:43:44 +03:00
UdjinM6
011a178c60
Other Dash-specific serializations 2021-05-28 12:31:13 +03:00
Kittywhiskers Van Gogh
01272b159d Merge #19373: Replace HexStr(o.begin(), o.end()) with HexStr(o) 2021-05-20 10:15:17 +05:30
UdjinM6
704d34b2e4
bls|ci: Fix C++17 build, add it to CI (#4055)
* ci: Add C++17 build

* bls: Add explicit CBLSSecretKey copy ctor and operator=
2021-04-28 16:44:01 +02:00
PastaPastaPasta
78f277bfe4
trivial/refactoring: simple bls refactoring / adjustments (#4114)
* use std::make_unique instead of reset which prevents a theoretical memory leak

* pass by value and use std::move

* use empty instead of comparing to size

* remove extra space

* adjust include postitioning

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-04-23 00:26:22 +02:00
PastaPastaPasta
c5b919d084
Update copyright (#4115)
* run: `python3 contrib/devtools/copyright_header.py update .`

* bump copyright year
2021-04-20 22:33:02 +03:00
PastaPastaPasta
9a5bd934d5
Minor bls refactoring (#4100)
* avoid deprecated C headers

* remove unused header

* typos

* unused include

* use static / const where possible

* make parameter const ref where possible

* Clang-Tidy: Parameter is passed by value and only copied once; consider moving it to avoid unnecessary copies

* Clang-Tidy: Passing result of std::move() as a const reference argument; no move will actually happen

* Clang-Tidy: Forwarding reference passed to std::move(), which may unexpectedly cause lvalues to be moved; use std::forward() instead

* access statically
2021-04-15 14:16:44 -04:00
dustinface
9c64708269
bls|depends: Upgrade to bls-signatures version 1.0.0 (#4027)
* build: Add cmake as depends package (cmake.mk)

The bls-signatures library requires cmake 3.14

* depends: Update chia_bls to version 1.0.0 of dashpay/bls-signatures

* depends: Rename package chia_bls to bls-dash

* depends: Disable blspy/tests/benchmarks build for chia_bls

Note: Building with tests would require the following:

depends: Fix macOS build for versions < 10.12

Seems like older versions of macOS pretend to support c++17 std libs but do not have/have issues with uncaught_exceptions. "Catch", the testing framework used in the bls lib wants those by default but setting `DCATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS` disables them which should be just fine to do in all cases here.
---
 depends/packages/chia_bls.mk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/depends/packages/chia_bls.mk b/depends/packages/chia_bls.mk
index e79a85844f..25749b74ab 100644
--- a/depends/packages/chia_bls.mk
+++ b/depends/packages/chia_bls.mk
@@ -28,6 +28,8 @@ define $(package)_set_vars
     $(package)_config_opts_darwin+= -DCMAKE_AR="$(host_prefix)/native/bin/$($(package)_ar)"
     $(package)_config_opts_darwin+= -DCMAKE_RANLIB="$(host_prefix)/native/bin/$($(package)_ranlib)"
   endif
+
+  $(package)_cppflags+= -DCATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS
 endef

 define $(package)_config_cmds
--

* depends: Drop obsolete variable

* bls: Integrate the upgraded version into the codebase

* depends: Pre-fetch relic to fix gitian

Can fetch apt packages only when building with lxc

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-03-26 15:32:31 +03:00
UdjinM6
bc3137166f
bls: Avoid needless hashing (#4013)
* bls: Only update cached hash in CBLSWrapper when it's really needed

* bls: Reset cached hash in CBLSLazyWrapper instead of re-assigning uint256() to it

* bench: Update expected numbers in bls benchmarks

* bls: Drop UpdateHash methods

Make sure the hash is updated via GetHash() only.
2021-03-12 17:54:20 -05:00
dustinface
a281cf6b3c
bls: Some char[] -> std::vector<uint8_t> refactoring in CBLSWrapper (#4010)
* refactor: CBLSWrapper::GetBuf -> CBLSWrapper::ToByteVector

* bls: Use std::vector<uint8_t> in CBLSWrapper::Unserialize

* bls: Refactor CBLSWrapper::SetBuf -> CBLSWrapper::SetByteVector

SetBuf(const void*, size_t) -> SetByteVector(std::vector<uint8_t>&)
2021-02-27 02:36:00 -05:00
dustinface
e6cc0b9bec
bls: Modify CBLSIES classes - Introduce individually encrypted objects (#3937)
* bls: Adjust CBLSIESEncryptedBlob to match CBLSIESMultiRecipientBlobs

With this change a single encrypted object of CBLSIESMultiRecipientBlobs is has the same structure like CBLSIESEncryptedBlob

* bls: Add CBLSIESEncryptedObject constructor

* bls: Add CBLSIESMultiRecipientObjects::Get

Allows to query a individual encrypted object as CBLSIESEncryptedObject

* bls: Drop unneeded constructor call

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-01-21 14:25:42 -06:00
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