Commit Graph

69 Commits

Author SHA1 Message Date
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
Tim Flynn
8fc8e6c8c2 Implement rate check using buffer (#1202)
* Implemented buffer for masternode rate checks

* Change upper limit on object timestamp to 1 hour in the future
2016-12-14 19:28:55 +04:00
Tim Flynn
df5abf1468 Convert masternode rate checks to use object timestamp (#1198)
* Change rate check logic to avoid DoS attacks

* Convert rate check to use object timestamp instead of arrival time

* Update cached variables before checking for superblocks

* Ensure that last times are monotonically non-decreasing

* Bump governance manager serialization format

* Improved rate check error reporting
2016-12-11 10:17:38 +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
Tim Flynn
8c12ab2b47 Don't penalize nodes during orphan processing (#1181) 2016-12-02 16:53:18 +04:00
Tim Flynn
e3e5b81a8d Removed CGovernanceManager::ClearSeen() (#1171) 2016-11-29 17:32:41 +04:00
Tim Flynn
286f6ad87e Add watchdog expiration map to governance cache (#1170)
* Fix misspelled logging category

* Added mapWatchdogObjects to governance cache and bumped format version
2016-11-29 04:01:03 +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
Tim Flynn
ecdc160119 Governance object deletion changes (#1167)
* Increase quorum for object deletion to 2/3 of MN network

* Implement expiration of watchdog objects

* Remove objects from the watchdog map itself

* Message fix for invalid objects
2016-11-25 18:08:48 +04:00
Tim Flynn
1b90d66ab6 Implement orphan object and vote timeouts (#1166) 2016-11-24 22:12:05 +04:00
Nathan Marley
ec59862506 Implement getcurrentvotes JSONRPC call (#1164) 2016-11-22 23:26:36 +04:00
UdjinM6
9c4e019c36 bump proto (#1162)
70202 -> 70203
2016-11-22 19:14:28 +04:00
Tim Flynn
e59bee8114 Masternode syncing changes (#1149)
* Modified DSEG to send mnb regardless of state

* Removed unused function

* Deactivate rate check when processing masternode orphan objects
2016-11-18 18:17:22 +04:00
Tim Flynn
90bd7cb62b Implemented delay for governance object deletion (#1151) 2016-11-18 18:17:00 +04:00
Tim Flynn
6deb3a65a3 Implemented missing masternode handling 2016-11-14 21:13:42 -05:00
Tim Flynn
35a45097ed Added IsValidLocallyMethod overload which returns masternode status flag 2016-11-14 21:13:08 -05:00
Tim Flynn
c31ba8ba4c New vote tallying implementation (#1135) 2016-11-13 21:52:34 +04:00
Tim Flynn
bc96f288ed Governance fixes (#1131)
* Added net logging messages in main.cpp

* Added logging for trigger removal

* Improved log message for CGovernanceManager::UpdatedBlockTip

* Improved log messages in CGovernanceManager::UpdateCachesAndClean

* Added more logging to CGovernanceTriggerManager

* Check vote validity before pushing inventory during sync

* Add triggers to map after loading governance.dat file
2016-11-05 20:13:30 +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
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
1eb399cf34 bump proto 70202 (#1054) 2016-09-30 22:19:26 +04:00
UdjinM6
231532d6d0 Align governance proto logic with logic for similar proto for other modules (#1049)
i.e MSG_GOVERNANCE_PEER_PROTO_VERSION -> MIN_GOVERNANCE_PEER_PROTO_VERSION (to check other peers) + PROTOCOL_VERSION (to announce own version)
2016-09-29 00:03:54 +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
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
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
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
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
Evan Duffield
b43381c2c6 Merge #878: governance propagation
98b7d29 fix invalid cached govobj values
581b46a added information explaining cached variable meanings
390c9c3 add dirty flag for future use
b76304e added other cached flags into output
2016-06-10 07:16:32 +02:00
Evan Duffield
95ba71570b Merge #864: govobj sync
487674f Governance object/vote syncing fixes
- disable fCached values
- use two maps for storing votes, by hash and parent-hash/type
- disable part of flatdb.dump (still overwriting)
- fixed govobj/votes relay and sync

15821fe various fixes
- Added const where possible
- Uncommented sync block
- Protocol min 70201
- Fixed bug which flags invalid votes incorrectly
- Formatting

aa8fdd7 fix curly braces

d8e39b1 Fix GetTypeHash bug
- Should not collide based on the outcome

732a8a3 fixed mismatched index for vote map
2016-06-08 08:57:16 +02:00
Evan Duffield
d0ad4ad0e4 V0.12.1.x govobj submission (#846)
* Remove nTime from IsCollateralValid and document function
2016-05-31 22:00:01 +02:00
Evan Duffield
a4954bf0fd Fixed governance object submission issues (#817)
- Terrible bug which caused governance objects to have their hashes corrupted, causing objects to become invalid
- More proposal -> governance name changes
2016-05-28 12:31:44 +02:00
Evan Duffield
5411d78b11 Fixed governance object submission issues (#812)
- Cleaned up governance object / added comments
2016-05-27 00:03:37 +02:00
Evan Duffield
8cbe280dd1 fix compiling issues 2016-05-25 09:56:58 -07:00
Evan Duffield
49ad98d1f3 cleanup 2016-05-24 11:29:23 -07:00
Evan Duffield
19664dac8f calculate sentinel flags from votes 2016-05-24 11:11:59 -07:00
Evan Duffield
869ff89d3b update gethash() 2016-05-23 15:52:10 -07:00
Evan Duffield
528c5edb19 fix fValid caching engine 2016-05-23 14:39:10 -07:00
Evan Duffield
18e9a33e2a changed fee to 0.1D for govobj submission 2016-05-23 11:16:46 -07:00
Evan Duffield
39d9ad87fb more refactoring 2016-05-23 11:10:20 -07:00
Evan Duffield
623ac049e2 More cleanup
- AddProposal -> AddGovernanceObject
- mapOrphanMasternodeBudgetVotes -> mapOrphanVotes
- UpdateProposal -> UpdateGovernanceObject
2016-05-23 10:58:39 -07:00
Evan Duffield
860d29f9c4 Budget system -> Governance System
- Changed Action -> Signal for clarity
- CBudgetVote -> CGovernanceVote
2016-05-23 10:53:05 -07:00
Evan Duffield
deb0f0ca14 fixed vote casting 2016-05-19 14:08:57 -07:00
Evan Duffield
9031c5e3cb Update some governance logic 2016-05-13 09:03:01 -07:00
Evan Duffield
ad5d48dae4 Created nice interface for converting between:
- vote outcomes between string and int
- vote actions between string and int
2016-04-26 11:27:22 -07:00
UdjinM6
71bdc09470 fix CGovernanceObject step1: make, copy constructor, uint256, rpc 2016-04-26 10:31:00 -07:00
Evan Duffield
3fe02f4777 any help? 2016-04-25 21:08:36 -07:00
Evan Duffield
fe5c4dd811 Converting governance system
- Generic usage of governance objects
- Added different voting types of signaling
- Removed budget commands (projection, mesc -- see sentinel https://github.com/evan82/sentinel/blob/master/docs/example4.md)
- Added various voting signaling mechanisms (origin funding, remove, valid, endorsed, milestones, outerstorage)
2016-04-19 09:51:15 -07:00