Commit Graph

86 Commits

Author SHA1 Message Date
UdjinM6
44055fb7b7
chore: Post v19 cleanup (#5622)
## Issue being fixed or feature implemented
Now that v19 is buried we can enforce basic bls scheme usage in
governance and coinjoin and drop some extra code we used for backwards
compatibility.

## What was done?
pls see individual commits

## How Has This Been Tested?
run tests, sync and mix on testnet

## Breaking Changes
n/a

## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone _(for repository
code-owners and collaborators only)_
2023-10-19 11:33:44 -05:00
Konstantin Akimov
1c66ac3f2a
refactor: remove start/count in bls-worker funcs due to spanification (#5599)
## Issue being fixed or feature implemented
Follow-up changes for this PR:
https://github.com/dashpay/dash/pull/5586/


## What was done?
Span has already "pointer + start + length", extra start/count variables
in function signatures are just duplicates.


## How Has This Been Tested?
Run unit/functional tests

## Breaking Changes
N/A


## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
2023-10-05 08:06:27 -05:00
PastaPastaPasta
b27765f358
refactor: further spanification of Dash code (#5586)
## Issue being fixed or feature implemented
Use Spans instead of const std::vector<T>&

## What was done?
Replaced with Span

## How Has This Been Tested?
Building, ran a few tests

## Breaking Changes
Should be none, please review potential lifetime issues in bls_worker;
it scares me a bit and I don't understand how we know these won't
dangle.

## Checklist:
_Go over all the following points, and put an `x` in all the boxes that
apply._
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone _(for repository
code-owners and collaborators only)_
2023-10-03 09:52:33 -05:00
Odysseas Gabrielides
494b5c744c
feat: mnlistdiff v20 CL sig quorums (#5377)
## Issue being fixed or feature implemented
Implementation of Randomness Beacon Part 3.

Starting from v20 activation fork, members for quorums are sorted using
(if available) the best CL signature found in Coinbase.
If no CL signature is present yet, then the usual way is used (By using
Blockhash instead)

The actual new way to shuffle is already implemented in
https://github.com/dashpay/dash/pull/5366.

SPV clients also need to calculate members, but they only know block
headers.
Since Coinbase is in the actual block, then they lack the required
information to correctly calculate quorum members.

## What was done?
- Message `MNLISTIDFF` is enriched with a new field `quorumsCLSigs`.
This field holds the Chainlock Signature required for each set of
indexes corresponding to quorums in field `newQuorums`.
-  Protocol version has been bumped to `70230`.
- Clients with protocol version greater or equal to `70230` will receive
the new field `quorumsCLSigs`.
- The same field is returned in `protx diff` RPC.

Note:
- Field `quorumsCLSigs` will populated only after v20 activation
- If for one or more quorums, no non-null CL sig was found in CbTx then
a null signature is returned in `quorumsCLSigs`.

## How Has This Been Tested?
- Functional test mininode's protocol version was bumped to `70230`.
- `feature_llmq_rotation.py` checks that `quorumsCLSigs` match in both
P2P and RPC messages.

## Breaking Changes
No

## Checklist:
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added or updated relevant unit/integration/functional/e2e
tests
- [x] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone _(for repository
code-owners and collaborators only)_

---------

Co-authored-by: thephez <thephez@users.noreply.github.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: pasta <pasta@dashboost.org>
2023-07-10 11:23:09 -05:00
Konstantin Akimov
96554c8268
refactor: removed flag checkMalleable from bls's related code (#5462)
## Issue being fixed or feature implemented
Current implementation of BLS wrapper has an unclear interface related
to `checkMalleable` flag.

There are 2 methods Unserialize, that has both default arguments:

```
template
inline void Unserialize(Stream& s, const bool specificLegacyScheme, bool checkMalleable = true);
template
inline void Unserialize(Stream& s, bool checkMalleable = true);
```

Let's assume that I am calling `Unserialize(s, true)` - it's very
non-obvious which one will be called and not error prune at all.

It should be re-implemented, and there should not be default argument. 

Pasta noticed that this flag can be useful from performance point of
view - let's have better new method such as `UnserializeNoMalleable` or
similar and use it when reindexing/etc. It should be specified explicit.

Reverting this change and adding new interface in future won't be
difficult task so far as changes are quite trivial.


## What was done?
Removed flag checkMalleable to simplify code because it's always true.
It splits from https://github.com/dashpay/dash/pull/5443


## How Has This Been Tested?
Run unit functional tests.

## Breaking Changes
No breaking changes - flag is always true.

## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
2023-07-03 00:06:09 -05:00
Konstantin Akimov
07fd889be9
refactor: deglobalization of bls_legacy_scheme 2/N (#5443)
## Issue being fixed or feature implemented
Many usages of `CBLS{Signature,PrivateKey,PublicKey}` assume using
global variable, even if can be specified explicitly.
Some of these usages have been deglobalized in this PR.

Some prior improvements and fixes are here:
[#5403](https://github.com/dashpay/dash/pull/5403)

## What was done?
- Refactored the uses of global variable of `bls_legacy_scheme` from
`SetHex`, `SetByteVector`, some rpc calls.
- Removed flag `checkMalleable` to simplify code because it's always
`true`.
- Removed dependency from `txmempool.h` on `bls.h` to speed up
compilation.

## How Has This Been Tested?
Run unit/functional tests.



## Breaking Changes
No breaking changes assumed. But in theory behaviour of some RPC can be
more explicit and predictable.

## Checklist:
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
2023-06-30 19:27:39 -05:00
UdjinM6
cc2479ab0c
fix: multiple 5403 followups (#5424)
## Issue being fixed or feature implemented
- CBLSLazyWrapper is doing to much and not enough at the same time
- nVersion assignment in CDeterministicMNState(Diff) is incomplete
- pubKeyOperator deserialization needs nVersion but nVersion is deser-ed
much later
- protx rpcs are implicitly converting pubKeyOperator (by forcing
nVersion=2), they shouldn't do that

## What was done?
pls see individual commits

## How Has This Been Tested?
- [x] run tests locally 
- [x] reindex on testnet:
  - [x] with and without `--assumevalid=0` to the tip
  - [x] with 19.1 almost to the forkpoint, then with this version
- [x] reindex on mainnet:
  - [x] with and without `--assumevalid=0` to the tip
  - [x] with 19.1 to height 1100000+, then with this version

## Breaking Changes
might need reindexing if you were running develop on testnet already

## Checklist:
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone _(for repository
code-owners and collaborators only)_
2023-06-11 10:00:10 +03:00
UdjinM6
54fb76f2f1
fix: Resolve mainnet v19 fork issues (#5403)
## Issue being fixed or feature implemented
same as  #5392, alternative solution

~based on #5402 atm, will rebase later~

## What was done?
pls see individual commits

## How Has This Been Tested?
reorg mainnet around forkpoint with a patched client (to allow low
difficulty), run tests

## Breaking Changes
Another evodb migration is required. Going back to an older version or
migrating after the fork requires reindexing.

## Checklist:
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone _(for repository
code-owners and collaborators only)_
2023-06-04 23:45:56 +03:00
pasta
f92e51b4c5 refactor: convert most std::vector const references to Spans in bls code 2023-04-19 01:12:28 +03:00
PastaPastaPasta
770eefcd08
ci: upgrade cppcheck to 2.10; fix / suppress reported issues (#5328)
## Issue being fixed or feature implemented
Upgraded version of cppcheck

## What was done?

## How Has This Been Tested?
Ran cppcheck

## Breaking Changes
None

## Checklist:
_Go over all the following points, and put an `x` in all the boxes that
apply._
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone _(for repository
code-owners and collaborators only)_
2023-04-16 12:08:33 -05:00
Odysseas Gabrielides
593ff7e929
fix: governance correct sig check (#5242)
## Issue being fixed or feature implemented

## What was done?
When verifying signature of `CGovernanceVote`/`CGovernanceObject` we
need to use the active scheme.

## How Has This Been Tested?

## Breaking Changes

## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation

**For repository code-owners and collaborators only**
- [x] I have assigned this pull request to a milestone
2023-03-11 11:44:35 -06:00
Odysseas Gabrielides
9cbc360f8a
fix: BLS checkMalleable protection (#5240)
<!--
*** Please remove the following help text before submitting: ***

Provide a general summary of your changes in the Title above

Pull requests without a rationale and clear improvement may be closed
immediately.

Please provide clear motivation for your patch and explain how it
improves
Dash Core user experience or Dash Core developer experience
significantly:

* Any test improvements or new tests that improve coverage are always
welcome.
* All other changes should have accompanying unit tests (see
`src/test/`) or
functional tests (see `test/`). Contributors should note which tests
cover
modified code. If no tests exist for a region of modified code, new
tests
  should accompany the change.
* Bug fixes are most welcome when they come with steps to reproduce or
an
explanation of the potential issue as well as reasoning for the way the
bug
  was fixed.
* Features are welcome, but might be rejected due to design or scope
issues.
If a feature is based on a lot of dependencies, contributors should
first
  consider building the system outside of Dash Core, if possible.
-->

## Issue being fixed or feature implemented
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->


## What was done?
<!--- Describe your changes in detail -->


## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->


## Breaking Changes
<!--- Please describe any breaking changes your code introduces -->


## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation

**For repository code-owners and collaborators only**
- [x] I have assigned this pull request to a milestone

---------

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
2023-03-09 10:13:00 +02:00
Odysseas Gabrielides
362e1db801
fix: bls operations crash protection (#5202)
Since new BLS scheme introduction, a sporadic crash was appearing from
time to time during functional tests.
The crash was an uncaught exception (std::invalid_argument, what="Relic
library error") thrown from BLS operations.
Affected tests: feature_llmq_is_conflicts.py,
feature_llmq_is_migration.py

## Issue being fixed or feature implemented
This PR doesn't solve the actual problem, but it protects the node from
crashing by catching exception thrown from BLS.
All BLS aggregation operations weren't calling BLS impl code within a
try catch block.
Now, all aggregations operations are protected from the uncaught
exception.

## What was done?


## How Has This Been Tested?


## Breaking Changes


## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation

**For repository code-owners and collaborators only**
- [x] I have assigned this pull request to a milestone
2023-02-19 17:06:50 -06:00
Konstantin Akimov
f26c479e23
fix: using checkMalleable in serialization of CBLSSignatureVersionWrapper (#5189)
## Issue being fixed or feature implemented
This changes are required, because constructor
`CBLSSignatureVersionWrapper` doesn't work as expected.
You may pass `checkMalleable = false` in constructor, but it will be
used `true` as default argument anyway


## What was done?
- fixed using flag `checkMalleable` in `CBLSSignatureVersionWrapper`
- removed unused `checkMalleable` in `ConstCBLSPublicKeyVersionWrapper`
- fixed order initialization in constructor (eliminate clang warning)
- re-ordered class members to reduce memory usage



## How Has This Been Tested?
Run functional/unit tests

## Breaking Changes
It changes API behavior but does it break anything?


## Checklist:
- [x] I have performed a self-review of my own code
- [x] I have assigned this pull request to a milestone
2023-02-10 14:14:57 +02:00
UdjinM6
498e8c5017 chore: run copyright_header.py update 2023-01-13 00:49:04 +03:00
Odysseas Gabrielides
78d057dd7a
feat!: BLS scheme upgrade (#5021)
Tracking issue is:
[(https://github.com/dashpay/dash/issues/5001)](https://github.com/dashpay/dash/issues/5001)

Co-authored-by: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: pasta <pasta@dashboost.org>
2022-12-29 23:45:31 -06:00
Kittywhiskers Van Gogh
305abe91f9
build/depends: commit dashpay/bls-signatures@66ee820f to source tree as vendored (#5077)
* Squashed 'src/dashbls/' content from commit 66ee820fbc

git-subtree-dir: src/dashbls
git-subtree-split: 66ee820fbc9e3b97370db8c164904af48327a124

* build: stop tracking build-system generated relic_conf.h.in

* build: add support for building bls-signatures from local subtree

* build: add exclusions to linting scripts and filters

* build: drop bls-signatures (bls-dash) from depends
2022-11-22 11:34:46 -06:00
PastaPastaPasta
ad88fab80d
test/refactor: upgrade to cppcheck 2.9 and fix warnings (#5049)
* refactor: resolve warnings thrown by cppcheck 2.9

* test: upgrade cppcheck to version 2.9
2022-10-18 13:24:00 +03:00
Odysseas Gabrielides
c3fc8acdcb
test: bls scheme basic/legacy tests (#5027)
* test: run bls tests utilizing both legacy and basic scheme

* linter fix

* Added todos for pending basic bls raw data

Co-authored-by: pasta <pasta@dashboost.org>
2022-09-30 10:29:51 -05:00
PastaPastaPasta
afbc817220
refactor/chore: update cppcheck to 2.8 with needed refactoring (#4926)
* refactor/chore: update cppcheck to 2.8 with needed refactoring

* use probably invalid index for default

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

* trivial: rename skContributions -> m_sk_contributions and skContributions2 -> skContributions

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2022-08-11 02:05:44 +03:00
Konstantin Akimov
7b9f0acbdd
fix: resolve some memory leaks (#4939)
- In wallet/rpcdump memory the leak would happen, if wallet is not correct JSON
 - In BLS the leak would happen, if object hasn't been pushed in queue by some reason. Need to remove temporary object also
2022-08-05 12:13:42 -05:00
PastaPastaPasta
d64b7229cd
chore: bump copyrights (#4873)
* chore: bump copyright in configure.ac

* chore: bump copyright via copyright_header.py

ran command `python3 contrib/devtools/copyright_header.py update .`
2022-06-08 02:36:46 +03:00
PastaPastaPasta
d561e3c726
refactor: misc bls/llmq refactoring (#4834)
* refactor: misc clang-tidy refactorings

* refactor(dkgsession): misc clang-tidy refactoring

* refactor: adjust blockprocessor.*

* refactor: adjust CChainLockSig api

* avoid function calls inside of assert
2022-05-13 00:11:39 +03:00
PastaPastaPasta
fe0ebb3c04
refactor: fix numerous compilation warnings (#4682)
* style: use clang-tidy style named parameters

* refactor: make IsTimeOutOfBounds testable by having current time be a parameter

* style: use x-> not (*x).

* refactor: make SelectCoinsGroupedByAddresses return a vector, remove out param

previous semantics was return false if the vecTally vector was empty. Now we just let the caller check if it is empty or not

* refactor: fix some sign-compare warnings

* refactor: consistently pre-declare stuff as struct / class inline with underlying type

* refactor: don't return const bool

* refactor: use ref to string

* refactor: use = default for CompactTallyItem

* refactor: adjust "initialization" ordering

* refactor: adjust how we handle negatives in GetProjectedMNPayees, use std::min

* refactor: don't bind a reference to a temporary value

* refactor: use a ref

* refactor: ensure attempt in SelectMemberForRecovery is non-negative.

* refactor: remove unused this capture

* refactor: fix numerous sign-compare warnings

* refactor: more consistently use size_t, use empty()
2022-02-11 19:15:26 +03:00
PastaPastaPasta
f503a7edc1
refactor: Fix warnings from cppcheck (#4625)
* src/evo/evodb.cpp:57:29: warning: Assert statement calls a function which may have desired side effects: 'IsClean'. [assertWithSideEffect]

* src/llmq/quorums.cpp:635:37: note: Null pointer dereference

src/llmq/quorums.cpp:635:37: warning: Either the condition 'pFrom==nullptr' is redundant or there is possible null pointer dereference: pFrom. [nullPointerRedundantCheck]
src/llmq/quorums.cpp:636:81: note: Assuming that condition 'pFrom==nullptr' is not redundant

* fix a bunch of cppcheck warnings

* cppcheck: run on many more files. Enable all checks except a few ignored ones.

ignored
```
    "Consider using std::transform algorithm instead of a raw loop."
    "Consider using std::accumulate algorithm instead of a raw loop."
```

* ci: build specific version of cppcheck instead of install from apt

* ci: use cppcheck 2.4, remove commented out line, fix symlink

cppcheck 2.6 is latest, however causes issues
```
src/spork.cpp:135:51: warning: Analysis failed. If the code is valid then please report this failure. [cppcheckError]
```
cppcheck 2.5 appears to get into an infinite loop

* no need to check presence before insertion

* use if-init, remove redundant check

* remove redundant check

* don't remove cmake? fix macOs depends build?

* cppcheck: one per line, alphabetize

* remove duplicate cmake install
2021-12-29 00:54:50 +03:00
Pasta
d09a88483d
fix: resolve issue with introduced SEED value 2021-12-28 00:27:12 -05:00
PastaPastaPasta
f2c603b45c
util: add ranges.h to emulate c++20 std::ranges (#4622)
* refactor: introduce ranges.h for prettier std algo. Also use it in dash core

* fix formatting, use ranges instead of std

* remove commented out code

* introduce ranges find_if_opt, count_if, find_if. Use them all, and more

* use std::accumulate

* capture everything so that threadsaftey analysis is happy

* fix linter

* fix linter

* remove pessimizing move
2021-12-21 15:05:29 +03:00
PastaPastaPasta
58d3e1381b
refactor: modifications to GenerateContributions (#4594)
* modifications to GenerateContributions

* Introduce some benchmarks to ensure there's no regression

* minor fixups

Signed-off-by: pasta <pasta@dashboost.org>
2021-12-12 16:37:26 +03:00
PastaPastaPasta
40c259bdf3
fix: resolve numerous compilation warnings under -Wall (#4599)
* fix: compilation warnings

./validation.h:266:13: warning: ‘bool AcceptToMemoryPoolWithTime(const CChainParams&, CTxMemPool&, CValidationState&, const CTransactionRef&, bool*, int64_t, bool, CAmount, bool)’ declared ‘static’ but never defined [-Wunused-function]
 static bool AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPool& pool, CValidationState &state, const CTransactionRef &tx,
             ^~~~~~~~~~~~~~~~~~~~~~~~~~

* fix: compilation warnings

./coinjoin/client.h: In constructor ‘CCoinJoinClientManager::CCoinJoinClientManager(CWallet&)’:
./coinjoin/client.h:199:10: warning: ‘CCoinJoinClientManager::fCreateAutoBackups’ will be initialized after [-Wreorder]
     bool fCreateAutoBackups; // builtin support for automatic backups
          ^~~~~~~~~~~~~~~~~~
./coinjoin/client.h:187:14: warning:   ‘CWallet& CCoinJoinClientManager::mixingWallet’ [-Wreorder]
     CWallet& mixingWallet;
              ^~~~~~~~~~~~
./coinjoin/client.h:205:14: warning:   when initialized here [-Wreorder]
     explicit CCoinJoinClientManager(CWallet& wallet) :
              ^~~~~~~~~~~~~~~~~~~~~~

* fix: compilation warnings

interfaces/wallet.cpp: In constructor ‘interfaces::{anonymous}::WalletImpl::WalletImpl(const std::shared_ptr<CWallet>&)’:
interfaces/wallet.cpp:594:30: warning: ‘interfaces::{anonymous}::WalletImpl::m_wallet’ will be initialized after [-Wreorder]
     std::shared_ptr<CWallet> m_wallet;
                              ^~~~~~~~
interfaces/wallet.cpp:191:18: warning:   ‘interfaces::{anonymous}::CoinJoinImpl interfaces::{anonymous}::WalletImpl::m_coinjoin’ [-Wreorder]
     CoinJoinImpl m_coinjoin;
                  ^~~~~~~~~~
interfaces/wallet.cpp:193:14: warning:   when initialized here [-Wreorder]
     explicit WalletImpl(const std::shared_ptr<CWallet>& wallet) : m_wallet(wallet), m_coinjoin(wallet) {}
              ^~~~~~~~~~

* fix: compilation warnings

validation.cpp:165:13: warning: ‘void CheckBlockIndex(const Consensus::Params&)’ declared ‘static’ but never defined [-Wunused-function]
 static void CheckBlockIndex(const Consensus::Params& consensusParams);
             ^~~~~~~~~~~~~~~

* fix: compilation warnings

bls/bls_worker.cpp: In constructor ‘ContributionVerifier::ContributionVerifier(CBLSId, const std::vector<std::shared_ptr<std::vector<CBLSPublicKey> > >&, const BLSSecretKeyVector&, size_t, bool, bool, ctpl::thread_pool&, std::function<void(const std::vector<bool>&)>)’:
bls/bls_worker.cpp:425:51: warning: ‘ContributionVerifier::doneCallback’ will be initialized after [-Wreorder]
     std::function<void(const std::vector<bool>&)> doneCallback;
                                                   ^~~~~~~~~~~~
bls/bls_worker.cpp:420:12: warning:   ‘size_t ContributionVerifier::batchCount’ [-Wreorder]
     size_t batchCount;
            ^~~~~~~~~~
bls/bls_worker.cpp:427:5: warning:   when initialized here [-Wreorder]
     ContributionVerifier(CBLSId _forId, const std::vector<BLSVerificationVectorPtr>& _vvecs,
     ^~~~~~~~~~~~~~~~~~~~

* fix: compilation warnings

bls/bls_worker.cpp:342:10: warning: ‘VectorAggregator<CBLSPublicKey>::parallel’ will be initialized after [-Wreorder]
     bool parallel;
          ^~~~~~~~
bls/bls_worker.cpp:340:12: warning:   ‘size_t VectorAggregator<CBLSPublicKey>::start’ [-Wreorder]
     size_t start;
            ^~~~~
bls/bls_worker.cpp:350:5: warning:   when initialized here [-Wreorder]
     VectorAggregator(const VectorVectorType& _vecs,
     ^~~~~~~~~~~~~~~~
bls/bls_worker.cpp:343:24: warning: ‘VectorAggregator<CBLSPublicKey>::workerPool’ will be initialized after [-Wreorder]
     ctpl::thread_pool& workerPool;
                        ^~~~~~~~~~
bls/bls_worker.cpp:337:18: warning:   ‘VectorAggregator<CBLSPublicKey>::DoneCallback VectorAggregator<CBLSPublicKey>::doneCallback’ [-Wreorder]
     DoneCallback doneCallback;
                  ^~~~~~~~~~~~
bls/bls_worker.cpp:350:5: warning:   when initialized here [-Wreorder]
     VectorAggregator(const VectorVectorType& _vecs,
     ^~~~~~~~~~~~~~~~

* fix: compilation warnings

bls/bls_worker.cpp:494:235:   required from here
bls/bls_worker.cpp:136:24: warning: ‘Aggregator<CBLSSecretKey>::workerPool’ will be initialized after [-Wreorder]
     ctpl::thread_pool& workerPool;
                        ^~~~~~~~~~
bls/bls_worker.cpp:135:10: warning:   ‘bool Aggregator<CBLSSecretKey>::parallel’ [-Wreorder]
     bool parallel;
          ^~~~~~~~
bls/bls_worker.cpp:152:5: warning:   when initialized here [-Wreorder]
     Aggregator(const std::vector<TP>& _inputVec,
     ^~~~~~~~~~

* fix: compilation warnings

bench/string_cast.cpp: In lambda function:
bench/string_cast.cpp:22:13: warning: statement has no effect [-Wunused-value]
         atoi("1");
         ~~~~^~~~~

* fix: compilation warnings

./llmq/dkgsessionhandler.h: In constructor ‘llmq::CDKGPendingMessages::CDKGPendingMessages(size_t, int)’:
./llmq/dkgsessionhandler.h:48:12: warning: ‘llmq::CDKGPendingMessages::maxMessagesPerNode’ will be initialized after [-Wreorder]
     size_t maxMessagesPerNode GUARDED_BY(cs);
            ^~~~~~~~~~~~~~~~~~
./llmq/dkgsessionhandler.h:47:15: warning:   ‘const int llmq::CDKGPendingMessages::invType’ [-Wreorder]
     const int invType;
               ^~~~~~~
llmq/dkgsessionhandler.cpp:23:1: warning:   when initialized here [-Wreorder]
 CDKGPendingMessages::CDKGPendingMessages(size_t _maxMessagesPerNode, int _invType) :
 ^~~~~~~~~~~~~~~~~~~

* fix: compilation warnings

Not sure this one is correct, but I believe so. Seems like the `!= 0` is completely not needed

rpc/masternode.cpp: In function ‘UniValue masternode_payments(const JSONRPCRequest&)’:
rpc/masternode.cpp:442:31: warning: suggest parentheses around comparison in operand of ‘!=’ [-Wparentheses]
     while (vecPayments.size() < std::abs(nCount) != 0 && pindex != nullptr) {
            ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~

* fix: compilation warnings

test/cachemultimap_tests.cpp:14:13: warning: ‘void cachemultimap_tests::DumpMap(const CacheMultiMap<int, int>&)’ defined but not used [-Wunused-function]
 static void DumpMap(const CacheMultiMap<int,int>& cmmap)
             ^~~~~~~

* fix: compilation warnings

In file included from qt/appearancewidget.cpp:11:
./qt/appearancewidget.h: In constructor ‘AppearanceWidget::AppearanceWidget(QWidget*)’:
./qt/appearancewidget.h:52:25: warning: ‘AppearanceWidget::prevFontFamily’ will be initialized after [-Wreorder]
     GUIUtil::FontFamily prevFontFamily;
                         ^~~~~~~~~~~~~~
./qt/appearancewidget.h:51:9: warning:   ‘int AppearanceWidget::prevScale’ [-Wreorder]
     int prevScale;
         ^~~~~~~~~
qt/appearancewidget.cpp:21:1: warning:   when initialized here [-Wreorder]
 AppearanceWidget::AppearanceWidget(QWidget* parent) :
 ^~~~~~~~~~~~~~~~

* fix: compilation warnings

In file included from qt/bitcoingui.cpp:6:
./qt/bitcoingui.h: In constructor ‘BitcoinGUI::BitcoinGUI(interfaces::Node&, const NetworkStyle*, QWidget*)’:
./qt/bitcoingui.h:212:31: warning: ‘BitcoinGUI::m_network_style’ will be initialized after [-Wreorder]
     const NetworkStyle* const m_network_style;
                               ^~~~~~~~~~~~~~~
./qt/bitcoingui.h:172:34: warning:   ‘const std::unique_ptr<QMenu> BitcoinGUI::trayIconMenu’ [-Wreorder]
     const std::unique_ptr<QMenu> trayIconMenu;
                                  ^~~~~~~~~~~~
qt/bitcoingui.cpp:81:1: warning:   when initialized here [-Wreorder]
 BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle, QWidget* parent) :
 ^~~~~~~~~~

* fix: compilation warnings

In file included from qt/masternodelist.cpp:1:
./qt/masternodelist.h: In constructor ‘MasternodeList::MasternodeList(QWidget*)’:
./qt/masternodelist.h:66:18: warning: ‘MasternodeList::walletModel’ will be initialized after [-Wreorder]
     WalletModel* walletModel;
                  ^~~~~~~~~~~
./qt/masternodelist.h:61:10: warning:   ‘bool MasternodeList::fFilterUpdatedDIP3’ [-Wreorder]
     bool fFilterUpdatedDIP3;
          ^~~~~~~~~~~~~~~~~~
qt/masternodelist.cpp:45:1: warning:   when initialized here [-Wreorder]
 MasternodeList::MasternodeList(QWidget* parent) :
 ^~~~~~~~~~~~~~
In file included from qt/masternodelist.cpp:1:
./qt/masternodelist.h:61:10: warning: ‘MasternodeList::fFilterUpdatedDIP3’ will be initialized after [-Wreorder]
     bool fFilterUpdatedDIP3;
          ^~~~~~~~~~~~~~~~~~
./qt/masternodelist.h:59:13: warning:   ‘int64_t MasternodeList::nTimeFilterUpdatedDIP3’ [-Wreorder]
     int64_t nTimeFilterUpdatedDIP3;
             ^~~~~~~~~~~~~~~~~~~~~~
qt/masternodelist.cpp:45:1: warning:   when initialized here [-Wreorder]
 MasternodeList::MasternodeList(QWidget* parent) :
 ^~~~~~~~~~~~~~

* fix: compilation warnings

In file included from qt/paymentserver.cpp:10:
./qt/paymentserver.h: In constructor ‘PaymentServer::PaymentServer(QObject*, bool)’:
./qt/paymentserver.h:156:28: warning: ‘PaymentServer::netManager’ will be initialized after [-Wreorder]
     QNetworkAccessManager* netManager;  // Used to fetch payment requests
                            ^~~~~~~~~~
./qt/paymentserver.h:147:19: warning:   ‘OptionsModel* PaymentServer::optionsModel’ [-Wreorder]
     OptionsModel *optionsModel;
                   ^~~~~~~~~~~~
qt/paymentserver.cpp:197:1: warning:   when initialized here [-Wreorder]
 PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) :
 ^~~~~~~~~~~~~
2021-12-01 22:59:34 +03:00
PastaPastaPasta
501cdaa91b
refac: use make_unique and constexpr (#4493)
* use make_unique

* use constexpr everywhere possible in dash code
2021-10-11 00:41:53 +03:00
PastaPastaPasta
8d5c586477
refactor: replace instances of typedef with using in dash code (#4488) 2021-10-06 00:26:29 +03:00
PastaPastaPasta
9da186bb61
refactor: Various small improvements (#4471)
* bls: use constexpr int instead of #define

* lint: bump c++ version to 17

* test: use BOOST_CHECK_EQUAL instead of BOOST_ASSERT, call boost assert in another location

* coinjoin: fix typo

* drop redundant LLMQType cast

* use numeric_limits instead of magic value

* net_processing.cpp whitespace fixes

* Add some const

* use std::all_of instead of raw for loop

* Introduce UNINITIALIZED_SESSION_ID and use it instead of a magic number

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-10-01 14:44:40 +03:00
pbattu
3063d17360 fix dash specific ubsan errors 2021-09-28 10:21:00 -03:00
UdjinM6
b57970a70d
Fix thread names for threads started via pools (#4349)
`RenameThreadPool` calls `ThreadRename` which adds `dash-` prefix internally
2021-08-24 19:18:52 +03:00
PastaPastaPasta
41b43ec240
Static analysis fixes (#4316)
* Make constructors explicit

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

* static analysis fixes

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

* Make pFrom nullptr check it's own

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

* revert std thread changes and hasOperatorKey

Signed-off-by: pasta <pasta@dashboost.org>
2021-08-07 00:55:51 +03:00
PastaPastaPasta
f87d62d677
refactor: misc bls, evo, include refactoring (#4305)
* refactor/bls: misc refactoring and spelling/grammar fixes in bls code

* refactor/evo: misc refactoring and spelling/grammar fixes in evo code

* refactor: some include changes

* refactor: remove redundant `public`

* fix linter

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

* Sort includes

* Move `class CTxDSIn;`

* Drop unused functions in CBLSWorker

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2021-07-31 21:29:12 +03:00
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