* Store time we saw mnb last time, bump sync timeout
if we received seen mnb but we are too close to MASTERNODE_NEW_START_REQUIRED_SECONDS
* Reset blockchain sync status if new blocks were accepted during sync
* Add some debug log output
* wait for at least one new block to be accepted
* bump CGovernanceManager-Version
* Few mn list sync changes:
- add more mn states
- only remove spent
- send mn ping in addition to mn announce on sync
- manage mn announces more carefully
- expire mns created from broadcasts with invalid ping
- old fWaitForPing logic for old nodes, should be helpful during migration period
This also adjusts active mn auto-start logic accordingly.
Should also store/check node we asked for mn list entry, not outpoint only. This should help to get mn list in sync when some nodes refuse to answer thus blocking such requests for the same outpoint for the next 3h and increasing mn list inconsistency.
- 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
* Revert behaviour introduced in 5e1a6afe7f, make nLastDsq local variable instead of being network-wide one. Should fix mixing for new clients and for those who was offline for too long.
* fix docs
* Make local address discovery more robust in CActiveMasternode
* parameter interaction: -masternode=1 -> setting -listen=1
* slightly postpone first run to give net thread a chance to connect to some peers
* make sure local address detected in CActiveMasternode::ManageStateInitial is valid
* Simplified address detection logic
- added description for 'deserialize'
- added 'type' filter to 'list'
- added 'count' command (changed CGovernanceManager::ToString to output a bit more detailed info)
* 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
- make script verification a part of IsInstantSendTxValid()
- relax nLockTime for IS txes since we don't have compatibility with 12.0 IS txes anyway now (fee is lower in 12.1)
* 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
* Added logging to PushInventory
* Fix LogPrint format
* Log errors found during governance syncing
* Turn off rate checks during syncing
* Turn off rate check during maintenance
- avoid processing same vote multiple times
- do not relay votes until synced
- do not ban for wrong signature of old votes
- do not check masternode ranks for old votes on regular (non-MN) nodes
* refactor IsBlockValueValid to return actual error string, use it in error message for bad-cb-amount
* make error messages in IsBlockValueValid even more verbose
* 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
* 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
```
* 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
- TXLOCKREQUEST should be processed as normal tx plus some custom logic, should not "fake" inventory
- should not create "fake" local lock, should instead keep track of orphan votes and reprocess them when corresponding TXLOCKREQUEST arrives
- orphan vote time map should be indexed by full outpoint, not by txid of mn collateral
bump MIN_INSTANTSEND_PROTO_VERSION
* slightly refactor IS:
- the only place where logic is changed: `ProcessTxLockVote()` - it should first try to find mn and fail if none was found and only then try to call `GetMasternodeRank()` (which is heavy)
- fixed few `cs_main`
- slightly optimized number of `tx.GetHash()` calls
- lots of `const` (fixed few related functions in main.cpp)
- few smaller fixes: iterators, log output, comments, etc
- use thread safe methods of mnodeman
- safety check in GetAverageUnknownVoteTime
* Fix CGovernanceManager initialization problem
* Added logging messages for cases where CGovernanceManager receives a message while not synced
* Prevent potential NULL pointer dereference
* Fix exit codes:
- `--help`, `--version` etc should exit with `0` i.e. no error ("not enough args" case should still trigger an error)
- error reading config file should exit with error
- slightly refactor AppInitRPC/AppInitRawTx to return standard exit codes (EXIT_FAILURE/EXIT_SUCCESS) or CONTINUE_EXECUTION (-1)
- every main()/exit() should return/use one of EXIT_ codes instead of magic numbers
Refactoring:
- IsDenomCompatibleWithSession, split in 3 - CreateNewSession, AddUserToExistingSession and IsAcceptableDenomAndCollateral
- CheckTimeout:
- should not rely on CDarkSendEntry nTimeAdded to clear entries, instead should rely on time of the last successful step i.e. nLastTimeChanged
- nLastTimeChanged should only be set when mixing moved forward in some way
State related:
- local pool should be in POOL_STATE_IDLE initially
- local pool should switch to POOL_STATE_QUEUE when connected to mn
- local pool should set session id only when in POOL_STATE_QUEUE
- SetState should set state local only, no relaying
- mixing wallets should rely on local logic and expected set of state switches rather then updates from masternodes
- deprecate STATUS_SET_STATE, POOL_STATE_UNKNOWN, POOL_STATE_TRANSMISSION, POOL_STATE_FINALIZE_TRANSACTION
Session related:
- deprecate fSessionFoundMasternode, use nSessionID instead
- deprecate nSessionUsers, use vecSessionCollaterals.size() instead
Other:
- deprecate IsNull()
- move few things to private
- remove deprecated
- bump min ps peer proto
- fail to process dsa when session is already ready
- fail to process dsvin if session is not ready yet
- fail to process any message on the wrong side (mn/client)
- fail in PrepareDenominate if pool already has entries
- fail if can't sign anything in final tx, also reset local pool in such case
- fix "number of entries" pushed on DSSTATUSUPDATE
* 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
* 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
* [UI] Fix for empty Masternode list when mncache.dat exists [review changes]
* [UI] Fix for empty Masternode list when mncache.dat exists [review changes]
* 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
* 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
* fix dstx acceptance
* two more fixes:
- do not re-verify dstx once accepted
- fix dstx prioritization
* return early for dstx conditions, more log verbosity
* Fix deadlocks by reducing scope of cs_main locks in rpcgovernance.cpp
* Remove unnecessary mutex lock in GetMasternodeVinAndKeys which can cause a deadlock
* Zmq sequence (#1)
* Fixes ZMQ startup with bad arguments.
pr 7621
* [ZMQ] append a message sequence number to every ZMQ notification
- pr 7762
- contrib/zmq/zmq_sub.py to python 3 compatible
* typo in MSG_RAWTXLOCK
MMSG_RAWTXLOCK to MSG_RAWTXLOCK
* s/Bitcoind/dashd/
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
There is a bug AddOrUpdateVote function in CGovernanceManager. If a new vote has been arrived it is checked if a corresponding parent object are present in the mapObjects. If it is not we need to sync the parent object and return false. But the syncing is never performed because the corresponding code is placed after return statement. So we need to sync and then return.
* 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
* GetMinCollateralFee should not validate object type, it should be IsValidLocally's job
* Explicitly set 0 fee for known free objects, set fee to MAX_MONEY for unknown one
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
* 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
* 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
* 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
* deprecate start-many
* remove outdated "enforce" rpc and enforceMasternodePaymentsTime
* "count" should lock cs_main and call GetNextMasternodeInQueueForPayment only when needed
* "masternodelist" fixes:
- rename "pubkey" -> payee", fix description
- fix "filter" description
- change "full" format: add lastpaidblock, move IP to the end of string to make it more table-ish
- fix "status" description
- fix "addr" filter, wasn't working
- trivial refactoring
* fix "start-alias" and "create-alias" error message - should be a bit more descriptive now
* rpcmasternode trivial cleanup
- add "spork" debug category
- move "seen" and "unknown" to new "spork" debug category to reduce log spam
- new/updated/seen messages should not overlap
* refactor CMasternodePaymentWinner::CheckSignature
* refactor CMasternodePaymentWinner::Sign - can only be signed by active masternode
* hold cs_mapMasternodeBlocks till the end of CMasternodePayments::AddWinningMasternode
* refactor CMasternodePaymentWinner::ToString
* use GetStorageLimit() in CMasternodePayments::CheckAndRemove
* refactor CMasternodePaymentWinner
* refactor CMasternodePayments::ProcessBlock
* trivial cleanup, adjusted few log messages
* fix error message returned by CMasternodePaymentWinner::IsValid to include actual bounds that were violated
* 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
* 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
* 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