* 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
* 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
* 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.
* 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
* 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
* 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.
* 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
* 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.
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)
* 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
* 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.
* 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
* 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