diff --git a/doc/bips.md b/doc/bips.md index 028234774..daa9211fc 100644 --- a/doc/bips.md +++ b/doc/bips.md @@ -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 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 112`](https://github.com/bitcoin/bips/blob/master/bip-0112.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 144`](https://github.com/bitcoin/bips/blob/master/bip-0144.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) diff --git a/src/Makefile.am b/src/Makefile.am index 4998a7d41..e058098a0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -74,13 +74,15 @@ endif .PHONY: FORCE check-symbols check-security # bitcoin core # + +# Disable BIP152 +# blockencodings.h BITCOIN_CORE_H = \ addrdb.h \ addrman.h \ amount.h \ arith_uint256.h \ base58.h \ - blockencodings.h \ bloom.h \ cashaddr.h \ cashaddrenc.h \ @@ -190,11 +192,13 @@ libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h # 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_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) + +# Disable BIP152 +# blockencodings.cpp libbitcoin_server_a_SOURCES = \ addrman.cpp \ addrdb.cpp \ bloom.cpp \ - blockencodings.cpp \ chain.cpp \ checkpoints.cpp \ httprpc.cpp \ @@ -496,6 +500,10 @@ clean-local: ## FIXME: How to get the appropriate modulename_CPPFLAGS in here? $(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) if GLIBC_BACK_COMPAT @echo "Checking glibc back compat..." diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 43be6a2fd..31fb05e09 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -37,7 +37,8 @@ JSON_TEST_FILES = \ RAW_TEST_FILES = GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h) - +# Disable BIP152 +# test/blockencodings_tests.cpp BITCOIN_TESTS =\ test/arith_uint256_tests.cpp \ test/scriptnum10.h \ @@ -47,7 +48,6 @@ BITCOIN_TESTS =\ test/base32_tests.cpp \ test/base64_tests.cpp \ test/bip32_tests.cpp \ - test/blockencodings_tests.cpp \ test/bloom_tests.cpp \ test/bswap_tests.cpp \ test/checkblock_tests.cpp \ diff --git a/src/main.cpp b/src/main.cpp index 1872e060c..8306a2c11 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,7 +7,10 @@ #include "addrman.h" #include "arith_uint256.h" +/* +// Disable BIP152 #include "blockencodings.h" +*/ #include "chainparams.h" #include "checkpoints.h" #include "checkqueue.h" @@ -219,12 +222,18 @@ namespace { uint256 hash; CBlockIndex* pindex; //!< Optional. bool fValidatedHeaders; //!< Whether this block has validated headers at the time of request. + /* + // Disable BIP152 std::unique_ptr partialBlock; //!< Optional, used for CMPCTBLOCK downloads + */ }; map::iterator> > mapBlocksInFlight; /** Stack of nodes which we have set to announce using compact blocks */ + /* + // Disable BIP152 list lNodesAnnouncingHeaderAndIDs; + */ /** Number of preferable block download peers. */ int nPreferredDownload = 0; @@ -300,10 +309,13 @@ struct CNodeState { bool fPreferredDownload; //! Whether this peer wants invs or headers (when possible) for block announcements. bool fPreferHeaders; + /* + // Disable BIP152 //! Whether this peer wants invs or cmpctblocks (when possible) for block announcements. bool fPreferHeaderAndIDs; //! Whether this peer will send us cmpctblocks if we request them bool fProvidesHeaderAndIDs; + */ CNodeState() { fCurrentlyConnected = false; @@ -321,8 +333,11 @@ struct CNodeState { nBlocksInFlightValidHeaders = 0; fPreferredDownload = false; fPreferHeaders = false; + /* + // Disable BIP152 fPreferHeaderAndIDs = 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. MarkBlockAsReceived(hash); + /* + // Disable BIP152 list::iterator it = state->vBlocksInFlight.insert(state->vBlocksInFlight.end(), {hash, pindex, pindex != NULL, std::unique_ptr(pit ? new PartiallyDownloadedBlock(&mempool) : NULL)}); + */ + list::iterator it = state->vBlocksInFlight.insert(state->vBlocksInFlight.end(), + {hash, pindex, pindex != NULL}); state->nBlocksInFlight++; state->nBlocksInFlightValidHeaders += it->fValidatedHeaders; if (state->nBlocksInFlight == 1) { @@ -483,6 +503,8 @@ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) { } } +/* +// Disable BIP152 void MaybeSetPeerAsAnnouncingHeaderAndIDs(const CNodeState* nodestate, CNode* pfrom) { if (nodestate->fProvidesHeaderAndIDs) { for (std::list::iterator it = lNodesAnnouncingHeaderAndIDs.begin(); it != lNodesAnnouncingHeaderAndIDs.end(); it++) { @@ -508,6 +530,7 @@ void MaybeSetPeerAsAnnouncingHeaderAndIDs(const CNodeState* nodestate, CNode* pf lNodesAnnouncingHeaderAndIDs.push_back(pfrom->GetId()); } } +*/ // Requires cs_main bool CanDirectFetch(const Consensus::Params &consensusParams) @@ -4855,7 +4878,11 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam boost::this_thread::interruption_point(); 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) { bool send = false; 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"); if (inv.type == MSG_BLOCK) pfrom->PushMessage(NetMsgType::BLOCK, block); + /* + // Disable BIP152 else if (inv.type == MSG_FILTERED_BLOCK) + */ + else // MSG_FILTERED_BLOCK { bool send = false; CMerkleBlock merkleBlock; @@ -4921,6 +4952,8 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam // else // no response } + /* + // Disable BIP152 else if (inv.type == MSG_CMPCT_BLOCK) { // 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 pfrom->PushMessage(NetMsgType::BLOCK, block); } + */ // Trigger the peer node to send a getblocks request for the next batch of inventory if (inv.hash == pfrom->hashContinue) @@ -4972,7 +5006,11 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam // Track requests for our stuff. 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) break; } } @@ -5183,6 +5221,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // nodes) pfrom->PushMessage(NetMsgType::SENDHEADERS); } + /* + // Disable BIP152 if (pfrom->nVersion >= SHORT_IDS_BLOCKS_VERSION) { // Tell our peer we are willing to provide version-1 cmpctblocks // 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; pfrom->PushMessage(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion); } + */ } @@ -5267,6 +5308,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, State(pfrom->GetId())->fPreferHeaders = true; } + /* + // Disable BIP152 else if (strCommand == NetMsgType::SENDCMPCT) { bool fAnnounceUsingCMPCTBLOCK = false; @@ -5286,6 +5329,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } } } + */ else if (strCommand == NetMsgType::INV) @@ -5333,10 +5377,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CNodeState *nodestate = State(pfrom->GetId()); if (CanDirectFetch(chainparams.GetConsensus()) && nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) { + /* + // Disable BIP152 if (nodestate->fProvidesHeaderAndIDs) vToFetch.push_back(CInv(MSG_CMPCT_BLOCK, inv.hash)); else vToFetch.push_back(inv); + */ + vToFetch.push_back(inv); // Mark block as in flight already, even though the actual "getdata" message only goes out // later (within the same cs_main lock, though). 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) { BlockTransactionsRequest req; @@ -5477,6 +5527,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } pfrom->PushMessage(NetMsgType::BLOCKTXN, resp); } + */ else if (strCommand == NetMsgType::GETHEADERS) @@ -5694,7 +5745,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, FlushStateToDisk(state, FLUSH_STATE_PERIODIC); } - + /* + // Disable BIP152 else if (strCommand == NetMsgType::CMPCTBLOCK && !fImporting && !fReindex) // Ignore blocks received while importing { 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 @@ -6063,6 +6116,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pindexLast->GetBlockHash().ToString(), pindexLast->nHeight); } if (vGetData.size() > 0) { + /* + // Disable BIP152 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 // 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 vGetData[0] = CInv(MSG_CMPCT_BLOCK, vGetData[0].hash); } + */ pfrom->PushMessage(NetMsgType::GETDATA, vGetData); } } @@ -6627,9 +6683,13 @@ bool SendMessages(CNode* pto) // add all to the inv queue. LOCK(pto->cs_inventory); vector vHeaders; + /* + // Disable BIP152 bool fRevertToInv = ((!state.fPreferHeaders && (!state.fPreferHeaderAndIDs || pto->vBlockHashesToAnnounce.size() > 1)) || 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 ProcessBlockAvailability(pto->id); // ensure pindexBestKnownBlock is up-to-date @@ -6681,6 +6741,8 @@ bool SendMessages(CNode* pto) } } } + /* + // Disable BIP152 if (!fRevertToInv && !vHeaders.empty()) { if (vHeaders.size() == 1 && state.fPreferHeaderAndIDs) { // We only send up to 1 block as header-and-ids, as otherwise @@ -6708,6 +6770,7 @@ bool SendMessages(CNode* pto) } else fRevertToInv = true; } + */ if (fRevertToInv) { // If falling back to using an inv, just try to inv the tip. // The last entry in vBlockHashesToAnnounce was our tip at some point @@ -6733,6 +6796,19 @@ bool SendMessages(CNode* pto) 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(); } diff --git a/src/protocol.cpp b/src/protocol.cpp index b0d813154..98202b8b0 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -35,10 +35,13 @@ const char *FILTERCLEAR="filterclear"; const char *REJECT="reject"; const char *SENDHEADERS="sendheaders"; const char *FEEFILTER="feefilter"; +/* +// Disable BIP152 const char *SENDCMPCT="sendcmpct"; const char *CMPCTBLOCK="cmpctblock"; const char *GETBLOCKTXN="getblocktxn"; const char *BLOCKTXN="blocktxn"; +*/ }; /** 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::SENDHEADERS, NetMsgType::FEEFILTER, + /* + // Disable BIP152 NetMsgType::SENDCMPCT, NetMsgType::CMPCTBLOCK, NetMsgType::GETBLOCKTXN, NetMsgType::BLOCKTXN, + */ }; const static std::vector allNetMessageTypesVec(allNetMessageTypes, allNetMessageTypes+ARRAYLEN(allNetMessageTypes)); @@ -171,7 +177,10 @@ std::string CInv::GetCommand() const case MSG_TX: return cmd.append(NetMsgType::TX); case MSG_BLOCK: return cmd.append(NetMsgType::BLOCK); case MSG_FILTERED_BLOCK: return cmd.append(NetMsgType::MERKLEBLOCK); + /* + // Disable BIP152 case MSG_CMPCT_BLOCK: return cmd.append(NetMsgType::CMPCTBLOCK); + */ default: throw std::out_of_range(strprintf("CInv::GetCommand(): type=%d unknown type", type)); } diff --git a/src/protocol.h b/src/protocol.h index 658ca965e..3de10ccfa 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -217,6 +217,8 @@ extern const char *SENDHEADERS; * @since protocol version 70013 as described by BIP133 */ extern const char *FEEFILTER; + +// Disable BIP152 /** * Contains a 1-byte bool and 8-byte LE version number. * 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. * @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 * list of "short txids". * @since protocol version 70014 as described by BIP 152 */ -extern const char *CMPCTBLOCK; +// extern const char *CMPCTBLOCK; /** * Contains a BlockTransactionsRequest * Peer should respond with "blocktxn" message. * @since protocol version 70014 as described by BIP 152 */ -extern const char *GETBLOCKTXN; +// extern const char *GETBLOCKTXN; /** * Contains a BlockTransactions. * Sent in response to a "getblocktxn" message. * @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) */ @@ -320,7 +322,10 @@ enum GetDataMsg MSG_BLOCK, // The following can only occur in getdata. Invs always use TX or BLOCK. MSG_FILTERED_BLOCK, + /* + // Disable BIP152 MSG_CMPCT_BLOCK, + */ }; /** inv message data */ diff --git a/src/serialize.h b/src/serialize.h index 04ab9aa2e..11641daa7 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -373,7 +373,10 @@ I ReadVarInt(Stream& is) #define FLATDATA(obj) REF(CFlatData((char*)&(obj), (char*)&(obj) + sizeof(obj))) #define VARINT(obj) REF(WrapVarInt(REF(obj))) +/* +// Disable BIP152 #define COMPACTSIZE(obj) REF(CCompactSize(REF(obj))) +*/ #define LIMITED_STRING(obj,n) REF(LimitedString< n >(REF(obj))) /** @@ -444,6 +447,8 @@ public: } }; +/* +// Disable BIP152 class CCompactSize { protected: @@ -465,6 +470,7 @@ public: n = ReadCompactSize(s); } }; +*/ template class LimitedString diff --git a/src/version.h b/src/version.h index a41cdebf8..b1c661e7e 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ * 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 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 static const int FEEFILTER_VERSION = 70013; +/* +// Disable BIP152 //! shord-id-based block download starts with this version static const int SHORT_IDS_BLOCKS_VERSION = 70014; //! not banning for invalid compact blocks starts with this version static const int INVALID_CB_NO_BAN_VERSION = 70015; +*/ #endif // BITCOIN_VERSION_H