Commit Graph

108 Commits

Author SHA1 Message Date
UdjinM6
6a3550b94f Fix some gov sync issues (#1191)
* Don't relay objects and votes until synced

* fix sync timeout for govobjs

* count objs and votes separately

* reuse GetHash() value, adjust log messages
2016-12-06 20:40:37 +04:00
UdjinM6
0e28de7e10 Merge #1189: release nodes after loop in CMasternodeSync::ProcessTick() 2016-12-05 11:06:51 +01:00
UdjinM6
b847642428 bug: int -> int64_t (#1179) 2016-12-02 16:53:28 +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
d9d6d4f6eb fix deadlock on sync (#1104) 2016-10-30 23:40: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
2feb321c2e IsBlockchainSynced should not proceed until we are past the latest checkpoint (#1070) 2016-10-11 01:11:20 +04:00
Evan Duffield
bdf1a6d24d Merge pull request #1045 from UdjinM6/fixSync1
Various sync fixes
2016-09-29 14:21:47 -07: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
UdjinM6
cfeda84a3c Do not switch from MASTERNODE_SYNC_SPORKS to next asset until blockchain is synced 2016-09-27 12:02:57 +03:00
UdjinM6
174ee8f880 apply IBD-like logic in IsBlockchainSynced 2016-09-27 11:56:10 +03:00
UdjinM6
b8557662d3 Rewrite fulfilled requests handling (#1040) 2016-09-27 11:50:04 +04:00
UdjinM6
d6637c2e8e simplify CMasternodePayments::IsEnoughData (always using GetStorageLimit) (#1025)
* simplify CMasternodePayments::IsEnoughData (always using GetStorageLimit)
2016-09-21 19:32:42 +04:00
UdjinM6
ec239ffa36 Mostly winner -> payment vote (#1033)
Followup for the recent winner_block PR (#1028) and name confusion discovered during code review.

"Mostly" because also:

- CMasternodeBlockPayees::GetPayee -> CMasternodeBlockPayees::GetBestPayee which describes what this function is actually doing a bit better imo;
- fixing constructor CMasternodePaymentVote empty constructor
2016-09-21 18:45:29 +04:00
UdjinM6
1e2d61ad0d Implement a way to sync only needed winners (#1028)
* store vote hashes in CMasternodePayee and use them in CMasternodePayments::Sync

* Request low data payment blocks in batches directly from some node instead of/after preliminary Sync.

* remove nVotes
2016-09-19 02:23:52 +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
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
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
7b10f9aaa6 Refactor CMasternodeSync (#956) 2016-08-28 14:12:14 +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
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
b4cb1e2610 Merge #911: Fix sync process: (#911)
- mn hash compatibility with 70103
- ignore some requests while syncing
- fix locking/initializing in sync
- do not ban for old mnw
- split budget/governance messages/invs
2016-08-05 18:25:03 +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
UdjinM6
989317c036 fix mnw sync issues (#825) 2016-05-29 20:35:09 +02:00
Evan Duffield
5e990d3859 fixed cleanup for sync 2016-05-24 13:14:47 -07:00
Evan Duffield
349e750e73 Cleanup
- removed some old comments
- renamed sync tracking requests to friendlier names
2016-05-24 13:12:20 -07:00
Evan Duffield
c6e0643d9e enabled governance item syncing 2016-05-24 12:25:33 -07:00
Evan Duffield
ac913c0258 Removed unimplemented commands / mnquorum / mnscanerror
- Scanning errors should be implemented via sentinel
2016-05-24 12:20:10 -07:00
Evan Duffield
60e048071f added budget item func 2016-05-09 09:31:11 -07:00
Evan Duffield
aee86618cd fixed greedy find/replace (opps) 2016-05-05 10:30:28 -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
Evan Duffield
6a68aea461 cleanup 2016-04-14 19:54:11 -07:00
Evan Duffield
019eb07ac0 almost compiles 2016-04-12 09:00:19 -07: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
UdjinM6
04efdd1150 Fix mn sync: - reset lasttime* right before switching to next asset - adjust target block count by 1.2 coeff - lower MASTERNODE_SYNC_TIMEOUT 120 -> 30
Closes #728
2016-03-09 07:22:54 +01:00
UdjinM6
a611fc3b1b Introduce CDSNotificationInterface - validation interface to listen to tip updates and trigger updates in DS, payments and budgets. Should significantly reduce number of references to chainActive.Tip() i.e.we should have less cs_main in dash-darksend thread and potential deadlocks. 2016-03-04 12:10:37 +03:00
Evan Duffield
89ff8a6d7e merged and fixed messages 2016-03-03 06:55:32 -07:00
Evan Duffield
a2fdef43e2 merged 2016-02-22 12:53:52 -07:00
UdjinM6
b654a6a320 refactor sync progress ui to use signals, remove lock from masternode str ui 2016-02-19 21:09:54 +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
a4aef837bd Merge remote-tracking branch 'origin/v0.12.1.x' into mergebtc0.12 + fix 2016-02-16 03:17:25 +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
5a04fb6a2f Syncing is working quite nice :) 2016-02-04 15:55:07 -07:00
Evan Duffield
8628cb7992 removed printf debugging for syncing process 2016-02-04 15:54:35 -07:00
Evan Duffield
65e480fc62 Syncing is working quite nice :) 2016-02-04 15:48:23 -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
8d1609f0a5 translations 20150902 2015-09-03 00:32:34 +03:00
Evan Duffield
25894972c1 reduce memory usage 2015-09-02 05:13:32 -07:00