mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
Merge #19204: p2p: Reduce inv traffic during IBD
fa525e4d1cnet: Avoid wasting inv traffic during IBD (MarcoFalke)fa06d7e934refactor: block import implies IsInitialBlockDownload (MarcoFalke)faba65e696Add ChainstateManager::ActiveChainstate (MarcoFalke)fabf3d64fftest: Add FeeFilterRounder test (MarcoFalke) Pull request description: Tx-inv messages are ignored during IBD, so it would be nice if we told peers to not send them in the first place. Do that by sending two `feefilter` messages: One when the connection is made (and the node is in IBD), and another one when the node leaves IBD. ACKs for top commit: jamesob: ACKfa525e4d1c([`jamesob/ackr/19204.1.MarcoFalke.p2p_reduce_inv_traffic_d`](https://github.com/jamesob/bitcoin/tree/ackr/19204.1.MarcoFalke.p2p_reduce_inv_traffic_d)) naumenkogs: utACKfa525e4gzhao408: ACKfa525e4d1cjonatack: re-ACKfa525e4checked diff `git range-diff19612cafa8a66c fa525e4`, re-reviewed, ran tests, ran a custom p2p IBD behavior test at9321e0f223. hebasto: re-ACKfa525e4d1c, only rebased since the [previous](https://github.com/bitcoin/bitcoin/pull/19204#pullrequestreview-429519667) review (verified with `git range-diff`). Tree-SHA512: 2c22a5def9822396fca45d808b165b636f1143c4bdb2eaa5c7e977f1f18e8b10c86d4c180da488def38416cf3076a26de15014dfd4d86b2a7e5af88c74afb8eb
This commit is contained in:
@@ -2576,7 +2576,7 @@ void ProcessMessage(
|
||||
LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol, disconnecting peer=%d\n", inv.hash.ToString(), pfrom.GetId());
|
||||
pfrom.fDisconnect = true;
|
||||
return;
|
||||
} else if (!fAlreadyHave && !fImporting && !fReindex && !::ChainstateActive().IsInitialBlockDownload()) {
|
||||
} else if (!fAlreadyHave && !chainman.ActiveChainstate().IsInitialBlockDownload()) {
|
||||
RequestTx(State(pfrom.GetId()), inv.hash, current_time);
|
||||
}
|
||||
}
|
||||
@@ -4392,10 +4392,21 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
|
||||
) {
|
||||
CAmount currentFilter = m_mempool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK();
|
||||
int64_t timeNow = GetTimeMicros();
|
||||
static FeeFilterRounder g_filter_rounder{CFeeRate{DEFAULT_MIN_RELAY_TX_FEE}};
|
||||
if (m_chainman.ActiveChainstate().IsInitialBlockDownload()) {
|
||||
// Received tx-inv messages are discarded when the active
|
||||
// chainstate is in IBD, so tell the peer to not send them.
|
||||
currentFilter = MAX_MONEY;
|
||||
} else {
|
||||
static const CAmount MAX_FILTER{g_filter_rounder.round(MAX_MONEY)};
|
||||
if (pto->m_tx_relay->lastSentFeeFilter == MAX_FILTER) {
|
||||
// Send the current filter if we sent MAX_FILTER previously
|
||||
// and made it out of IBD.
|
||||
pto->m_tx_relay->nextSendTimeFeeFilter = timeNow - 1;
|
||||
}
|
||||
}
|
||||
if (timeNow > pto->m_tx_relay->nextSendTimeFeeFilter) {
|
||||
static CFeeRate default_feerate(DEFAULT_MIN_RELAY_TX_FEE);
|
||||
static FeeFilterRounder filterRounder(default_feerate);
|
||||
CAmount filterToSend = filterRounder.round(currentFilter);
|
||||
CAmount filterToSend = g_filter_rounder.round(currentFilter);
|
||||
// We always have a fee filter of at least minRelayTxFee
|
||||
filterToSend = std::max(filterToSend, ::minRelayTxFee.GetFeePerK());
|
||||
if (filterToSend != pto->m_tx_relay->lastSentFeeFilter) {
|
||||
|
||||
Reference in New Issue
Block a user