Commit Graph

164 Commits

Author SHA1 Message Date
UdjinM6
98990b683a Refactor: CDarkSendSigner (#1410)
* Refactor: CDarkSendSigner -> CMessageSigner + CMasternodeBroadcast::IsVinAssociatedWithPubkey

* move IsVinAssociatedWithPubkey to CMasternode

* static IsVinAssociatedWithPubkey -> no params IsInputAssociatedWithPubkey
2017-04-12 10:04:06 +03:00
UdjinM6
68e1a8c790 Safety check in CInstantSend::SyncTransaction (#1412) 2017-04-11 13:54:34 +03:00
UdjinM6
1c63052c3e fix recently observed crash on IsValid (#1375)
* fix recently observed crash on IsValid

+some small cleanup

* txin.prevout.n should not exceed txOutpointCreated.vout.size()

* fix log output
2017-03-01 21:30:43 +01:00
UdjinM6
bd3978fd4b Fix IS vote expiration/cleanup: (#1316)
- vote should be removed when corresponding orphan vote expires
- fix CInstantSend::SyncTransaction: mapTxLockVotes is indexed by vote hash, not by tx hash (use votes from candidates and from orhpan vote map to avoid looping through the whole vote map)
2017-02-04 22:17:45 +04:00
UdjinM6
1486acfb99 remove IS number of inputs limit, add warning instead (#1308) 2017-02-03 02:38:33 +04:00
UdjinM6
e2eaf1d0d7 Fix few block processing bugs (#1291)
* protect mapRejectedBlocks by cs_main

* few block reprocessing fixes:
- DisconnectBlock should fail on DisconnectTip failure
- ResolveConflicts should fail on DisconnectBlock failure
- ReprocessBlocks cleanup

* don't ban on IsBlockValueValid/IsBlockPayeeValid failure
2017-01-30 10:01:08 +04:00
Tim Flynn
04ed5db62c Fix Vote iteration bug (#1290)
* Fix Vote iteration bug

* Fix order of statements
2017-01-29 23:09:21 +04:00
UdjinM6
60409df822 InstantSend overhaul (#1288)
* Multi-quorum InstantSend, complete refactoring
+ cleanup for IS and partial protobump

* more changes:
- allow InstantSend tx to have 10 inputs max
- store many unique tx hashes in mapVotedOutpoints
- more checks in AcceptToMemoryPoolWorker (moved from ProcessMessage + CTxLockRequest(tx).IsValid() )

* More changes:
- let multiple lock candidates compete for votes
- fail to vote on the same outpoint twice early

* More changes:
- notify CInstantSend on UpdatedBlockTip -> remove cs_main from CheckAndRemove()
- notify CInstantSend on SyncTransaction -> count expiration block starting from the block corresponding tx was confirmed instead of the block lock candidate/vote was created
- fixed few locks

* add comments about nConfirmedHeight

* Fix "Block vs Lock" edge case

* Fix "Block vs Lock" edge case, p2

* Fix issues:
- fix logic for locking inputs and notifying - see UpdateLockedTransaction, TryToFinalizeLockCandidate
- add missing hash inserting in ProcessTxLockVote
- add nMaxBlocks param to ResolveConflicts to limit max depth allowed to disconnect blocks recursively
- fix false positive mempool conflict
- add missing mutex locks
- fix fRequireUnspent logic in CTxLockRequest::IsValid
2017-01-29 12:22:14 +04:00
UdjinM6
b5239b790e Merge #1267: Fix IS locking/crashes 2017-01-18 07:38:13 +01:00
UdjinM6
a0c93ebaa5 cleanup/fix includes: (#1214)
- some were not used, some were included twice, some were in the wrong place, some were missing (but it compiled because some were in the wrong place)
- organized a bit better, grouped dash specific includes in original bitcoin files, should save some time solving conflicts when/if merging patches later
2016-12-20 17:27:59 +04:00
Holger Schinzel
e1702cd4ec bump copyright notice to 2017 (#1207) 2016-12-20 17:26:45 +04:00
UdjinM6
a11bd2c5ba small ix fixes: (#1193)
- make script verification a part of IsInstantSendTxValid()
- relax nLockTime for IS txes since we don't have compatibility with 12.0 IS txes anyway now (fee is lower in 12.1)
2016-12-09 00:03:57 +04:00
UdjinM6
0600a6ce1a Fix (dead)locks (#1169)
* locks in PS

* lock in governance

* locks in IS

* lock in ProcessGetData

* locks in CMasternodeSync

* centralize mnodeman.Check call

* locks order in mnpayments

* use current block chainTip when possible (less locks)

* add missing lock in CountInputsWithAmount

* fix deadlock RequestLowDataPaymentBlocks/IsTransactionValid

* LOCK2 in CheckMnbAndUpdateMasternodeList, CheckAndUpdate, SendVerifyRequest

* LOCK(cs) is not needed here

* Decouple governance init actions from serialization
Should fix this:
```
Assertion failed: lock governance.cs not held in governance-classes.cpp:117; locks held:
cs_Shutdown  init.cpp:200 (TRY)
cs  ./governance.h:195
cs  governance.cpp:835
Abort trap: 6
```
2016-11-28 18:21:50 +04:00
UdjinM6
470239bbc5 Fix IS: (#1161)
- TXLOCKREQUEST should be processed as normal tx plus some custom logic, should not "fake" inventory
- should not create "fake" local lock, should instead keep track of orphan votes and reprocess them when corresponding TXLOCKREQUEST arrives
- orphan vote time map should be indexed by full outpoint, not by txid of mn collateral

bump MIN_INSTANTSEND_PROTO_VERSION
2016-11-22 18:54:26 +04:00
UdjinM6
785adad57e Slightly refactor/fix IS (#1153)
* slightly refactor IS:
- the only place where logic is changed: `ProcessTxLockVote()` - it should first try to find mn and fail if none was found and only then try to call `GetMasternodeRank()` (which is heavy)
- fixed few `cs_main`
- slightly optimized number of `tx.GetHash()` calls
- lots of `const` (fixed few related functions in main.cpp)
- few smaller fixes: iterators, log output, comments, etc
- use thread safe methods of mnodeman
- safety check in GetAverageUnknownVoteTime
2016-11-22 00:40:32 +04:00
UdjinM6
ce88ab3144 Refactor IS - rename only (+related log messages) (#1146) 2016-11-17 04:31:35 +04:00
UdjinM6
2d55b70381 (log) tweaks and (general) cleanup (#1086)
* docs

* deprecated/unused/duplicate

* comments

* log cleanup/verbosity tuning

* names/ifs/whitespaces/std
2016-10-22 20:52:14 +04:00
UdjinM6
6e9d1779b9 (mostly trivial) Refactor CMasternode/Ping/Broadcast (#1022)
* Refactor CMasternode/Ping/Broadcast
Most noticable:
- pubkey -> pubKeyCollateralAddress
- pubkey2 -> pubKeyMasternode
- VerifySignature -> CheckSignature
- removed PoSe related stuff (deprecated)

Other variable name changes are trivial. Also adjusted debug log output.

* fix constructors
2016-09-16 02:00:06 +04:00
UdjinM6
9bf1e00f09 rename NetMsgType::IX -> NetMsgType::TXLOCKREQUEST, NetMsgType::IXLOCKVOTE -> NetMsgType::TXLOCKVOTE (#1021) 2016-09-16 00:07:01 +04:00
UdjinM6
36c4b6dc2e Trivial refactoring/cleanup (#990) 2016-09-05 20:09:25 +04:00
UdjinM6
46744394a2 More instantx->instantsend (few more ds->privatesend) (#984) 2016-09-02 16:17:32 +04:00
UdjinM6
0597900c16 Changes for sporks: (#981)
- rename all 3 instantsend sporks
- remove SPORK_7_MASTERNODE_SCANNING (not used anymore)
- change `_DEFAULT` for spork 2 and 3, adjust comments for for them
- fix GetSporkNameByID() (should not return smth_DEFAULT)
2016-09-01 18:55:25 +04:00
UdjinM6
bc80d7e2a5 Merge #969: Masternode sync improvements
da406e3 Masternode sync improvements
    - add simple helpers for few more sync states (use them where appropriate instead of old code + rpc output)
    - use new helpers to avoid meaningless message processing
    - actually fail if sync shouldn't continue due to lack of info, make sure Reset is used to quit failed state
2016-08-29 21:11:34 +02:00
UdjinM6
67def9ef2e Merge #948 Refactor CDarkSendSigner
f0ed400 darkSendSigner.SignMessage() should not return error message

154f1b6 darkSendSigner.VerifyMessage() should return non-localized message, its callers should populate error to debug.log

b130c32 darkSendSigner.GetKeysFromSecret() should not return error message, its callers should handle it
2016-08-19 05:50:04 -06:00
UdjinM6
e20e1dc5da Merge #939: More IS refactoring
149f27a More IS refactoring
2016-08-12 07:55:41 +02:00
UdjinM6
ee266f2d01 Merge #938: Fix bug in #895
68ff166 Fix bug in #895
2016-08-12 07:45:06 +02:00
UdjinM6
7f89bba83e Refactor InstantSend to use block count instead of local time to set expiration limit - nInstantSendKeepLock. Also make it (and number of blocks to reprocess in case of a conflict) a part of Consensus params and set it to lower numbers for testnet/regtest to be able to break things easier there.
Bump MIN_INSTANTX_PROTO_VERSION
2016-08-08 16:43:15 +03:00
UdjinM6
5a8c0c9b9d Merge #928: Refactor All The Things - part1
86d8505 Refactor CActiveMasternode
+ move strMasterNodeAddr to CActiveMasternode

a005c79 Refactor InstantSend
+ new lock cs_instantsend to protect maps on CleanTransactionLocksList()
+ new DEFAULT_INSTANTSEND_DEPTH constant
+ rename MIN_INSTANTX_PROTO_VERSION to MIN_INSTANTSEND_PROTO_VERSION and bump it

d24182c Refactor Privatesend
+ decouple from util.h and version.h
+ more functions for CDarksendBroadcastTx: constructors, signing, serialization
+ move from rand() to insecure_rand() in general but to GetRand() for session id
+ fix defaults
2016-08-05 21:49:45 +02:00
UdjinM6
d514ee7f9a Merge #922: Refactor/fix spork
42bdf42 Refactor/fix spork:
- move ProcessSpork, GetSporkValue, IsSporkActive, ExecuteSpork and mapSporksActive to CSporkManager
- move Sign, CheckSignature, Relay to CSporkMessage
- move ReprocessBlocks out of sporks to main.cpp / rename DisconnectBlocksAndReprocess to DisconnectBlocks
- rename SporkKey to SporkPubKey
- bugfix: only set strMasterPrivKey if spork signature produced by that key was verified successfully
- few log format changes, cleaned up includes
2016-07-30 13:04:27 +02:00
UdjinM6
90adb89233 Merge #903: Implement transaction lock zmq notifications
15a6a16 Implement transaction lock zmq notifications
3bc86a6 always push zmqpubhashtxlock even if tx is not from/to our wallet
568315b fix typo
b6d41d2 fix data size for notification name
339be11 implement zmqpubrawtxlock
70f44f9 update zmq_sub.py with hashtxlock and rawtxlock
2016-07-15 08:38:33 +02:00
UdjinM6
175508d6b7 Merge #908: Remove global strMasterNodePrivKey
00743b8 Remove global strMasterNodePrivKey - no need to extract keys all the time, store them in CActiveMasternode and reuse when needed
2016-07-15 08:36:00 +02:00
UdjinM6
9764e22ed8 Merge #893: Cleanup
3249a63 Fix logging - CTransaction::ToString() always has `\n` at the end of a string, avoid adding empty line
ec03753 make mnw errors and ThreadCheckDarkSendPool less spammy
5b678af fix errorMessage - it should not have `\n`, let output code handle line endings instead
a81cdf7 rename `dash-darksend` thread to `dash-privatesend`
5e4f468 fix/remove outdated code
f1c9678 Break tooltip about third party urls in 2 lines
2016-06-27 17:25:22 +02:00
UdjinM6
f5e3042b7a create INSTANTSEND_MIN_FEE to manage IS fee in one place (#829) 2016-05-30 08:22:15 +02:00
crowning-
7ee810d3b6 [UI] Rebranding: PrivateSend/InstantSend (update 2) (#804)
* [UI] Rebranding: PrivateSend/InstantSend (update 2)
* [UI] Changed name of sendtoaddress parameters: use_ix -> use_is and use_ds -> use_ps
2016-05-25 07:25:16 +02:00
UdjinM6
00915ca31a Fix IX (locks arrive faster then the lock request itself) and add ixnotify to trigger external script 2016-03-24 19:05:44 +03:00
UdjinM6
5e7496ee5e More refactoring for IX:
- move ix internal logic out of CMerkleTx
- fix bug in GetInputAgeIX
2016-03-23 17:51:41 +03:00
UdjinM6
f679e24316 Refactor IX/DSTX messages handling:
- Fix CreateTransaction and GetDepthInMainChain for IX compatibility
 - Prepare IsIXTXValid for the next update (see FIXME in CreateTransaction)
 - Unify processing of TX/IX/DSTX a bit more
 - Clean up some code
2016-03-22 02:24:36 +03:00
UdjinM6
8e560080a1 Fix comments, remove ._str() from LogPrintfs, few trivial changes 2016-03-06 18:21:06 +01:00
UdjinM6
67cd10c87d Add some locks to protect chainActive.Tip() and mapBlockIndex
(fixing only few of them here, see next commit for further changes)
2016-03-04 12:10:37 +03:00
UdjinM6
95dab0b541 Remove unnecessary locks and chainActive.Tip() references 2016-03-04 12:10:37 +03:00
UdjinM6
c676748beb Replace all hardcoded network message strings with NetMsgType:: constants, log unknown commands (net debug category only) 2016-02-19 07:59:00 +03:00
UdjinM6
a5ac60b868 Merge remote-tracking branch 'bitcoin/0.12' into HEAD
+ merge fixes
+ keepass on evhttp
2016-02-06 16:48:04 +03:00
UdjinM6
e2aaf09700 Cleanup
- lower unobvious dependency through header files, move few includes to the right places
- some trivial code cleanup

Closes #680
2016-01-31 12:08:45 +01:00
UdjinM6
657bd1103e Few cleanups:
- compiling errors
- output
- CBitcoinAddress usage cleanup
- refresh qt project file
- fix typo in `masternode` debug category
2015-08-28 23:16:58 +03:00
evan82
dac2b0fae5 Merge pull request #490 from UdjinM6/v0.12.0.x_process_on_IsBlockchainSynced
V0.12.0.x process DS,IX,MN,DGBB on IsBlockchainSynced, not on IBD
2015-08-07 06:18:50 -07:00
UdjinM6
8063bcc8aa process DS,IX,MN,DGBB on IsBlockchainSynced, not on IBD 2015-08-07 07:48:55 +03:00
UdjinM6
f57c470f95 ask for mn / lower ban score for mnw 2015-08-07 06:07:40 +03:00
UdjinM6
7d78c98f0d Few more lock-related fixes:
- do not lock cs_main for mnodeman.CheckAndRemove() - we have trylock inside CMasternode.Check, should be enough
- fast cs_main lock for ix
- use RelayInv instead of manually locking nodes / pushing inv
- do not lock cs_vNodes / ClearFulfilledRequest on every 100th block, CMasternodeSync should already handle resync by itself better now
2015-08-05 01:54:31 +03:00
Evan Duffield
c770283371 Lower IX conf minimum
- 1 less than the "send IX" gui requires, incase of a block propagating the network at the time
2015-08-04 10:42:05 -07:00
Evan Duffield
334c3ea971 Added ReprocessBlocks 2015-08-02 16:08:37 -07:00
evan82
718c7f14f9 Merge pull request #384 from UdjinM6/v0.12.0.x_debug_categories
V0.12.0.x additional debug categories
2015-08-01 15:48:03 -07:00
Evan Duffield
fa9a0ec037 Use reconsider blocks for IX instead of disconnect 2015-07-31 12:39:02 -07:00
UdjinM6
1c7c81afb3 cleanup other incorrect ix log outputs 2015-07-31 18:52:19 +03:00
UdjinM6
184611f2ac add instantx debug category 2015-07-31 18:52:19 +03:00
UdjinM6
afd715286a fix all kind of lock issues 2015-07-30 16:44:18 +03:00
Evan Duffield
304ab6c7ab Various improvements to the proposal system
- Proposal scripts are now checked correctly
- Fee transactions are created correctly for IX and non-IX types
2015-07-12 14:02:39 -07:00
Evan Duffield
c701839a43 Proposal Security Overhaul
Submissions to the network now require a fee to be paid to the network (mining fee) using a special transaction with a OP_RETURN && ProposalHash in one of the outputs. This allows the network to filter spam quickly, while also allowing anyone to submit a proposal to the network.

To implement these changes we've introduced a few new commands:

mnbudget prepare PROPOSAL-NAME URL PAYMENT_COUNT BLOCK_START DASH_ADDRESS DASH_AMOUNT YES|NO|ABSTAIN [USE_IX(TRUE|FALSE)]
- To create the special transaction

mnbudget submit PROPOSAL-NAME URL PAYMENT_COUNT BLOCK_START DASH_ADDRESS DASH_AMOUNT YES|NO|ABSTAIN FEE_TX
- After the transaction is accepted by the network and has 3 confirmations, you can submit the transaction to the network here

mnbudget show
- Get the proposal hash from here

mnbudget vote PROPOSAL-HASH YES|NO|ABSTAIN
- You can now simply vote by hash using this command
2015-07-11 13:20:12 -07:00
evan82
2a3b96e020 Merge pull request #411 from UdjinM6/v0.12.0.x_various_small_fixes
V0.12.0.x various small fixes
2015-07-08 07:19:41 -07:00
UdjinM6
9cfdaffee5 introduce RelayInv 2015-07-08 04:31:10 +03:00
UdjinM6
d94967d958 small fixes 2015-07-07 15:47:22 +03:00
Evan Duffield
f1b868f098 Removed PoSe due to consensus issues
- With nodes coming and going on the network, the network could come to different opinions about who should get paid next in line due to some nodes being flagged as failing a PoSe check. This will have to be fixed by introducing a blockchain based PoSe system, but that's out of the scope of this release. To fix the issues in the interrim, I'm removing PoSe checks for the time being.
2015-06-23 16:44:31 -07:00
UdjinM6
d53968ea56 fix ix comments 2015-06-04 21:54:33 +03:00
UdjinM6
64eebc3316 0.12 dirty merge'n'fix (bitcoin 0.10) 2015-04-04 19:24:37 +03:00
Evan Duffield
e5267319ef Complete implementation of Proof-of-Service
- Ensures ports remain open and client are responsive to IX requests.
- Completely 100% decentralized. This farms out the work of checking the masternode network to the masternode network. 1% of the network is determistically selected to check another 1% of the network each block. It takes six separate checks to deactivate a node, thus making it tamper proof.
- Nodes are kept in the masternode list if they fail enough PoSe checks to deactivate. They will continue to be checked until the operator fixes them. However they will not be paid while they're failing checks.
2015-03-16 09:32:18 -07:00
UdjinM6
2e0d7ab0b6 fix even more console spam 2015-03-05 19:40:17 +03:00
UdjinM6
1ded1b9ec2 Few fixes for processing extra messages:
- call ProcessMessageMasternodePayments on ProcessBlock (lost after moving mnodeman functionality)
- do not process extra functionality messages (DS, IX, spork) on initial download / reindex
2015-02-26 17:40:43 +03:00
UdjinM6
0d51e1c90d better naming/readability (Find) 2015-02-25 14:54:03 +03:00
UdjinM6
adddff85a2 CMasternodeMan - masternode manager class - part1(broken) 2015-02-23 23:01:21 +03:00
Evan Duffield
23ea75f737 Add maximum out value for IX via spork 2015-02-11 08:08:55 -07:00
Evan Duffield
257078d2a4 Full Spork Implementation
Many sporks are supported at once, with efficient broadcasting
via inventory messages.
2015-02-09 12:49:00 -07:00
Evan Duffield
dd48c4a352 enable IX when fork detected 2015-02-08 11:59:09 -07:00
Evan Duffield
ddc31b0ff7 fixed issues with ix signature propagation 2015-02-07 20:54:36 -07:00
Evan Duffield
2f56ecb10a protocol version 2015-02-07 20:04:08 -07:00
Evan Duffield
3a263ed1bf fixed platform issues with calcscore / better re-converge after fork 2015-02-07 10:30:16 -07:00
Evan Duffield
3a72da77ac clean up tx lock votes on expiration 2015-02-06 13:19:22 -07:00
Evan Duffield
012f0e5660 Implemented inventory system for IX messages 2015-02-06 12:07:22 -07:00
Evan Duffield
dfb3da5ec3 version/protocol bump/min protocol 2015-02-06 09:03:50 -07:00
Evan Duffield
b65d718cf5 debugging 2015-02-06 08:54:39 -07:00
Evan Duffield
76e36bfbea only vote when in the top X nodes 2015-02-05 21:41:17 -07:00
Evan Duffield
6149e55710 extend txlock expiration 2015-02-05 17:49:55 -07:00
Evan Duffield
b27a6a3cac fixed score calculation 2015-02-05 17:32:03 -07:00
Evan Duffield
f51ee91a2c track requests per IX 2015-02-05 11:29:13 -07:00
Evan Duffield
d5376687d4 improvements for resolving forks 2015-02-05 10:56:11 -07:00
Evan Duffield
97d73a72b5 cancel out conflicting locks 2015-02-05 09:48:57 -07:00
Evan Duffield
c8fc2633ee Various IX improvements
- Fixed a segfault with listtransactions and IX
- Improved the feed back of IX while processing
2015-02-05 08:52:02 -07:00
Evan Duffield
77bade91be version bump 2015-02-04 21:05:36 -07:00
Evan Duffield
4064c2f5ef Improved IX security / quicker tx scanning 2015-02-04 14:59:19 -07:00
Evan Duffield
ea06ed5bae fix segfault with disablewallet 2015-02-04 14:19:18 -07:00
Evan Duffield
6ae98a8790 use authoritive block height for IX 2015-02-04 14:09:50 -07:00
Evan Duffield
2a0d3dfb9d Use hash after transaction was mined
- Prevents an attacker from gaming which masternodes they'll use
2015-02-04 13:25:12 -07:00
Evan Duffield
712eb7e9d9 improved conflict resolution 2015-02-04 13:20:13 -07:00
Evan Duffield
efe22ea1ae fixed segfault 2015-02-04 07:44:23 -07:00
Evan Duffield
b1c772a190 minimum fees for IX 2015-02-04 03:44:41 -07:00
UdjinM6
877405c8fb use more common syntax to make it clear that actually 6 confirmations are required for IX to work / +comments 2015-02-04 13:20:33 +03:00
Evan Duffield
d4896934e1 add transaction scanning for new transactions 2015-02-03 18:35:29 -07:00
Evan Duffield
e3ef585263 minor changes 2015-02-03 18:19:54 -07:00
Evan Duffield
f4b26d6f10 Enforcing IX locks
- Scan IX locks on new blocks to make sure no conflicting txes are present
- Upon completion of a IX lock, check for conflicts and remove blocks if needed
2015-02-03 15:40:00 -07:00
Evan Duffield
feb9a1e922 Improved masternode payments 2015-02-03 10:17:30 -07:00
Evan Duffield
2992907d91 Better DOS protection, fixed min confirmations 2015-02-02 10:33:52 -07:00
Evan Duffield
d07014ce1e add simple dos protection / IX vote class improvements 2015-02-02 07:38:50 -07:00