Skip to content

Commit ed857ac

Browse files
authored
Merge #608: Bitcoin v0.15.1 backport to master
2 parents 77d4ea8 + dcf4f87 commit ed857ac

File tree

12 files changed

+600
-213
lines changed

12 files changed

+600
-213
lines changed

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
22
AC_PREREQ([2.60])
33
define(_CLIENT_VERSION_MAJOR, 2)
4-
define(_CLIENT_VERSION_MINOR, 2)
5-
define(_CLIENT_VERSION_REVISION, 2)
4+
define(_CLIENT_VERSION_MINOR, 4)
5+
define(_CLIENT_VERSION_REVISION, 0)
66
define(_CLIENT_VERSION_BUILD, 0)
77
define(_CLIENT_VERSION_IS_RELEASE, true)
88
define(_COPYRIGHT_YEAR, 2018)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
Raven Core version *2.4.0* is now available!!
2+
==============
3+
4+
<https://github.com/RavenProject/Ravencoin/releases/tag/v2.4.0>
5+
6+
7+
This is a major release containing bug fixes and enhancements for all builds before it. It is highly recommended that users
8+
upgrade to this version.
9+
10+
Please report bugs using the issue tracker at GitHub:
11+
12+
<https://github.com/RavenProject/Ravencoin/issues>
13+
14+
To receive security and update notifications, please subscribe to:
15+
16+
<https://ravencoin.org/en/list/announcements/join/>
17+
18+
How to Upgrade
19+
==============
20+
21+
If you are running an older version, shut it down. Wait until it has completely
22+
shut down (which might take a few minutes for older versions), then run the
23+
installer (on Windows) or just copy over `/Applications/Raven-Qt` (on Mac)
24+
or `ravend`/`raven-qt` (on Linux).
25+
26+
Downgrading warning
27+
==============
28+
29+
You may downgrade at any time if needed.
30+
31+
Note: There are no consensus-rule changes between versions v2.2.3/v2.2.2 and 2.4.0 - running versions in this range
32+
will not fork the chain.
33+
34+
Compatibility
35+
==============
36+
37+
Raven Core is extensively tested on multiple operating systems using
38+
the Linux kernel, macOS 10.8+, and Windows 10(x64) and later. 32-bit versions of Windows,
39+
and Windows XP are not supported.
40+
41+
Raven Core should also work on most other Unix-like systems but is not
42+
frequently tested on them.
43+
44+
Raven Core has been tested with macOS 10.14 Mojave, but it is recommended that *developers*
45+
do not update to Mojave. There is an incompatibility with Berkeley-db 4.8.30 that causes
46+
the binaries to seg-fault. There is a workaround, but as of this release users should
47+
not update to Mojave (see build-OSX.md for current status of this issue). There are no
48+
known issues running the release binaries on Mojave.
49+
50+
Raven Core has not been tested with macOS Catalina(beta). Please use at your own risk.
51+
52+
Notable changes
53+
==============
54+
*This list includes changes from all releases between 2.2.2/2.2.3 and 2.4.0*
55+
- Backport of Bitcoin v0.15.1 networking updates
56+
- Reorganization of pointer access objects in functions
57+
58+
59+
2.4.0 Change log
60+
==============
61+
62+
Changelog available here: <https://github.com/RavenProject/Ravencoin/commits/release_2.4.0>
63+
64+
Credits
65+
==============
66+
67+
Thanks to everyone who directly contributed to this release:
68+
69+
- Most importantly - The Raven Community!
70+
- @blondfrogs (Jeremy Anderson) - [77f5a7838082669dbb7c21b4a93ce65e2a447963](https://github.com/RavenProject/Ravencoin/pull/608/commits/77f5a7838082669dbb7c21b4a93ce65e2a447963)
71+
- @blondfrogs (Jeremy Anderson) - [fbbc40d22646c31465fa04a8a55f4734c3f75a9c](https://github.com/RavenProject/Ravencoin/pull/608/commits/fbbc40d22646c31465fa04a8a55f4734c3f75a9c)
72+
- @practicalswift - [ba4d362a2b4ba814bba2aa2589231ba470f20e3f](https://github.com/RavenProject/Ravencoin/pull/608/commits/ba4d362a2b4ba814bba2aa2589231ba470f20e3f)
73+
- @sdaftuar - [3027dd58001624f388dc522ec9c73eb5fc9aee70](https://github.com/RavenProject/Ravencoin/pull/608/commits/3027dd58001624f388dc522ec9c73eb5fc9aee70)
74+
- @sdaftuar - [dc5cc1e5980b30a21427f75a7d4085f4755d4085](https://github.com/RavenProject/Ravencoin/pull/608/commits/dc5cc1e5980b30a21427f75a7d4085f4755d4085)
75+
- @sdaftuar - [a743e754fd90ce3299b237700082e12c8cbcf3b4](https://github.com/RavenProject/Ravencoin/pull/608/commits/a743e754fd90ce3299b237700082e12c8cbcf3b4)
76+
- @sdaftuar - [08efce585df53f86f13ec5d1dff689237c0ce4cc](https://github.com/RavenProject/Ravencoin/pull/608/commits/08efce585df53f86f13ec5d1dff689237c0ce4cc)
77+
- @sdaftuar - [2d4826beee72e1a3749c1eb090a37139f3099a22](https://github.com/RavenProject/Ravencoin/pull/608/commits/2d4826beee72e1a3749c1eb090a37139f3099a22)
78+
- @TheBlueMatt - [ffeb6ee6b27e778fdee188d12032b6ac7d2d1eb4](https://github.com/RavenProject/Ravencoin/pull/608/commits/ffeb6ee6b27e778fdee188d12032b6ac7d2d1eb4)
79+
- @TheBlueMatt - [c27081c79eb6dca48e457d8dd5b09090771a75b7](https://github.com/RavenProject/Ravencoin/pull/608/commits/c27081c79eb6dca48e457d8dd5b09090771a75b7)
80+

src/consensus/tx_verify.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,17 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, c
381381
}
382382

383383
//! Check to make sure that the inputs and outputs CAmount match exactly.
384-
bool Consensus::CheckTxAssets(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, std::vector<std::pair<std::string, uint256> >& vPairReissueAssets, const bool fRunningUnitTests)
384+
bool Consensus::CheckTxAssets(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, std::vector<std::pair<std::string, uint256> >& vPairReissueAssets, const bool fRunningUnitTests, CAssetsCache* assetsCache)
385385
{
386+
if (!fRunningUnitTests) {
387+
if (!assetsCache)
388+
assetsCache = GetCurrentAssetCache();
389+
}
390+
391+
if (!assetsCache && !fRunningUnitTests) {
392+
return error("%s : Assets Cache is null, failing", __func__);
393+
}
394+
386395
// are the actual inputs available?
387396
if (!inputs.HaveInputs(tx)) {
388397
return state.DoS(100, false, REJECT_INVALID, "bad-txns-inputs-missing-or-spent", false,
@@ -428,15 +437,14 @@ bool Consensus::CheckTxAssets(const CTransaction& tx, CValidationState& state, c
428437
else
429438
totalOutputs.insert(make_pair(transfer.strName, transfer.nAmount));
430439

431-
auto currentActiveAssetCache = GetCurrentAssetCache();
432440
if (!fRunningUnitTests) {
433441
if (IsAssetNameAnOwner(transfer.strName)) {
434442
if (transfer.nAmount != OWNER_ASSET_AMOUNT)
435443
return state.DoS(100, false, REJECT_INVALID, "bad-txns-transfer-owner-amount-was-not-1");
436444
} else {
437445
// For all other types of assets, make sure they are sending the right type of units
438446
CNewAsset asset;
439-
if (!currentActiveAssetCache->GetAssetMetaDataIfExists(transfer.strName, asset))
447+
if (!assetsCache->GetAssetMetaDataIfExists(transfer.strName, asset))
440448
return state.DoS(100, false, REJECT_INVALID, "bad-txns-transfer-asset-not-exist");
441449

442450
if (asset.strName != transfer.strName)
@@ -453,9 +461,8 @@ bool Consensus::CheckTxAssets(const CTransaction& tx, CValidationState& state, c
453461
return state.DoS(100, false, REJECT_INVALID, "bad-tx-asset-reissue-bad-deserialize");
454462

455463
if (!fRunningUnitTests) {
456-
auto currentActiveAssetCache = GetCurrentAssetCache();
457464
std::string strError;
458-
if (!reissue.IsValid(strError, *currentActiveAssetCache)) {
465+
if (!reissue.IsValid(strError, *assetsCache)) {
459466
return state.DoS(100, false, REJECT_INVALID,
460467
"bad-txns" + strError);
461468
}

src/consensus/tx_verify.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace Consensus {
3535
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee);
3636

3737
/** RVN START */
38-
bool CheckTxAssets(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, std::vector<std::pair<std::string, uint256> >& vPairReissueAssets, const bool fRunningUnitTests = false);
38+
bool CheckTxAssets(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, std::vector<std::pair<std::string, uint256> >& vPairReissueAssets, const bool fRunningUnitTests = false, CAssetsCache* assetsCache=nullptr);
3939
/** RVN END */
4040
} // namespace Consensus
4141

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
12951295
g_connman = std::unique_ptr<CConnman>(new CConnman(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max())));
12961296
CConnman& connman = *g_connman;
12971297

1298-
peerLogic.reset(new PeerLogicValidation(&connman));
1298+
peerLogic.reset(new PeerLogicValidation(&connman, scheduler));
12991299
RegisterValidationInterface(peerLogic.get());
13001300

13011301
// sanitize comments per BIP-0014, format user agent and check total size

src/net.cpp

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,11 @@ static std::vector<CAddress> convertSeed6(const std::vector<SeedSpec6> &vSeedsIn
140140
const int64_t nOneWeek = 7*24*60*60;
141141
std::vector<CAddress> vSeedsOut;
142142
vSeedsOut.reserve(vSeedsIn.size());
143-
for (const auto& seed_in : vSeedsIn) {
143+
for (std::vector<SeedSpec6>::const_iterator i(vSeedsIn.begin()); i != vSeedsIn.end(); ++i)
144+
{
144145
struct in6_addr ip;
145-
memcpy(&ip, seed_in.addr, sizeof(ip));
146-
CAddress addr(CService(ip, seed_in.port), NODE_NETWORK);
146+
memcpy(&ip, i->addr, sizeof(ip));
147+
CAddress addr(CService(ip, i->port), NODE_NETWORK);
147148
addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
148149
vSeedsOut.push_back(addr);
149150
}
@@ -1706,15 +1707,46 @@ void CConnman::ProcessOneShot()
17061707
}
17071708
}
17081709

1709-
void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
1710+
bool CConnman::GetTryNewOutboundPeer()
1711+
{
1712+
return m_try_another_outbound_peer;
1713+
}
1714+
1715+
void CConnman::SetTryNewOutboundPeer(bool flag)
1716+
{
1717+
m_try_another_outbound_peer = flag;
1718+
LogPrint(BCLog::NET, "net: setting try another outbound peer=%s\n", flag ? "true" : "false");
1719+
}
1720+
1721+
// Return the number of peers we have over our outbound connection limit
1722+
// Exclude peers that are marked for disconnect, or are going to be
1723+
// disconnected soon (eg one-shots and feelers)
1724+
// Also exclude peers that haven't finished initial connection handshake yet
1725+
// (so that we don't decide we're over our desired connection limit, and then
1726+
// evict some peer that has finished the handshake)
1727+
int CConnman::GetExtraOutboundCount()
1728+
{
1729+
int nOutbound = 0;
1730+
{
1731+
LOCK(cs_vNodes);
1732+
for (CNode* pnode : vNodes) {
1733+
if (!pnode->fInbound && !pnode->m_manual_connection && !pnode->fFeeler && !pnode->fDisconnect && !pnode->fOneShot && pnode->fSuccessfullyConnected) {
1734+
++nOutbound;
1735+
}
1736+
}
1737+
}
1738+
return std::max(nOutbound - nMaxOutbound, 0);
1739+
}
1740+
1741+
void CConnman::ThreadOpenConnections()
17101742
{
17111743
// Connect to specific addresses
1712-
if (!connect.empty())
1744+
if (gArgs.IsArgSet("-connect"))
17131745
{
17141746
for (int64_t nLoop = 0;; nLoop++)
17151747
{
17161748
ProcessOneShot();
1717-
for (const std::string& strAddr : connect)
1749+
for (const std::string& strAddr : gArgs.GetArgs("-connect"))
17181750
{
17191751
CAddress addr(CService(), NODE_NONE);
17201752
OpenNetworkConnection(addr, false, nullptr, strAddr.c_str(), false, false, true);
@@ -1796,7 +1828,8 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
17961828
// * Only make a feeler connection once every few minutes.
17971829
//
17981830
bool fFeeler = false;
1799-
if (nOutbound >= nMaxOutbound) {
1831+
1832+
if (nOutbound >= nMaxOutbound && !GetTryNewOutboundPeer()) {
18001833
int64_t nTime = GetTimeMicros(); // The current time right now (in microseconds).
18011834
if (nTime > nNextFeeler) {
18021835
nNextFeeler = PoissonNextSend(nTime, FEELER_INTERVAL);
@@ -2224,6 +2257,7 @@ CConnman::CConnman(uint64_t nSeed0In, uint64_t nSeed1In) : nSeed0(nSeed0In), nSe
22242257
semOutbound = nullptr;
22252258
semAddnode = nullptr;
22262259
flagInterruptMsgProc = false;
2260+
SetTryNewOutboundPeer(false);
22272261

22282262
Options connOptions;
22292263
Init(connOptions);
@@ -2373,7 +2407,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
23732407
return false;
23742408
}
23752409
if (connOptions.m_use_addrman_outgoing || !connOptions.m_specified_outgoing.empty())
2376-
threadOpenConnections = std::thread(&TraceThread<std::function<void()> >, "opencon", std::function<void()>(std::bind(&CConnman::ThreadOpenConnections, this, connOptions.m_specified_outgoing)));
2410+
threadOpenConnections = std::thread(&TraceThread<std::function<void()> >, "opencon", std::function<void()>(std::bind(&CConnman::ThreadOpenConnections, this)));
23772411

23782412
// Process messages
23792413
threadMessageHandler = std::thread(&TraceThread<std::function<void()> >, "msghand", std::function<void()>(std::bind(&CConnman::ThreadMessageHandler, this)));

src/net.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,19 @@ class CConnman
254254
void GetBanned(banmap_t &banmap);
255255
void SetBanned(const banmap_t &banmap);
256256

257+
// This allows temporarily exceeding nMaxOutbound, with the goal of finding
258+
// a peer that is better than all our current peers.
259+
void SetTryNewOutboundPeer(bool flag);
260+
bool GetTryNewOutboundPeer();
261+
262+
// Return the number of outbound peers we have in excess of our target (eg,
263+
// if we previously called SetTryNewOutboundPeer(true), and have since set
264+
// to false, we may have extra peers that we wish to disconnect). This may
265+
// return a value less than (num_outbound_connections - num_outbound_slots)
266+
// in cases where some outbound connections are not yet fully connected, or
267+
// not yet fully disconnected.
268+
int GetExtraOutboundCount();
269+
257270
bool AddNode(const std::string& node);
258271
bool RemoveAddedNode(const std::string& node);
259272
std::vector<AddedNodeInfo> GetAddedNodeInfo();
@@ -312,7 +325,7 @@ class CConnman
312325
void ThreadOpenAddedConnections();
313326
void AddOneShot(const std::string& strDest);
314327
void ProcessOneShot();
315-
void ThreadOpenConnections(std::vector<std::string> connect);
328+
void ThreadOpenConnections();
316329
void ThreadMessageHandler();
317330
void AcceptConnection(const ListenSocket& hListenSocket);
318331
void ThreadSocketHandler();
@@ -416,6 +429,11 @@ class CConnman
416429
std::thread threadOpenAddedConnections;
417430
std::thread threadOpenConnections;
418431
std::thread threadMessageHandler;
432+
433+
/** flag for deciding to connect to an extra outbound peer,
434+
* in excess of nMaxOutbound
435+
* This takes the place of a feeler connection */
436+
std::atomic_bool m_try_another_outbound_peer;
419437
};
420438
extern std::unique_ptr<CConnman> g_connman;
421439
void Discover(boost::thread_group& threadGroup);

0 commit comments

Comments
 (0)