Commit Graph

180 Commits

Author SHA1 Message Date
UdjinM6
17cebbed15 fix excessive banning, remove some redundant logic (#1172)
* Since we send all mnb's now regardless of mn state, ping check for sigTime being too old is obsolete (and wrong).
Also removing fRequireEnabled, this logic is deprecated too it seems.

* remove (pre-)enabled check in CMasternodeMan::Add
2016-11-30 05:33:37 +04:00
Tim Flynn
c31ba8ba4c New vote tallying implementation (#1135) 2016-11-13 21:52:34 +04:00
UdjinM6
afc74707f8 PoSe changes: (#1105)
* PoSe changes:
- use helpers to alter nPoSeBanScore within predefined range only
- use nPoSeBanHeight instead of timeout of inactivity to ban masternodes till some block in the future (currently should block for the whole payment cycle)
- add log output on pose score increase in CheckSameAddr
2016-10-31 00:56:47 +04:00
Tim Flynn
1a81c341bc Set initial masternode last watchdog time to mnb.sigTime (#1098)
Set last watchdog time to mnb.sigTime when masternodes are first added or updated from a broadcast
2016-10-27 20:00:06 +04:00
UdjinM6
19569c1d66 Fix CActiveMasternode (#1102)
* add GetStateString and static CMasternode::StateToString helpers

* Fix CActiveMasternode:
- should run `ManageStateLocal` only when `eType == MASTERNODE_LOCAL`
- should set `nState = ACTIVE_MASTERNODE_NOT_CAPABLE` in `ManageStateInitial` to let `GetStatus` return proper message
- more/better log output
2016-10-27 01:21:39 +04:00
Tim Flynn
e30f8bf6a0 Allow masternode broadcasts to update masternode information regardless of state (#1094)
* Allow MN broadcasts to update MN information regardless of state

* Add masternode public keys to log output for debugging

* Moved log message from start-alias to CMasternodeBroadcast::Create

* Fixed log message
2016-10-25 18:37:33 +04:00
UdjinM6
c0a830aa8e fix fCheckSigTimeOnly (renamed to fSimpleCheck) in CMasternodePing::CheckAndUpdate (#1093) 2016-10-25 17:46:21 +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
66c40e0687 always check for valid block hash in mnping (#1076) 2016-10-21 01:12:42 +04:00
UdjinM6
342bda5fdc new PoSe - MNVERIFY (#1066) 2016-10-21 01:11:30 +04:00
Tim Flynn
94e38e3184 V0.12.1.x sentinel watchdog pr (#1079)
Squashed:

* Replaced unsafe mnodeman.Find function with Get in governance-vote.cpp

* Reject unparsable governance objects

* Implemented sentinel watchdog objects (separated out from locking changes)

* Added WATCHDOG support to rpcgovernance.cpp

* Implemented WATCHDOG_EXPIRED state for masternodes

* Added serialization of watchdog timestamps

* Masternode fixes
 - Added version check to CMasternodeMan deserialization
 - Added several missing locking calls in CMasternodeMan

* Fixed missing member initialization in CMasternode constructor and added more logging

* Added MASTERNODE_WATCHDOG_MAX_SECONDS to governanceinfo

* Added masternodewatchdogmaxseconds info to getgovernanceinfo help

* Make masternodes remain in WATCHDOG_EXPIRED state unless removed or collateral expires

* Allow watchdog object creation by WATCHDOG_EXPIRED MN

* Fixed MN validation logic for governance object creation

* Count total masternodes instead of enabled masternodes in masternode-sync

* Transition out of WATCHDOG_EXPIRED state if the watchdog is inactive

* Fixed IsWatchdogExpired bug

* Fixed rate check for watchdog objects and no longer check MN state when validating governance objects

* Applied PR #1061 patch

* Ported locking changes from other branch

* Require only 1 block between new watchdog objects

* Accept pings for WATCHDOG_EXPIRED masternodes

* Lock CmasternodeMan::cs in CmasternodeMan::ProcessMessage

* Several governance changes
 - Fixed uninitialized value in CGovernancePayment class
 - Return an error on submission if any superblock payment cannot be parsed
 - Added logging more statements

* Explicitly initialize all governance object members

* Fix deadlock

* Fixed non-threadsafe access to masternode in activemasternode.cpp

* Revert added wallet lock

* Changed CActiveMasternode so that watchdog expired nodes can still send pings

* Modified CActiveMasternode to run pinger regardless of state when MN is in list

* Added voter and time information to getvotes command

* Improved CActiveMasternode state management

* Implemented GetInfo functions for more efficient thread-safe access to masternode information

* Added CActiveMasternode debug logging messages

* Fixed initial type setting and error message for incorrect protocol version

* Changes based on code review comments

* Set active state for local mode
2016-10-17 22:54:28 +04:00
UdjinM6
d5dcf2b668 Refactor CalculateScore, move GetBlockHash out of it (#1068) 2016-10-13 13:45:18 +04:00
UdjinM6
321fd64921 Masternodes should be allowed to annonce ipv4 addresses only from now (#1065) 2016-10-10 13:13:07 +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
4ccc32615d Linearize and simplify few CMasternode* functions (#1020)
* linearize CMasternodePing::CheckAndUpdate

* simplify CMasternodeMan::CheckAndRemove

* linearize CMasternodeMan::ProcessMessage, DSEG part

* fail fast in CMasternode::Check on spent vin, slightly improve readability
2016-09-15 17:30:51 +04:00
UdjinM6
a3ffedba7c masternode score related fixes (#1019)
* refactor CalculateScore (remove mod, remove extra cs_main lock)

* remove GetCurrentMasternode, use GetNextMasternodeInQueueForPayment instead

* fix masternode rpc "current" (calculate node to pay next block), add rpc "winner" (calculate node to vote for)

* remove "calcscore" rpc
2016-09-15 10:50:41 +04:00
Evan Duffield
6f84dc15c0 Merge pull request #1009 from UdjinM6/lastPaid
Improve mn winners detection
2016-09-13 08:35:59 -07:00
UdjinM6
0534632d2b add cs_main lock to GetCollateralAge 2016-09-12 21:06:59 +03:00
UdjinM6
57eb2e1842 Update and store collateral block height and block height at which MN was last paid (scan blockchain to find out who actually was paid). Use storage limit instead of mn count to fetch enough data. Calculate new winner using info about block height at which MNs were paid instead of time. 2016-09-12 02:03:59 +03:00
UdjinM6
08f8300985 Remove deprecated masternode sync members 2016-09-11 21:00:45 +03:00
UdjinM6
36c4b6dc2e Trivial refactoring/cleanup (#990) 2016-09-05 20:09:25 +04: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
Tim Flynn
de7b2b6c51 Merge #944: V0.12.1.x governance pr - part 1 - base functionality
068c178 Added DBG macro in util.h to facilitate debugging

    - This macro allows debugging statements (typically printf's or cout's) to
      be activated or deactivated with a single comment.  Uncomment the line:
      //#define ENABLE_DASH_DEBUG
      in util.h to enable debugging statements.

    - When commented any code wrapped with the DBG() macro will simply be removed
      by the preprocessor.  When not commented all such wrapped statements will
      be present.

    - For maximum effectiveness it is best that util.h be the first effective include
      in all source files.  It is also possible to enable the macro for a single file
      by temporarily adding #define ENABLE_DASH_DEBUG to the top of the file.

    - Code committed to non-development branches should always have the define
      commented.

d125d9b V0.12.1.x -- merging trigger/generic object/superblock changes for testnet phase II

    - This commit contains the core governance system changes for 0.12.1.  Any unrelated
      changes have either been removed or moved to separate commits.

120724c File mode fixes

    - Changed mode 0755->0644 on several source files.

c7f9e11 Updated todo reminders

    - Added reminder to revert temporary reduction of number of votes
      required to trigger superblock to 1 for testing

92adc98 Made CSuperblockManager::IsValidSuperblockHeight an inline function

    - This is for efficiency since this function is called often and is
      only 1 line of code.

c050ed7 Added comment explaining rationale for no LOCK(cs) in CSuperblock::IsValid

dc933fe Removed unused CSuperblockManager::IsBlockValid function

decec88 Moved calls to SuperblockManager::IsValidSuperblockHeight into IsSuperblockTriggered.

    - Since calls to the later function are always protected by the former there's
      no reason to keep these separate and this simplifies the code in
      masternode-payments.cpp.

8672885 Reestablished expected value check for non-superblocks in IsBlockValueValid

b01cbe0 Changes to IsBlockValueValid to fix rpc test failure

a937c76 Changed include order to allow per file activation of the DBG macro

d116aa5 Fixed IsValidSuperblockHeight logic

    - Note this has an effect on testing because we can now only create
      1 superblock per day.  Devs may need to temporarily change testnet params
      for easier testing.

2d0c2de Convert superblock payments to CAmount

    - We assume that payment values in JSON are in units of DASH
      for consistency with other RPC functions, such as
      createrawtransaction.

376b833 Revert temporary testing value for nAbsVoteReq

    - Also ensure that number of votes required is never smaller than 1

8c89f4b Cleaned up CSuperblock error handling

    - Exceptions are now thrown consistently rather than using a mix of
      exceptions and return code checking.  Exceptions are now caught only
      in AddNewTrigger when the CSuperblock constructor is called.  Unnecessary object
      status members have been removed.

d7c8a6b Removed utilstrencodings header

    - This appears to help with travis tests, for unknown reasons.

c4dfc7a Fixed some minor code review issues

63c3580 Reverted locking change in miner.

    - This should have been done in the original PR but was overlooked.

4ab72de Fixed variable name to match common practice and bracket formatting

886a678 Improvements to vote conversion code

    - Replaced redundantly defined function with inclusion of governance-vote.h

    - Replaced magic numbers with their corresponding constant symbols

0a37966 Reordered governance message handling
2016-08-17 09:08:25 +02:00
UdjinM6
a73c31f3f0 Fix GetBlockHash - Currently it's doing the job already done by chainActive and it's off by 1 block 2016-08-07 01:04: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
8f9544c46e Merge #917: Move broadcast creation to CMasternodeBroadcast
8ee7b8a Move broadcast creation to CMasternodeBroadcast
2016-07-29 07:32:08 +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
3d2bc6a4ca Merge #861: More compatibility for old ipv6 format + refactor
- try old format ipv6 if new format failed to verify
- sanitize log strings
- remove redundant ability to sign CMasternodeBroadcast in `protocolVersion < 70201` way
- verify CMasternodeBroadcast immediately on Sign
- move all CMasternodeBroadcast sig verification from CheckAndUpdate to VerifySignature
- initialize nDos at the beginning of functions so that we don't accidentally ban or reject legit MN if caller function forgot to reinitialize it
2016-06-03 06:59:19 +02:00
UdjinM6
284e2c41cc merge #855: Fix bad mn sig ipv6
51696ac make use of getnameinfo() optional (default: true)
bec39b8 fix mnb sig bug for ipv6 addresses: use pure byte to hex conversion for construction of masternode broadcast signature, better logging
2016-06-02 08:11:56 +02:00
UdjinM6
d705da741c fix masternode signatures, bump PROTOCOL_VERSION
strMessage for masternode broadcast (which we sign and verify) looks like this currently:
[2001:1608:45:3::242:ac11:6]:199991464464536
                                  ?~}&?Q?S?Ǚ?q	?0??????O?I/Y?(
?f?jJF??m??bssknN??9鲜JXVs?ә?5T?8??????~70200
which I believe in some cases leads to "Got bad Masternode ping signature" errors and banning.

I propose to change the way strMessage is composed so that it looks like this:
[2002:82ff:c04:2:a90f:2261:43c4:2745]:1999514645552319591ec70225aacadfafa4ab5d21e87cdce641fd4030d029485434533c5e481578a9d471089fb5ec170200

Further more nDos for old masternodes is set to 0 to stop false positives (message still gets rejected though).
2016-05-30 11:37:35 +03:00
UdjinM6
4d55bc9666 Cleanup/maintenance (#830)
* remove instance references inside own class

* better logging

* remove unused

* fix tabs/spaces

* bitcoin->dash

* fix README.md
2016-05-30 08:22:30 +02:00
UdjinM6
9745914c15 remove hardcoded strDarksendPoolDummyAddress (#828)
- use "" account address instead
- remove `collateralPubKey` and `SetCollateralAddress()` from darksend and create `dummyScriptPubkey` and `InitDummyScriptPubkey()` in masternodeman instead
- initialize `dummyScriptPubkey` before loading cache otherwise MNs could be removed because of the invalid tx
2016-05-30 08:22:08 +02:00
UdjinM6
c3b950d457 fix mn anounce: (#813)
- every node should check for "pre-enabled" status of a newly added mn to relay message further (was "enabled" which is wrong - if node is enabled, that's not the first announce, so no need to relay it because most likely we were the one who asked for that mn directly via dseg)
- we should not add ourselves to mn list if announce message has outdated protocol version (report this in log)
- we should remove ourselves from saved list if we start updated mn for the first time and just loaded old list from mncache.dat
2016-05-27 08:24:44 +02:00
UdjinM6
87ad368643 Optimize processing of a (potentially) new MN:
- Move heavy `IsVinAssociatedWithPubkey` deep inside of `CheckInputsAndAdd` to be actually executed only once per masternode and only after much simpler checks were executed;
- Verify `GetInputAge` (it uses cache) before trying to enter `AcceptToMemoryPool` (which hash many ifs and checks inside).
2016-05-24 03:15:53 +03:00
Evan Duffield
d8453bb92b Use chainparams instead of standalone func for mn confirms
- Use function instead of chainparams directly
2016-05-19 13:54:23 -07:00
Evan Duffield
2ca8c85820 fixed voting errors 2016-05-19 11:34:43 -07:00
UdjinM6
eaf57b3fb7 Implemented masternodebroadcast
This set of rpc commands provide an ability to create masternode broadcast messages offline
and relay them from online node later (messages expire in ~1 hour).

Arguments:
1. command        (string or set of strings, required) The command to execute
2. passphrase     (string, optional) The wallet passphrase
Available commands:
  create-alias  - Create single remote masternode broadcast message by assigned alias configured in masternode.conf
  create-all    - Create remote masternode broadcast messages for all masternodes configured in masternode.conf
  decode        - Decode masternode broadcast message
  relay         - Relay masternode broadcast message to the network

Closes #741
2016-03-17 08:29:53 +01:00
UdjinM6
38f386ae1c Few small changes: - Better log output (a bit more granular for mnb, fixing "\n"s and few other small issues) - Unify variable/class members naming a bit
Closes #733
2016-03-16 07:48:37 +01:00
TheLazieR Yip
8675ce1929 Check New MasterNodeBroadcast Time
Closes #722
2016-03-07 12:00:29 +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
6fc9b4c772 Replace hardcoded 9999 with Params(CBaseChainParams::MAIN).GetDefaultPort() 2016-02-17 21:52:37 +03:00
UdjinM6
a4aef837bd Merge remote-tracking branch 'origin/v0.12.1.x' into mergebtc0.12 + fix 2016-02-16 03:17:25 +03:00
UdjinM6
832e7505dd Merge remote-tracking branch 'bitcoin/0.12' into mergebtc0.12
+ fix AcceptToMemoryPool fDryRun for mnb
2016-02-06 18:53:20 +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
Evan Duffield
83f87b0f2d merged 2016-02-04 12:39:53 -07:00
Evan Duffield
eeb53b9682 Vastly faster syncing process / small budget system changes
- Syncing process is now event based, rather than timeout based. This means the system can tell when it's done with each step and moves on between phases much faster. In initial testing it seems to be about 10-15x faster and has synced everytime successfully.
- Please remove print debugging when the syncing system is proven to be debugged.
2016-02-04 12:29:09 -07: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
evan82
ddf71c0764 Merge pull request #561 from UdjinM6/v0.12.1.x_pre_enabled
V0.12.1.x pre-enabled status from masternodes
2015-09-22 07:14:10 -07:00
UdjinM6
f68a5d8102 remove depreciated dsee/dseep code
Closes #606
2015-09-12 16:35:37 +02:00
Evan Duffield
eebb03eb13 reduce memory usage 2015-09-02 05:20:06 -07:00