mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge pull request #4333 from Munkybooty/backports-0.18-pr13
Backports 0.18 pr13
This commit is contained in:
commit
592cd0a939
@ -2,7 +2,7 @@
|
||||
# - sudo/dist/group are set so as to get Blue Box VMs, necessary for [loopback]
|
||||
# IPv6 support
|
||||
|
||||
dist: bionic
|
||||
dist: xenial
|
||||
|
||||
os: linux
|
||||
language: minimal
|
||||
|
@ -10,6 +10,8 @@ travis_retry docker pull "$DOCKER_NAME_TAG"
|
||||
env | grep -E '^(CCACHE_|WINEDEBUG|LC_ALL|BOOST_TEST_RANDOM|CONFIG_SHELL)' | tee /tmp/env
|
||||
if [[ $HOST = *-mingw32 ]]; then
|
||||
DOCKER_ADMIN="--cap-add SYS_ADMIN"
|
||||
elif [[ $BITCOIN_CONFIG = *--with-sanitizers=*address* ]]; then # If ran with (ASan + LSan), Docker needs access to ptrace (https://github.com/google/sanitizers/issues/764)
|
||||
DOCKER_ADMIN="--cap-add SYS_PTRACE"
|
||||
fi
|
||||
DOCKER_ID=$(docker run $DOCKER_ADMIN -idt --mount type=bind,src=$TRAVIS_BUILD_DIR,dst=$TRAVIS_BUILD_DIR --mount type=bind,src=$CCACHE_DIR,dst=$CCACHE_DIR -w $TRAVIS_BUILD_DIR --env-file /tmp/env $DOCKER_NAME_TAG)
|
||||
|
||||
|
@ -4,7 +4,7 @@ Upstream-Contact: Dash Core Group, Inc https://www.dash.org/team/
|
||||
Source: https://github.com/dashpay/dash
|
||||
|
||||
Files: *
|
||||
Copyright: 2009-2017, Bitcoin Core Developers,
|
||||
Copyright: 2009-2019, Bitcoin Core Developers,
|
||||
2019-2020, Dash Core Developers
|
||||
License: Expat
|
||||
Comment: The Bitcoin Core Developers encompasses the current developers listed on bitcoin.org,
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (c) 2017 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
@ -1,11 +1,11 @@
|
||||
package=expat
|
||||
$(package)_version=2.2.5
|
||||
$(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_2_2_5/
|
||||
$(package)_version=2.2.6
|
||||
$(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_2_2_6/
|
||||
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
|
||||
$(package)_sha256_hash=d9dc32efba7e74f788fcc4f212a43216fc37cf5f23f4c2339664d473353aedf6
|
||||
$(package)_sha256_hash=17b43c2716d521369f82fc2dc70f359860e90fa440bea65b3b85f0b246ea81f2
|
||||
|
||||
define $(package)_set_vars
|
||||
$(package)_config_opts=--disable-static
|
||||
$(package)_config_opts=--disable-static --without-docbook
|
||||
endef
|
||||
|
||||
define $(package)_config_cmds
|
||||
|
@ -1,9 +1,9 @@
|
||||
PACKAGE=qt
|
||||
$(package)_version=5.9.6
|
||||
$(package)_version=5.9.7
|
||||
$(package)_download_path=https://download.qt.io/archive/qt/5.9/$($(package)_version)/submodules
|
||||
$(package)_suffix=opensource-src-$($(package)_version).tar.xz
|
||||
$(package)_file_name=qtbase-$($(package)_suffix)
|
||||
$(package)_sha256_hash=eed620cb268b199bd83b3fc6a471c51d51e1dc2dbb5374fc97a0cc75facbe36f
|
||||
$(package)_sha256_hash=36dd9574f006eaa1e5af780e4b33d11fe39d09fd7c12f3b9d83294174bd28f00
|
||||
$(package)_dependencies=openssl zlib
|
||||
$(package)_linux_dependencies=freetype fontconfig libxcb
|
||||
$(package)_qt_libs=corelib network widgets gui plugins testlib
|
||||
@ -11,10 +11,10 @@ $(package)_patches=fix_qt_pkgconfig.patch mac-qmake.conf fix_configure_mac.patch
|
||||
|
||||
# Update OSX_QT_TRANSLATIONS when this is updated
|
||||
$(package)_qttranslations_file_name=qttranslations-$($(package)_suffix)
|
||||
$(package)_qttranslations_sha256_hash=9822084f8e2d2939ba39f4af4c0c2320e45d5996762a9423f833055607604ed8
|
||||
$(package)_qttranslations_sha256_hash=b36da7d93c3ab6fca56b32053bb73bc619c8b192bb89b74e3bcde2705f1c2a14
|
||||
|
||||
$(package)_qttools_file_name=qttools-$($(package)_suffix)
|
||||
$(package)_qttools_sha256_hash=50e75417ec0c74bb8b1989d1d8e981ee83690dce7dfc0c2169f7c00f397e5117
|
||||
$(package)_qttools_sha256_hash=d62e0f70d99645d6704dbb8976fb2222443061743689943d40970c52c49367a1
|
||||
|
||||
$(package)_extra_sources = $($(package)_qttranslations_file_name)
|
||||
$(package)_extra_sources += $($(package)_qttools_file_name)
|
||||
@ -27,6 +27,7 @@ $(package)_config_opts += -c++std c++11
|
||||
$(package)_config_opts += -confirm-license
|
||||
$(package)_config_opts += -dbus-runtime
|
||||
$(package)_config_opts += -hostprefix $(build_prefix)
|
||||
$(package)_config_opts += -no-compile-examples
|
||||
$(package)_config_opts += -no-cups
|
||||
$(package)_config_opts += -no-egl
|
||||
$(package)_config_opts += -no-eglfs
|
||||
@ -69,9 +70,20 @@ $(package)_config_opts += -system-zlib
|
||||
$(package)_config_opts += -static
|
||||
$(package)_config_opts += -silent
|
||||
$(package)_config_opts += -v
|
||||
$(package)_config_opts += -no-feature-dial
|
||||
$(package)_config_opts += -no-feature-ftp
|
||||
$(package)_config_opts += -no-feature-lcdnumber
|
||||
$(package)_config_opts += -no-feature-pdf
|
||||
$(package)_config_opts += -no-feature-printer
|
||||
$(package)_config_opts += -no-feature-printdialog
|
||||
$(package)_config_opts += -no-feature-concurrent
|
||||
$(package)_config_opts += -no-feature-sql
|
||||
$(package)_config_opts += -no-feature-statemachine
|
||||
$(package)_config_opts += -no-feature-syntaxhighlighter
|
||||
$(package)_config_opts += -no-feature-textbrowser
|
||||
$(package)_config_opts += -no-feature-textodfwriter
|
||||
$(package)_config_opts += -no-feature-udpsocket
|
||||
$(package)_config_opts += -no-feature-wizard
|
||||
$(package)_config_opts += -no-feature-xml
|
||||
|
||||
ifneq ($(build_os),darwin)
|
||||
|
@ -28,6 +28,8 @@ Developer Notes
|
||||
- [Strings and formatting](#strings-and-formatting)
|
||||
- [Shadowing](#shadowing)
|
||||
- [Threads and synchronization](#threads-and-synchronization)
|
||||
- [Scripts](#scripts)
|
||||
- [Shebang](#shebang)
|
||||
- [Source code organization](#source-code-organization)
|
||||
- [GUI](#gui)
|
||||
- [Subtrees](#subtrees)
|
||||
@ -621,6 +623,31 @@ TRY_LOCK(cs_vNodes, lockNodes);
|
||||
}
|
||||
```
|
||||
|
||||
Scripts
|
||||
--------------------------
|
||||
|
||||
### Shebang
|
||||
|
||||
- Use `#!/usr/bin/env bash` instead of obsolete `#!/bin/bash`.
|
||||
|
||||
- [*Rationale*](https://github.com/dylanaraps/pure-bash-bible#shebang):
|
||||
|
||||
`#!/bin/bash` assumes it is always installed to /bin/ which can cause issues;
|
||||
|
||||
`#!/usr/bin/env bash` searches the user's PATH to find the bash binary.
|
||||
|
||||
OK:
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
```
|
||||
|
||||
Wrong:
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
```
|
||||
|
||||
Source code organization
|
||||
--------------------------
|
||||
|
||||
|
10
doc/tor.md
10
doc/tor.md
@ -136,9 +136,13 @@ preconfigured and the creation of a hidden service is automatic. If permission p
|
||||
are seen with `-debug=tor` they can be resolved by adding both the user running Tor and
|
||||
the user running dashd to the same group and setting permissions appropriately. On
|
||||
Debian-based systems the user running dashd can be added to the debian-tor group,
|
||||
which has the appropriate permissions. An alternative authentication method is the use
|
||||
of the `-torpassword` flag and a `hash-password` which can be enabled and specified in
|
||||
Tor configuration.
|
||||
which has the appropriate permissions.
|
||||
|
||||
An alternative authentication method is the use
|
||||
of the `-torpassword=password` option. The `password` is the clear text form that
|
||||
was used when generating the hashed password for the `HashedControlPassword` option
|
||||
in the tor configuration file. The hashed password can be obtained with the command
|
||||
`tor --hash-password password` (read the tor manual for more details).
|
||||
|
||||
## 5. Privacy recommendations
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export LC_ALL=C
|
||||
set -e
|
||||
|
@ -227,6 +227,15 @@ public:
|
||||
return *phashBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this block's and all previous blocks' transactions have been
|
||||
* downloaded (and stored to disk) at some point.
|
||||
*
|
||||
* Does not imply the transactions are consensus-valid (ConnectTip might fail)
|
||||
* Does not imply the transactions are still stored on disk. (IsBlockPruned might return true)
|
||||
*/
|
||||
bool HaveTxsDownloaded() const { return nChainTx != 0; }
|
||||
|
||||
int64_t GetBlockTime() const
|
||||
{
|
||||
return (int64_t)nTime;
|
||||
|
@ -678,7 +678,7 @@ void SetupServerArgs()
|
||||
|
||||
gArgs.AddArg("-rest", strprintf("Accept public REST requests (default: %u)", DEFAULT_REST_ENABLE), false, OptionsCategory::RPC);
|
||||
gArgs.AddArg("-rpcallowip=<ip>", "Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times", false, OptionsCategory::RPC);
|
||||
gArgs.AddArg("-rpcauth=<userpw>", "Username and hashed password for JSON-RPC connections. The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A canonical python script is included in share/rpcuser. The client then connects normally using the rpcuser=<USERNAME>/rpcpassword=<PASSWORD> pair of arguments. This option can be specified multiple times", false, OptionsCategory::RPC);
|
||||
gArgs.AddArg("-rpcauth=<userpw>", "Username and HMAC-SHA-256 hashed password for JSON-RPC connections. The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A canonical python script is included in share/rpcuser. The client then connects normally using the rpcuser=<USERNAME>/rpcpassword=<PASSWORD> pair of arguments. This option can be specified multiple times", false, OptionsCategory::RPC);
|
||||
gArgs.AddArg("-rpcbind=<addr>[:port]", "Bind to given address to listen for JSON-RPC connections. Do not expose the RPC server to untrusted networks such as the public internet! This option is ignored unless -rpcallowip is also passed. Port is optional and overrides -rpcport. Use [host]:port notation for IPv6. This option can be specified multiple times (default: 127.0.0.1 and ::1 i.e., localhost, or if -rpcallowip has been specified, 0.0.0.0 and :: i.e., all addresses)", false, OptionsCategory::RPC);
|
||||
gArgs.AddArg("-rpccookiefile=<loc>", "Location of the auth cookie. Relative paths will be prefixed by a net-specific datadir location. (default: data dir)", false, OptionsCategory::RPC);
|
||||
gArgs.AddArg("-rpcpassword=<pw>", "Password for JSON-RPC connections", false, OptionsCategory::RPC);
|
||||
|
@ -704,7 +704,7 @@ static void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vec
|
||||
return;
|
||||
}
|
||||
if (pindex->nStatus & BLOCK_HAVE_DATA || chainActive.Contains(pindex)) {
|
||||
if (pindex->nChainTx)
|
||||
if (pindex->HaveTxsDownloaded())
|
||||
state->pindexLastCommonBlock = pindex;
|
||||
} else if (mapBlocksInFlight.count(pindex->GetBlockHash()) == 0) {
|
||||
// The block is not already downloaded, and not yet in flight.
|
||||
@ -1491,7 +1491,7 @@ void static ProcessGetBlockData(CNode* pfrom, const CChainParams& chainparams, c
|
||||
LOCK(cs_main);
|
||||
const CBlockIndex* pindex = LookupBlockIndex(inv.hash);
|
||||
if (pindex) {
|
||||
if (pindex->nChainTx && !pindex->IsValid(BLOCK_VALID_SCRIPTS) &&
|
||||
if (pindex->HaveTxsDownloaded() && !pindex->IsValid(BLOCK_VALID_SCRIPTS) &&
|
||||
pindex->IsValid(BLOCK_VALID_TREE)) {
|
||||
// If we have the block and all of its parents, but have not yet validated it,
|
||||
// we might be in the middle of connecting it (ie in the unlock of cs_main
|
||||
|
@ -134,6 +134,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle,
|
||||
if (QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||
createTrayIcon(networkStyle);
|
||||
}
|
||||
notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
|
||||
|
||||
// Create status bar
|
||||
statusBar();
|
||||
@ -708,8 +709,7 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
|
||||
unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel());
|
||||
|
||||
OptionsModel* optionsModel = _clientModel->getOptionsModel();
|
||||
if(optionsModel)
|
||||
{
|
||||
if (optionsModel && trayIcon) {
|
||||
// be aware of the tray icon disable state change reported by the OptionsModel object.
|
||||
connect(optionsModel,SIGNAL(hideTrayIconChanged(bool)),this,SLOT(setTrayIconVisible(bool)));
|
||||
|
||||
@ -835,12 +835,9 @@ void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
|
||||
{
|
||||
assert(QSystemTrayIcon::isSystemTrayAvailable());
|
||||
|
||||
trayIcon = new QSystemTrayIcon(this);
|
||||
trayIcon = new QSystemTrayIcon(networkStyle->getTrayAndWindowIcon(), this);
|
||||
QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + networkStyle->getTitleAddText();
|
||||
trayIcon->setToolTip(toolTip);
|
||||
trayIcon->setIcon(networkStyle->getTrayAndWindowIcon());
|
||||
trayIcon->hide();
|
||||
notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
|
||||
}
|
||||
|
||||
void BitcoinGUI::createIconMenu(QMenu *pmenu)
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
@ -1605,7 +1605,7 @@ static UniValue getchaintips(const JSONRPCRequest& request)
|
||||
} else if (block->nStatus & BLOCK_CONFLICT_CHAINLOCK) {
|
||||
// This block or one of its ancestors is conflicting with ChainLocks.
|
||||
status = "conflicting";
|
||||
} else if (block->nChainTx == 0) {
|
||||
} else if (!block->HaveTxsDownloaded()) {
|
||||
// This block cannot be connected because full block data for it or one of its parents is missing.
|
||||
status = "headers-only";
|
||||
} else if (block->IsValid(BLOCK_VALID_SCRIPTS)) {
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||
|
||||
thread_local FastRandomContext g_insecure_rand_ctx;
|
||||
FastRandomContext g_insecure_rand_ctx;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const uint256& num)
|
||||
{
|
||||
|
@ -19,7 +19,14 @@
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
thread_local extern FastRandomContext g_insecure_rand_ctx;
|
||||
/**
|
||||
* This global and the helpers that use it are not thread-safe.
|
||||
*
|
||||
* If thread-safety is needed, the global could be made thread_local (given
|
||||
* that thread_local is supported on all architectures we support) or a
|
||||
* per-thread instance could be used in the multi-threaded test.
|
||||
*/
|
||||
extern FastRandomContext g_insecure_rand_ctx;
|
||||
|
||||
/**
|
||||
* Flag to make GetRand in random.h return the same number
|
||||
|
@ -148,12 +148,13 @@ BOOST_AUTO_TEST_CASE(processnewblock_signals_ordering)
|
||||
// create a bunch of threads that repeatedly process a block generated above at random
|
||||
// this will create parallelism and randomness inside validation - the ValidationInterface
|
||||
// will subscribe to events generated during block validation and assert on ordering invariance
|
||||
boost::thread_group threads;
|
||||
std::vector<std::thread> threads;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
threads.create_thread([&blocks]() {
|
||||
threads.emplace_back([&blocks]() {
|
||||
bool ignored;
|
||||
FastRandomContext insecure;
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
auto block = blocks[InsecureRandRange(blocks.size() - 1)];
|
||||
auto block = blocks[insecure.randrange(blocks.size() - 1)];
|
||||
ProcessNewBlock(Params(), block, true, &ignored);
|
||||
}
|
||||
|
||||
@ -167,7 +168,9 @@ BOOST_AUTO_TEST_CASE(processnewblock_signals_ordering)
|
||||
});
|
||||
}
|
||||
|
||||
threads.join_all();
|
||||
for (auto& t : threads) {
|
||||
t.join();
|
||||
}
|
||||
while (GetMainSignals().CallbacksPending() > 0) {
|
||||
UninterruptibleSleep(std::chrono::milliseconds{100});
|
||||
}
|
||||
|
@ -2881,7 +2881,7 @@ CBlockIndex* CChainState::FindMostWorkChain() {
|
||||
CBlockIndex *pindexTest = pindexNew;
|
||||
bool fInvalidAncestor = false;
|
||||
while (pindexTest && !chainActive.Contains(pindexTest)) {
|
||||
assert(pindexTest->nChainTx || pindexTest->nHeight == 0);
|
||||
assert(pindexTest->HaveTxsDownloaded() || pindexTest->nHeight == 0);
|
||||
|
||||
// Pruned nodes may have entries in setBlockIndexCandidates for
|
||||
// which block files have been deleted. Remove those as candidates
|
||||
@ -3188,7 +3188,7 @@ bool CChainState::PreciousBlock(CValidationState& state, const CChainParams& par
|
||||
// call preciousblock 2**31-1 times on the same set of tips...
|
||||
nBlockReverseSequenceId--;
|
||||
}
|
||||
if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS) && !(pindex->nStatus & BLOCK_CONFLICT_CHAINLOCK) && pindex->nChainTx) {
|
||||
if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS) && !(pindex->nStatus & BLOCK_CONFLICT_CHAINLOCK) && pindex->HaveTxsDownloaded()) {
|
||||
setBlockIndexCandidates.insert(pindex);
|
||||
PruneBlockIndexCandidates();
|
||||
}
|
||||
@ -3259,7 +3259,7 @@ bool CChainState::InvalidateBlock(CValidationState& state, const CChainParams& c
|
||||
// add it again.
|
||||
BlockMap::iterator it = mapBlockIndex.begin();
|
||||
while (it != mapBlockIndex.end()) {
|
||||
if (it->second->IsValid(BLOCK_VALID_TRANSACTIONS) && !(it->second->nStatus & BLOCK_CONFLICT_CHAINLOCK) && it->second->nChainTx && !setBlockIndexCandidates.value_comp()(it->second, chainActive.Tip())) {
|
||||
if (it->second->IsValid(BLOCK_VALID_TRANSACTIONS) && !(it->second->nStatus & BLOCK_CONFLICT_CHAINLOCK) && it->second->HaveTxsDownloaded() && !setBlockIndexCandidates.value_comp()(it->second, chainActive.Tip())) {
|
||||
setBlockIndexCandidates.insert(it->second);
|
||||
}
|
||||
it++;
|
||||
@ -3330,7 +3330,7 @@ bool CChainState::MarkConflictingBlock(CValidationState& state, const CChainPara
|
||||
// add it again.
|
||||
BlockMap::iterator it = mapBlockIndex.begin();
|
||||
while (it != mapBlockIndex.end()) {
|
||||
if (it->second->IsValid(BLOCK_VALID_TRANSACTIONS) && !(it->second->nStatus & BLOCK_CONFLICT_CHAINLOCK) && it->second->nChainTx && !setBlockIndexCandidates.value_comp()(it->second, chainActive.Tip())) {
|
||||
if (it->second->IsValid(BLOCK_VALID_TRANSACTIONS) && !(it->second->nStatus & BLOCK_CONFLICT_CHAINLOCK) && it->second->HaveTxsDownloaded() && !setBlockIndexCandidates.value_comp()(it->second, chainActive.Tip())) {
|
||||
setBlockIndexCandidates.insert(it->second);
|
||||
}
|
||||
it++;
|
||||
@ -3372,7 +3372,7 @@ void CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) {
|
||||
if (!it->second->IsValid() && it->second->GetAncestor(nHeight) == pindex) {
|
||||
it->second->nStatus &= ~BLOCK_FAILED_MASK;
|
||||
setDirtyBlockIndex.insert(it->second);
|
||||
if (it->second->IsValid(BLOCK_VALID_TRANSACTIONS) && !(it->second->nStatus & BLOCK_CONFLICT_CHAINLOCK) && it->second->nChainTx && setBlockIndexCandidates.value_comp()(chainActive.Tip(), it->second)) {
|
||||
if (it->second->IsValid(BLOCK_VALID_TRANSACTIONS) && !(it->second->nStatus & BLOCK_CONFLICT_CHAINLOCK) && it->second->HaveTxsDownloaded() && setBlockIndexCandidates.value_comp()(chainActive.Tip(), it->second)) {
|
||||
setBlockIndexCandidates.insert(it->second);
|
||||
}
|
||||
if (it->second == pindexBestInvalid) {
|
||||
@ -3468,7 +3468,7 @@ void CChainState::ReceivedBlockTransactions(const CBlock& block, CBlockIndex* pi
|
||||
pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS);
|
||||
setDirtyBlockIndex.insert(pindexNew);
|
||||
|
||||
if (pindexNew->pprev == nullptr || pindexNew->pprev->nChainTx) {
|
||||
if (pindexNew->pprev == nullptr || pindexNew->pprev->HaveTxsDownloaded()) {
|
||||
// If pindexNew is the genesis block or all parents are BLOCK_VALID_TRANSACTIONS.
|
||||
std::deque<CBlockIndex*> queue;
|
||||
queue.push_back(pindexNew);
|
||||
@ -4318,7 +4318,7 @@ bool CChainState::LoadBlockIndex(const Consensus::Params& consensus_params, CBlo
|
||||
// Pruned nodes may have deleted the block.
|
||||
if (pindex->nTx > 0) {
|
||||
if (pindex->pprev) {
|
||||
if (pindex->pprev->nChainTx) {
|
||||
if (pindex->pprev->HaveTxsDownloaded()) {
|
||||
pindex->nChainTx = pindex->pprev->nChainTx + pindex->nTx;
|
||||
} else {
|
||||
pindex->nChainTx = 0;
|
||||
@ -4332,7 +4332,7 @@ bool CChainState::LoadBlockIndex(const Consensus::Params& consensus_params, CBlo
|
||||
pindex->nStatus |= BLOCK_FAILED_CHILD;
|
||||
setDirtyBlockIndex.insert(pindex);
|
||||
}
|
||||
if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS) && !(pindex->nStatus & BLOCK_CONFLICT_CHAINLOCK) && (pindex->nChainTx || pindex->pprev == nullptr))
|
||||
if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS) && !(pindex->nStatus & BLOCK_CONFLICT_CHAINLOCK) && (pindex->HaveTxsDownloaded() || pindex->pprev == nullptr))
|
||||
setBlockIndexCandidates.insert(pindex);
|
||||
if (pindex->nStatus & BLOCK_FAILED_MASK && (!pindexBestInvalid || pindex->nChainWork > pindexBestInvalid->nChainWork))
|
||||
pindexBestInvalid = pindex;
|
||||
@ -4959,7 +4959,7 @@ void CChainState::CheckBlockIndex(const Consensus::Params& consensusParams)
|
||||
assert(pindex->GetBlockHash() == consensusParams.hashGenesisBlock); // Genesis block's hash must match.
|
||||
assert(pindex == chainActive.Genesis()); // The current active chain's genesis block must be this block.
|
||||
}
|
||||
if (pindex->nChainTx == 0) assert(pindex->nSequenceId <= 0); // nSequenceId can't be set positive for blocks that aren't linked (negative is used for preciousblock)
|
||||
if (!pindex->HaveTxsDownloaded()) assert(pindex->nSequenceId <= 0); // nSequenceId can't be set positive for blocks that aren't linked (negative is used for preciousblock)
|
||||
// VALID_TRANSACTIONS is equivalent to nTx > 0 for all nodes (whether or not pruning has occurred).
|
||||
// HAVE_DATA is only equivalent to nTx > 0 (or VALID_TRANSACTIONS) if no pruning has occurred.
|
||||
if (!fHavePruned) {
|
||||
@ -4972,9 +4972,9 @@ void CChainState::CheckBlockIndex(const Consensus::Params& consensusParams)
|
||||
}
|
||||
if (pindex->nStatus & BLOCK_HAVE_UNDO) assert(pindex->nStatus & BLOCK_HAVE_DATA);
|
||||
assert(((pindex->nStatus & BLOCK_VALID_MASK) >= BLOCK_VALID_TRANSACTIONS) == (pindex->nTx > 0)); // This is pruning-independent.
|
||||
// All parents having had data (at some point) is equivalent to all parents being VALID_TRANSACTIONS, which is equivalent to nChainTx being set.
|
||||
assert((pindexFirstNeverProcessed != nullptr) == (pindex->nChainTx == 0)); // nChainTx != 0 is used to signal that all parent blocks have been processed (but may have been pruned).
|
||||
assert((pindexFirstNotTransactionsValid != nullptr) == (pindex->nChainTx == 0));
|
||||
// All parents having had data (at some point) is equivalent to all parents being VALID_TRANSACTIONS, which is equivalent to HaveTxsDownloaded().
|
||||
assert((pindexFirstNeverProcessed == nullptr) == pindex->HaveTxsDownloaded());
|
||||
assert((pindexFirstNotTransactionsValid == nullptr) == pindex->HaveTxsDownloaded());
|
||||
assert(pindex->nHeight == nHeight); // nHeight must be consistent.
|
||||
assert(pindex->pprev == nullptr || pindex->nChainWork >= pindex->pprev->nChainWork); // For every block except the genesis block, the chainwork must be larger than the parent's.
|
||||
assert(nHeight < 2 || (pindex->pskip && (pindex->pskip->nHeight < nHeight))); // The pskip pointer must point back for all but the first 2 blocks.
|
||||
|
@ -46,7 +46,7 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
|
||||
self.num_nodes = 4
|
||||
self.setup_clean_chain = False
|
||||
# Need a bit of extra time for the nodes to start up for this test
|
||||
self.rpc_timewait = 90
|
||||
self.rpc_timeout = 90
|
||||
|
||||
# Set -maxmempool=0 to turn off mempool memory sharing with dbcache
|
||||
# Set -rpcservertimeout=900 to reduce socket disconnects in this
|
||||
|
@ -29,7 +29,7 @@ class PruneTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.setup_clean_chain = True
|
||||
self.num_nodes = 6
|
||||
self.rpc_timewait = 900
|
||||
self.rpc_timeout = 900
|
||||
|
||||
# Create nodes 0 and 1 to mine.
|
||||
# Create node 2 to test pruning.
|
||||
|
@ -25,6 +25,7 @@ from test_framework.util import (
|
||||
assert_raises_rpc_error,
|
||||
bytes_to_hex_str as b2x,
|
||||
)
|
||||
from test_framework.script import CScriptNum
|
||||
|
||||
|
||||
def assert_template(node, block, expect, rehash=True):
|
||||
@ -59,11 +60,19 @@ class MiningTest(BitcoinTestFramework):
|
||||
assert 'proposal' in tmpl['capabilities']
|
||||
assert 'coinbasetxn' not in tmpl
|
||||
|
||||
coinbase_tx = create_coinbase(height=int(tmpl["height"]) + 1)
|
||||
next_height = int(tmpl["height"])
|
||||
coinbase_tx = create_coinbase(height=next_height)
|
||||
# sequence numbers must not be max for nLockTime to have effect
|
||||
coinbase_tx.vin[0].nSequence = 2 ** 32 - 2
|
||||
coinbase_tx.rehash()
|
||||
|
||||
# round-trip the encoded bip34 block height commitment
|
||||
assert_equal(CScriptNum.decode(coinbase_tx.vin[0].scriptSig), next_height)
|
||||
# round-trip negative and multi-byte CScriptNums to catch python regression
|
||||
assert_equal(CScriptNum.decode(CScriptNum.encode(CScriptNum(1500))), 1500)
|
||||
assert_equal(CScriptNum.decode(CScriptNum.encode(CScriptNum(-1500))), -1500)
|
||||
assert_equal(CScriptNum.decode(CScriptNum.encode(CScriptNum(-1))), -1)
|
||||
|
||||
block = CBlock()
|
||||
block.nVersion = tmpl["version"]
|
||||
block.hashPrevBlock = int(tmpl["previousblockhash"], 16)
|
||||
|
@ -30,7 +30,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
self.setup_clean_chain = True
|
||||
self.extra_args = [['-usehd=0']] * self.num_nodes
|
||||
|
||||
def setup_network(self, split=False):
|
||||
def setup_network(self):
|
||||
self.setup_nodes()
|
||||
|
||||
connect_nodes_bi(self.nodes, 0, 1)
|
||||
|
@ -45,7 +45,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
# TODO: remove -txindex. Currently required for getrawtransaction call.
|
||||
self.extra_args = [["-txindex"], ["-txindex"], ["-txindex"]]
|
||||
|
||||
def setup_network(self, split=False):
|
||||
def setup_network(self):
|
||||
super().setup_network()
|
||||
connect_nodes_bi(self.nodes, 0, 2)
|
||||
|
||||
|
@ -386,6 +386,22 @@ class CScriptNum:
|
||||
r[-1] |= 0x80
|
||||
return bytes([len(r)]) + r
|
||||
|
||||
@staticmethod
|
||||
def decode(vch):
|
||||
result = 0
|
||||
# We assume valid push_size and minimal encoding
|
||||
value = vch[1:]
|
||||
if len(value) == 0:
|
||||
return result
|
||||
for i, byte in enumerate(value):
|
||||
result |= int(byte) << 8*i
|
||||
if value[-1] >= 0x80:
|
||||
# Mask for all but the highest result bit
|
||||
num_mask = (2**(len(value)*8) - 1) >> 1
|
||||
result &= num_mask
|
||||
result *= -1
|
||||
return result
|
||||
|
||||
|
||||
class CScript(bytes):
|
||||
"""Serialized script
|
||||
|
@ -107,7 +107,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
self.nodes = []
|
||||
self.network_thread = None
|
||||
self.mocktime = 0
|
||||
self.rpc_timewait = 60 # Wait for up to 60 seconds for the RPC server to respond
|
||||
self.rpc_timeout = 60 # Wait for up to 60 seconds for the RPC server to respond
|
||||
self.supports_cli = False
|
||||
self.bind_to_localhost_only = True
|
||||
self.extra_args_from_options = []
|
||||
@ -321,7 +321,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
assert_equal(len(binary), num_nodes)
|
||||
for i in range(num_nodes):
|
||||
numnode = len(self.nodes)
|
||||
self.nodes.append(TestNode(numnode, get_datadir_path(self.options.tmpdir, numnode), self.extra_args_from_options, chain=self.chain, rpchost=rpchost, timewait=self.rpc_timewait, bitcoind=binary[i], bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, extra_conf=extra_confs[i], extra_args=extra_args[i], use_cli=self.options.usecli))
|
||||
self.nodes.append(TestNode(numnode, get_datadir_path(self.options.tmpdir, numnode), self.extra_args_from_options, chain=self.chain, rpchost=rpchost, timewait=self.rpc_timeout, bitcoind=binary[i], bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, extra_conf=extra_confs[i], extra_args=extra_args[i], use_cli=self.options.usecli))
|
||||
|
||||
def start_node(self, i, *args, **kwargs):
|
||||
"""Start a dashd"""
|
||||
@ -492,7 +492,13 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
args.append("-connect=127.0.0.1:" + str(p2p_port(0)))
|
||||
if extra_args is not None:
|
||||
args.extend(extra_args)
|
||||
self.nodes.append(TestNode(i, get_datadir_path(self.options.cachedir, i), chain=self.chain, extra_conf=["bind=127.0.0.1"], extra_args=[], extra_args_from_options=self.extra_args_from_options, rpchost=None, timewait=self.rpc_timewait, bitcoind=self.options.bitcoind, bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=None))
|
||||
self.nodes.append(TestNode(i, get_datadir_path(self.options.cachedir, i), chain=self.chain, extra_conf=["bind=127.0.0.1"], extra_args=[], extra_args_from_options=self.extra_args_from_options, rpchost=None,
|
||||
timewait=self.rpc_timeout,
|
||||
bitcoind=self.options.bitcoind,
|
||||
bitcoin_cli=self.options.bitcoincli,
|
||||
mocktime=self.mocktime,
|
||||
coverage_dir=None,
|
||||
))
|
||||
self.nodes[i].args = args
|
||||
self.start_node(i)
|
||||
|
||||
|
@ -362,7 +362,7 @@ def get_auth_cookie(datadir, chain):
|
||||
assert password is None # Ensure that there is only one rpcpassword line
|
||||
password = line.split("=")[1].strip("\n")
|
||||
chain = get_chain_folder(datadir, chain)
|
||||
if os.path.isfile(os.path.join(datadir, chain, ".cookie")):
|
||||
if os.path.isfile(os.path.join(datadir, chain, ".cookie")) and os.access(os.path.join(datadir, chain, ".cookie"), os.R_OK):
|
||||
with open(os.path.join(datadir, chain, ".cookie"), 'r', encoding="ascii") as f:
|
||||
userpass = f.read()
|
||||
split_userpass = userpass.split(':')
|
||||
|
@ -45,7 +45,7 @@ class WalletBackupTest(BitcoinTestFramework):
|
||||
# nodes 1, 2,3 are spenders, let's give them a keypool=100
|
||||
self.extra_args = [["-keypool=100"], ["-keypool=100"], ["-keypool=100"], []]
|
||||
|
||||
def setup_network(self, split=False):
|
||||
def setup_network(self):
|
||||
self.setup_nodes()
|
||||
connect_nodes(self.nodes[0], 3)
|
||||
connect_nodes(self.nodes[1], 3)
|
||||
|
@ -21,7 +21,7 @@ class WalletGroupTest(BitcoinTestFramework):
|
||||
self.setup_clean_chain = True
|
||||
self.num_nodes = 3
|
||||
self.extra_args = [[], [], ['-avoidpartialspends']]
|
||||
self.rpc_timewait = 120
|
||||
self.rpc_timeout = 120
|
||||
|
||||
def run_test (self):
|
||||
# Mine some coins
|
||||
|
@ -20,23 +20,23 @@ fi
|
||||
RET=0
|
||||
PREV_BRANCH=`git name-rev --name-only HEAD`
|
||||
PREV_HEAD=`git rev-parse HEAD`
|
||||
for i in `git rev-list --reverse $1`; do
|
||||
if git rev-list -n 1 --pretty="%s" $i | grep -q "^scripted-diff:"; then
|
||||
git checkout --quiet $i^ || exit
|
||||
SCRIPT="`git rev-list --format=%b -n1 $i | sed '/^-BEGIN VERIFY SCRIPT-$/,/^-END VERIFY SCRIPT-$/{//!b};d'`"
|
||||
for commit in `git rev-list --reverse $1`; do
|
||||
if git rev-list -n 1 --pretty="%s" $commit | grep -q "^scripted-diff:"; then
|
||||
git checkout --quiet $commit^ || exit
|
||||
SCRIPT="`git rev-list --format=%b -n1 $commit | sed '/^-BEGIN VERIFY SCRIPT-$/,/^-END VERIFY SCRIPT-$/{//!b};d'`"
|
||||
if test -z "$SCRIPT"; then
|
||||
echo "Error: missing script for: $i"
|
||||
echo "Error: missing script for: $commit"
|
||||
echo "Failed"
|
||||
RET=1
|
||||
else
|
||||
echo "Running script for: $i"
|
||||
echo "Running script for: $commit"
|
||||
echo "$SCRIPT"
|
||||
eval "$SCRIPT"
|
||||
git --no-pager diff --exit-code $i && echo "OK" || (echo "Failed"; false) || RET=1
|
||||
(eval "$SCRIPT")
|
||||
git --no-pager diff --exit-code $commit && echo "OK" || (echo "Failed"; false) || RET=1
|
||||
fi
|
||||
git reset --quiet --hard HEAD
|
||||
else
|
||||
if git rev-list "--format=%b" -n1 $i | grep -q '^-\(BEGIN\|END\)[ a-zA-Z]*-$'; then
|
||||
if git rev-list "--format=%b" -n1 $commit | grep -q '^-\(BEGIN\|END\)[ a-zA-Z]*-$'; then
|
||||
echo "Error: script block marker but no scripted-diff in title"
|
||||
echo "Failed"
|
||||
RET=1
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Shebang must use python3 (not python or python2)
|
||||
# Assert expected shebang lines
|
||||
|
||||
export LC_ALL=C
|
||||
EXIT_CODE=0
|
||||
@ -10,4 +10,11 @@ for PYTHON_FILE in $(git ls-files -- "*.py"); do
|
||||
EXIT_CODE=1
|
||||
fi
|
||||
done
|
||||
for SHELL_FILE in $(git ls-files -- "*.sh"); do
|
||||
if [[ $(head -n 1 "${SHELL_FILE}") != "#!/usr/bin/env bash" &&
|
||||
$(head -n 1 "${SHELL_FILE}") != "#!/bin/sh" ]]; then
|
||||
echo "Missing expected shebang \"#!/usr/bin/env bash\" or \"#!/bin/sh\" in ${SHELL_FILE}"
|
||||
EXIT_CODE=1
|
||||
fi
|
||||
done
|
||||
exit ${EXIT_CODE}
|
Loading…
Reference in New Issue
Block a user