Commit Graph

195 Commits

Author SHA1 Message Date
UdjinM6
d9d6d4f6eb fix deadlock on sync (#1104) 2016-10-30 23:40:30 +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
Tim Flynn
db3a4afddb Replaced LOCK with LOCK2 to prevent a deadlock (#1103) 2016-10-27 19:58:12 +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
342bda5fdc new PoSe - MNVERIFY (#1066) 2016-10-21 01:11:30 +04:00
Tim Flynn
cce7896d70 Allow last ping time to be updated for masternodes in the EXPIRED state (#1083) 2016-10-18 15:11: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
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
crowning-
e32e28afb9 [PrivateSend] Performance tweak: faster shuffling of Masternodes vector (#1063) 2016-10-09 15:46:46 +04:00
UdjinM6
cc3b3a145e only bump nTimeLast* when valid new/updated message arrived, do not bump on invalid or 'seen' 2016-09-29 23:23:02 +03:00
UdjinM6
c1b292be39 use references instead of creating copies when trying to sort masternodes by rank/score (#1032) 2016-09-20 02:27:36 +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
UdjinM6
8b13d45b5c more determinism for CompareScore* (#1017) 2016-09-15 10:50:28 +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
Evan Duffield
6f84dc15c0 Merge pull request #1009 from UdjinM6/lastPaid
Improve mn winners detection
2016-09-13 08:35:59 -07:00
UdjinM6
640c594dc4 make sort deterministic in cases when 2 mns are counted as paid in the same block for some reason (e.g. previous fork) 2016-09-13 13:58:33 +03:00
UdjinM6
3d9d91ea96 replace magic number with const (MASTERNODES_LAST_PAID_SCAN_BLOCKS) 2016-09-13 02:21: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
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
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
27cba53e64 Merge #941: Simplify CountByIP()
10c249f Simplify CountByIP()
2016-08-12 07:58:55 +02:00
Evan Duffield
5793bee9d6 Merge pull request #931 from UdjinM6/fixGetBlockHashAtHeight
Fix GetBlockHash
2016-08-08 12:32:23 -07: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
crowning-
072fd72ca3 Merge #930: [UI] IPv4, IPv6 and TOR stats added to Information tab
d07ca0c [UI] IPV4, IPv6 and TOR stats added to Information tab

aaa320e [UI] IPv4, IPv6 and TOR stats added to Information tab
2016-08-06 22:52:01 +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
UdjinM6
36c28fad1b Merge #925: fix a bug in #920
e7a2670 fix a bug in #920
2016-07-30 13:34:48 +02:00
UdjinM6
17dfbdea1b Merge #924: Fix AddRef() usage
513506f Fixing AddRef() usage
Using AddRef() in ConnectNode() for existing connections doesn't feel right considering how refs are released in ThreadSocketHandler(). I guess this could be the reason that sometimes refs stay >0 no matter what and nodes stuck in vNodesDisconnected forever which means that node never get deleted and FinalizeNode signal is never fired which in its turn means that for example mapBlocksInFlight can't be cleaned properly and then blocks stuck.

This commit should solve the issue by:
- removing AddRef() for existing connections
- adding AddRef() in CNode's constructor using the same conditions as in ThreadSocketHandler()
- addding AddRef() in ConnectNode() and Release() in ThreadSocketHandler() for mixing nodes
- removing explicit calls to Release() (back to `pnode->fDisconnect = true` in `CMasternodeMan::ProcessMasternodeConnections`)

9da4a83 fix names/comments
2016-07-30 13:05:41 +02:00
UdjinM6
a4d012069a Merge #920: Slightly refactor FindRandomNotInVec
61e16a3 Slightly refactor FindRandomNotInVec
2016-07-29 07:29:41 +02: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
ebaee8f083 moved serialdb to template based class 2016-04-09 23:31:32 -07:00
UdjinM6
981efed749 Few debug related fixes
- make logthreadnames work correctly without logtimestamps (and with emty strings again)
 - fix crash in debug (it3)
 - log debug info about locks in one line
 - show actual DS rounds instead of n/a in coin control while in debug mode
 - fix initial string in debug.log: "Bitcoin version" -> "Dash version"
2016-03-25 16:41:11 +03:00
UdjinM6
54096c30ec Allow user to use 2 modes for masternodebroadcast:
- safe - process mnb as if it was received via network
 - fast - skip most checks and relay
2016-03-18 02:37:48 +03: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
UdjinM6
e0c4dd0129 Fix crash in CheckAndRemove
Closes #732
2016-03-14 14:27:20 +01:00
UdjinM6
5c2a0cc9ec Fix bug that prevented new blocks to update tip during mixing
Closes #706
2016-03-02 12:54:46 +01: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
8ad088ab75 Add few more debug messages for masternode category 2016-02-17 21:53:55 +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
crowning-
cfc8cc2fe5 dseg shouldn't be send for local addresses
Closes #695
2016-02-15 14:06:47 +01: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