Commit Graph

33 Commits

Author SHA1 Message Date
UdjinM6
c82e433913
Streamline, refactor and unify PS checks for mixing entries and final txes (#3246)
* Move PS mixing entry verification on masternodes into `AddEntry()`

Also streamline logic a bit and drop unused/excessive parts.

* Unify PS checks among masternodes and clients

* No need to re-check outputs over and over again

* No need to count, fail early if any output is missing

* No need to look any further once we found the input we expected

A tx with duplicate inputs would be considered invalid anyway and we also know there are no duplicates because we just verified the final tx above.

Also drop an unused variable.

* Unify LogPrint-s

* Drop human-readable strings for unused PoolMessage-s

* Apply suggestions from code review

Co-Authored-By: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

* Re-introduce zero-fee checks

* fix log

* Move all txin/txout verification logic shared by CPrivateSendClientSession::SignFinalTransaction() and CPrivateSendServer::AddEntry() into CPrivateSendBaseSession::IsValidInOuts()

* fix nit

* Add missing return

* Use CCoinsViewMemPool instead of doing it manually

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
Co-authored-by: Alexander Block <ablock84@gmail.com>
2020-01-01 17:12:25 +03:00
strophy
9de994988b Compliance changes to terminology (#3211)
Replace inaccurate user-facing descriptions of PS as anonymous to mixed or private, since Dash is a transparent blockchain.
2019-11-21 23:49:35 +03:00
UdjinM6
fd50c1c715
Hold cs_main/cs_wallet in main MakeCollateralAmounts (#3197)
* Hold cs_main/cs_wallet in main MakeCollateralAmounts

Otherwise smth else can alter wallet state and we might end up creating conflicting txes.

* AssertLockHeld
2019-11-13 23:04:12 +03:00
UdjinM6
460e0f475a
Fix locking of funds for mixing (#3194)
* Fix locking of funds for mixing

Lock funds earlier and actually lock mixing collaterals

* Streamline the locking logic in PrepareDenominate
2019-11-13 23:03:52 +03:00
UdjinM6
a7492c1d3a Handle coin type via CCoinControl (#3172) 2019-10-23 09:56:44 +02:00
UdjinM6
33d04ebf28
Disable move ctor/operator for CKeyHolder (#3162)
* Disable move ctor/operator for CKeyHolder

Also fixes these warnings:
```
In file included from dsnotificationinterface.cpp:12:
In file included from ./privatesend/privatesend-client.h:8:
./privatesend/privatesend-util.h:18:5: warning: explicitly defaulted move constructor is implicitly deleted [-Wdefaulted-function-deleted]
    CKeyHolder(CKeyHolder&&) = default;
    ^
./privatesend/privatesend-util.h:13:17: note: move constructor of 'CKeyHolder' is implicitly deleted because field 'reserveKey' has a deleted move constructor
    CReserveKey reserveKey;
                ^
./wallet/wallet.h:1282:5: note: 'CReserveKey' has been explicitly marked deleted here
    CReserveKey(const CReserveKey&) = delete;
    ^
In file included from dsnotificationinterface.cpp:12:
In file included from ./privatesend/privatesend-client.h:8:
./privatesend/privatesend-util.h:19:17: warning: explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]
    CKeyHolder& operator=(CKeyHolder&&) = default;
                ^
./privatesend/privatesend-util.h:13:17: note: move assignment operator of 'CKeyHolder' is implicitly deleted because field 'reserveKey' has a deleted move assignment operator
    CReserveKey reserveKey;
                ^
./wallet/wallet.h:1283:18: note: 'operator=' has been explicitly marked deleted here
    CReserveKey& operator=(const CReserveKey&) = delete;
                 ^
2 warnings generated.
```

* Slightly refactor `CKeyHolderStorage::AddKey()` to clarify that it's ptr and not the object itself that we are moving
2019-10-19 13:40:12 +03:00
UdjinM6
4b6af8f2c1
Few fixes related to SelectCoinsGroupedByAddresses (#3144)
* Fix cache usage in SelectCoinsGroupedByAddresses

* Reset cache flags in SelectCoinsGroupedByAddresses when a block is (dis)connected

* MakeCollateralAmounts should call SelectCoinsGroupedByAddresses with a limited number of inputs
2019-10-17 12:36:18 +03:00
UdjinM6
4112414710
Introduce getprivatesendinfo and deprecate getpoolinfo (#3140)
* Introduce getprivatesendinfo and deprecate getpoolinfo

* s/ToJson/GetJsonInfo/

* s/queues/queue_size/

* Add TODO to explain `denomination` string convertion

* s/entries/entries_count/

* Use `CURRENCY_UNIT`

* Who needs safety belts after all
2019-10-09 19:48:53 +03:00
UdjinM6
152c10bc4b
Various fixes for mixing queues (#3138)
* Always check for expired queues on masternodes

* Check if a queue is too old or too far into the future

Instead of only checking that it's to old

* Check that no masternode can spam us with dsqs regardless of dsq readiness
2019-10-09 19:48:32 +03:00
PastaPastaPasta
746b5f8cda Remove commented out code (#3117)
* Remove LogPrints which have been commented out.

We have version control systems for a reason, if we want code to not run it should be removed. I personally see no value in keeping these around. I presume at one point they were spamming debug.log so we commented them out, but we really should have just removed them.

I believe all of this is dash specific code but any conflicts this does create are so minor they are not of concern imo.

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

* remove a couple of extra comments

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

* remove commented out code

Signed-off-by: Pasta <pasta@dashboost.org>
2019-09-30 09:55:26 +02:00
UdjinM6
ac0270871c
Respect logips config option in few more log outputs (#3078)
* Introduce CNode::GetLogString() and use it where appropriate

* All other cases

* fix typo

* drop useless argument
2019-09-22 23:48:15 +03:00
Alexander Block
7662c0b79a A couple of fixes 2019-09-20 11:10:07 +02:00
PastaPastaPasta
ac90abe892 When mixing, always try to join an exsisting queue, only fall back to starting a new queue (#3085)
Signed-off-by: Pasta <pasta@dashboost.org>
2019-09-17 15:07:56 +03:00
PastaPastaPasta
6b5b70fab8 Remove liquidity provider privatesend (#3082)
* remove liquidity provider. The reason behind this is two fold:
1. it is very likely nobody is currently running this on the mainnet (due to already strong liquidity), it provides no use for testnet as there you can just enable mixing and get the same affect. Because of this reason I don't find it okay to just remove it outright.
2. even if people did use it (or if some do as a novelty) it likely hurts the privacy of the system. This is because as a liquidity provider your outputs will always take many (sometimes hundreds) blocks before being used in a new mixing round, whereas real user's funds will normally be mixed again very rapidly.

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

* remove unused function

Signed-off-by: Pasta <pasta@dashboost.org>
2019-09-15 23:08:05 +03:00
Pasta
0cccde9df7 fix all of the problems
Signed-off-by: Pasta <pasta@dashboost.org>
2019-09-03 18:55:21 -05:00
UdjinM6
c22169d579
Reduce non-debug PS log output (#3076) 2019-09-03 22:48:35 +03:00
Pasta
1a0d52814e
#10483 scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
-BEGIN VERIFY SCRIPT-
sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h
sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp
sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp
sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp
sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp
sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp
-END VERIFY SCRIPT-

Signed-off-by: Pasta <pasta@dashboost.org>
2019-08-12 09:07:03 -05:00
PastaPastaPasta
2cbf726ab0 Backport #8694: Basic multiwallet support (#3022)
* Merge #8694: Basic multiwallet support

c237bd7 wallet: Update formatting (Luke Dashjr)
9cbe8c8 wallet: Forbid -salvagewallet, -zapwallettxes, and -upgradewallet with multiple wallets (Luke Dashjr)
a2a5f3f wallet: Base backup filenames on original wallet filename (Luke Dashjr)
b823a4c wallet: Include actual backup filename in recovery warning message (Luke Dashjr)
84dcb45 Bugfix: wallet: Fix warningStr, errorStr argument order (Luke Dashjr)
008c360 Wallet: Move multiwallet sanity checks to CWallet::Verify, and do other checks on all wallets (Luke Dashjr)
0f08575 Wallet: Support loading multiple wallets if -wallet used more than once (Luke Dashjr)
b124cf0 Wallet: Replace pwalletMain with a vector of wallet pointers (Luke Dashjr)
19b3648 CWalletDB: Store the update counter per wallet (Luke Dashjr)
74e8738 Bugfix: ForceSetArg should replace entr(ies) in mapMultiArgs, not append (Luke Dashjr)
23fb9ad wallet: Move nAccountingEntryNumber from static/global to CWallet (Luke Dashjr)
9d15d55 Bugfix: wallet: Increment "update counter" when modifying account stuff (Luke Dashjr)
f28eb80 Bugfix: wallet: Increment "update counter" only after actually making the applicable db changes to avoid potential races (Luke Dashjr)

Tree-SHA512: 23f5dda58477307bc07997010740f1dc729164cdddefd2f9a2c9c7a877111eb1516d3e2ad4f9b104621f0b7f17369c69fcef13d28b85cb6c01d35f09a8845f23

* pwalletMain -> vpwallets

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

* add gArgs

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

* continued pwalletsMain -> vpwallets

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

* remove external pwalletMains and pwalletMain -> vpwallet

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

* add external referance to vpwallets

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

* more pWalletMain -> vpwallets[0]

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

* code review

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

* revert LOCK(cs_main) move

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

* import wallet.h and remove extern

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

* batch.* -> WriteIC and EraseIC

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

* wrap wallet.h include inside of an ifdef

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

* drop wallet.h

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

* add dropped "!"

Signed-off-by: Pasta <pasta@dashboost.org>
2019-07-11 10:50:52 +03:00
PastaPastaPasta
bdec34c949 remove DS mixes once they have been included in a chainlocked block (#3015)
* remove DS mixes once they have been included in a chainlocked block

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

* Use multiple if checks instead of one line conditional

Signed-off-by: Pasta <pasta@dashboost.org>
2019-07-07 01:07:03 +03:00
UdjinM6
b75e1cebd3
Decouple lite mode and client-side PrivateSend (#2893)
* Decouple lite mode and client-side PrivateSend

`-enableprivatesend`:
1. off by default in lite mode but can be overridden
2. does not start mixing, use `-privatesendautostart` (default is off) or `privatesend` rpc instead

* Disable PS when there is no wallet, do not auto-start mixing when wallet is locked

* Check for `!fEnablePrivateSend` and `!fPrivateSendRunning` instead of `!pwalletMain` in ps client code

* Add meaningful `privatesend` rpc error messages for various cases when mmixing is disabled
2019-06-27 23:24:43 +03:00
UdjinM6
b9a738528c
Remove skipped denom from the list on tx commit (#2997)
* Remove skipped denom from the list on tx commit

Regardless of the tx type (PS or not).

* Update src/privatesend/privatesend-client.cpp

Co-Authored-By: Alexander Block <ablock84@gmail.com>
2019-06-26 14:39:36 +03:00
Wladimir J. van der Laan
2edd094a21
Merge #10189: devtools/net: add a verifier for scriptable changes. Use it to make CNode::id private.
0f3471f net: make CNode's id private (Cory Fields)
9ff0a51 scripted-diff: net: Use accessor rather than node's id directly (Cory Fields)
e50c33e devtools: add script to verify scriptable changes (Cory Fields)

skipped travis changes

Tree-SHA512: a0ff50f4e1d38a2b63109b4996546c91b3e02e00d92c0bf04f48792948f78b1f6d9227a15d25c823fd4723a0277fc6a32c2c1287c7abbb7e50fd82ffb0f8d994

pnode->id to pnode->GetId()

Signed-off-by: Pasta <pasta@dashboost.org>
2019-06-19 08:20:15 -05:00
UdjinM6
d63202bdce
Should send "reject" when mixing queue is full (#2981) 2019-06-18 14:33:44 +03:00
UdjinM6
8d5781f408
Stop reporting/processing the number of mixing participants in DSSTATUSUPDATE (#2980)
* Stop reporting/processing the number of mixing participants

* Introduce CPrivateSendStatusUpdate class to encapsulate serialization of DSSTATUSUPDATE msg

And make corresponding enums serializable too.

* Revert range checks removal
2019-06-18 14:33:30 +03:00
PastaPastaPasta
7334aa553c adjust privatesend formatting and follow some best practices (#2979)
* adjust privatesend files formatting and follow some best practices

* code review

Signed-off-by: Pasta <Pasta@dash.org>

* use auto for iterators

Signed-off-by: Pasta <Pasta@dash.org>

* review pt2

Signed-off-by: Pasta <Pasta@dash.org>
2019-06-18 14:33:05 +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
Alexander Block
617c4a4cc0 Use mapDSTX.find() instead of count() and [] 2019-05-27 16:40:05 +02:00
Alexander Block
8df25bbfe4 Call and implemente new signals in CPrivateSend
Instead of relying on CDSNotificationInterface running compatibility code.
This also removes locking of cs_main, as this seemed to be not needed.
2019-05-27 16:40:05 +02:00
UdjinM6
250195185f
Adjust CDSNotificationInterface to align with CValidationInterface changes 2019-05-27 09:03:19 -05:00
UdjinM6
c08e761015
Tighten rules for DSVIN/DSTX (#2897)
* Tighten rules for dstx

* Tighten rules for dsvin

* NULL -> nullptr

* Make `ConsumeCollateral()` a private function instead of a lamda and reuse it in `Charge*Fees()`

* Make sure inputs and outputs are of the same size

Introduces new response ERR_SIZE_MISMATCH, old clients will simply bail out.

* Drop now redundant vecTxOut.size() check

* Check max inputs size

* Fix log category
2019-05-23 12:13:34 +03:00
PastaPastaPasta
29194b1f5a Backport Bitcoin#9424, Bitcoin#10123 and Bitcoin#10153 (#2918)
* Contains dashification. disables `-debug dash`
Merge #9424: Change LogAcceptCategory to use uint32_t rather than sets of strings.

6b3bb3d Change LogAcceptCategory to use uint32_t rather than sets of strings. (Gregory Maxwell)

Tree-SHA512: ebb5bcf9a7d00a32dd1390b727ff4d29330a038423611da01268d8e1d2c0229e52a1098e751d4e6db73ef4ae862e1e96d38249883fcaf12b68f55ebb01035b34
Signed-off-by: Pasta <Pasta@dash.org>

31 -> 32

Signed-off-by: Pasta <Pasta@dash.org>

* Merge #10123: Allow debug logs to be excluded from specified component

3bde556 Add -debugexclude option to switch off logging for specified components (John Newbery)

Tree-SHA512: 30202e3f2085fc2fc5dd4bedb92988f4cb162c612a42cf8f6395a7da326f34975ddc347f82bc4ddca6c84c438dc0cc6e87869f90c7ff88105dbeaa52a947fa43

* bump to uint64_t due to added Dash codes

Signed-off-by: Pasta <Pasta@dash.org>

* bump to uint64_t due to added Dash codes cont.

Signed-off-by: Pasta <Pasta@dash.org>

* string -> BCLog format

Signed-off-by: Pasta <Pasta@dash.org>

* uint32_t -> uint64_t

Signed-off-by: Pasta <Pasta@dash.org>

* Fix CBatchedLogger

* Fix most fDebug-s

* Fix `debug` rpc

* Fix BENCH and RAND conflicts

* Add ALERT and use it

* Update LogPrint-s in dash-specific code

* Tweak few log categories

Specifically:
- use PRIVATESEND in `CPrivateSendClientManager::GetRandomNotUsedMasternode()`
- use ZMQ in `CZMQPublishRawGovernanceVoteNotifier::NotifyGovernanceVote()` and `CZMQPublishRawGovernanceObjectNotifier::NotifyGovernanceObject()`

* Drop no longer used MASTERNODE category

* Merge #10153: logging: Fix off-by-one for shrinkdebugfile default

faab624 logging: Fix off-by-one for shrinkdebugfile (MarcoFalke)

Tree-SHA512: d6153e06067906172ff0611af9e585a3ecf0a7d56925b6ad7c12e75aa802441047059b9b6f6c78e79916c3f2abc8f1998bfd2d5b84201ec6421f727c08da3c21

* Shift dash-specific log categories to start from `1ul << 32` to avoid potential future conflicts with bitcoin ones

* Fix `dash` category

* remove debugCategories

Signed-off-by: Pasta <Pasta@dash.org>

* Prepend "std::" to find call

* Check for BCLog::PRIVATESEND instead of logCategories != BCLog::NONE

* Use BCLog::MNPAYMENTS category instead of checking for logCategories != BCLog::NONE

* Move "End Dash" comment below "ALERT"

When adding new entries here, we'll otherwise get confused with ordering
and might end up forgetting that adding something Dash specific must
continue with the bit after 43.
2019-05-23 00:51:39 +03:00
PastaPastaPasta
32aa229c7f Reorganize Dash Specific code into folders (#2753)
* rename instantx.* file to instantsend.*

* Reorganize Dash Specific code into folders

add to privatesend folder the header files

Signed-off-by: Pasta <Pasta@dash.org>

add "masternode" to imports

Signed-off-by: Pasta <Pasta@dash.org>

add "masternode" to imports

Signed-off-by: Pasta <Pasta@dash.org>

add "masternode" to imports pt 2

Signed-off-by: Pasta <Pasta@dash.org>
2019-05-21 15:26:15 +02:00