* Keep the most recent gobject vote only
We don't need to store full vote data for old votes - we never relay them to other nodes anyway.
Still keep old hashes to avoid re-requesting data etc.
* add comment
* Drop getvotes rpc
* Compare vote signals, do not compare hashes
Also add comments
On testnet it's quite usual to have multiple MNs on the same IP. Now that
we have LLMQs and DKGs which require deterministic intra quorum connections,
we must allow them to connect to each other even if the IPs are shared very
often.
* Drop all kind of invalid votes from all types of gobjects
Currently we only do so for proposal "funding" votes which looks incomplete.
* Apply review suggestions
* Fix potential deadlock in LoadWallet()
```
POTENTIAL DEADLOCK DETECTED
Previous lock order was:
(1) cs_main wallet/wallet.cpp:3881
(2) cs_wallet wallet/wallet.cpp:3881
Current lock order is:
(2) pwallet->cs_wallet wallet/walletdb.cpp:589
(1) cs_main wallet/wallet.cpp:1252
```
* Add comment in CWallet::MarkConflicted re new cs_main lock in CWalletDB::LoadWallet()
* Reset local/static cache in LogAcceptCategory when categories change
Without this, it is always required to first set debug to 0, wait a few
seconds (until LogAcceptCategory is called by all affected threads) and
then call "debug somecategory". Otherwise "ptrCategory" never gets updated.
This PR also stores a cache counter locally and globally and updates
"ptrCategory" when the counters do not match.
* Lock cs_args in LogAcceptCategory
* Prepare Dash-related stuff before starting ThreadImport
* Ensure activeMasternodeManager is not null in ThreadImport when DIP3 is active and we are running in masternode mode
* Pass CNode* to IsMasternodeQuorumNode and let it also check verifiedProRegTxHash
This makes IsMasternodeQuorumNode return true on incoming peer connections
as well.
* Let GetMasternodeQuorumNodes also take verifiedProRegTxHash into account
This makes it return NodeIds for incoming peer connections as well.
* Remove AddParticipatingNode and the need for it
This was needed in the past when we were unable to identify incoming
connections from other quorum members. Now that we have MNAUTH, we can
easily identify all connected members.
* Don't track interestedIn quorums in CSigSharesNodeState anymore
Same as with the previous commit, we're now able to easily identify which
nodes to announce sig shares to.
* Remove unused CConnman::GetMasternodeQuorumAddresses
* Sort evo/* source files in Makefile.am
* Keep track of proRegTxHash in CConnman::masternodeQuorumNodes map
We will later need the proRegTxHash
* Fix serialization of std::tuple with const rvalue elements
Having serialization and deserialization in the same specialized template
results in compilation failures due to the "if(for_read)" branch.
* Implement MNAUTH message
This allows masternodes to authenticate themself.
* Protect fresh incoming connections for a second from eviction
Give fresh connections some time to do the VERSION/VERACK handshake and
an optional MNAUTH when it's a masternode. When an MNAUTH happened, the
incoming connection is then forever protected against eviction.
If a timeout of 1 second occurs or the first message after VERACK is not
MNAUTH, the node is not protected anymore and becomes eligable for
eviction.
* Avoid connecting to masternodes if an incoming connection is from the same one
Now that incoming connections from MNs authenticate them self, we can avoid
connecting to the same MNs through intra-quorum connections.
* Apply review suggestions
* Manually pull builder base image and let travis retry it on failure
* Split base package installation in Dockerfile.builder into multiple RUN lines
This allows better local cache usage on failure and retry.
* Use travis_retry for docker build
* Fix warning about size_t to int conversion
* Fix loop in CLLMQUtils::GetQuorumConnections to add at least 2 connections
When reaching very small quorum sizes, the current algorithm results in
only a single connection to be added. This would be fine usually, but is an
issue when this connection fails. We should always have at least one backup
connection.
This fixes simple PoSe test failures where the quorum size gets down to 4
with one of the 4 members being down. If other nodes are unlucky to connect
to this node, they fail as well even though 3 members in a quorum should
work fine.
* Update src/llmq/quorums_utils.cpp
Co-Authored-By: codablock <ablock84@gmail.com>
* Bump MAX_OUTBOUND_MASTERNODE_CONNECTIONS to 250 on masternodes
Masternodes now need to connect to much more other MNs due to the intra-quorum
communication.
250 is a very conservative value loosely based on the absolute worst-case
number of outgoing connections required, assuming that a MN manages to
become part of all 24 active LLMQs.
* Fix infinite loop in CConnman::Interrupt
* Move out conditional calc into it's own variable
Co-Authored-By: codablock <ablock84@gmail.com>
* check matches for special transactions additional data
* additional method to check matches for CKeyID
* remove code duplication
* unit tests for bloom filters for DIP2 txes
* automatically update filters if special transaction matches
* unit tests for filter updates
* Error in comment
Co-Authored-By: gladcow <sergey@dash.org>
* use switch instead of if-chain
* fix version check
* remove code duplication
* add negative tests in unit tests
* Introduce "qsendrecsigs" to indicate that plain recovered sigs should be sent
Full nodes, including masternodes, will send this message automatically.
Other node implementations (e.g. SPV) are usually not interested and would
not send this message.
* Use std::atomic<bool> instead of std::atomic_bool
Not related to this PR, but a small enough change to include it here as
well.
* Add support for log category to CBatchedLogger
* Use "llmq" logging category in LLMQ code
* Use "chainlocks" logging category in ChainLocks code
* Log errors without logging category
* 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.
* Remove unused parameters from CInstantSendManager::ProcessTx
* Pass txHash in CheckCanLock by reference instead of pointer
* Dont' allow locking of TXs without inputs
* Remove unused local variable nInstantSendConfirmationsRequired
* Don't subtract 1 from nInstantSendConfirmationsRequired
This was necessary in the old system but is not necessary in the new system.
It also prevented proper retroactive signing of chained TXs in regtest as
it resulted in child TXs to return true immediately for CheckCanLock when
it should actually have waited for the parent TX to become locked first.
* Access chainActive.Height() while cs_main is locked
* Properly read and write lastChainLockBlock
"pindex" is NOT the chainlocked block after the while loop finishes. We
must use the pindex (renamed to pindexChainLock now) given on method entry.
Also, the GetLastChainLockBlock() result was not assigned to,
lastChainLockBlock which resulted in the while loop to run unnecessarily
long.
* Generalize filtering in NewPoWValidBlock and SyncTransaction
We're actually interested in all TXs that have inputs, so no need to
explicitly check for tx types.
* Use tx.IsCoinBase() instead of checking for index 0
* Handle cases where a TX is not received yet in wait_for_instantlock
* Wait on all nodes for the locks
Otherwise we end up with the sender having it locked but other nodes
not yet, failing the test.
* Fix LogPrintf call in CChainLocksHandler::DoInvalidateBlock
* Unify autoIS/send_smth functions
* Rename autoix-mempool.py -> autois-mempool.py
* Make sure create_raw_trx produces expected results
* Make sure sender has enough inputs and nodes are synced before starting the actual test
* Mine one block to clean mempool up
* 2 blocks is enough for IS on regtest
This also unifies it across different IS tests
* Allow wait_for_instantlock to be called on any node, not only on the one that has the tx in the wallet
* No need to query for tx this often in wait_for_instantlock
* Rename create_raw_trx -> create_raw_tx
* Fund sender with a single TX instead of 30
* Require only 3 out of 5 signatures for old InstantSend in regtest mode
* Use LLMQs of size 5 with threshold of 3 for regtest
* Fix wrong check for out-of-range bits in CFixedBitSet
* Reduce number of masternodes in masternode/LLMQ tests
* Add missing \n to LogPrintf call
* Use correct indexes for isolated/receiver/sender nodes
The way it was before resulted in nodes 1-3 being unused and 6-8 being used
for these 3 special nodes even though these are masternodes.
* Avoid stopping/starting isolated node in p2p-instantsend.py
It's enough to disable networking for this node.