Commit Graph

225 Commits

Author SHA1 Message Date
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
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
Holger Schinzel
96dda2790c added testnet checkpoint (#1235) 2016-12-30 08:05:29 +01:00
Holger Schinzel
e1702cd4ec bump copyright notice to 2017 (#1207) 2016-12-20 17:26:45 +04:00
UdjinM6
072b0fd708 fix annoying compiler warnings (#1204) 2016-12-14 17:33:46 +04:00
UdjinM6
b8557662d3 Rewrite fulfilled requests handling (#1040) 2016-09-27 11:50:04 +04:00
Evan Duffield
7d1dd5f63c Merge pull request #1008 from UdjinM6/makeTestnetMixingHarder
Make testnet mixing as hard as on mainnet
2016-09-13 08:16:41 -07:00
UdjinM6
8641ae189b Assign base58Prefixes[EXT_COIN_TYPE] properly (#1007) 2016-09-12 21:40:46 +04:00
UdjinM6
9ae4d51bc7 Make testnet mixing harder.
Require 3 participants (same as on mainnet)
2016-09-11 21:34:26 +03:00
Tim Flynn
a31e0cadec Set mainnet superblock cycle to monthly 2016-09-11 14:01:26 -04:00
Tim Flynn
740d1e0b1e Push out mainnet superblock start, in case people run 12.1 on mainnet (#999) 2016-09-09 19:51:46 +04:00
Holger Schinzel
9738a238fa Merge #997: update testnet checkpoint
696d8f4 update testnet checkpoint
2016-09-08 13:33:29 +02:00
Tim Flynn
b68e119e4d Changed testnet parameters to activate superblocks for 12.1 with sentinel. (#971)
- Note that this is expected to fork testnet around block 60000
2016-08-29 03:22:25 +04:00