Skip to content

Commit

Permalink
Merge #608: Bitcoin v0.15.1 backport to master
Browse files Browse the repository at this point in the history
  • Loading branch information
blondfrogs authored Jul 2, 2019
2 parents 77d4ea8 + dcf4f87 commit ed857ac
Show file tree
Hide file tree
Showing 12 changed files with 600 additions and 213 deletions.
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 2)
define(_CLIENT_VERSION_MINOR, 2)
define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_MINOR, 4)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
Expand Down
80 changes: 80 additions & 0 deletions doc/release-notes/release-notes-2.4.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
Raven Core version *2.4.0* is now available!!
==============

<https://github.com/RavenProject/Ravencoin/releases/tag/v2.4.0>


This is a major release containing bug fixes and enhancements for all builds before it. It is highly recommended that users
upgrade to this version.

Please report bugs using the issue tracker at GitHub:

<https://github.com/RavenProject/Ravencoin/issues>

To receive security and update notifications, please subscribe to:

<https://ravencoin.org/en/list/announcements/join/>

How to Upgrade
==============

If you are running an older version, shut it down. Wait until it has completely
shut down (which might take a few minutes for older versions), then run the
installer (on Windows) or just copy over `/Applications/Raven-Qt` (on Mac)
or `ravend`/`raven-qt` (on Linux).

Downgrading warning
==============

You may downgrade at any time if needed.

Note: There are no consensus-rule changes between versions v2.2.3/v2.2.2 and 2.4.0 - running versions in this range
will not fork the chain.

Compatibility
==============

Raven Core is extensively tested on multiple operating systems using
the Linux kernel, macOS 10.8+, and Windows 10(x64) and later. 32-bit versions of Windows,
and Windows XP are not supported.

Raven Core should also work on most other Unix-like systems but is not
frequently tested on them.

Raven Core has been tested with macOS 10.14 Mojave, but it is recommended that *developers*
do not update to Mojave. There is an incompatibility with Berkeley-db 4.8.30 that causes
the binaries to seg-fault. There is a workaround, but as of this release users should
not update to Mojave (see build-OSX.md for current status of this issue). There are no
known issues running the release binaries on Mojave.

Raven Core has not been tested with macOS Catalina(beta). Please use at your own risk.

Notable changes
==============
*This list includes changes from all releases between 2.2.2/2.2.3 and 2.4.0*
- Backport of Bitcoin v0.15.1 networking updates
- Reorganization of pointer access objects in functions


2.4.0 Change log
==============

Changelog available here: <https://github.com/RavenProject/Ravencoin/commits/release_2.4.0>

Credits
==============

Thanks to everyone who directly contributed to this release:

- Most importantly - The Raven Community!
- @blondfrogs (Jeremy Anderson) - [77f5a7838082669dbb7c21b4a93ce65e2a447963](https://github.com/RavenProject/Ravencoin/pull/608/commits/77f5a7838082669dbb7c21b4a93ce65e2a447963)
- @blondfrogs (Jeremy Anderson) - [fbbc40d22646c31465fa04a8a55f4734c3f75a9c](https://github.com/RavenProject/Ravencoin/pull/608/commits/fbbc40d22646c31465fa04a8a55f4734c3f75a9c)
- @practicalswift - [ba4d362a2b4ba814bba2aa2589231ba470f20e3f](https://github.com/RavenProject/Ravencoin/pull/608/commits/ba4d362a2b4ba814bba2aa2589231ba470f20e3f)
- @sdaftuar - [3027dd58001624f388dc522ec9c73eb5fc9aee70](https://github.com/RavenProject/Ravencoin/pull/608/commits/3027dd58001624f388dc522ec9c73eb5fc9aee70)
- @sdaftuar - [dc5cc1e5980b30a21427f75a7d4085f4755d4085](https://github.com/RavenProject/Ravencoin/pull/608/commits/dc5cc1e5980b30a21427f75a7d4085f4755d4085)
- @sdaftuar - [a743e754fd90ce3299b237700082e12c8cbcf3b4](https://github.com/RavenProject/Ravencoin/pull/608/commits/a743e754fd90ce3299b237700082e12c8cbcf3b4)
- @sdaftuar - [08efce585df53f86f13ec5d1dff689237c0ce4cc](https://github.com/RavenProject/Ravencoin/pull/608/commits/08efce585df53f86f13ec5d1dff689237c0ce4cc)
- @sdaftuar - [2d4826beee72e1a3749c1eb090a37139f3099a22](https://github.com/RavenProject/Ravencoin/pull/608/commits/2d4826beee72e1a3749c1eb090a37139f3099a22)
- @TheBlueMatt - [ffeb6ee6b27e778fdee188d12032b6ac7d2d1eb4](https://github.com/RavenProject/Ravencoin/pull/608/commits/ffeb6ee6b27e778fdee188d12032b6ac7d2d1eb4)
- @TheBlueMatt - [c27081c79eb6dca48e457d8dd5b09090771a75b7](https://github.com/RavenProject/Ravencoin/pull/608/commits/c27081c79eb6dca48e457d8dd5b09090771a75b7)

17 changes: 12 additions & 5 deletions src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,17 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, c
}

//! Check to make sure that the inputs and outputs CAmount match exactly.
bool Consensus::CheckTxAssets(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, std::vector<std::pair<std::string, uint256> >& vPairReissueAssets, const bool fRunningUnitTests)
bool Consensus::CheckTxAssets(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, std::vector<std::pair<std::string, uint256> >& vPairReissueAssets, const bool fRunningUnitTests, CAssetsCache* assetsCache)
{
if (!fRunningUnitTests) {
if (!assetsCache)
assetsCache = GetCurrentAssetCache();
}

if (!assetsCache && !fRunningUnitTests) {
return error("%s : Assets Cache is null, failing", __func__);
}

// are the actual inputs available?
if (!inputs.HaveInputs(tx)) {
return state.DoS(100, false, REJECT_INVALID, "bad-txns-inputs-missing-or-spent", false,
Expand Down Expand Up @@ -428,15 +437,14 @@ bool Consensus::CheckTxAssets(const CTransaction& tx, CValidationState& state, c
else
totalOutputs.insert(make_pair(transfer.strName, transfer.nAmount));

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

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

if (!fRunningUnitTests) {
auto currentActiveAssetCache = GetCurrentAssetCache();
std::string strError;
if (!reissue.IsValid(strError, *currentActiveAssetCache)) {
if (!reissue.IsValid(strError, *assetsCache)) {
return state.DoS(100, false, REJECT_INVALID,
"bad-txns" + strError);
}
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/tx_verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Consensus {
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee);

/** RVN START */
bool CheckTxAssets(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, std::vector<std::pair<std::string, uint256> >& vPairReissueAssets, const bool fRunningUnitTests = false);
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);
/** RVN END */
} // namespace Consensus

Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
g_connman = std::unique_ptr<CConnman>(new CConnman(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max())));
CConnman& connman = *g_connman;

peerLogic.reset(new PeerLogicValidation(&connman));
peerLogic.reset(new PeerLogicValidation(&connman, scheduler));
RegisterValidationInterface(peerLogic.get());

// sanitize comments per BIP-0014, format user agent and check total size
Expand Down
50 changes: 42 additions & 8 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,11 @@ static std::vector<CAddress> convertSeed6(const std::vector<SeedSpec6> &vSeedsIn
const int64_t nOneWeek = 7*24*60*60;
std::vector<CAddress> vSeedsOut;
vSeedsOut.reserve(vSeedsIn.size());
for (const auto& seed_in : vSeedsIn) {
for (std::vector<SeedSpec6>::const_iterator i(vSeedsIn.begin()); i != vSeedsIn.end(); ++i)
{
struct in6_addr ip;
memcpy(&ip, seed_in.addr, sizeof(ip));
CAddress addr(CService(ip, seed_in.port), NODE_NETWORK);
memcpy(&ip, i->addr, sizeof(ip));
CAddress addr(CService(ip, i->port), NODE_NETWORK);
addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
vSeedsOut.push_back(addr);
}
Expand Down Expand Up @@ -1706,15 +1707,46 @@ void CConnman::ProcessOneShot()
}
}

void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
bool CConnman::GetTryNewOutboundPeer()
{
return m_try_another_outbound_peer;
}

void CConnman::SetTryNewOutboundPeer(bool flag)
{
m_try_another_outbound_peer = flag;
LogPrint(BCLog::NET, "net: setting try another outbound peer=%s\n", flag ? "true" : "false");
}

// Return the number of peers we have over our outbound connection limit
// Exclude peers that are marked for disconnect, or are going to be
// disconnected soon (eg one-shots and feelers)
// Also exclude peers that haven't finished initial connection handshake yet
// (so that we don't decide we're over our desired connection limit, and then
// evict some peer that has finished the handshake)
int CConnman::GetExtraOutboundCount()
{
int nOutbound = 0;
{
LOCK(cs_vNodes);
for (CNode* pnode : vNodes) {
if (!pnode->fInbound && !pnode->m_manual_connection && !pnode->fFeeler && !pnode->fDisconnect && !pnode->fOneShot && pnode->fSuccessfullyConnected) {
++nOutbound;
}
}
}
return std::max(nOutbound - nMaxOutbound, 0);
}

void CConnman::ThreadOpenConnections()
{
// Connect to specific addresses
if (!connect.empty())
if (gArgs.IsArgSet("-connect"))
{
for (int64_t nLoop = 0;; nLoop++)
{
ProcessOneShot();
for (const std::string& strAddr : connect)
for (const std::string& strAddr : gArgs.GetArgs("-connect"))
{
CAddress addr(CService(), NODE_NONE);
OpenNetworkConnection(addr, false, nullptr, strAddr.c_str(), false, false, true);
Expand Down Expand Up @@ -1796,7 +1828,8 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
// * Only make a feeler connection once every few minutes.
//
bool fFeeler = false;
if (nOutbound >= nMaxOutbound) {

if (nOutbound >= nMaxOutbound && !GetTryNewOutboundPeer()) {
int64_t nTime = GetTimeMicros(); // The current time right now (in microseconds).
if (nTime > nNextFeeler) {
nNextFeeler = PoissonNextSend(nTime, FEELER_INTERVAL);
Expand Down Expand Up @@ -2224,6 +2257,7 @@ CConnman::CConnman(uint64_t nSeed0In, uint64_t nSeed1In) : nSeed0(nSeed0In), nSe
semOutbound = nullptr;
semAddnode = nullptr;
flagInterruptMsgProc = false;
SetTryNewOutboundPeer(false);

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

// Process messages
threadMessageHandler = std::thread(&TraceThread<std::function<void()> >, "msghand", std::function<void()>(std::bind(&CConnman::ThreadMessageHandler, this)));
Expand Down
20 changes: 19 additions & 1 deletion src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,19 @@ class CConnman
void GetBanned(banmap_t &banmap);
void SetBanned(const banmap_t &banmap);

// This allows temporarily exceeding nMaxOutbound, with the goal of finding
// a peer that is better than all our current peers.
void SetTryNewOutboundPeer(bool flag);
bool GetTryNewOutboundPeer();

// Return the number of outbound peers we have in excess of our target (eg,
// if we previously called SetTryNewOutboundPeer(true), and have since set
// to false, we may have extra peers that we wish to disconnect). This may
// return a value less than (num_outbound_connections - num_outbound_slots)
// in cases where some outbound connections are not yet fully connected, or
// not yet fully disconnected.
int GetExtraOutboundCount();

bool AddNode(const std::string& node);
bool RemoveAddedNode(const std::string& node);
std::vector<AddedNodeInfo> GetAddedNodeInfo();
Expand Down Expand Up @@ -312,7 +325,7 @@ class CConnman
void ThreadOpenAddedConnections();
void AddOneShot(const std::string& strDest);
void ProcessOneShot();
void ThreadOpenConnections(std::vector<std::string> connect);
void ThreadOpenConnections();
void ThreadMessageHandler();
void AcceptConnection(const ListenSocket& hListenSocket);
void ThreadSocketHandler();
Expand Down Expand Up @@ -416,6 +429,11 @@ class CConnman
std::thread threadOpenAddedConnections;
std::thread threadOpenConnections;
std::thread threadMessageHandler;

/** flag for deciding to connect to an extra outbound peer,
* in excess of nMaxOutbound
* This takes the place of a feeler connection */
std::atomic_bool m_try_another_outbound_peer;
};
extern std::unique_ptr<CConnman> g_connman;
void Discover(boost::thread_group& threadGroup);
Expand Down
Loading

0 comments on commit ed857ac

Please sign in to comment.