Commit Graph

237 Commits

Author SHA1 Message Date
Alexander Block
1dbf5a0f63 Fix transaction/block versions for devnet genesis blocks (#2056)
* Fix transaction/block versions for devnet genesis blocks

56ff71fcec mistakenly increased the coinbase transaction version instead
of the block version. This fixes it.

* Use v1 for coinbase transaction
2018-05-13 23:56:21 +03:00
Alexander Block
7719b7ec25 Update BIP147 deployment times, nMinimumChainWork and defaultAssumeValid (#2030)
* Update BIP147 deployment times

* Update nMinimumChainWork and defaultAssumeValid of mainnet
2018-04-20 13:54:49 +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
Nathan Marley
99085c5b68 swap devnet magic bytes around (#2028)
Prevents testnet and devnet messages from being confused and helps
differentiate which network messages should refer to.
2018-04-20 13:52:31 +03:00
UdjinM6
8b09e779b6
Bump testnet checkpoint and nMinimumChainWork/defaultAssumeValid params (#2026)
* bump testnet minchainwork/assumevalid

* add testnet checkpoint at block 100000

blockhash: 0000000003aa53e24b6e60ef97642e4193611f2bcb75ea1fa8105f0b5ffd5242
2018-04-11 14:07:37 +03:00
UdjinM6
9e98c856f2
A pack of small fixes (#1992)
* Make sure gobject collateral was mined

`CGovernanceObject::IsCollateralValid()` would still fail for non-mined collateral later trying to check confirmations

* Fix powLimit for mainnet/testnet

That's a legacy thing, slightly rising it to match the actual bit-shifted value has no effect because real values are already lower.
Also clarify values for all networks in comments.

* Check for script addresses in CSuperblock::ParsePaymentSchedule()

Sentinel should already be downvoting such triggers if they would exist, no need to store/relay them.

* Do not process already known valid vote twice in CGovernanceObject::ProcessVote()

This should be handled by `CGovernanceManager::ProcessVote()` but imo it's better to have this at the `CGovernanceObject::ProcessVote()` level as well.

* Make sure CGovernanceObjectVoteFile::AddVote() never adds/updates already known votes

The way `CGovernanceObjectVoteFile::AddVote()` is used (i.e. wrapped in `CGovernanceObjectVoteFile::HasVote()` condition) it's already the case. Hoever nothing would guarantee consistency if it would be used elsewhere without such wrapper, so it's better to have similar check inside.

* Do not even try mnb recovery when -connect is set

`CConnman::ThreadOpenMasternodeConnections()` thread won't even start when `-connect` is set, so no need to ask for recovery, there is nothing that is going to be able to process such request.

* No need for SIGHASH_ANYONECANPAY in PS collateral signature

Collateral is just a normal tx created and signed by each participant individually, there is no need for special sig types.

* Release semMasternodeOutbound in CConnman::Interrupt()

Re-align Dash code with Bitcoin.
2018-03-19 16:08:32 +03:00
UdjinM6
7d5223b5e4
Network-specific thresholds for required confirmations (IS) (#1962) 2018-03-10 15:35:09 +03:00
UdjinM6
4ffa7bac02
Introduce DIP0001Height (#1973)
Block height at which DIP0001 becomes active

Also drop fDIP0001WasLockedIn
2018-03-08 15:18:24 +03:00
UdjinM6
9ef38c6d73
Switch CNetFulfilledRequestManager and CMasternodeMan maps/funcs to CService (#1967)
* Switch CNetFulfilledRequestManager and CMasternodeMan maps/funcs to CService

This is to make them work correctly on regtest.
We make sure that behaviour on other networks is not affected though.

* Add fAllowMultiplePorts to chainparams

Tweak either we should allow nodes with the same address and multiple ports or not for this specific chain
2018-03-08 15:16:52 +03:00
Alexander Block
611879aa6d Use spork addresses instead of raw keys and allow changing them on startup (#1969)
* Support passing CKeyID to CMessageSigner/CHashSigner

* Use Dash addresses instead of raw public keys for sporks

The spork addresses are identical to the previously used public keys.

Also use CKeyID/CKey directly inside CSporkManager instead of parsing the
addresses/keys over and over. The default spork key (from chainparams) is
initialized with InitDefaultSporkAddress(). SetPrivKey parses the private
key now and stores it in sporkPrivKey instead of parsing it in
CSporkMessage::Sign().

* Allow setting of spork address via command line

* Remove unused strMasternodePaymentsPubKey chainparam

Traces from the past...

* Review fixes

1. Remove the need for InitDefaultSporkAddress
2. Remove bogus checks for hex private keys
3. Alphabetical order for new include
4. Add . to help string

* Add regtest spork key

As this key is not meant to be private, the private key is also added in
the form of a comment (for later use in regtests)

* Review fixes
2018-03-02 16:15:04 +03:00
Alexander Block
9876207ce2 Multiple devnet fixes (#1960)
* Add missing help string for -devnet

* Remove testnet seeds from devnet

* Activate BIP34/65/66 at height 2 instead of 1

Height 1 is the genesis block and not the devnet genesis block. The genesis
block is still at version 1, resulting in re-indexing to fail.
2018-03-02 16:12:31 +03:00
Alexander Block
e37b6c7dab Fix BIP147 deployment threshold parameter (#1955)
It should be 50 and not 59
2018-02-27 16:39:34 +03:00
UdjinM6
5b1c4d8a11
Few (mostly trivial) cleanups and fixes (#1940)
* Drop nBudgetProposalEstablishingTime

* Refactor: replace `== COutPoint()` with `.IsNull()`

* Refactor: add `operator bool()` to CMasternodePing

* Refactor: actually use `operator bool()` for CPendingDsaRequest

* Refactor: fixing code style in TrafficGraphData

* Fix some comments and whitespaces

* Drop CGovernanceVote::GetTypeHash()

* Drop legacy X11 code

No longer used... if it ever was used at all.

* Move `<boost/foreach.hpp>` out of coins.h

* Simplify CMasternodeBlockPayees::GetRequiredPaymentsString()

Also less of boost::lexical_cast

* Drop CTxDSIn::nSentTimes

* Fix few warnings

* fix warning (timer)

* fix nit
2018-02-21 19:32:08 +03:00
UdjinM6
ed712eb819
Fix nDelayGetHeadersTime (int64_t max == never delay) (#1916)
* Fix nDelayGetHeadersTime (int64_t max == never delay)

* Rewrite conditions in a more natural way i.e. (now - last_best > threshold)
2018-02-12 21:34:53 +03:00
Suhas Daftuar
2c810d2c3f Allow changing BIP9 parameters on regtest 2018-02-08 10:40:51 +01:00
Alexander Block
99b2789a73 Fix DeserializeAndCheckBlockTest benchmark and store hashDevnetGenesisBlock in consensus (#1888)
* Use Dash block for DeserializeAndCheckBlockTest

Replaced Bitcoin block with the largest Dash block I could find on mainnet.

* Store hashDevnetGenesisBlock in Consensus::Params

Remove the need for chainparams to be available when the devnetGenesis hash
is needed. Fixes a crash in CheckBlockHeader() when called from benchmarking
code, which does not initialize the Params() function.
2018-02-01 20:05:35 +03:00
UdjinM6
8a387ee09c
Drop SPORK_13_OLD_SUPERBLOCK_FLAG and check superblock start hash (#1872) 2018-02-01 15:42:21 +03:00
Alexander Block
c017353a99 Add softfork deployment for BIP147 2018-01-30 20:18:51 +01:00
Alexander Block
b97eecc058 Fix review nits 2018-01-22 08:05:44 +01:00
Alexander Block
4d651621ef Update mainnet chainparams to use correct heights for BIP34/BIP65/BIP66 2018-01-21 14:29:06 +01:00
Alexander Block
3824192e42 Update testnet chainparams to use correct heights for BIP34/BIP65/BIP66 2018-01-21 14:29:06 +01:00
Alexander Block
cd0c910a88 Use new data structures for devnet checkpointData/chainTxData 2018-01-21 14:14:33 +01:00
Wladimir J. van der Laan
658479355e Merge #9472: Disentangle progress estimation from checkpoints and update it
df36371 Update estimated transaction count data (Pieter Wuille)
e356d9a Shorten variable names and switch to tx/s (Pieter Wuille)
6dd8116 Remove SIGCHECK_VERIFICATION_FACTOR (Pieter Wuille)
3641141 Move tx estimation data out of CCheckPointData (Pieter Wuille)
a4bac66 [MOVEONLY] Move progress estimation out of checkpoints (Pieter Wuille)
2018-01-21 12:48:32 +01:00
Alexander Block
56ff71fcec Update devnet to activate BIP34/BIP65/BIP66 immediately 2018-01-21 12:48:31 +01:00
Wladimir J. van der Laan
7321bfdd6b Merge #8391: Consensus: Remove ISM
122786d Consensus: Remove ISM (NicolasDorier)
2018-01-20 09:22:40 +01:00
Alexander Block
7939a23e3b Use std::move when calling MakeTransactionRef 2018-01-16 08:30:52 +01:00
Alexander Block
07cd44c0e2 Use MakeTransactionRef in CreateDevNetGenesisBlock 2018-01-15 07:03:20 +01:00
Wladimir J. van der Laan
f12610c030 Merge #9125: Make CBlock a vector of shared_ptr of CTransactions
b4e4ba4 Introduce convenience type CTransactionRef (Pieter Wuille)
1662b43 Make CBlock::vtx a vector of shared_ptr<CTransaction> (Pieter Wuille)
da60506 Add deserializing constructors to CTransaction and CMutableTransaction (Pieter Wuille)
0e85204 Add serialization for unique_ptr and shared_ptr (Pieter Wuille)
2018-01-15 06:14:16 +01:00
Wladimir J. van der Laan
c4faa32181 Merge #8921: RPC: Chainparams: Remove Chainparams::fTestnetToBeDeprecatedFieldRPC
b26a7b5 RPC: Chainparams: Remove Chainparams::fTestnetToBeDeprecatedFieldRPC (Jorge Timón)
2018-01-12 09:58:14 +01:00
Wladimir J. van der Laan
402eb55732 Merge #8208: Do not set extra flags for unfiltered DNS seed results
bc0a895 Do not set extra flags for unfiltered DNS seed results (Pieter Wuille)
2017-12-28 11:44:59 +01:00
Pieter Wuille
b3e26cc757 Merge #8083: Add support for dnsseeds with option to filter by servicebits
2d83013d Add support for dnsseeds with option to filter by servicebits (Jonas Schnelli)
2017-12-22 16:33:56 +01:00
Wladimir J. van der Laan
738e1c51c0 Merge #7793: [doxygen] Fix member comments
fada0c4 [doc] Fix doxygen comments for members (MarcoFalke)
2017-12-20 14:45:12 +01:00
Alexander Block
cd9c6994c2 Implement named devnets (#1791)
* Initial devnet

* Move genesis block adding into its own method

* Introduce -allowprivatenet to lift limitation on RFC1918 addresses

Normally, RFC1918 (192.168.x.x/10.x.x.x/...) addresses are not allowed
to be relayed. Also, masternodes won't start when the address is considered
invalid.

This is needed to test local devnet or regtest based networks.

* Lift the requirement of minimum MN age for regtest/devnet

* Implement named devnets

This allows the creation of multiple independent devnets. Each one is
identified by a name which is hardened into a "devnet genesis" block,
which is automatically positioned at height 1. Validation rules will
ensure that a node from devnet=test1 never be able to accept blocks
from devnet=test2. This is done by checking the expected devnet genesis
block.

The genesis block of the devnet is the same as the one from regtest. This
starts the devnet with a very low difficulty, allowing us to fill up
needed balances for masternodes very fast.

Also, the devnet name is put into the sub-version of the VERSION message.
If a node connects to the wrong network, it will immediately be disconnected.

* Allow to select multiple addresses from the same group in devnet/regtest

The selection code normally only allows to select addresses from the same
group (e.g. 192.168.x.x) once. This results in connecting to only a single
node in devnet/regtest.

* Show the devnet name in the title bar and on the loading screen

* Add AllowMultipleAddressesFromGroup to chainparams and use it in net.cpp

* Remove unused/unneeded scripts from devnet geneses creation

1. OP_RETURN not needed in input script of devnet genesis
2. genesisOutputScript was unused

* Fix copy/paste error in -allowprivatenet description

* Improve -devnet parameter error handling

- Only allow one of -devnet, -regtest or -testnet
- Only allow -devnet=name to be specified once

* Use different datadir for each devnet

* Fix `devnet-devnet` issue

* Fix devnet splashscreen (should use testnet img)

* Avoid passing devNetName around (most of the time)

* Remove nMaxTipAge from CDevNetParams

Not present anymore after rebase on develop
2017-12-20 14:45:01 +03:00
Wladimir J. van der Laan
2474fd0aea Merge pull request #7208
64360f1 Make max tip age an option instead of chainparam (Wladimir J. van der Laan)
2017-12-10 00:04:02 +01:00
UdjinM6
3028af19f1
post-DIP0001 cleanup (#1763)
* post-DIP0001 cleanup

also fixes tests

* bump nMinimumChainWork and defaultAssumeValid
2017-12-07 12:43:23 +03:00
UdjinM6
865b61b503
Unify GetNextWorkRequired (#1737)
* unify GetNextWorkRequired

* drop enum
2017-12-01 08:15:11 +03:00
Alexander Block
2de7560b2f Update nMinimumChainWork and defaultAssumeValid to more recent values (#1680)
* Update nMinimumChainWork and defaultAssumeValid to more recent values

* Update checkpoint data of mainnet to height 750000
2017-10-12 15:05:31 +03:00
UdjinM6
0b6955a7b8 update nMinimumChainWork and defaultAssumeValid for testnet (#1668) 2017-10-05 00:01:29 +03:00
UdjinM6
33dbafbba5 fork testnet again to re-test dip0001 because of 2 bugs found in 1st attempt (#1667) 2017-10-04 23:13:32 +03:00
UdjinM6
381ffdc4bb Fork testnet to test 12.2 migration (#1660) 2017-10-02 00:02:01 +03:00
UdjinM6
cd262bf641 DIP0001 implementation (#1594)
* DIP0001 implementation

* add option in ComputeBlockVersion to assume that masternode is upgraded (and skip rank calculation)

* fix mainnet DIP0001 nTimeout

* schedule DIP0001 testnet activation start for Sep 18th, 2017 (bump timeout too)
2017-09-11 17:13:30 +03:00
Alexander Block
169afafd50 Fix duplicate headers download in initial sync (#1589)
* Fix duplicate headers download in initial sync

Now that initial block download is delayed until the headers sync is done,
it was noticed that the initial headers sync may happen multiple times in
parallel in the case new blocks are announced. This happens because for
every block in INV that is received, a getheaders message is immediately
sent out resulting in a full download of the headers chain starting from
the point of where the initial headers sync is currently at. This happens
once for each peer that announces the new block. This slows down the
initial headers sync and increases the chance of another block being
announced before it is finished, probably leading to the same behavior
as already described, slowing down the sync even more...and so on.

This commit delays sending of GETHEADERS to later in case the chain is too
far behind while a new block gets announced. Header chains will still be
downloaded multiple times, but the downloading will start much closer
to the tip of the chain, so the damage is not that bad anymore.

This ensures that we get all headers from all peers, even if any of them
is on another chain. This should avoid what happened in
https://github.com/bitcoin/bitcoin/pull/8054
which needed to be reverted later.

This fixes the Bitcoin issue https://github.com/bitcoin/bitcoin/issues/6755

* Introduce DelayGetHeadersTime chain param and fix tests

The delaying of GETHEADERS in combination with very old block times in
test cases resulted in the delaying being triggered when the first newly
mined block arrives. This results in a completely stalled sync.

This is fixed by avoiding delaying in when running tests.

* Disconnect peers which are not catched up

Peers which stop sending us headers too early are very likely peers which
did not catch up before and stalled for some reason. We should disconnect
these peers and chose another one to continue.
2017-09-04 09:10:52 +03:00
Alexander Block
ccee103a0e Backport "assumed valid blocks" feature from Bitcoin 0.13 (#1582)
* IBD check uses minimumchain work instead of checkpoints.

This introduces a 'minimum chain work' chainparam which is intended
 to be the known amount of work in the chain for the network at the
 time of software release.  If you don't have this much work, you're
 not yet caught up.

This is used instead of the count of blocks test from checkpoints.

This criteria is trivial to keep updated as there is no element of
subjectivity, trust, or position dependence to it. It is also a more
reliable metric of sync status than a block count.

* Remove GetTotalBlocksEstimate and checkpoint tests that test nothing.

GetTotalBlocksEstimate is no longer used and it was the only thing
 the checkpoint tests were testing.

Since checkpoints are on their way out it makes more sense to remove
 the test file than to cook up a new pointless test.

# Conflicts:
#	src/Makefile.test.include
#	src/test/Checkpoints_tests.cpp

* IsInitialBlockDownload no longer uses header-only timestamps.

This avoids a corner case (mostly visible on testnet) where bogus
 headers can keep nodes in IsInitialBlockDownload.

* Delay parallel block download until chain has sufficient work

nMinimumChainWork is an anti-DoS threshold; wait until we have a proposed
tip with more work than that before downloading blocks towards that tip.

* Add timeout for headers sync

At startup, we choose one peer to serve us the headers chain, until
our best header is close to caught up.  Disconnect this peer if more
than 15 minutes + 1ms/expected_header passes and our best header
is still more than 1 day away from current time.

* Introduce assumevalid setting to skip presumed valid scripts.

This disentangles the script validation skipping from checkpoints.

A new option is introduced "assumevalid" which specifies a block whos
 ancestors we assume all have valid scriptsigs and so we do not check
 them when they are also burried under the best header by two weeks
 worth of work.

Unlike checkpoints this has no influence on consensus unless you set
 it to a block with an invalid history.  Because of this it can be
 easily be updated without risk of influencing the network consensus.

This results in a massive IBD speedup.

This approach was independently recommended by Peter Todd and Luke-Jr
 since POW based signature skipping (see PR#9180) does not have the
 verifiable properties of a specific hash and may create bad incentives.

The downside is that, like checkpoints, the defaults bitrot and older
 releases will sync slower.  On the plus side users can provide their
 own value here, and if they set it to something crazy all that will
 happen is more time will be spend validating signatures.

Checkblocks and checklevel are also moved to the hidden debug options:
 Especially now that checkblocks has a low default there is little need
 to change these settings, and users frequently misunderstand them as
 influencing security or IBD speed.  By hiding them we offset the
 space added by this new option.

* Add consensusParams to FindNextBlocksToDownload

* Adjust check in headers timeout logic to align with 144 blocks in Dash
2017-08-23 17:21:08 +03:00
UdjinM6
96f0d6ec2b various trivial cleanup fixes (#1501) 2017-07-03 16:14:07 +03:00
UdjinM6
a28fa724c2 fix BIP34 starting blocks for mainnet/testnet (#1476) 2017-06-06 02:46:58 +03:00
UdjinM6
27f3218de9 HD wallet (#1405)
* HD wallet

Minimal set of changes (no refactoring) backported from Bitcoin upstream to make HD wallets work in Dash 0.12.1.x+

* minimal bip44 (hardcoded account and change)

* minimal bip39

Additional cmd-line options for new wallet:
-mnemonic
-mnemonicpassphrase

* Do not recreate HD wallet on encryption

Adjusted keypool.py test

* Do not store any private keys for hd wallet besides the master one

Derive all keys on the fly.
Original idea/implementation - btc PR9298, backported and improved

* actually use bip39

* pbkdf2 test

* backport wallet-hd.py test

* Allow specifying hd seed, add dumphdseed rpc, fix bugs

- -hdseed cmd-line param to specify HD seed on wallet creation
- dumphdseed rpc to dump HD seed
- allow seed of any size
- fix dumpwallet rpc bug (wasn't decrypting HD seed)
- print HD seed and extended public masterkey on dumpwallet

* top up keypool on HD wallet encryption

* split HD chain: external/internal

* add missing cs_wallet lock in init.cpp

* fix `const char *` issues (use strings)

* default mnemonic passphrase is an empty string in all cases

* store mnemonic/mnemonicpassphrase

replace dumphdseed with dumphdinfo

* Add fCrypted flag to CHDChain

* prepare internal structures for multiple HD accounts

(plus some code cleanup)

* use secure allocator for storing sensitive HD data

* use secure strings for mnemonic(passphrase)

* small fix in GenerateNewHDChain

* use 24 words for mnemonic by default

* make sure mnemonic passphrase provided by user does not exceed 256 symbols

* more usage of secure allocators and memory_cleanse

* code cleanup

* rename: CSecureVector -> SecureVector

* add missing include

* fix warning in rpcdump.cpp

* refactor mnemonic_check (also fix a bug)

* move bip39 functions to CMnemonic

* Few fixes for CMnemonic:
- use `SecureVector` for data, bits, seed
- `Check` should return bool

* init vectors with desired size where possible
2017-05-29 14:51:40 +03:00
Holger Schinzel
eaf90b7717 replace legacy dnsseed (#1395) 2017-03-15 00:55:52 +01:00
UdjinM6
cedd269cb0 shift CSV deployment window on mainnet to "Feb 5th, 2017 - Feb 5th, 2018" (#1314) 2017-02-04 04:41:18 +04:00
Tim Flynn
0ecc7c61eb Adjust start of 12.1 superblocks (#1311) 2017-02-03 21:41:22 +04:00
Tim Flynn
399330d42d Improve governance syncing efficiency with bloom filter (#1299)
* Use bloom filter for governance vote syncing

Modify masternode-sync to send bloom filters

Correctly initialize bloom filter

Set fUseFilter argument

Increase bloom filter size to account for multiple signals

Set bloom filter parameters

Use constants for bloom filter parameters

Added filter size check

Added filter size check in masternode-sync

Update bloom filter

Changed bloom parameters

* Bump protocol version

* Update sync time for inv's

* Changes based on code review comments

* Make bloom filter size network dependent

* Fix network dependent filter parameters

* Remove unneeded constant definition

* Move constant definition

* Add blank line
2017-02-02 12:50:44 +04:00