Commit Graph

20 Commits

Author SHA1 Message Date
UdjinM6
91a996e325
Make sure mempool txes are properly processed by CChainLocksHandler despite node restarts (#3226)
* Pass nAcceptTime via TransactionAddedToMempool and use it for ChainLocks

Otherwise the "first seen" time is way off after node restart

* Don't skip TransactionAddedToMempool for chainlocks while blockchain is not synced yet

Otherwise txes from mempool.dat won't be processed there
2019-12-07 13:56:17 +03:00
UdjinM6
60a8a93578 Drop CDSNotificationInterface::SyncTransaction() 2019-05-28 11:59:55 +02:00
Alexander Block
6afa605f6f Pass disconnected/deleted pindex instead of pprev into BlockDisconnected
CDSNotificationInterface::BlockDisconnected still calls SyncTransaction
with pprev to keep compatibility.
2019-05-27 16:40:05 +02:00
UdjinM6
250195185f
Adjust CDSNotificationInterface to align with CValidationInterface changes 2019-05-27 09:03:19 -05:00
UdjinM6
428f304506
Implement rawchainlocksig and rawtxlocksig (#2930)
* Pass is-lock into `CInstantSendManager::UpdateWalletTransaction()`

* Implement `rawtxlocksig` which pushes tx+islock

* Implement `rawchainlocksig` which pushes block+clsig

* fix log category
2019-05-23 12:13:58 +03:00
Alexander Block
db781b32dc Pass oldList and diff instead of newList into NotifyMasternodeListChanged 2019-04-09 13:28:40 +02:00
Alexander Block
c3602372cc Implement retroactive IS locking of transactions first seen in blocks instead of mempool (#2770)
* Don't rely on UTXO set in CheckCanLock

The UTXO set only works for TXs in the mempool and won't work when we try
to retroactively lock unlocked TXs from blocks.

This is safe as ProcessTx is only called when a TX was accepted into the
mempool or connected in a block, which means that all input checks were
good.

* Rename RetryLockMempoolTxs to RetryLockTxs and let it retry connected TXs

* Instead of manually calling ProcessTx, let SyncTransaction handle all cases

SyncTransaction is called from AcceptToMemoryPool and when transactions got
connected in a block. So this is the time we want to run TXs through
ProcessTx. This also enables retroactive signing of TXs that were unknown
before a new block appeared.

* Test retroactive signing and safe TXs in LLMQ ChainLocks tests

* Also test for retroactive signing of chained TXs

* Honor lockedParentTx when looking for TXs to retry signing

* Stop scanning for TXs to retry after a depth of 6

* Generate 6 block to avoid retroactive signing overloading Travis

* Avoid retroactive signing

* Don't rely on NewPoWValidBlock and use SyncTransaction to build blockTxs

NewPoWValidBlock is not guaranteed to be called when blocks come in fast.
When a block is accepted in AcceptBlock, NewPoWValidBlock is only called
when the new block is a successor of the currently active tip. This is not
the case when after the first block a second block is accepted immediately
as the first block is not connected yet.

This might be a bug actually in the handling of NewPoWValidBlock, so we
might need to check/fix this later, but currently I prefer to not touch
that part.

Instead, we now use SyncTransaction to gather TXs for blockTxs. This works
because SyncTransaction is called for all transactions in a freshly
connected block in one go. The call also happens before UpdatedBlockTip is
called, so it's fine with the existing logic.

* Use tx.IsCoinBase() instead of checking index 0

Also check for empty vin.
2019-03-19 13:55:51 +03:00
Alexander Block
9e9081110b Add override keywork to CDSNotificationInterface::NotifyChainLock 2019-03-07 21:15:09 +01:00
Alexander Block
bd7edc8ae9 Track txids of new blocks and first-seen time of TXs in CChainLocksHandler 2019-03-07 21:15:09 +01:00
Alexander Block
83dbcc483f Implement CInstantSendManager and related P2P messages 2019-03-07 21:14:31 +01:00
Alexander Block
f95aae2b30 Remove all legacy/compatibility MN code (#2600)
* Remove CActiveLegacyMasternodeManager

* Remove sentinelping RPC

* Remove unused P2P messages and inv types

There are still places where these are used in the code. The next commits
will clean these up.

* Remove MNB/MNP/MNVERIFY related code from masternode(man).h/cpp

* Remove all legacy code regarding block MN payee voting

* Remove MASTERNODE_SYNC_LIST and MASTERNODE_SYNC_MNW states

Also replace all uses of IsMasternodeListSynced and IsWinnersListSynced
with IsBlockchainSynced.

* Remove unsupported masternode RPCs

* Remove UpdateLastPaid methods

* Remove duplicate deterministicmns.h include

* Remove masternode.conf support

* Remove legacy MN lists support from masternode list GUI

* Remove unnecessary AskForMN call

* Remove compatibility code in CPrivateSendQueue::GetSignatureHash

* Don't add locally calculated MN payee in case GetBlockTxOuts failed

This is not valid in DIP3 mode

* Remove check for IsDeterministicMNsSporkActive in "masternode status"

* Move CMasternode::IsValidNetAddr to CActiveDeterministicMasternodeManager

* Remove use of CMasternode::CheckCollateral in governance code

* Remove uses of MASTERNODE_SENTINEL_PING_MAX_SECONDS/MASTERNODE_SENTINEL_PING_MAX_SECONDS

* Remove support for "-masternodeprivkey"

* Remove pre-DIP3 vote cleanup

* Remove compatibility code for quorumModifierHash/masternodeProTxHash

* Remove check for invalid nBlockHeight in CMasternodePayments::GetBlockTxOuts

...and let it crash instead. We expect this method to be called with the
correct height now (after DIP3 was fully deployed).

* Remove ECDSA based Sign/CheckSignature from CGovernanceObject

Only masternodes sign governance objects, so there is no need for ECDSA
support here anymore.

* Always add superblock and MN reward payments into new block

* Always check block payees (except if fLiteMode==true)

* Always allow superblock and MN payees in same block

* Remove/Fix a few references to masternode.conf and related stuff

Also delete guide-startmany.md and masternode_conf.md

* Implement NotifyMasternodeListChanged signal and call governance maintenance

* Remove non-DIP3 code path from CMasternodeMan::Find

* Remove remaining unused code from CMasternode/CMasternodeMan

* Always load governance.dat on startup

* Mine an empty block instead of incrementing nHeight from chain tip in miner tests

This test is crashing otherwise in GetBlockTxOuts as it tries to access a
previous block that is not existing.

* Skip MN payments verification on historical blocks (pre-DIP3 blocks)

Even though DIP3 was active on BIP9 level, the spork was not active yet at
that point meaning that payments were not enforced at that time.

* Remove unused state and CollateralStatus enums

* Unconditionally return false from IsBlockPayeeValid when IsTransactionValid returns false

IsTransactionValid already handles the case where IsDIP3Active() returns
false, making it return true.

* Add override keyword to CDSNotificationInterface::NotifyMasternodeListChanged

* Fix help for masternodelist status (POSE_BANNED and no OUTPOINT_SPENT)
2019-01-03 12:17:43 +03:00
gladcow
2ea6f7d82e Use override keyword for overriden class member functions (#1644)
* Use `override` keyword for all overriden functions

* more override
2018-02-15 10:29:15 +03:00
Alexander Block
e3da73ebf8 Update Dash related code to use new SyncTransaction notifications interface 2018-01-08 18:41:06 +01:00
Wladimir J. van der Laan
8874b2e0fd Merge #6480: include the chaintip blockindex in the SyncTransaction signal, add signal UpdateTip()
7d0bf0b include the chaintip *blockIndex in the SyncTransaction signal (Jonas Schnelli)
2017-12-11 08:30:26 +01:00
Oleg Girko
753b1e486b Eliminate remaining uses of g_connman in Dash-specific code. (#1635)
This monstrous change eliminates all remaining uses of
g_connman global variable in Dash-specific code.

Unlike previous changes eliminating g_connman use
that were isolated to particular modules, this one covers
multiple modules simultaneously because they are so interdependent
that change in one module was quickly spreading to others.

This is mostly invariant change that was done by
* changing all functions using g_connman to use connman argument,
* changing all functions calling these functions to use connman argument,
* repeating previous step until there's nothing to change.

After multiple iterations, this process converged to final result,
producing code that is mostly equivalent to original one, but passing
CConnman instance through arguments instead of global variable.

The only exception to equivalence of resulting code is that I had to
create overload of CMasternodeMan::CheckAndRemove() method without arguments
that does nothing just for use in CFlatDB<CMasternodeMan>::Dump() and
CFlatDB<CMasternodeMan>::Load() methods.
Normal CMasternodeMan::CheckAndRemove() overload now has argument of
CConnman& type and is used everywhere else.

The normal overload has this code in the beginning:

    if(!masternodeSync.IsMasternodeListSynced()) return;

Masternode list is not synced yet when we load "mncache.dat" file,
and we save "mncache.dat" file on shutdown, so I presume that it's OK
to use overload that does nothing in both cases.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
2017-09-19 17:51:38 +03:00
UdjinM6
4f0618ae8a Fix sync issues (#1599)
- add `MASTERNODE_SYNC_WAITING` sync state/asset and initial timeout
- wait for block headers to be downloaded (new signal `AcceptedBlockHeader`)
- wait for blocks to reach best headers tip before switching to masternode list sync (new signal `NotifyHeaderTip`)
- switched sync from `UpdatedBlockTip` to a combination of `AcceptedBlockHeader` and `NotifyHeaderTip`
- all blockchain-related bumps should take place only while we are still syncing blockchain, should be no such bumps after that
2017-09-03 16:30:08 +03:00
UdjinM6
b5f7be6498 slightly refactor CDSNotificationInterface (#1581) 2017-08-29 02:51:33 +03:00
UdjinM6
87707c0127 fix CDSNotificationInterface::UpdatedBlockTip signature (#1562)
to match the one in CValidationInterface
2017-08-04 20:43:48 +03:00
UdjinM6
60409df822 InstantSend overhaul (#1288)
* Multi-quorum InstantSend, complete refactoring
+ cleanup for IS and partial protobump

* more changes:
- allow InstantSend tx to have 10 inputs max
- store many unique tx hashes in mapVotedOutpoints
- more checks in AcceptToMemoryPoolWorker (moved from ProcessMessage + CTxLockRequest(tx).IsValid() )

* More changes:
- let multiple lock candidates compete for votes
- fail to vote on the same outpoint twice early

* More changes:
- notify CInstantSend on UpdatedBlockTip -> remove cs_main from CheckAndRemove()
- notify CInstantSend on SyncTransaction -> count expiration block starting from the block corresponding tx was confirmed instead of the block lock candidate/vote was created
- fixed few locks

* add comments about nConfirmedHeight

* Fix "Block vs Lock" edge case

* Fix "Block vs Lock" edge case, p2

* Fix issues:
- fix logic for locking inputs and notifying - see UpdateLockedTransaction, TryToFinalizeLockCandidate
- add missing hash inserting in ProcessTxLockVote
- add nMaxBlocks param to ResolveConflicts to limit max depth allowed to disconnect blocks recursively
- fix false positive mempool conflict
- add missing mutex locks
- fix fRequireUnspent logic in CTxLockRequest::IsValid
2017-01-29 12:22:14 +04: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