Commit Graph

681 Commits

Author SHA1 Message Date
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
5299d39338 Multiple refactorings/fixes for LLMQ bases InstantSend and ChainLocks (#2779)
* 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
2019-03-19 10:38:16 +03:00
UdjinM6
e52763d21b Refactor and fix instantsend tests/utils (#2776)
* 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
2019-03-18 14:50:44 +01:00
Alexander Block
a69a5cf4a0 Use smaller (3 out of 5) quorums for regtest/Travis (#2774)
* 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.
2019-03-15 11:48:24 +03:00
UdjinM6
396ebc2dc7 Fix tests after 2768 (#2772)
* No free non-prioritised txes can be mined/relayed now

* fix typo
2019-03-15 07:18:16 +01:00
PastaPastaPasta
6f90cf7a17 Merge bitcoin#9602: Remove coin age priority and free transactions - implementation (#2768)
b421e6d Update example bitcoin.conf (Alex Morcos)
7d4e950 Allow setting minrelaytxfee to 0 (Alex Morcos)
359e8a0 [cleanup] Remove coin age priority completely. (Alex Morcos)
f9b9371 [rpc] Remove priorityDelta from prioritisetransaction (Alex Morcos)
49be7e1 [rpc] Remove priority information from mempool RPC calls (Alex Morcos)
0315888 [test] Remove priority from tests (Alex Morcos)
f838005 No longer allow "free" transactions (Alex Morcos)
ad727f4 [rpc] sendrawtransaction no longer bypasses minRelayTxFee (Alex Morcos)
fe282ac [cleanup] Remove estimatePriority and estimateSmartPriority (Alex Morcos)
400b151 [debug] Change -printpriority option (Alex Morcos)
272b25a [mining] Remove -blockprioritysize. (Alex Morcos)
12839cd [rpc] Remove estimatepriority and estimatesmartpriority. (Alex Morcos)
ddf58c7 wallet: Remove sendfree (MarcoFalke)

Tree-SHA512: a9a4499405923ce794ef18f9e334dbbd59dfc73a3dc2df6f85cc9c62af6f353ec2eed9c2d5e58e904f918d0d7ab738f403dd4939d9bc2276136864fe63710782
Signed-off-by: Pasta <Pasta@dash.org>

Fix backport and fix dash specific priority code
2019-03-14 17:44:42 +03:00
Alexander Block
3a1aeb000e Multiple fixes/refactorings for ChainLocks (#2765)
* Print which DKG type aborted

* Don't directly call EnforceBestChainLock and instead schedule the call

Calling EnforceBestChainLock might result in switching chains, which in
turn might end up calling signals, so we get into a recursive call chain.

Better to call EnforceBestChainLock from the scheduler.

* Regularly call EnforceBestChainLock and reset error flags on locked chain

* Don't invalidate blocks from CChainLocksHandler::TrySignChainTip

As the name of this method implies, it's trying to sign something and not
enforce/invalidate chains. Invalidating blocks is the job of
EnforceBestChainLock.

* Only call ActivateBestChain when tip != best CL tip

* Fix unprotected access of bestChainLockBlockIndex and bail out if its null

* Fix ChainLocks tests after changes in enforcement handling

* Only invoke NotifyChainLock signal from EnforceBestChainLock

This ensures that NotifyChainLock is not prematurely called before the
block is fully connected.

* Use a mutex to ensure that only one thread executes ActivateBestChain

It might happen that 2 threads enter ActivateBestChain at the same time
start processing block by block, while randomly switching between threads
so that sometimes one thread processed the block and then another one
processes it. A mutex protects ActivateBestChain now against this race.

* Rename local copy of bestChainLockBlockIndex to currentBestChainLockBlockIndex

* Don't call ActivateBestChain when best CL is part of the main chain
2019-03-13 16:00:54 +03:00
Alexander Block
152a78eab2 Add compatibility code to P2PFingerprintTest until we catch up with backports 2019-03-12 10:43:47 +01:00
Wladimir J. van der Laan
9344dee8aa Merge #11580: Do not send (potentially) invalid headers in response to getheaders
725b79a [test] Verify node doesn't send headers that haven't been fully validated (Russell Yanofsky)
3788a84 Do not send (potentially) invalid headers in response to getheaders (Matt Corallo)

Pull request description:

  Nowhere else in the protocol do we send headers which are for
  blocks we have not fully validated except in response to getheaders
  messages with a null locator. On my public node I have not seen any
  such request (whether for an invalid block or not) in at least two
  years of debug.log output, indicating that this should have minimal
  impact.

Tree-SHA512: c1f6e0cdcdfb78ea577d555f9b3ceb1b4b60eff4f6cf313bfd8b576c9562d797bea73abc23f7011f249ae36dd539c715f3d20487ac03ace60e84e1b77c0c1e1a
2019-03-12 10:43:47 +01:00
Wladimir J. van der Laan
d1a6022605 Merge #11113: [net] Ignore getheaders requests for very old side blocks
eff4bd8 [test] P2P functional test for certain fingerprinting protections (Jim Posen)
a2be3b6 [net] Ignore getheaders requests for very old side blocks (Jim Posen)

Pull request description:

  Sending a getheaders message with an empty locator and a stop hash is a request for a single header by hash. The node will respond with headers for blocks not in the main chain as well as those in the main chain. To avoid fingerprinting, the node should, however, ignore requests for headers on side branches that are too old. This replicates the logic that currently exists for `getdata` requests for blocks.

Tree-SHA512: e04ef61e2b73945be6ec5977b3c5680b6dc3667246f8bfb67afae1ecaba900c0b49b18bbbb74869f7a37ef70b6ed99e78ebe0ea0a1569369fad9e447d720ffc4
2019-03-12 10:43:47 +01:00
Alexander Block
cd0f94fb54 Give wait_for_quorum_phase more time 2019-03-12 09:20:17 +01:00
Alexander Block
e21da2d99b Move simple PoSe tests into llmq-simplepose.py
These tend to fail quite often on Travis due to multiple reasons. One
reason is that establishing intra quorum connections take some time and
the tests in dip3-deterministicmns.py did not sleep long enough. Another
reason is that the individual stages were not really checked for completion
but instead just a hardcoded sleep was used. And another reason was that
with a total of 13 MNs, it's not guaranteed that every DKG results in one
MN to be punished.
2019-03-12 07:02:52 +01:00
Alexander Block
6488135f46 Track index into self.nodes in mninfo 2019-03-12 07:02:52 +01:00
UdjinM6
fbf0dcb086
Various small cleanups (#2761)
* Fix remaining `print`s in tests

* use AssertLockHeld(cs) instead of relying on comments

* actually use `clsig` in `EnforceBestChainLock()`

* fix log output in `EnforceBestChainLock()`

* drop comments
2019-03-11 16:32:26 +03:00
UdjinM6
9f40afce86
Merge pull request #2727 from PastaPastaPasta/backports-0.15-pr7
Backports 0.15 pr7
2019-03-11 11:15:51 +03:00
Pasta
609114a803 Code review: re-add string cast in mininode.py 2019-03-08 17:05:10 -06:00
pasta
85ffc1d647 drop swap_outputs_in_rawtx and DecimalEncoder in smartfees.py 2019-03-08 14:28:00 -06:00
Alexander Block
bc593c84b7 Revert "Fix use of missing self.log in blockchain.py"
This reverts commit b06a6a2e74.
2019-03-08 14:22:49 -06:00
Alexander Block
0e91ebcf42 Use logging framework in Dash specific tests 2019-03-08 14:22:40 -06:00
Alexander Block
4d3365ddb2 Completely disable InstantSend while filling mempool in autoix-mempool.py
Otherwise we overload Travis and tests start to randomly fail.
2019-03-07 21:15:09 +01:00
Alexander Block
f8f867a6bb Sync blocks after generating in mine_quorum() 2019-03-07 21:15:09 +01:00
Alexander Block
3e60d2d2db Adjust LLMQ based InstantSend tests for new spork20 2019-03-07 21:15:09 +01:00
UdjinM6
41a71fe443 update autoix-mempool.py to test both "old" and "new" InstantSend (and fix CheckCanLock to respect mempool limits) 2019-03-07 21:15:09 +01:00
UdjinM6
843b6d7a95 update p2p-autoinstantsend.py to test both "old" and "new" InstantSend 2019-03-07 21:15:09 +01:00
UdjinM6
a8da11ac5d update p2p-instantsend.py to test both "old" and "new" InstantSend 2019-03-07 21:15:09 +01:00
Pasta
0db2d1596a
code review and reset file perms 2019-03-03 20:50:39 -06:00
Alexander Block
d2573c43b6 Only return from wait_for_chainlock when the block is actually processed (#2728)
getblock also returns blocks which are not processed yet or in the middle
of processing.
2019-02-27 20:42:06 +03:00
Pasta
c3eb0c7887 reset file perms 2019-02-26 16:50:25 -06:00
Wladimir J. van der Laan
c17356efcf Merge #9970: Improve readability of segwit.py, smartfees.py
1269b8a Fix logging bug and improve readability of smartfees.py (Suhas Daftuar)
b9f34e8 Improve readability of segwit.py (Suhas Daftuar)

Tree-SHA512: 2c8ff61678c6c407a95a6530e9bd650ae6bb7c9e52f6dd5f256e19253a1358dd1a7aa33a9639fcb07f443e3a21dae71b9f0865c5f1fcaacb2097a3c6766c7eef
2019-02-26 16:41:15 -06:00
MarcoFalke
b09e3e080d Merge #9977: QA: getblocktemplate_longpoll.py should always use >0 fee tx
655df06 QA: getblocktemplate_longpoll.py should always use >0 fee tx (Suhas Daftuar)

Tree-SHA512: 016647ba1408f8aaa3fc954835542354d54bf2391c4252c1c505101edbbe1cf8dd6a07060930109d0341f86360b9391dfef439999a93a5bae68fc901dace0b71
2019-02-26 16:41:09 -06:00
Wladimir J. van der Laan
ee2048ae44 Merge #9830: Add safe flag to listunspent result
dcf2112 Add safe flag to listunspent result (NicolasDorier)
af61d9f Add COutput::fSafe member for safe handling of unconfirmed outputs (Russell Yanofsky)

Tree-SHA512: 311edb6fa8075b3ede5b24cb8c6e5d133ccd8ac9ecafea07b604ffa812ee4f071337e31695e662d8573590a0460af20aaaeb39d49c9ea87924449ea50bdfb0b3
2019-02-26 16:41:02 -06:00
MarcoFalke
914bd78770 Merge #9972: Fix extended rpc tests broken by #9768
d055bd6 Fix extended rpc tests broken by 8910b4717e (John Newbery)

Tree-SHA512: 30e019bd7e17013143e419777491ac0efd9760dddac7232d320c9afe80bc2fb383acd331e20cd5b3e21df1177c0e4a5221c99f831e90cf869d3affca206b9728
2019-02-26 16:41:00 -06:00
MarcoFalke
dad8c67d38 Merge #9768: [qa] Add logging to test_framework.py
64c0800 Use logging in individual tests (John Newbery)
38ad281 Use logging in test_framework/comptool.py (John Newbery)
ff19073 Use logging in test_framework/blockstore.py (John Newbery)
2a9c7c7 Use logging in test_framework/util.py (John Newbery)
b0dec4a Remove manual debug settings in qa tests. (John Newbery)
af1363c Always enable debug log and microsecond logging for test nodes. (John Newbery)
6d0e325 Use logging in mininode.py (John Newbery)
553a976 Add logging to p2p-segwit.py (John Newbery)
0e6d23d Add logging to test_framework.py (John Newbery)

Tree-SHA512: 42ee2acbf444ec32d796f930f9f6e272da03c75e93d974a126d4ea9b2dbaa77cc57ab5e63ce3fd33d609049d884eb8d9f65272c08922d10f8db69d4a60ad05a3
2019-02-26 15:54:32 -06:00
Alexander Block
48d92f116e Implement optional pretty printed stacktraces (#2420)
* Add libbacktrace to depends

This is currently only useful to extract symbols. It fails to gather
stacktraces when compiled with MinGW, so we can only use it to get symbol
information from a stack trace which we gathered outside of libbacktrace.

* Add -mbig-obj to CXXFLAGS for MinGW builds

* Implement stacktraces for C++ exceptions

This is a hack and should only be used for debugging. It works by wrapping
the C++ ABI __wrap___cxa_allocate_exception. The wrapper records a backtrace
and stores it in a global map. Later the stacktrace can be retrieved with
GetExceptionStacktraceStr.

This commit also adds handlers to pretty print uncaught exceptions and
signals.

* Use GetPrettyExceptionStr for all unhandled exceptions

* Use --enable-stacktraces in CI for linux32/linux64

* Register exception translators to pretty print exceptions in unit tests

* Catch and print python exceptions when stopping nodes

Otherwise the code at the bottom is never executed when nodes crash,
leading to no output of debug.log files on Travis.

* Remove now unneeded/unused TestCrash methods
2019-02-21 21:37:15 +03:00
UdjinM6
0b552be20b
Fix file permissions broken in 2682 (#2717) 2019-02-20 12:03:48 +03:00
UdjinM6
a79b928532
Merge pull request #2682 from PastaPastaPasta/backports-0.15-pr6
Backports 0.15 pr6
2019-02-19 13:04:49 +03:00
Pasta
bb90eb4bf0 backports-0.15-pr6 code review 2019-02-16 15:09:51 -06:00
UdjinM6
86fc050495
Drop no longer used code and bump min protos (#2697)
* Drop registry deletion of the old key

* Drop no longer used CGovernanceObjectVoteFile::RemoveOldVotes()

* Drop temporary disconnect code and bump min protos to 70213

* drop comment

* fix
2019-02-12 22:51:21 +03:00
Wladimir J. van der Laan
1be5a72a97
Merge #9853: Fix error codes from various RPCs
adaa281 Update release notes to include RPC error code changes. (John Newbery)
338bf06 Add commenting around JSON error codes (John Newbery)
dab804c Return correct error codes in fundrawtransaction(). (John Newbery)
a012087 Return correct error codes in setban(). (John Newbery)
960bc7f Return correct error codes in removeprunedfunds(). (John Newbery)
c119096 Return correct error codes in blockchain.cpp. (John Newbery)
6d07c62 Return correct error codes in bumpfee(). (John Newbery)

Tree-SHA512: 4bb39ad221cd8c83d98ac5d7ad642f3a8c265522720dc86b2eebc70e74439a85b06d6ddcd6a874e879d986511de3ab0878bb7fe58b50cb0546b78913632ea809
2019-02-05 13:40:40 -06:00
Wladimir J. van der Laan
22cda1a92f Merge #9929: tests: Delete unused function _rpchost_to_args
99fecf8 tests: Delete unused function _rpchost_to_args (Wladimir J. van der Laan)

Tree-SHA512: 40911d048d3fd7b3ce83e9b3caf2a409d55b47cbe08ea4450a16ca72264300bb12d5ef7dbcf335885975119b5977f949e6879546840064138fb506e24494d849
2019-02-04 19:58:09 -06:00
UdjinM6
d343bfa520
Merge pull request #2647 from PastaPastaPasta/backports-0.15-pr5
Backports 0.15 pr5
2019-02-04 21:58:02 +03:00
Pasta
071035b93a
Apply code review suggestions #2647 2019-02-01 13:39:23 -06:00
Wladimir J. van der Laan
b821dfa7dc
Merge #9739: Fix BIP68 activation test
f5aba8a Move tx version 2 standardness check to after bip68 activation (John Newbery)
99c0e81 Fix BIP68 activation test (John Newbery)

Tree-SHA512: 3633d5359705b33a22cd3d8ea28f41abd93ccc6fe9943c8004f6149add991771df9ea12b4e14192e39e14b414bb5ecc7218e516cfeec97e4c5df29778ac57060
2019-02-01 10:50:57 -06:00
Wladimir J. van der Laan
56890f98f2
Merge #9832: [qa] assert_start_raises_init_error
025dec0 [qa] assert_start_raises_init_error (NicolasDorier)

Tree-SHA512: 0fe3ecbd47625b181aed92f15445ac26993e1a8b9843bbc1088c4adcea774e503b870912a18e13dca3f255c22a9964c1c0ca92c758907538143f316c5272ea4a
2019-02-01 10:50:53 -06:00
Alexander Block
18950f923e Optimize DKG debug message processing for performance and lower bandwidth (#2672)
* Allow sub-batch verification in CBLSInsecureBatchVerifier

* Implement batch verification of CDKGDebugStatus messages

* Use uint8_t for statusBitset in CDKGDebugMemberStatus and CDKGDebugSessionStatus

No need to waste one byte per member and per LLMQ type.

* Reserve 4k of buffer for CSerializedNetMsg buffer

Profiling has shown that a lot of time is spent in resizing the data
vector when large messages are involved.

* Remove nHeight from CDKGDebugStatus

This field changes every block and causes all masternodes to propagate
its status for every block, even if nothing DKG related has changed.

* Leave out session statuses when we're not a member of that session

Otherwise MNs which are not members of DKG sessions will spam the network

* Remove receivedFinalCommitment from CDKGDebugSessionStatus

This is not bound to a session and thus is prone to spam the network when
final commitments are propagated in the finalization phase.

* Add "minableCommitments" to "quorum dkgstatus"

* Hold cs_main while calling GetMinableCommitment

* Abort processing of pending debug messages when spork18 gets disabled

* Don't ask for debug messages when we've already seen them

"statuses" only contains the current messages but none of the old messages,
so nodes kept re-requesting old messages.
2019-02-01 10:49:01 +03:00
Alexander Block
54f576ea7c
Fix LLMQ related test failures on Travis (#2666)
* Use fast_dip3_enforcement instead of fast_dip3_activation

DashTestFramework was refactored before ChainLocks got merged, causing tests
to fail now.

* Move updating of DKG debug status into WaitForNextPhase

Otherwise callers of the RPCs might believe that the next phase has already
started and start producing more blocks, which would then cancel the
current session if it happens faster than the phase handler thread can
progress to the next phase.
2019-01-30 14:05:22 +01:00
Alexander Block
f6828b19b6
Merge pull request #2643 from codablock/pr_llmq_chainlocks
Implement LLMQ based ChainLocks
2019-01-29 15:59:05 +01:00
UdjinM6
25cb14b615 Fix confusion between dip3 activation and enforcement (#2651)
* Fix confusion between dip3 activation and enforcement

* drop DIP0003ActivationHeight for now
2019-01-29 15:54:38 +01:00
Alexander Block
15e1c3b080
Merge pull request #2646 from PastaPastaPasta/backports-0.15-pr4
Backports 0.15 pr4
2019-01-29 15:52:03 +01:00
Alexander Block
ad4b3cda30 Instead of asserting signatures once, wait for them to change to the expected state 2019-01-28 14:45:20 +01:00