Commit Graph

689 Commits

Author SHA1 Message Date
UdjinM6
18e1edabff
Backport 2618 to v0.13.0.x (#2619)
Add owner and voting addresses to rpc output, unify it across different methods.
Also fix keyid option in `masternode list` rpc.
2019-01-11 12:53:54 +03:00
UdjinM6
0dce846d5a
Add an option to use specific address as a source of funds in protx rpc commands (otherwise use payoutAddress/operatorPayoutAddress) (#2581)
* Add an option to use specific address as a source of funds in protx rpc commands

* fix typo "must"

* Always use payoutAddress (or operatorPayoutAddress) as a default if no fundAddress was specified

* make sure we actually selected some inputs

* fundAddress -> feeSourceAddress

* Align help text with new logic

* fix protx_update_service

* fix protx_revoke

* Add fRequireAllInputs to CCoinControl and use it in FundSpecialTx

This avoids adding all inputs even though they are not needed.

* Allow to specify empty operator payout address and simplify fee code in update_service

DIP3 tests were failing to call "protx update_service" as it did not accept
an empty "operatorPayoutAddress".

This also simplifies handling of the feeSourceAddr.

* Specify source for funds and fees in DIP3 tests
2018-12-28 12:24:48 +03:00
UdjinM6
378dadd0f7 Ensure EvoDB consistency for quorum commitments by storing the best block hash (#2537)
* Ensure EvoDB consistency by storing the best block hash

This approach is similar to the one used for chainstate currently.
Ensures that:
- nodes that upgraded after DIP3 has all the data processed correctly (they will crash and require reindex);
- evodb/ is removed when blocks/ is removed (otherwise sync will fail due to duplicate records).

* Implement CEvoDB::VerifyBestBlock/WriteBestBlock and call them from ConnectBlock/DisconnectBlock

* Fix walletbackup.py
2018-12-13 09:11:50 +01:00
Alexander Block
d9b28fe1ad
Introduce dummy (ping-like) contributions for the dummy DKG (#2542)
* Implement creation and propagation of dummy contributions

These act as a ping which is broadcast a few blocks before the dummy
commitments are created. They are meant to determine online/offline members.

* Use information about received dummy contributions to determine validMembers

* Fix PoSe tests

* Fix dummy DKG phase progress in PoSe tests and give tests more time

Mine one block at a time until we reach the mining phase.
2018-12-10 06:04:33 +01:00
Alexander Block
d94092b60b
Fix spork propagation while in IBD and fix spork integration tests (#2533)
* Fix spork syncing issue in sporks tests

https://github.com/dashpay/dash/pull/2522 caused an issue with sporks syncing
in tests. The introduced time check in CMasternodeSync::ProcessTick causes
masternode sync to never start when mocktime is enabled, so this commit
disables mocktime for sporks.py.

Disabling mocktime however leads to fInitialDownload never becoming false
in CMasternodeSync::UpdatedBlockTip, so mnsync is never started. To fix
this, the tests now create a block before connecting the last node.

This however doesn't work because node1 will ignore the "getheaders" request
from node2 as it has not finished mnsync yet...so we also have to force
finish mnsync for node1.

* Also respond with getdata for announced sporks while in IBD

There was never a good reason to ignore spork announcements while in IBD.
At the same time, this poses the risk of missing out on sporks while in IBD.
This also fixes an issue in sporks testing, as nodes did not request for
announced sporks.

* Use wait_to_sync instead of custom loop
2018-12-06 14:43:36 +01:00
Alexander Block
a4f5ba38b6
Implement CDummyDKG and CDummyCommitment until we have the real DKG merged (#2492)
* Add SPORK_17_QUORUM_DKG_ENABLED spork

* Implement CDummyDKG and CDummyCommitment until we have the real DKG merged

This is only used on testnet/devnet/regtest and will NEVER be used on
mainnet. It is NOT SECURE AT ALL!

See comment in quorums_dummydkg.h for more details.

* Test simple PoSe in DIP3 tests

* Generate 2 instead of 4 blocks per iteration in PoSe tests

4 was based on old chainparams where I used larger phases.

* Only sleep when necessary in PoSe tests

* Fix typo in comment

* Give PoSe tests more time and sync after fast-forward
2018-11-26 16:53:20 +01:00
Alexander Block
c248c48e4d
Try to fix a few sporadic instant send failures in DIP3 tests (#2500)
* Sleep in wait_for_instant_lock when TX is not known yet

We'll otherwise stress the CPU quite a lot, which might in turn result in
instant send timeouts.

* Wait for all nodes to have the instant send lock

Otherwise individual nodes might end up not being able to catch up,
especially when it's the last iteration and we generate 6 blocks after it.

* Use getrawtransaction in wait_for_instant_lock instead of gettransaction

gettransaction fails if the TX is not owned by the wallet

* Give instant send tests more time after DIP3 activation

Signature verification changes to BLS when DIP3 gets activated, which is
much more resource hungry. Give instant send tests more time after DIP3
activation until we do proper batched verification of instant send
signatures.
2018-11-26 16:22:54 +01:00
Alexander Block
7a709b81d8 Perform less instant send tests in DIP3 tests (#2499)
These take quite some time on Travis.
2018-11-26 16:23:46 +03:00
Alexander Block
245c3220e9
Sync blocks before creating TXs (#2496) 2018-11-26 13:40:36 +01:00
Alexander Block
f5beeafa14
Also restart MNs which didn't have the collateral moved, but do it later (#2483) 2018-11-23 16:45:56 +01:00
Alexander Block
22b5952c5a
Implement and enforce DIP6 commitments (#2477)
* Add LLMQ parameters to consensus params

* Add DIP6 quorum commitment special TX

* Implement CQuorumBlockProcessor which validates and handles commitments

* Add quorum commitments to new blocks

* Propagate QFCOMMITMENT messages to all nodes

* Allow special transactions in blocks which have no inputs/outputs

But only for TRANSACTION_QUORUM_COMMITMENT for now.

* Add quorum commitments to self-crafted blocks in DIP3 tests

* Add simple fork logic for current testnet

This should avoid a fork on the current testnet. It only applies to the
current chain which activated DIP3 at height 264000 and block
00000048e6e71d4bd90e7c456dcb94683ae832fcad13e1760d8283f7e89f332f.

When we revert the chain to retest the DIP3 deployment, this fork logic
can be removed again.

* Use quorumVvecHash instead of quorumHash to make null commitments unique

Implementation of https://github.com/dashpay/dips/pull/31

* Re-add quorum commitments after pruning mempool selected blocks

* Refactor CQuorumBlockProcessor::ProcessBlock to have less nested if/else statements

Also add BEGIN/END markers for temporary code.

* Add comments/documentation to LLMQParams

* Move code which determines if a commitment is required into IsCommitmentRequired

This should make the code easier to read and also removes some duplication.

The also changes the error types that are possible from 3 to 2 now. Instead
of having "bad-qc-already-mined" and "bad-qc-not-mining-phase", there is
only "bad-qc-not-allowed" now.

* Use new parameter from consensus parames for the temporary fork
2018-11-23 15:42:09 +01:00
Alexander Block
5ffc31bce4
Forbid version=0 in special TXs (#2473) 2018-11-22 06:05:32 +01:00
Alexander Block
c60687fe61 Sleep longer between attempts in sync_blocks 2018-11-15 15:25:04 +01:00
Alexander Block
91af72b18f Allow to specify how log to sleep between attempts in wait_until 2018-11-15 09:44:37 +01:00
Alexander Block
3c99d9e358 Fix test_fail_create_protx in DIP3 tests
This slipped through in a previous pull request and makes tests fail.
2018-11-15 08:06:52 +01:00
Alexander Block
4de70f0ace Test P2SH/multisig payee addresses in DIP3 tests 2018-11-15 08:06:21 +01:00
Alexander Block
f4ec3db067
Merge pull request #2442 from UdjinM6/spectx
Various fixes for special txes
2018-11-15 05:18:44 +01:00
Alexander Block
7c1f110893
Revert #2441 and retry fixing (#2444)
* Revert "Restart MNs in DIP3 tests even if collateral has not moved (#2441)"

This reverts commit 153afb9062.

* Reuse old legacy MN key when upgrading to protx
2018-11-14 18:40:31 +01:00
UdjinM6
658b7afd18 Make error messages re payload a bit more specific 2018-11-14 16:57:41 +03:00
Alexander Block
153afb9062 Restart MNs in DIP3 tests even if collateral has not moved (#2441)
These need to be restarted even in this case as keys are cycled when
upgrade_mn_protx is called. This resulted in invalid IX votes but was not
noticed because only 2 MNs were affected (still 8 of 10 votes succesful)
2018-11-13 15:24:30 +03:00
Alexander Block
c27e62935f
Allow reusing of external collaterals in DIP3 (#2427)
* Allow to reuse collaterals and addresses in ProRegTx

This also requires to move out the duplication check from CheckService to
the 2 individual ProTx check methods.

* Implement replacement logic for reused collaterals

* Add tests for new replacement logic
2018-11-10 10:54:16 +01:00
UdjinM6
bea590958b
Fix auto-IS tests (#2414)
* no `-debug` by default (it's too heavy)

* drop useless `sync_masternodes` calls and add a couple where they could be actually usefull

* change autoix-mempool.py test logic:
1. use separate nodes to send test txes
2. sync nodes while filling the mempool
2018-11-05 12:28:04 +03:00
Alexander Block
9da9d575aa Allow collaterals for non-DIP3 MNs which were created after DIP3/BIP9 activation (#2412)
* Remove reference to now removed "protocolVersion"

* Allow to use non-DIP3 collaterals after DIP3 activation

This removes a rule which only made sense when we assumed all collaterals
would remain in DIP3 ProRegTx transactions after DIP3 activation.

As we allow to refer external collaterals now, this rule should vanish as
well.

* Sleep in case block time is ahead of real time

See comment. This was not a problem before as we had enough time passed
between the last block that caused this and the start-alias call.
Now we added another start-alias call which is directly after we generated
many blocks.
2018-11-04 14:55:50 +03:00
UdjinM6
51addf9a03
Fix p2p-instantsend.py test (#2408) 2018-11-02 00:58:57 +03:00
Alexander Block
30a2b283a8 Sign ProRegTx collaterals with a string message instead of payload hash, split protx register into prepare/submit (#2395) 2018-11-02 00:57:10 +03:00
Alexander Block
28a6007a40 Prepare DIP3 for testnet and reuse DIP3 deployment for autoix deployment (#2389)
* Add BIP9 parameters for DIP3 deployment on testnet

* Remove autoix BIP9 deployment and reuse DIP3 deployment

* Add BIP9CheckMasternodesUpgraded to chain params

This controls if miners should check for upgraded masternodes first before
adding BIP9 bits to the block version. This only makes sense in network
where masternodes are up and running before BIP9 activation, which is not
necessarely the case in regtest and devnet.

Also refactor ComputeBlockVersion to use fCheckMasternodesUpgraded instead
of the inverse fAssumeMasternodeIsUpgraded. It is set to false by default
and only set to true in CreateNewBlock.

* Check for upgraded masternodes for DIP3 activation (only mainnet and testnet)

* Bump PROTOCOL_VERSION and DMN_PROTO_VERSION

We probably have nodes with 70211 already running on testnet.
2018-10-26 19:42:52 +03:00
Alexander Block
8f9b004cab Support "fast" mode when calling sync_masternodes (#2383)
This will call "mnsync next" multiple times to force finishing of mnsync.
Also reduce sleep time to 200ms.
2018-10-26 19:41:40 +03:00
UdjinM6
0692de1c58 Fix prepare_masternodes/create_masternodes in DashTestFramework (#2382)
Specify masternodeblsprivkey which is required in masternode mode now.
This should fix IS test failures which occur because of `Warning: You should specify a masternodeblsprivkey in the configuration. Please see documentation for help.` init error (there are other issues, so auto-IS test are still going to fail).
2018-10-26 07:03:48 +02:00
Alexander Block
e3df910822 Allow referencing other TX outputs for ProRegTx collateral (#2366)
* Pass CCoinsView reference to special TX handling methods

* Allow referencing other TX outputs for ProRegTx collateral

* Remove "collateralAmount" from "protx register"

* Rename "protx register" to "protx fund_register"

* Remove UpdateSpork15Value from CDeterministicMNManager

Was not used/implemented anymore

* Lock masternode collaterals after chain/DIP3 is fully initialized

Otherwise detection of collaterals does not work.

* Implement new "protx register" RPC which uses existing collaterals

* Remove "masternode info" RPC

It is not consistent with other "masternode" RPCs anymore as it requires
the ProRegTx hash while all other RPCs work with the collateral.

* Load sporks from disk cache before initializing the chain

Otherwise spork15 is not loaded when we check it for the first time.

* Implement "protx info" RPC

* Use "protx info" instead of "masternode info" in DIP3 tests

* Test external collaterals for ProTx

* Handle review comments

* Don't pass CCoinView reference when it's not used

* Revert "Pass CCoinsView reference to special TX handling methods"

This reverts commit 28688724e1.

* Use GetUTXOCoin instead of now removed coinsView

Also remove collateral height check as GetUTXOCoin only returns confirmed
coins.

* Add conflict handling for external collaterals to mempool

* Handle review comments (squashed Github suggestions)

Co-Authored-By: codablock <ablock84@gmail.com>
2018-10-25 17:29:50 +03:00
Alexander Block
eaa856eb78 Remove nProtocolVersion and add mode/type fields to DIP3 (#2358)
* Remove nProtocolVersion fields from deterministic masternode lists

This field was part of my initial implementation from DIP3. One of the last
changes of DIP3 was then to remove this field, which I did not bring back
into code yet. This commit removes it now.

We use PROTOCOL_VERSION now in cases were compatibility in the the pre-DIP3
list is needed.

* Add type and mode fields in DIP3 special TXs

These were added to DIP3 but not in-code yet.

* Add DMN_PROTO_VERSION
2018-10-23 14:15:38 +03:00
Alexander Block
c9d2745188 Use BLS keys for the DIP3 operator key (#2352)
* Use BLS keys for operator keys

* Add "bls generate" RPC to generate BLS keys

* Use unique_ptr to store blsKeyOperator and blsPubKeyOperator

Needed because the Chia BLS library crashes when keys are created before
the library is initialized, even if keys are not used. This is the case here
as we have static instances here.

* Remove unnecessary CheckSignature calls

This seems to be some garbage I left in by mistake.

* Fixed review comments

* Fix rpc help for operator keys

All keys that are used as examples are random. None of the secret keys
belongs to any of the public keys.

* Use .GetHash() instead of ::SerializeHash() for BLS pubkeys in txmempool.cpp

* Rename mapProTxBlsPubKeys to mapProTxBlsPubKeyHashes
2018-10-21 22:45:16 +03:00
gladcow
11a0cbf84d InstantSend-related tests refactoring (#2333)
* create base class for dash-specific tests

* use common base class in p2p-autoinstantsend.py

* use common base class in p2p-instantsend.py

* rename check_IX_lock to wait_for_instantlock
2018-10-20 17:08:02 +03:00
gladcow
81d60bc283 Fix the issue with transaction amount precision in IS tests (#2353)
* fix issue with trx amounts precision in autoix-mempool.py

* fix issue with trx amounts precision in p2p-autoinstantsend.py

* fix issue with trx amounts precision in p2p-instantsend.py

* Rallback adding empty line

* Rallback adding empty line
2018-10-18 16:24:30 +03:00
UdjinM6
90ad75911a
Fix auto-IS and tests (#2331)
* fix CTxLockRequest::GetMinFee()

* Force regular IS txes to include MIN_FEE * n_inputs fee on creation regardless of auto-IS status

* set_autoix_spork_state should bump mocked time

* make sure IS fee matches the expected one

* turn off spork16 and test all types of txes again
2018-10-15 14:59:57 +03:00
gladcow
f7ab6c469c M-of-N-like sporks (#2288)
* support set of keys to sign spork

* several addresses support in -sporkkey

* tests for multykey sporks

* command line option -minsporkkeys

* make spork active only after given number of signers

* use signature in spork hash calculation

* test for new and old spork messages interaction

* add multikeyspork.py to integration tests

* change test to have ability to distinguish default spork value

* require min spork keys number to be more than the half of the common spork keys number

* calc current spork value with majority of signers

* set test nodes time in integration test

* extract keyid from signed spork message directly

* change -sporkaddr option syntax to process several addresses

* codestyle fixes

* fix test comments

* codestyle fixes

* simplify CSporkManager::SporkValueIsActive

* Calc signature hash without signature field

* do not restore pubkey ids from cach

* Calc different keyids to check signature because not all sporks can be synced at moment

* codestyle fixes

* Fix CSporkManager::CheckAndRemove to use several keys

* codestyle fixes

* Correct processing of not actual spork6 value with GetSignerKeyID
2018-09-30 20:01:33 +03:00
gladcow
5454bea377 Automatic InstantSend locks for "simple" transactions (#2140)
* add locktransaction rpc call

* Remove special instantsend fee for simple transactions

* Function to check if trx is simple enough to be autolocked

* Automatic lock for all received from peers simple trxes

If we get a new transaction with CInv message and it is "simple" and
is accepted in mempool, we initiate its lock. We don't lock orphan trxes
that accepted in mempool after this trx because they are locked by other
peers.

* Automatically lock simple trxes in wallet

* protocol bump for InstantSend without special fee

* Add function to detect used mempool share

* Mempool threshold for auto IX locks

* Add SPORK_16_INSTANTSEND_AUTOLOCKS spork

* Make autolocks active only when spork SPORK_16_INSTANTSEND_AUTOLOCKS is active

* BIP9 autolocks activation

* revert increasing min peer protocol version for mn rank

* move IsTrxSimple check to CTxLockRequest class

* make MAX_INPUTS_FOR_AUTO_IX private member of CTxLockRequest class

* make AUTO_IX_MEMPOOL_THRESHOLD private member of CInstantSend class

* remove locktransaction RPC call

* tests for automatic IS locks

* fix mempool threshod calculation

* bump mocktime in activate_autoix_bip9

* set node times

* no need to spam the node with gettransaction rpc requests that often

* use `spork active` instead of leaking spork logic into tests

* codestyle fixes

* add test description in comments

* fix typo

* sync test nodes more often during BIP9 activation

* Use 4th bit in BIP9 activation

* Fix comments according codestyle guide

* Call AcceptLockRequest and Vote at the first node creating autoix lock

* fix mempool used memory calculation

* rallback not necessary change in CWallet::CreateTransaction

* test for stopping autolocks for full mempool

* Inject "simple autolockable" txes into txlockrequest logic
2018-09-26 17:17:47 +03:00
PastaPastaPasta
8ea40102c0 Remove leftover RBF code from BTC (#2297)
* Remove leftover RBF code from BTC

* remove rbf #include

* remove rbf in rpc-tests

* removes replace-by-fee.py

* remove help text related to rbf

* remove comment text relating to rbf

* remove "-mempoolreplacement" cli option

* Remove (effectively dead) RBF code which would never have been called anyway and some assosiated variables

* since `setConflicts` is always empty, this is dead code

* Since we don't have RBF, don't have to do this check. Also, since `setConflicts` is always empty this is dead code

* removes unneccesary if as it will always be true

* remove unused `set<uint256> setConflicts`

* Removes replacement of conflicting txs, as conflicting txs are never accepted

* removes RBF from `validForFeeEstimation`

* removes (probably) unnecessary lock

* remove replacing part of the AcceptToMemoryPool and AcceptToMemoryPoolWIthTime

* fixes err in ps.cpp, didn't remove arg

* RBF in net_processing.cpp

* remove arg in ps-server.cpp

* removes another arg in PS code

* removes rawtx.c AcceptToMemoryPool arg

* removes arg in txvalidationcache_tests.cpp

* remove extra args

* forgot an arg

* fix typo in 82898b0

* remove unused fEnableReplacement in validation.h

* remove the removal reason REPLACED in txmempool.h

* removed unused variable

* comment typo
2018-09-20 15:39:34 +03:00
Alexander Block
47ca06ab33 DIP3 integration tests (#2280)
* Implement dip3 integration tests

This tests the full upgrade path from legacy MNs to deterministic MNs

* Invoke UpdatedBlockTip signal when invalidateblock RPC is called

Currently, UpdatedBlockTip would only be called if the invalidation resulted
in another chain becoming the longest one. This is inconsistent behavior
and was spotted when running dip3 integration tests.
2018-09-11 17:32:45 +03:00
Alexander Block
cb37c39725 Bump PROTOCOL_VERSION to 70211, bump MIN_* protocols to 70210 (#2256)
Bump PROTOCOL_VERSION to 70211, bump MIN_* protocols to 70210
2018-09-05 19:34:56 +03:00
Alexander Block
c7f75afdd6 Fix nulldummy tests by creating correct DIP4 coinbase transactions 2018-09-03 10:46:52 +02:00
Alexander Block
bcc0719578 Calculate and enforce DIP4 masternodes merkle root in CbTx
Also add "coinbase_payload" field to block templates
2018-09-03 10:46:51 +02:00
Alexander Block
b606bde9a9 Support version 3 transaction serialization in mininode.py 2018-08-29 11:36:14 +02:00
gladcow
1767e3457e Save/load spork cache (#2206)
* CSporkManager class serialization

* Read/write sporks.dat file

* Move mapSporks into CSporkManager and serialize it

* fix GetSporkByHash

* spork tests

* add missed cs lock

* clear mapSporksByHash in CSporkManager::Clear

* use spork active rpc call to hide spork inner logic

* set small pause between rpc calls in cycles
2018-08-13 23:21:21 +03:00
gladcow
6da2837bdd InstantSend Integration tests (#2141)
* adjust `AddLocal` method only in regtest mode

* Create Masternodes in regtest

* sentinelping call for masternodes

* set externalip option for masternodes in regtest

* fix MNB relay during masternodes creation

* fix node_count naming

* instantsend doublespend

* decrease node restarts

* prevent spending masternode collaterals

* move long test to the test list start

* remove InstantSend spork sending

* remove spork-specific code

* fix checking double spend rejection
2018-07-12 12:04:42 +03:00
UdjinM6
806d7f0496
Fix rpc tests broken by 2110 (#2118) 2018-06-12 21:37:31 +03:00
UdjinM6
8d8fdb4339
sendrawtransaction no longer bypasses transaction policy limits by default (#2110)
* [rpc] sendrawtransaction no longer bypasses minRelayTxFee

The prioritisetransaction API can always be used if a transaction needs to be submitted that bypasses minRelayTxFee.

* Allow to bypass transaction policy limits in sendrawtransaction

Add new rpc param to sendrawtransaction to have an ability to tweak its behaviour.
Default is `false` i.e. "do not bypass".

* fix
2018-06-12 14:33:23 +03:00
Nathan Marley
41680f4d94 small cleanup in a few places (#2058)
* move nStart closer to used and initialize it

* Quells warning displayed with `-Wmaybe-uninitialized` flag

* remove unused mnEntries vectors

* add devnet magic bytes to mininode.py

* remove unused governance-misc.h file

* remove old TODO comments

* replace map count/insert w/emplace in instantx.cpp

This feels like an optimization, something about:

```
if map.count(key)
     return false
else
     insert(pair)
     return true
```

... just feels icky. Plus, `vote.GetMasternodeOutpoint()` is only called
once. The previous version might be slightly more readable, however.

* Revert "replace map count/insert w/emplace in instantx.cpp"

This reverts commit d7f876e863.
2018-05-13 23:57:12 +03:00
UdjinM6
b07503f013
Some cleanup (mostly trivial) (#2038)
* Drop CInstantSend::IsEnoughOrphanVotesForTxAndOutPoint

* small cleanup in rpc tests

* move some pieces from .h to .cpp

* fix few log outputs

* fix some comments

* some trivial fixes + readability
2018-04-20 13:53:23 +03:00
UdjinM6
a648d6efff
Drop delayed headers logic and fix duplicate initial headers sync by handling block inv correctly (#2032)
* Drop custom logic for delaying GETHEADERS

Reverts "Fix duplicate headers download in initial sync (#1589)" and all following fixes

This reverts commit 169afafd50.

* Fix duplicate initial headers sync
2018-04-20 13:53:05 +03:00
UdjinM6
138441eb82
Add forkpoint to getchaintips (#2039) 2018-04-18 14:50:52 +03:00