diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2020-12-15 12:50:38 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2020-12-17 02:54:02 +0000 |
commit | cf7e1571d33980362f1a03f81124fc37a07aa0f0 (patch) | |
tree | f20deee5a798f3665bcb618a30e9c28cc2f77c89 /src/cryptonote_protocol/cryptonote_protocol_handler.inl | |
parent | protocol: drop peers we can't download anything from in sync mode (diff) | |
download | monero-cf7e1571d33980362f1a03f81124fc37a07aa0f0.tar.xz |
protocol: reject claimed block hashes that already are in the chain
Diffstat (limited to '')
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler.inl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 994fa7101..47961f132 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -2548,6 +2548,8 @@ skip: } std::unordered_set<crypto::hash> hashes; + uint64_t height = arg.start_height; + const uint64_t blockchain_height = m_core.get_current_blockchain_height(); for (const auto &h: arg.m_block_ids) { if (!hashes.insert(h).second) @@ -2556,6 +2558,17 @@ skip: drop_connection(context, true, false); return 1; } + if (height < blockchain_height) + { + const crypto::hash block_in_chain = m_core.get_block_id_by_height(height); + if ((height < context.m_expect_height - 1 && block_in_chain == h) || (height == context.m_expect_height - 1 && block_in_chain != h)) + { + LOG_ERROR_CCONTEXT("sent existing block " << h << " at height " << height << ", expected height was " << context.m_expect_height << ", dropping connection"); + drop_connection(context, true, false); + return 1; + } + } + ++height; } uint64_t n_use_blocks = m_core.prevalidate_block_hashes(arg.start_height, arg.m_block_ids, arg.m_block_weights); |