Commit Graph

30 Commits

Author SHA1 Message Date
Tim Flynn
c438e74563 Improve governance debugging information (#1221)
* Add missing MN vin to error message for missing masternodes

* Added creation time and masternode vin to gobject output
2016-12-22 07:20:05 +04: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
ff12698ed5 Clean up rpcgovernance (#1213) 2016-12-20 03:06:06 +04:00
UdjinM6
30da3f56a7 gobject rpc changes: (#1201)
- added description for 'deserialize'
- added 'type' filter to 'list'
- added 'count' command (changed CGovernanceManager::ToString to output a bit more detailed info)
2016-12-12 05:44:46 +04:00
Tim Flynn
15bb93d5e8 Rate check fixes (#1196)
* Fix rate checks for governance objects

* Do not update last vote time when rate checks are disabled

* Bump governance serialization version
2016-12-09 00:00:49 +04:00
Tim Flynn
4dac0025a7 Governance relaying fixes (#1195)
* Vote relaying changes
 - Remove vote relaying from ProcessVote
 - Remove vote relaying from orphan vote processing
 - Relay vote in ProcessMessages (only)

* Do not relay governance objects during orphan processing

* Restore relaying of local votes

* Changed overloaded function name: ProcessVote->ProcessVoteAndRelay
2016-12-07 08:16:34 +04:00
Nathan Marley
ec59862506 Implement getcurrentvotes JSONRPC call (#1164) 2016-11-22 23:26:36 +04:00
Spencer Lievens
73568be5a3 Remove Duplicated Include for darksend.h (#1150) 2016-11-18 00:39:08 +04:00
Tim Flynn
c31ba8ba4c New vote tallying implementation (#1135) 2016-11-13 21:52:34 +04:00
TheLazieR Yip
fb3b2f1853 Fix errors in DBG when compile with ENABLE_DASH_DEBUG defined. (#1111) 2016-10-31 13:11:57 +04:00
UdjinM6
ed0a0d2393 fix1087 (#1088) 2016-10-23 01:01:30 +04:00
Tim Flynn
1b230f4ddc Deadlock fixes (#1087)
* Fix deadlocks by reducing scope of cs_main locks in rpcgovernance.cpp

* Remove unnecessary mutex lock in GetMasternodeVinAndKeys which can cause a deadlock
2016-10-22 20:52:36 +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
Tim Flynn
0d324eafa8 rpcgovernance improvements (#1052)
* rpcgovernance improvements
 - Modified govject get to return full object data along with vote counts
 - Cleaned up vote count reporting code

* Added cached flags to gobject get output
2016-09-30 05:48:18 +04:00
Tim Flynn
ce28ad4206 Fixes to rpcgovernance.cpp (#1030)
* Fixes to rpcgovernance.cpp
 - Replaced use of non-unique public key with vin in vote-conf, vote-alias and vote-many
 - Replaced use of non-threadsafe CmasternodeMan::Find function with Get
 - Added LOCK(cs_main) to getgovernanceinfo

* Fixed rpcgovernance.cpp voting error messages
2016-09-19 01:11:03 +04:00
Tim Flynn
fcb985a93f Governance changes (#1029)
* Implemented several governance changes
 - Limit strData size to avoid propagation of very large messages
 - Remove unused CGovernanceObject::SetData method
 - Remove CGovernanceObject::strName field to avoid data redundancy

* Fixed parameter count bug in gobject prepare
2016-09-17 23:37:48 +04:00
Tim Flynn
4e6bb6a375 Fixed incorrect rpcgovernance error/usage message (#1023) 2016-09-16 11:43:15 +04:00
Tim Flynn
906c62e01c Fixes for a number of issues with governance object validation and propagation (#1018)
* Remove unnecessary call to IsCollateralValid and hence allow superblocks
to propagate

* Added CMasternodeMan::Get overload for masternode vin

* Use vin as masternode identifier instead of public key

* Fixed missing member in copy constructor, improved logging

* Added logging for MasternodeRateCheck failures

* Removed pubkeyMasternode field from CGovernanceObject

* Impose MN trigger creation rate limit only when MN info is synced

* Improve rpcgovernance error handling
 - Prevent attempts to prepare trigger objects (and waste the collateral)
 - Improve clarity of gobject submit error messages
2016-09-15 10:49:24 +04:00
UdjinM6
f5738c001f (trivial) governance cleanup (#1011)
* trivial governance cleanup:
- spaces
- names
- no "using namespace std;"
- few log and rpc messages adjusted
- remove unused
- use defined types
- move few members to private

* fixing after code review
2016-09-12 11:40:00 +04:00
Nathan Marley
1043252d43 consistent JSON return value for failed vote (#1001)
* consistent JSON return value for failed vote

* make JSON output for voting results consistent

* result should be either 'success' or 'failed'
* error message belongs in 'errorMessage' field
2016-09-12 05:17:41 +04:00
Nathan Marley
b31ee8441a restore vote-many (#1003) 2016-09-11 21:58:17 +04:00
Tim Flynn
d81e729b0a Governance bug fix (#998)
* Added more specific error message about attempts to submit superblocks by
non-masternodes

* Fixed governance object validation bug

* Fixed logic bug in governance object submission
2016-09-09 19:52:10 +04:00
Tim Flynn
f76f6fbb8e Governance Fixes/Refactoring Pack (#995)
* Improved exception handling
 - Removed attempts to catch exceptions in intermediate helper function calls
 - Made helper functions for JSON parsing private

* Governance voting fixes
 - Converted voting defines to enums for better type safety
 - Enabled gobject voteraw rpc command
 - Removed unused parameter from gobject getvotes rpc command

* Fixed help message for gobject get

* Improved encapsulation of CGovernanceVote objects
 - CGovernanceVote data members are now private
 - Necessary to ensure that enum values are used for signals and outcomes since data members remain int's for compatibility with serialiation code

* Removed unused cs_budget mutex (has been replaced with governance.cs)

* Fix code review issues
 - Restored early return in ConvertVoteSignal
 - Removed special case for "none" string to make clear that NONE is
   for invalid strings
 - Removed commented defines (informational comments preserved)

* Fixed code review issues
 - Fixed error messages for vote-conf, vote-alias and voteraw
 - Removed voteraw from gobject command list and help messages because
   it is actually a top-level command
 - Fixed parameter indices for voteraw
2016-09-08 15:40:19 +04:00
crowning-
a6a0f75614 Merge #982: [RPC] new command 'getsuperblockheight'
1080018 [RPC] new command 'getsuperblockheight' to return the last/next superblock height
2436067 [RPC] new command 'getsuperblockheight' [update 1]
753e00d [RPC] new command 'getsuperblockheight' [update 2]
1ec9289 [RPC] new command 'getsuperblockheight' [update 2]
dbac6e6 [RPC] new command 'getsuperblockheight' [update 3]
e1b7b15 [RPC] new command 'getsuperblockheight' [obsolete include removed]
ee85293 Code review results changes
2016-09-08 13:33:25 +02:00
Tim Flynn
5e564e17d3 Bug fixes for the governance rpc interface (#993)
* Bug fixes for the governance rpc interface
 - Allow use of the gobject getvotes command
 - Fix order of arguments to CGovernanceVote constructor

* Added getvotes to gobject help message and fixed parameter name in the
error/usage message.
2016-09-07 16:02:24 +04:00
Tim Flynn
8c09a459b1 V0.12.1.x governance fees pr (#988)
* Implemented different fees for different types of governance objects

* Added fee amounts to object returned by getgovernanceinfo

* Implement new requireents for Superblock creation
 - Superblocks creation requires a valid masternode signature
 - Superblock creation no longer requires a collateral fee
 - Superblock creation rate is limited to roughly 1 per masternode per cycle

* Fixed getgovernanceinfo help message

* Removed old governance fee constant

* Fixed bug in IsSignatureValid and added debugging code

* Fixed parent hash variable index and added debugging code

* Modified GetBudgetSystemCollateralTX to take fee amount parameter

* Changes due to code review comments
 - Naming changes
 - Removed confusing comment
2016-09-05 03:44:10 +04:00
Tim Flynn
0c65204ee6 Merge #967: V0.12.1.x sentinel pr 1 (#967)
d371930 Added nMinGivernanceQuorum chain parameter

6e24c9c Replace hardcoded minimum with nMinGovernanceQuorum parameter

66c0d9e Added new RPC calls needed by Sentinel
 - getsuperblockcycle
 - getsuperblockbudget
 - getmingovernancequorum

6bb2338 Replaced two new RPC calls with getgovernanceinfo

c9fbd8a Changed parameter nMinGovernanceQuorum to nGovernanceMinQuorum
2016-08-28 13:15:48 -06: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