Disable BIP152

This commit is contained in:
lateminer
2019-03-08 23:13:53 +03:00
parent 7e60659f73
commit 2e32c7fd02
8 changed files with 119 additions and 11 deletions

View File

@@ -33,7 +33,7 @@ BIPs that are implemented by Bitcoin Core (up-to-date up to **v0.13.0**):
* [`BIP 147`](https://github.com/bitcoin/bips/blob/master/bip-0147.mediawiki): NULLDUMMY softfork as of **v0.13.1** ([PR 8636](https://github.com/bitcoin/bitcoin/pull/8636) and [PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)). * [`BIP 147`](https://github.com/bitcoin/bips/blob/master/bip-0147.mediawiki): NULLDUMMY softfork as of **v0.13.1** ([PR 8636](https://github.com/bitcoin/bitcoin/pull/8636) and [PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)).
* [`BIP 152`](https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki): Compact block transfer and related optimizations are used as of **v0.13.0** ([PR 8068](https://github.com/bitcoin/bitcoin/pull/8068)). * [`BIP 152`](https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki): Compact block transfer and related optimizations are used as of **v0.13.0** ([PR 8068](https://github.com/bitcoin/bitcoin/pull/8068)).
BIPs disabled in Blackcoin More (up-to-date up to **v2.13.2.1**): BIPs disabled in Blackcoin More (up-to-date up to **v2.13.2.2**):
* [`BIP 68`](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki) * [`BIP 68`](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki)
* [`BIP 112`](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki) * [`BIP 112`](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki)
* [`BIP 113`](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki) * [`BIP 113`](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki)
@@ -42,3 +42,4 @@ BIPs disabled in Blackcoin More (up-to-date up to **v2.13.2.1**):
* [`BIP 143`](https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki) * [`BIP 143`](https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki)
* [`BIP 144`](https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki) * [`BIP 144`](https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki)
* [`BIP 145`](https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki) * [`BIP 145`](https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki)
* [`BIP 152`](https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki)

View File

@@ -74,13 +74,15 @@ endif
.PHONY: FORCE check-symbols check-security .PHONY: FORCE check-symbols check-security
# bitcoin core # # bitcoin core #
# Disable BIP152
# blockencodings.h
BITCOIN_CORE_H = \ BITCOIN_CORE_H = \
addrdb.h \ addrdb.h \
addrman.h \ addrman.h \
amount.h \ amount.h \
arith_uint256.h \ arith_uint256.h \
base58.h \ base58.h \
blockencodings.h \
bloom.h \ bloom.h \
cashaddr.h \ cashaddr.h \
cashaddrenc.h \ cashaddrenc.h \
@@ -190,11 +192,13 @@ libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h
# server: shared between bitcoind and bitcoin-qt # server: shared between bitcoind and bitcoin-qt
libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS)
libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
# Disable BIP152
# blockencodings.cpp
libbitcoin_server_a_SOURCES = \ libbitcoin_server_a_SOURCES = \
addrman.cpp \ addrman.cpp \
addrdb.cpp \ addrdb.cpp \
bloom.cpp \ bloom.cpp \
blockencodings.cpp \
chain.cpp \ chain.cpp \
checkpoints.cpp \ checkpoints.cpp \
httprpc.cpp \ httprpc.cpp \
@@ -496,6 +500,10 @@ clean-local:
## FIXME: How to get the appropriate modulename_CPPFLAGS in here? ## FIXME: How to get the appropriate modulename_CPPFLAGS in here?
$(AM_V_GEN) $(WINDRES) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPFLAGS) -DWINDRES_PREPROC -i $< -o $@ $(AM_V_GEN) $(WINDRES) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPFLAGS) -DWINDRES_PREPROC -i $< -o $@
.mm.o:
$(AM_V_CXX) $(OBJCXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CXXFLAGS) $(QT_INCLUDES) $(AM_CXXFLAGS) $(PIE_FLAGS) $(CXXFLAGS) -c -o $@ $<
check-symbols: $(bin_PROGRAMS) check-symbols: $(bin_PROGRAMS)
if GLIBC_BACK_COMPAT if GLIBC_BACK_COMPAT
@echo "Checking glibc back compat..." @echo "Checking glibc back compat..."

View File

@@ -37,7 +37,8 @@ JSON_TEST_FILES = \
RAW_TEST_FILES = RAW_TEST_FILES =
GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h) GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h)
# Disable BIP152
# test/blockencodings_tests.cpp
BITCOIN_TESTS =\ BITCOIN_TESTS =\
test/arith_uint256_tests.cpp \ test/arith_uint256_tests.cpp \
test/scriptnum10.h \ test/scriptnum10.h \
@@ -47,7 +48,6 @@ BITCOIN_TESTS =\
test/base32_tests.cpp \ test/base32_tests.cpp \
test/base64_tests.cpp \ test/base64_tests.cpp \
test/bip32_tests.cpp \ test/bip32_tests.cpp \
test/blockencodings_tests.cpp \
test/bloom_tests.cpp \ test/bloom_tests.cpp \
test/bswap_tests.cpp \ test/bswap_tests.cpp \
test/checkblock_tests.cpp \ test/checkblock_tests.cpp \

View File

@@ -7,7 +7,10 @@
#include "addrman.h" #include "addrman.h"
#include "arith_uint256.h" #include "arith_uint256.h"
/*
// Disable BIP152
#include "blockencodings.h" #include "blockencodings.h"
*/
#include "chainparams.h" #include "chainparams.h"
#include "checkpoints.h" #include "checkpoints.h"
#include "checkqueue.h" #include "checkqueue.h"
@@ -219,12 +222,18 @@ namespace {
uint256 hash; uint256 hash;
CBlockIndex* pindex; //!< Optional. CBlockIndex* pindex; //!< Optional.
bool fValidatedHeaders; //!< Whether this block has validated headers at the time of request. bool fValidatedHeaders; //!< Whether this block has validated headers at the time of request.
/*
// Disable BIP152
std::unique_ptr<PartiallyDownloadedBlock> partialBlock; //!< Optional, used for CMPCTBLOCK downloads std::unique_ptr<PartiallyDownloadedBlock> partialBlock; //!< Optional, used for CMPCTBLOCK downloads
*/
}; };
map<uint256, pair<NodeId, list<QueuedBlock>::iterator> > mapBlocksInFlight; map<uint256, pair<NodeId, list<QueuedBlock>::iterator> > mapBlocksInFlight;
/** Stack of nodes which we have set to announce using compact blocks */ /** Stack of nodes which we have set to announce using compact blocks */
/*
// Disable BIP152
list<NodeId> lNodesAnnouncingHeaderAndIDs; list<NodeId> lNodesAnnouncingHeaderAndIDs;
*/
/** Number of preferable block download peers. */ /** Number of preferable block download peers. */
int nPreferredDownload = 0; int nPreferredDownload = 0;
@@ -300,10 +309,13 @@ struct CNodeState {
bool fPreferredDownload; bool fPreferredDownload;
//! Whether this peer wants invs or headers (when possible) for block announcements. //! Whether this peer wants invs or headers (when possible) for block announcements.
bool fPreferHeaders; bool fPreferHeaders;
/*
// Disable BIP152
//! Whether this peer wants invs or cmpctblocks (when possible) for block announcements. //! Whether this peer wants invs or cmpctblocks (when possible) for block announcements.
bool fPreferHeaderAndIDs; bool fPreferHeaderAndIDs;
//! Whether this peer will send us cmpctblocks if we request them //! Whether this peer will send us cmpctblocks if we request them
bool fProvidesHeaderAndIDs; bool fProvidesHeaderAndIDs;
*/
CNodeState() { CNodeState() {
fCurrentlyConnected = false; fCurrentlyConnected = false;
@@ -321,8 +333,11 @@ struct CNodeState {
nBlocksInFlightValidHeaders = 0; nBlocksInFlightValidHeaders = 0;
fPreferredDownload = false; fPreferredDownload = false;
fPreferHeaders = false; fPreferHeaders = false;
/*
// Disable BIP152
fPreferHeaderAndIDs = false; fPreferHeaderAndIDs = false;
fProvidesHeaderAndIDs = false; fProvidesHeaderAndIDs = false;
*/
} }
}; };
@@ -431,8 +446,13 @@ bool MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const Consensus::Pa
// Make sure it's not listed somewhere already. // Make sure it's not listed somewhere already.
MarkBlockAsReceived(hash); MarkBlockAsReceived(hash);
/*
// Disable BIP152
list<QueuedBlock>::iterator it = state->vBlocksInFlight.insert(state->vBlocksInFlight.end(), list<QueuedBlock>::iterator it = state->vBlocksInFlight.insert(state->vBlocksInFlight.end(),
{hash, pindex, pindex != NULL, std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock(&mempool) : NULL)}); {hash, pindex, pindex != NULL, std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock(&mempool) : NULL)});
*/
list<QueuedBlock>::iterator it = state->vBlocksInFlight.insert(state->vBlocksInFlight.end(),
{hash, pindex, pindex != NULL});
state->nBlocksInFlight++; state->nBlocksInFlight++;
state->nBlocksInFlightValidHeaders += it->fValidatedHeaders; state->nBlocksInFlightValidHeaders += it->fValidatedHeaders;
if (state->nBlocksInFlight == 1) { if (state->nBlocksInFlight == 1) {
@@ -483,6 +503,8 @@ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) {
} }
} }
/*
// Disable BIP152
void MaybeSetPeerAsAnnouncingHeaderAndIDs(const CNodeState* nodestate, CNode* pfrom) { void MaybeSetPeerAsAnnouncingHeaderAndIDs(const CNodeState* nodestate, CNode* pfrom) {
if (nodestate->fProvidesHeaderAndIDs) { if (nodestate->fProvidesHeaderAndIDs) {
for (std::list<NodeId>::iterator it = lNodesAnnouncingHeaderAndIDs.begin(); it != lNodesAnnouncingHeaderAndIDs.end(); it++) { for (std::list<NodeId>::iterator it = lNodesAnnouncingHeaderAndIDs.begin(); it != lNodesAnnouncingHeaderAndIDs.end(); it++) {
@@ -508,6 +530,7 @@ void MaybeSetPeerAsAnnouncingHeaderAndIDs(const CNodeState* nodestate, CNode* pf
lNodesAnnouncingHeaderAndIDs.push_back(pfrom->GetId()); lNodesAnnouncingHeaderAndIDs.push_back(pfrom->GetId());
} }
} }
*/
// Requires cs_main // Requires cs_main
bool CanDirectFetch(const Consensus::Params &consensusParams) bool CanDirectFetch(const Consensus::Params &consensusParams)
@@ -4855,7 +4878,11 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
boost::this_thread::interruption_point(); boost::this_thread::interruption_point();
it++; it++;
/*
// Disable BIP152
if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK || inv.type == MSG_CMPCT_BLOCK) if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK || inv.type == MSG_CMPCT_BLOCK)
*/
if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK)
{ {
bool send = false; bool send = false;
BlockMap::iterator mi = mapBlockIndex.find(inv.hash); BlockMap::iterator mi = mapBlockIndex.find(inv.hash);
@@ -4895,7 +4922,11 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
assert(!"cannot load block from disk"); assert(!"cannot load block from disk");
if (inv.type == MSG_BLOCK) if (inv.type == MSG_BLOCK)
pfrom->PushMessage(NetMsgType::BLOCK, block); pfrom->PushMessage(NetMsgType::BLOCK, block);
/*
// Disable BIP152
else if (inv.type == MSG_FILTERED_BLOCK) else if (inv.type == MSG_FILTERED_BLOCK)
*/
else // MSG_FILTERED_BLOCK
{ {
bool send = false; bool send = false;
CMerkleBlock merkleBlock; CMerkleBlock merkleBlock;
@@ -4921,6 +4952,8 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
// else // else
// no response // no response
} }
/*
// Disable BIP152
else if (inv.type == MSG_CMPCT_BLOCK) else if (inv.type == MSG_CMPCT_BLOCK)
{ {
// If a peer is asking for old blocks, we're almost guaranteed // If a peer is asking for old blocks, we're almost guaranteed
@@ -4933,6 +4966,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
} else } else
pfrom->PushMessage(NetMsgType::BLOCK, block); pfrom->PushMessage(NetMsgType::BLOCK, block);
} }
*/
// Trigger the peer node to send a getblocks request for the next batch of inventory // Trigger the peer node to send a getblocks request for the next batch of inventory
if (inv.hash == pfrom->hashContinue) if (inv.hash == pfrom->hashContinue)
@@ -4972,7 +5006,11 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
// Track requests for our stuff. // Track requests for our stuff.
GetMainSignals().Inventory(inv.hash); GetMainSignals().Inventory(inv.hash);
/*
// Disable BIP152
if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK || inv.type == MSG_CMPCT_BLOCK) if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK || inv.type == MSG_CMPCT_BLOCK)
*/
if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK)
break; break;
} }
} }
@@ -5183,6 +5221,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// nodes) // nodes)
pfrom->PushMessage(NetMsgType::SENDHEADERS); pfrom->PushMessage(NetMsgType::SENDHEADERS);
} }
/*
// Disable BIP152
if (pfrom->nVersion >= SHORT_IDS_BLOCKS_VERSION) { if (pfrom->nVersion >= SHORT_IDS_BLOCKS_VERSION) {
// Tell our peer we are willing to provide version-1 cmpctblocks // Tell our peer we are willing to provide version-1 cmpctblocks
// However, we do not request new block announcements using // However, we do not request new block announcements using
@@ -5193,6 +5233,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
uint64_t nCMPCTBLOCKVersion = 1; uint64_t nCMPCTBLOCKVersion = 1;
pfrom->PushMessage(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion); pfrom->PushMessage(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion);
} }
*/
} }
@@ -5267,6 +5308,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
State(pfrom->GetId())->fPreferHeaders = true; State(pfrom->GetId())->fPreferHeaders = true;
} }
/*
// Disable BIP152
else if (strCommand == NetMsgType::SENDCMPCT) else if (strCommand == NetMsgType::SENDCMPCT)
{ {
bool fAnnounceUsingCMPCTBLOCK = false; bool fAnnounceUsingCMPCTBLOCK = false;
@@ -5286,6 +5329,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
} }
} }
} }
*/
else if (strCommand == NetMsgType::INV) else if (strCommand == NetMsgType::INV)
@@ -5333,10 +5377,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
CNodeState *nodestate = State(pfrom->GetId()); CNodeState *nodestate = State(pfrom->GetId());
if (CanDirectFetch(chainparams.GetConsensus()) && if (CanDirectFetch(chainparams.GetConsensus()) &&
nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) { nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
/*
// Disable BIP152
if (nodestate->fProvidesHeaderAndIDs) if (nodestate->fProvidesHeaderAndIDs)
vToFetch.push_back(CInv(MSG_CMPCT_BLOCK, inv.hash)); vToFetch.push_back(CInv(MSG_CMPCT_BLOCK, inv.hash));
else else
vToFetch.push_back(inv); vToFetch.push_back(inv);
*/
vToFetch.push_back(inv);
// Mark block as in flight already, even though the actual "getdata" message only goes out // Mark block as in flight already, even though the actual "getdata" message only goes out
// later (within the same cs_main lock, though). // later (within the same cs_main lock, though).
MarkBlockAsInFlight(pfrom->GetId(), inv.hash, chainparams.GetConsensus()); MarkBlockAsInFlight(pfrom->GetId(), inv.hash, chainparams.GetConsensus());
@@ -5433,6 +5481,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
} }
/*
// Disable BIP152
else if (strCommand == NetMsgType::GETBLOCKTXN) else if (strCommand == NetMsgType::GETBLOCKTXN)
{ {
BlockTransactionsRequest req; BlockTransactionsRequest req;
@@ -5477,6 +5527,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
} }
pfrom->PushMessage(NetMsgType::BLOCKTXN, resp); pfrom->PushMessage(NetMsgType::BLOCKTXN, resp);
} }
*/
else if (strCommand == NetMsgType::GETHEADERS) else if (strCommand == NetMsgType::GETHEADERS)
@@ -5694,7 +5745,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
FlushStateToDisk(state, FLUSH_STATE_PERIODIC); FlushStateToDisk(state, FLUSH_STATE_PERIODIC);
} }
/*
// Disable BIP152
else if (strCommand == NetMsgType::CMPCTBLOCK && !fImporting && !fReindex) // Ignore blocks received while importing else if (strCommand == NetMsgType::CMPCTBLOCK && !fImporting && !fReindex) // Ignore blocks received while importing
{ {
CBlockHeaderAndShortTxIDs cmpctblock; CBlockHeaderAndShortTxIDs cmpctblock;
@@ -5932,6 +5984,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
} }
} }
} }
*/
else if (strCommand == NetMsgType::HEADERS && !fImporting && !fReindex) // Ignore headers received while importing else if (strCommand == NetMsgType::HEADERS && !fImporting && !fReindex) // Ignore headers received while importing
@@ -6063,6 +6116,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
pindexLast->GetBlockHash().ToString(), pindexLast->nHeight); pindexLast->GetBlockHash().ToString(), pindexLast->nHeight);
} }
if (vGetData.size() > 0) { if (vGetData.size() > 0) {
/*
// Disable BIP152
if (nodestate->fProvidesHeaderAndIDs && vGetData.size() == 1 && mapBlocksInFlight.size() == 1 && pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) { if (nodestate->fProvidesHeaderAndIDs && vGetData.size() == 1 && mapBlocksInFlight.size() == 1 && pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
// We seem to be rather well-synced, so it appears pfrom was the first to provide us // We seem to be rather well-synced, so it appears pfrom was the first to provide us
// with this block! Let's get them to announce using compact blocks in the future. // with this block! Let's get them to announce using compact blocks in the future.
@@ -6070,6 +6125,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// In any case, we want to download using a compact block, not a regular one // In any case, we want to download using a compact block, not a regular one
vGetData[0] = CInv(MSG_CMPCT_BLOCK, vGetData[0].hash); vGetData[0] = CInv(MSG_CMPCT_BLOCK, vGetData[0].hash);
} }
*/
pfrom->PushMessage(NetMsgType::GETDATA, vGetData); pfrom->PushMessage(NetMsgType::GETDATA, vGetData);
} }
} }
@@ -6627,9 +6683,13 @@ bool SendMessages(CNode* pto)
// add all to the inv queue. // add all to the inv queue.
LOCK(pto->cs_inventory); LOCK(pto->cs_inventory);
vector<CBlock> vHeaders; vector<CBlock> vHeaders;
/*
// Disable BIP152
bool fRevertToInv = ((!state.fPreferHeaders && bool fRevertToInv = ((!state.fPreferHeaders &&
(!state.fPreferHeaderAndIDs || pto->vBlockHashesToAnnounce.size() > 1)) || (!state.fPreferHeaderAndIDs || pto->vBlockHashesToAnnounce.size() > 1)) ||
pto->vBlockHashesToAnnounce.size() > MAX_BLOCKS_TO_ANNOUNCE); pto->vBlockHashesToAnnounce.size() > MAX_BLOCKS_TO_ANNOUNCE);
*/
bool fRevertToInv = (!state.fPreferHeaders || pto->vBlockHashesToAnnounce.size() > MAX_BLOCKS_TO_ANNOUNCE);
CBlockIndex *pBestIndex = NULL; // last header queued for delivery CBlockIndex *pBestIndex = NULL; // last header queued for delivery
ProcessBlockAvailability(pto->id); // ensure pindexBestKnownBlock is up-to-date ProcessBlockAvailability(pto->id); // ensure pindexBestKnownBlock is up-to-date
@@ -6681,6 +6741,8 @@ bool SendMessages(CNode* pto)
} }
} }
} }
/*
// Disable BIP152
if (!fRevertToInv && !vHeaders.empty()) { if (!fRevertToInv && !vHeaders.empty()) {
if (vHeaders.size() == 1 && state.fPreferHeaderAndIDs) { if (vHeaders.size() == 1 && state.fPreferHeaderAndIDs) {
// We only send up to 1 block as header-and-ids, as otherwise // We only send up to 1 block as header-and-ids, as otherwise
@@ -6708,6 +6770,7 @@ bool SendMessages(CNode* pto)
} else } else
fRevertToInv = true; fRevertToInv = true;
} }
*/
if (fRevertToInv) { if (fRevertToInv) {
// If falling back to using an inv, just try to inv the tip. // If falling back to using an inv, just try to inv the tip.
// The last entry in vBlockHashesToAnnounce was our tip at some point // The last entry in vBlockHashesToAnnounce was our tip at some point
@@ -6733,6 +6796,19 @@ bool SendMessages(CNode* pto)
pto->id, hashToAnnounce.ToString()); pto->id, hashToAnnounce.ToString());
} }
} }
// Disable BIP152
} else if (!vHeaders.empty()) {
if (vHeaders.size() > 1) {
LogPrint("net", "%s: %u headers, range (%s, %s), to peer=%d\n", __func__,
vHeaders.size(),
vHeaders.front().GetHash().ToString(),
vHeaders.back().GetHash().ToString(), pto->id);
} else {
LogPrint("net", "%s: sending header %s to peer=%d\n", __func__,
vHeaders.front().GetHash().ToString(), pto->id);
}
pto->PushMessage(NetMsgType::HEADERS, vHeaders);
state.pindexBestHeaderSent = pBestIndex;
} }
pto->vBlockHashesToAnnounce.clear(); pto->vBlockHashesToAnnounce.clear();
} }

View File

@@ -35,10 +35,13 @@ const char *FILTERCLEAR="filterclear";
const char *REJECT="reject"; const char *REJECT="reject";
const char *SENDHEADERS="sendheaders"; const char *SENDHEADERS="sendheaders";
const char *FEEFILTER="feefilter"; const char *FEEFILTER="feefilter";
/*
// Disable BIP152
const char *SENDCMPCT="sendcmpct"; const char *SENDCMPCT="sendcmpct";
const char *CMPCTBLOCK="cmpctblock"; const char *CMPCTBLOCK="cmpctblock";
const char *GETBLOCKTXN="getblocktxn"; const char *GETBLOCKTXN="getblocktxn";
const char *BLOCKTXN="blocktxn"; const char *BLOCKTXN="blocktxn";
*/
}; };
/** All known message types. Keep this in the same order as the list of /** All known message types. Keep this in the same order as the list of
@@ -67,10 +70,13 @@ const static std::string allNetMessageTypes[] = {
NetMsgType::REJECT, NetMsgType::REJECT,
NetMsgType::SENDHEADERS, NetMsgType::SENDHEADERS,
NetMsgType::FEEFILTER, NetMsgType::FEEFILTER,
/*
// Disable BIP152
NetMsgType::SENDCMPCT, NetMsgType::SENDCMPCT,
NetMsgType::CMPCTBLOCK, NetMsgType::CMPCTBLOCK,
NetMsgType::GETBLOCKTXN, NetMsgType::GETBLOCKTXN,
NetMsgType::BLOCKTXN, NetMsgType::BLOCKTXN,
*/
}; };
const static std::vector<std::string> allNetMessageTypesVec(allNetMessageTypes, allNetMessageTypes+ARRAYLEN(allNetMessageTypes)); const static std::vector<std::string> allNetMessageTypesVec(allNetMessageTypes, allNetMessageTypes+ARRAYLEN(allNetMessageTypes));
@@ -171,7 +177,10 @@ std::string CInv::GetCommand() const
case MSG_TX: return cmd.append(NetMsgType::TX); case MSG_TX: return cmd.append(NetMsgType::TX);
case MSG_BLOCK: return cmd.append(NetMsgType::BLOCK); case MSG_BLOCK: return cmd.append(NetMsgType::BLOCK);
case MSG_FILTERED_BLOCK: return cmd.append(NetMsgType::MERKLEBLOCK); case MSG_FILTERED_BLOCK: return cmd.append(NetMsgType::MERKLEBLOCK);
/*
// Disable BIP152
case MSG_CMPCT_BLOCK: return cmd.append(NetMsgType::CMPCTBLOCK); case MSG_CMPCT_BLOCK: return cmd.append(NetMsgType::CMPCTBLOCK);
*/
default: default:
throw std::out_of_range(strprintf("CInv::GetCommand(): type=%d unknown type", type)); throw std::out_of_range(strprintf("CInv::GetCommand(): type=%d unknown type", type));
} }

View File

@@ -217,6 +217,8 @@ extern const char *SENDHEADERS;
* @since protocol version 70013 as described by BIP133 * @since protocol version 70013 as described by BIP133
*/ */
extern const char *FEEFILTER; extern const char *FEEFILTER;
// Disable BIP152
/** /**
* Contains a 1-byte bool and 8-byte LE version number. * Contains a 1-byte bool and 8-byte LE version number.
* Indicates that a node is willing to provide blocks via "cmpctblock" messages. * Indicates that a node is willing to provide blocks via "cmpctblock" messages.
@@ -224,25 +226,25 @@ extern const char *FEEFILTER;
* "cmpctblock" message rather than an "inv", depending on message contents. * "cmpctblock" message rather than an "inv", depending on message contents.
* @since protocol version 70014 as described by BIP 152 * @since protocol version 70014 as described by BIP 152
*/ */
extern const char *SENDCMPCT; // extern const char *SENDCMPCT;
/** /**
* Contains a CBlockHeaderAndShortTxIDs object - providing a header and * Contains a CBlockHeaderAndShortTxIDs object - providing a header and
* list of "short txids". * list of "short txids".
* @since protocol version 70014 as described by BIP 152 * @since protocol version 70014 as described by BIP 152
*/ */
extern const char *CMPCTBLOCK; // extern const char *CMPCTBLOCK;
/** /**
* Contains a BlockTransactionsRequest * Contains a BlockTransactionsRequest
* Peer should respond with "blocktxn" message. * Peer should respond with "blocktxn" message.
* @since protocol version 70014 as described by BIP 152 * @since protocol version 70014 as described by BIP 152
*/ */
extern const char *GETBLOCKTXN; // extern const char *GETBLOCKTXN;
/** /**
* Contains a BlockTransactions. * Contains a BlockTransactions.
* Sent in response to a "getblocktxn" message. * Sent in response to a "getblocktxn" message.
* @since protocol version 70014 as described by BIP 152 * @since protocol version 70014 as described by BIP 152
*/ */
extern const char *BLOCKTXN; // extern const char *BLOCKTXN;
}; };
/* Get a vector of all valid message types (see above) */ /* Get a vector of all valid message types (see above) */
@@ -320,7 +322,10 @@ enum GetDataMsg
MSG_BLOCK, MSG_BLOCK,
// The following can only occur in getdata. Invs always use TX or BLOCK. // The following can only occur in getdata. Invs always use TX or BLOCK.
MSG_FILTERED_BLOCK, MSG_FILTERED_BLOCK,
/*
// Disable BIP152
MSG_CMPCT_BLOCK, MSG_CMPCT_BLOCK,
*/
}; };
/** inv message data */ /** inv message data */

View File

@@ -373,7 +373,10 @@ I ReadVarInt(Stream& is)
#define FLATDATA(obj) REF(CFlatData((char*)&(obj), (char*)&(obj) + sizeof(obj))) #define FLATDATA(obj) REF(CFlatData((char*)&(obj), (char*)&(obj) + sizeof(obj)))
#define VARINT(obj) REF(WrapVarInt(REF(obj))) #define VARINT(obj) REF(WrapVarInt(REF(obj)))
/*
// Disable BIP152
#define COMPACTSIZE(obj) REF(CCompactSize(REF(obj))) #define COMPACTSIZE(obj) REF(CCompactSize(REF(obj)))
*/
#define LIMITED_STRING(obj,n) REF(LimitedString< n >(REF(obj))) #define LIMITED_STRING(obj,n) REF(LimitedString< n >(REF(obj)))
/** /**
@@ -444,6 +447,8 @@ public:
} }
}; };
/*
// Disable BIP152
class CCompactSize class CCompactSize
{ {
protected: protected:
@@ -465,6 +470,7 @@ public:
n = ReadCompactSize<Stream>(s); n = ReadCompactSize<Stream>(s);
} }
}; };
*/
template<size_t Limit> template<size_t Limit>
class LimitedString class LimitedString

View File

@@ -9,7 +9,7 @@
* network protocol versioning * network protocol versioning
*/ */
static const int PROTOCOL_VERSION = 70015; static const int PROTOCOL_VERSION = 70013;
//! initial proto version, to be increased after version/verack negotiation //! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209; static const int INIT_PROTO_VERSION = 209;
@@ -42,10 +42,13 @@ static const int SENDHEADERS_VERSION = 70012;
//! "feefilter" tells peers to filter invs to you by fee starts with this version //! "feefilter" tells peers to filter invs to you by fee starts with this version
static const int FEEFILTER_VERSION = 70013; static const int FEEFILTER_VERSION = 70013;
/*
// Disable BIP152
//! shord-id-based block download starts with this version //! shord-id-based block download starts with this version
static const int SHORT_IDS_BLOCKS_VERSION = 70014; static const int SHORT_IDS_BLOCKS_VERSION = 70014;
//! not banning for invalid compact blocks starts with this version //! not banning for invalid compact blocks starts with this version
static const int INVALID_CB_NO_BAN_VERSION = 70015; static const int INVALID_CB_NO_BAN_VERSION = 70015;
*/
#endif // BITCOIN_VERSION_H #endif // BITCOIN_VERSION_H