From df45564cf0ad3b591d4eb8cc2354093bcb7df14c Mon Sep 17 00:00:00 2001 From: dexX7 Date: Fri, 27 Mar 2015 01:07:49 +0100 Subject: [PATCH 1/7] Initialization: set fallback locale as environment variable The scope of `std::locale::global` appears to be smaller than `setenv("LC_ALL", ...)` and insufficient to fix messed up locale settings for the whole application. --- src/util.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index a03f55c91..4fea18b30 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -713,18 +713,19 @@ void RenameThread(const char* name) void SetupEnvironment() { + std::locale loc("C"); // On most POSIX systems (e.g. Linux, but not BSD) the environment's locale // may be invalid, in which case the "C" locale is used as fallback. #if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__) try { - std::locale(""); // Raises a runtime error if current locale is invalid + loc = std::locale(""); // Raises a runtime error if current locale is invalid } catch (const std::runtime_error&) { - std::locale::global(std::locale("C")); + setenv("LC_ALL", "C", 1); } #endif // The path locale is lazy initialized and to avoid deinitialization errors // in multithreading environments, it is set explicitly by the main thread. - boost::filesystem::path::imbue(std::locale()); + boost::filesystem::path::imbue(loc); } void SetThreadPriority(int nPriority) From 7494e0915b1b6ab0d68b77a2f9140e365e41cef8 Mon Sep 17 00:00:00 2001 From: dexX7 Date: Wed, 25 Mar 2015 12:09:17 +0100 Subject: [PATCH 2/7] Initialization: setup environment before starting tests The environment is prepared by the main thread to guard against invalid locale settings and to prevent deinitialization issues of Boost path, which can result in app crashes. --- src/test/test_bitcoin.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 5269e3bda..30626267f 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -30,6 +30,7 @@ struct TestingSetup { boost::thread_group threadGroup; TestingSetup() { + SetupEnvironment(); fPrintToDebugLog = false; // don't want to write to debug.log file fCheckBlockIndex = true; SelectParams(CBaseChainParams::UNITTEST); From 323de27f4b6a9673902cb414c3b0e3879b1366e7 Mon Sep 17 00:00:00 2001 From: dexX7 Date: Fri, 27 Mar 2015 01:33:34 +0100 Subject: [PATCH 3/7] Initialization: setup environment before starting QT tests The environment is prepared by the main thread to guard against invalid locale settings. --- src/qt/test/test_main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp index f2161c2f7..7d7282db1 100644 --- a/src/qt/test/test_main.cpp +++ b/src/qt/test/test_main.cpp @@ -6,6 +6,7 @@ #include "config/bitcoin-config.h" #endif +#include "util.h" #include "uritests.h" #ifdef ENABLE_WALLET @@ -27,6 +28,7 @@ Q_IMPORT_PLUGIN(qkrcodecs) // This is all you need to run all the tests int main(int argc, char *argv[]) { + SetupEnvironment(); bool fInvalid = false; // Don't remove this, it's needed to access From bac6fca3c91ba4c0e3c64d65c5c359b50036a2b6 Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Mon, 13 Apr 2015 12:26:28 -0400 Subject: [PATCH 4/7] Set nSequenceId when a block is fully linked Also adds a test to CheckBlockIndex Conflicts: src/main.cpp Rebased-From: c1ecee8f723c2635fbd51100fa09acdb0cbec8a0 Github-Pull: #6010 --- src/main.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4685c779a..c37e1092e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2319,10 +2319,6 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl pindexNew->nUndoPos = 0; pindexNew->nStatus |= BLOCK_HAVE_DATA; pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS); - { - LOCK(cs_nBlockSequenceId); - pindexNew->nSequenceId = nBlockSequenceId++; - } setDirtyBlockIndex.insert(pindexNew); if (pindexNew->pprev == NULL || pindexNew->pprev->nChainTx) { @@ -2335,6 +2331,10 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl CBlockIndex *pindex = queue.front(); queue.pop_front(); pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx; + { + LOCK(cs_nBlockSequenceId); + pindex->nSequenceId = nBlockSequenceId++; + } if (chainActive.Tip() == NULL || !setBlockIndexCandidates.value_comp()(pindex, chainActive.Tip())) { setBlockIndexCandidates.insert(pindex); } @@ -3272,6 +3272,11 @@ void static CheckBlockIndex() assert(pindex->GetBlockHash() == Params().HashGenesisBlock()); // Genesis block's hash must match. assert(pindex == chainActive.Genesis()); // The current active chain's genesis block must be this block. } + // HAVE_DATA is equivalent to VALID_TRANSACTIONS and equivalent to nTx > 0 (we stored the number of transactions in the block) + assert(!(pindex->nStatus & BLOCK_HAVE_DATA) == (pindex->nTx == 0)); + assert(((pindex->nStatus & BLOCK_VALID_MASK) >= BLOCK_VALID_TRANSACTIONS) == (pindex->nTx > 0)); + if (pindex->nChainTx == 0) assert(pindex->nSequenceId == 0); // nSequenceId can't be set for blocks that aren't linked + // All parents having data is equivalent to all parents being VALID_TRANSACTIONS, which is equivalent to nChainTx being set. assert((pindexFirstMissing != NULL) == (pindex->nChainTx == 0)); // nChainTx == 0 is used to signal that all parent block's transaction data is available. assert(pindex->nHeight == nHeight); // nHeight must be consistent. assert(pindex->pprev == NULL || pindex->nChainWork >= pindex->pprev->nChainWork); // For every block except the genesis block, the chainwork must be larger than the parent's. From 139cd8177be4895f8b4c2befee35030bdf961326 Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Sun, 19 Apr 2015 11:47:56 -0700 Subject: [PATCH 5/7] Cap nAttempts penalty at 8 and switch to pow instead of a division loop. On hosts that had spent some time with a failed internet connection their nAttempts penalty was going through the roof (e.g. thousands for all peers) and as a result the connect search was pegging the CPU and failing to get more than a 4 connections after days of running (because it was taking so long per try). Rebased-From: a784f90c9892f06b9fea4e7579f5eca3585482c3 Github-Pull: #6029 --- src/addrman.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/addrman.cpp b/src/addrman.cpp index 015589343..ad7fa9bd5 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -67,9 +67,8 @@ double CAddrInfo::GetChance(int64_t nNow) const if (nSinceLastTry < 60 * 10) fChance *= 0.01; - // deprioritize 50% after each failed attempt - for (int n = 0; n < nAttempts; n++) - fChance /= 1.5; + // deprioritize 66% after each failed attempt, but at most 1/28th to avoid the search taking forever or overly penalizing outages. + fChance *= pow(0.66, min(nAttempts, 8)); return fChance; } From bf8ad0dc6b9c195cba7f432f7556e4ba78aa664a Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Mon, 20 Apr 2015 14:04:32 +0200 Subject: [PATCH 6/7] update release notes for 0.10.1rc3 --- doc/release-notes.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/release-notes.md b/doc/release-notes.md index 981e62441..cdb2369bb 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -59,6 +59,7 @@ behavior, not code moves, refactors or string updates. RPC: - `7f502be` fix crash: createmultisig and addmultisigaddress +- `eae305f` Fix missing lock in submitblock Block (database) and transaction handling: - `1d2cdd2` Fix InvalidateBlock to add chainActive.Tip to setBlockIndexCandidates @@ -66,6 +67,8 @@ Block (database) and transaction handling: - `002c8a2` fix possible block db breakage during re-index - `a1f425b` Add (optional) consistency check for the block chain data structures - `1c62e84` Keep mempool consistent during block-reorgs +- `57d1f46` Fix CheckBlockIndex for reindex +- `bac6fca` Set nSequenceId when a block is fully linked P2P protocol and network code: - `78f64ef` don't trickle for whitelisted nodes @@ -77,6 +80,7 @@ P2P protocol and network code: - `0c6f334` Always use a 50% chance to choose between tried and new entries (countermeasure 2 against eclipse attacks) - `214154e` Do not bias outgoing connections towards fresh addresses (countermeasure 2 against eclipse attacks) - `aa587d4` Scale up addrman (countermeasure 6 against eclipse attacks) +- `139cd81` Cap nAttempts penalty at 8 and switch to pow instead of a division loop Validation: - `d148f62` Acquire CCheckQueue's lock to avoid race condition @@ -98,6 +102,9 @@ Tests: Miscellaneous: - `c9e022b` Initialization: set Boost path locale in main thread - `23126a0` Sanitize command strings before logging them. +- `323de27` Initialization: setup environment before starting QT tests +- `7494e09` Initialization: setup environment before starting tests +- `df45564` Initialization: set fallback locale as environment variable Credits ======= @@ -113,6 +120,8 @@ Thanks to everyone who contributed to this release: - Ivan Pustogarov - Jonas Nick - Jonas Schnelli +- Matt Corallo +- mrbandrews - Pieter Wuille - Ruben de Vries - Suhas Daftuar From d8ac90184254fea3a7f4991fd0529dfbd750aea0 Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Sat, 25 Apr 2015 10:04:50 +0200 Subject: [PATCH 7/7] doc: improve credits in release notes --- doc/release-notes.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/doc/release-notes.md b/doc/release-notes.md index cdb2369bb..5e939600a 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -3,8 +3,7 @@ Bitcoin Core version 0.10.1 is now available from: This is a new minor version release, bringing bug fixes and translation -updates. If you are using 0.10.0, it is recommended to upgrade to this -version. +updates. It is recommended to upgrade to this version. Please report bugs using the issue tracker at github: @@ -109,7 +108,7 @@ Miscellaneous: Credits ======= -Thanks to everyone who contributed to this release: +Thanks to everyone who directly contributed to this release: - Alex Morcos - Cory Fields @@ -118,7 +117,6 @@ Thanks to everyone who contributed to this release: - Gavin Andresen - Gregory Maxwell - Ivan Pustogarov -- Jonas Nick - Jonas Schnelli - Matt Corallo - mrbandrews @@ -127,4 +125,19 @@ Thanks to everyone who contributed to this release: - Suhas Daftuar - Wladimir J. van der Laan +And all those who contributed additional code review and/or security research: +- 21E14 +- Alison Kendler +- Aviv Zohar +- Ethan Heilman +- Evil-Knievel +- fanquake +- Jeff Garzik +- Jonas Nick +- Luke Dashjr +- Patrick Strateman +- Philip Kaufmann +- Sergio Demian Lerner +- Sharon Goldberg + As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/).