diff --git a/contrib/debian/examples/bitcoin.conf b/contrib/debian/examples/bitcoin.conf --- a/contrib/debian/examples/bitcoin.conf +++ b/contrib/debian/examples/bitcoin.conf @@ -16,8 +16,8 @@ # Bind to given address and always listen on it. Use [host]:port notation for IPv6 #bind= -# Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6 -#whitebind= +# Bind to given address and add permission flags to peers connecting to it. Use [host]:port notation for IPv6 +#whitebind=perm@ ############################################################## ## Quick Primer on addnode vs connect ## diff --git a/doc/reduce-traffic.md b/doc/reduce-traffic.md --- a/doc/reduce-traffic.md +++ b/doc/reduce-traffic.md @@ -50,7 +50,7 @@ Doing so disables the automatic broadcasting of transactions from wallet. Not relaying other's transactions could hurt your privacy if used while a wallet is loaded or if you use the node to broadcast transactions. -- If a peer is whitelisted and "-whitelistforcerelay" is set to "1" (which will - also set "whitelistrelay" to "1"), we will still receive and relay their transactions. +- If a peer has the forcerelay permission, we will still receive and relay + their transactions. - It makes block propagation slower because compact block relay can only be used when transaction relay is enabled. diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -457,9 +457,8 @@ "-blocksonly", strprintf("Whether to reject transactions from network peers. " "Automatic broadcast and rebroadcast of any transactions " - "from inbound peers is disabled, unless " - "'-whitelistforcerelay' is '1', in which case whitelisted " - "peers' transactions will be relayed. RPC transactions are" + "from inbound peers is disabled, unless the peer has the " + "'forcerelay' permission. RPC transactions are" " not affected. (default: %u)", DEFAULT_BLOCKSONLY), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -230,8 +230,8 @@ static const std::chrono::seconds AVG_ADDRESS_BROADCAST_INTERVAL{30}; /** * Average delay between trickled inventory transmissions in seconds. - * Blocks and whitelisted receivers bypass this, outbound peers get half this - * delay. + * Blocks and peers with noban permission bypass this, outbound peers + * get half this delay. */ static const unsigned int INVENTORY_BROADCAST_INTERVAL = 5; /** @@ -2440,8 +2440,8 @@ nodestate->pindexBestKnownBlock->nChainWork < nMinimumChainWork) { // This peer has too little work on their headers chain to help - // us sync -- disconnect if using an outbound slot (unless - // whitelisted or addnode). + // us sync -- disconnect if it is an outbound disconnection + // candidate. // Note: We compare their tip to nMinimumChainWork (rather than // ::ChainActive().Tip()) because we won't start block download // until we have a headers chain that has at least @@ -3216,8 +3216,8 @@ // block-relay-only peer bool fBlocksOnly = !g_relay_txes || (pfrom.m_tx_relay == nullptr); - // Allow whitelisted peers to send data other than blocks in blocks only - // mode if whitelistrelay is true + // Allow peers with relay permission to send data other than blocks + // in blocks only mode if (pfrom.HasPermission(PF_RELAY)) { fBlocksOnly = false; } @@ -3667,16 +3667,16 @@ } if (pfrom.HasPermission(PF_FORCERELAY)) { - // Always relay transactions received from whitelisted peers, - // even if they were already in the mempool, allowing the node - // to function as a gateway for + // Always relay transactions received from peers with + // forcerelay permission, even if they were already in the + // mempool, allowing the node to function as a gateway for // nodes hidden behind it. if (!m_mempool.exists(tx.GetId())) { LogPrintf("Not relaying non-mempool transaction %s from " - "whitelisted peer=%d\n", + "forcerelay peer=%d\n", tx.GetId().ToString(), pfrom.GetId()); } else { - LogPrintf("Force relaying tx %s from whitelisted peer=%d\n", + LogPrintf("Force relaying tx %s from peer=%d\n", tx.GetId().ToString(), pfrom.GetId()); RelayTransaction(tx.GetId(), m_connman); } @@ -3855,7 +3855,8 @@ ReadStatus status = partialBlock.InitData(cmpctblock, vExtraTxnForCompact); if (status == READ_STATUS_INVALID) { - // Reset in-flight state in case of whitelist + // Reset in-flight state in case Misbehaving does not + // result in a disconnect MarkBlockAsReceived(pindex->GetBlockHash()); Misbehaving(pfrom, 100, "invalid compact block"); return; @@ -4013,7 +4014,8 @@ *it->second.second->partialBlock; ReadStatus status = partialBlock.FillBlock(*pblock, resp.txn); if (status == READ_STATUS_INVALID) { - // Reset in-flight state in case of whitelist. + // Reset in-flight state in case of Misbehaving does not + // result in a disconnect. MarkBlockAsReceived(resp.blockhash); Misbehaving( pfrom, 100, @@ -5672,8 +5674,9 @@ state.nHeadersSyncTimeout && nSyncStarted == 1 && (nPreferredDownload - state.fPreferredDownload >= 1)) { - // Disconnect a (non-whitelisted) peer if it is our only - // sync peer, and we have others we could be using instead. + // Disconnect a peer (without the noban permission) if it + // is our only sync peer, and we have others we could be + // using instead. // Note: If all our peers are inbound, then we won't // disconnect our sync peer for stalling; we have bigger // problems if we can't get any outbound peers. @@ -5684,10 +5687,9 @@ pto->fDisconnect = true; return true; } else { - LogPrintf( - "Timeout downloading headers from whitelisted " - "peer=%d, not disconnecting\n", - pto->GetId()); + LogPrintf("Timeout downloading headers from noban " + "peer=%d, not disconnecting\n", + pto->GetId()); // Reset the headers sync state so that we have a chance // to try downloading from a different peer. Note: this // will also result in at least one more getheaders diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -951,9 +951,8 @@ if (!ReadBlockFromDisk(block, pblockindex, config.GetChainParams().GetConsensus())) { // Block not found on disk. This could be because we have the block - // header in our index but don't have the block (for example if a - // non-whitelisted node sends us an unrequested long chain of valid - // blocks, we add the headers to our index, but don't accept the block). + // header in our index but not yet have the block or did not accept the + // block. throw JSONRPCError(RPC_MISC_ERROR, "Block not found on disk"); } diff --git a/src/test/netbase_tests.cpp b/src/test/netbase_tests.cpp --- a/src/test/netbase_tests.cpp +++ b/src/test/netbase_tests.cpp @@ -464,7 +464,7 @@ BOOST_CHECK(error.original.find("Invalid P2P permission") != std::string::npos); - // Check whitelist error + // Check netmask error BOOST_CHECK(!NetWhitelistPermissions::TryParse( "bloom,forcerelay,noban@1.2.3.4:32", whitelistPermissions, error)); BOOST_CHECK( diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -1225,7 +1225,7 @@ * @param[in] config The global config. * @param[in] pblock The block we want to process. * @param[in] fForceProcessing Process this block even if unrequested; - * used for non-network block sources and whitelisted peers. + * used for non-network block sources. * @param[out] fNewBlock A boolean which is set to indicate if the block * was first received via this call. * @returns If the block was processed, independently of block validity diff --git a/test/functional/p2p_blocksonly.py b/test/functional/p2p_blocksonly.py --- a/test/functional/p2p_blocksonly.py +++ b/test/functional/p2p_blocksonly.py @@ -65,9 +65,9 @@ assert_equal(self.nodes[0].getmempoolinfo()['size'], 1) self.log.info( - 'Check that txs from whitelisted peers are not rejected and relayed to others') + 'Check that txs from forcelay peers are not rejected and relayed to others') self.log.info( - "Restarting node 0 with whitelist permission and blocksonly") + "Restarting node 0 with forcerelay permission and blocksonly") self.restart_node(0, ["-persistmempool=0", "-whitelist=127.0.0.1", @@ -92,15 +92,15 @@ txid = self.nodes[0].testmempoolaccept([sigtx])[0]['txid'] self.log.info( - 'Check that the tx from whitelisted first_peer is relayed to others (ie.second_peer)') + 'Check that the tx from forcerelay first_peer is relayed to others (ie.second_peer)') with self.nodes[0].assert_debug_log(["received getdata"]): first_peer.send_message(msg_tx(FromHex(CTransaction(), sigtx))) self.log.info( - 'Check that the whitelisted peer is still connected after sending the transaction') + 'Check that the forcerelay peer is still connected after sending the transaction') assert_equal(first_peer.is_connected, True) second_peer.wait_for_tx(txid) assert_equal(self.nodes[0].getmempoolinfo()['size'], 1) - self.log.info("Whitelisted peer's transaction is accepted and relayed") + self.log.info("Forcerelay peer's transaction is accepted and relayed") if __name__ == '__main__': diff --git a/test/functional/p2p_permissions.py b/test/functional/p2p_permissions.py --- a/test/functional/p2p_permissions.py +++ b/test/functional/p2p_permissions.py @@ -130,10 +130,10 @@ self.sync_all() self.log.debug( - "Create a connection from a whitelisted wallet that rebroadcasts raw txs") + "Create a connection from a forcerelay peer that rebroadcasts raw txs") # A python mininode is needed to send the raw transaction directly. # If a full node was used, it could only rebroadcast via the inv-getdata - # mechanism. However, even for whitelisted connections, a full node would + # mechanism. However, even for forcerelay connections, a full node would # currently not request a txid that is already in the mempool. self.restart_node(1, extra_args=["-whitelist=forcerelay@127.0.0.1"]) p2p_rebroadcast_wallet = self.nodes[1].add_p2p_connection( @@ -160,7 +160,7 @@ " is already in the mempool") connect_nodes(self.nodes[1], 0) with self.nodes[1].assert_debug_log( - ["Force relaying tx {} from whitelisted peer=0".format(txid)]): + ["Force relaying tx {} from peer=0".format(txid)]): p2p_rebroadcast_wallet.send_txs_and_test([tx], self.nodes[1]) wait_until(lambda: txid in self.nodes[0].getrawmempool()) @@ -173,7 +173,7 @@ self.nodes[1], success=False, reject_reason='Not relaying non-mempool transaction ' - '{} from whitelisted peer=0'.format(txid), + '{} from forcerelay peer=0'.format(txid), ) def checkpermission(self, args, expectedPermissions, whitelisted): diff --git a/test/functional/p2p_unrequested_blocks.py b/test/functional/p2p_unrequested_blocks.py --- a/test/functional/p2p_unrequested_blocks.py +++ b/test/functional/p2p_unrequested_blocks.py @@ -4,7 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test processing of unrequested blocks. -Setup: two nodes, node0+node1, not connected to each other. Node1 will have +Setup: two nodes, node0 + node1, not connected to each other. Node1 will have nMinimumChainWork set to 0x10, so it won't process low-work unrequested blocks. We have one P2PInterface connection to node0 called test_node, and one to node1 @@ -87,18 +87,10 @@ ["-minimumchainwork=0x10"]] def setup_network(self): - # Node0 will be used to test behavior of processing unrequested blocks - # from peers which are not whitelisted, while Node1 will be used for - # the whitelisted case. - # Node2 will be used for non-whitelisted peers to test the interaction - # with nMinimumChainWork. self.setup_nodes() def run_test(self): - # Setup the p2p connections - # test_node connects to node0 (not whitelisted) test_node = self.nodes[0].add_p2p_connection(P2PInterface()) - # min_work_node connects to node1 (whitelisted) min_work_node = self.nodes[1].add_p2p_connection(P2PInterface()) # 1. Have nodes mine a block (leave IBD) @@ -258,8 +250,7 @@ assert_equal(self.nodes[0].getbestblockhash(), all_blocks[286].hash) assert_raises_rpc_error(-1, "Block not found on disk", self.nodes[0].getblock, all_blocks[287].hash) - self.log.info( - "Successfully reorged to longer chain from non-whitelisted peer") + self.log.info("Successfully reorged to longer chain") # 8. Create a chain which is invalid at a height longer than the # current chain, but which has more blocks on top of that