mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 21:03:28 +01:00
protocol: fix false positives dropping peers
it'd trigger on reorgs
This commit is contained in:
parent
b2221881a1
commit
bcdc6c62b7
@ -2063,10 +2063,16 @@ skip:
|
|||||||
bool queue_proceed = nspans < BLOCK_QUEUE_NSPANS_THRESHOLD || size < block_queue_size_threshold;
|
bool queue_proceed = nspans < BLOCK_QUEUE_NSPANS_THRESHOLD || size < block_queue_size_threshold;
|
||||||
// get rid of blocks we already requested, or already have
|
// get rid of blocks we already requested, or already have
|
||||||
if (skip_unneeded_hashes(context, true) && context.m_needed_objects.empty() && context.m_num_requested == 0)
|
if (skip_unneeded_hashes(context, true) && context.m_needed_objects.empty() && context.m_num_requested == 0)
|
||||||
|
{
|
||||||
|
if (context.m_remote_blockchain_height > m_block_queue.get_next_needed_height(bc_height))
|
||||||
{
|
{
|
||||||
MERROR(context << "Nothing we can request from this peer, and we did not request anything previously");
|
MERROR(context << "Nothing we can request from this peer, and we did not request anything previously");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
MDEBUG(context << "Nothing to get from this peer, and it's not ahead of us, all done");
|
||||||
|
context.m_state = cryptonote_connection_context::state_normal;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
uint64_t next_needed_height = m_block_queue.get_next_needed_height(bc_height);
|
uint64_t next_needed_height = m_block_queue.get_next_needed_height(bc_height);
|
||||||
uint64_t next_block_height;
|
uint64_t next_block_height;
|
||||||
if (context.m_needed_objects.empty())
|
if (context.m_needed_objects.empty())
|
||||||
@ -2203,10 +2209,16 @@ skip:
|
|||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
if (skip_unneeded_hashes(context, false) && context.m_needed_objects.empty() && context.m_num_requested == 0)
|
if (skip_unneeded_hashes(context, false) && context.m_needed_objects.empty() && context.m_num_requested == 0)
|
||||||
|
{
|
||||||
|
if (context.m_remote_blockchain_height > m_block_queue.get_next_needed_height(m_core.get_current_blockchain_height()))
|
||||||
{
|
{
|
||||||
MERROR(context << "Nothing we can request from this peer, and we did not request anything previously");
|
MERROR(context << "Nothing we can request from this peer, and we did not request anything previously");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
MDEBUG(context << "Nothing to get from this peer, and it's not ahead of us, all done");
|
||||||
|
context.m_state = cryptonote_connection_context::state_normal;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const uint64_t first_block_height = context.m_last_response_height - context.m_needed_objects.size() + 1;
|
const uint64_t first_block_height = context.m_last_response_height - context.m_needed_objects.size() + 1;
|
||||||
static const uint64_t bp_fork_height = m_core.get_earliest_ideal_height_for_version(8);
|
static const uint64_t bp_fork_height = m_core.get_earliest_ideal_height_for_version(8);
|
||||||
@ -2309,30 +2321,16 @@ skip:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we're still around, we might be at a point where the peer is pruned, so we could either
|
// we can do nothing, so drop this peer to make room for others unless we think we've downloaded all we need
|
||||||
// drop it to make space for other peers, or ask for a span further down the line
|
const uint64_t blockchain_height = m_core.get_current_blockchain_height();
|
||||||
const uint32_t next_stripe = get_next_needed_pruning_stripe().first;
|
if (std::max(blockchain_height, m_block_queue.get_next_needed_height(blockchain_height)) >= m_core.get_target_blockchain_height())
|
||||||
const uint32_t peer_stripe = tools::get_pruning_stripe(context.m_pruning_seed);
|
|
||||||
const uint32_t local_stripe = tools::get_pruning_stripe(m_core.get_blockchain_pruning_seed());
|
|
||||||
if (!(m_sync_pruned_blocks && peer_stripe == local_stripe) && next_stripe && peer_stripe && next_stripe != peer_stripe)
|
|
||||||
{
|
{
|
||||||
// at this point, we have to either close the connection, or start getting blocks past the
|
|
||||||
// current point, or become dormant
|
|
||||||
MDEBUG(context << "this peer is pruned at seed " << epee::string_tools::to_string_hex(context.m_pruning_seed) <<
|
|
||||||
", next stripe needed is " << next_stripe);
|
|
||||||
if (!context.m_is_income)
|
|
||||||
{
|
|
||||||
if (should_drop_connection(context, next_stripe))
|
|
||||||
{
|
|
||||||
m_p2p->add_used_stripe_peer(context);
|
|
||||||
return false; // drop outgoing connections
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// we'll get back stuck waiting for the go ahead
|
|
||||||
context.m_state = cryptonote_connection_context::state_normal;
|
context.m_state = cryptonote_connection_context::state_normal;
|
||||||
MLOG_PEER_STATE("Nothing to do for now, switching to normal state");
|
MLOG_PEER_STATE("Nothing to do for now, switching to normal state");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
MLOG_PEER_STATE("We can download nothing from this peer, dropping");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
skip:
|
skip:
|
||||||
|
@ -112,5 +112,6 @@ namespace tests
|
|||||||
bool prune_blockchain(uint32_t pruning_seed) const { return true; }
|
bool prune_blockchain(uint32_t pruning_seed) const { return true; }
|
||||||
bool get_txpool_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes) { return false; }
|
bool get_txpool_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes) { return false; }
|
||||||
bool get_pool_transaction_hashes(std::vector<crypto::hash>& txs, bool include_unrelayed_txes = true) const { return false; }
|
bool get_pool_transaction_hashes(std::vector<crypto::hash>& txs, bool include_unrelayed_txes = true) const { return false; }
|
||||||
|
crypto::hash get_block_id_by_height(uint64_t height) const { return crypto::null_hash; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,7 @@ public:
|
|||||||
bool has_block_weights(uint64_t height, uint64_t nblocks) const { return false; }
|
bool has_block_weights(uint64_t height, uint64_t nblocks) const { return false; }
|
||||||
bool get_txpool_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes) { return false; }
|
bool get_txpool_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes) { return false; }
|
||||||
bool get_pool_transaction_hashes(std::vector<crypto::hash>& txs, bool include_unrelayed_txes = true) const { return false; }
|
bool get_pool_transaction_hashes(std::vector<crypto::hash>& txs, bool include_unrelayed_txes = true) const { return false; }
|
||||||
|
crypto::hash get_block_id_by_height(uint64_t height) const { return crypto::null_hash; }
|
||||||
void stop() {}
|
void stop() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user