mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 21:03:28 +01:00
protocol: reject claimed block hashes that already are in the chain
This commit is contained in:
parent
af0a25544e
commit
cf7e1571d3
@ -2548,6 +2548,8 @@ skip:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_set<crypto::hash> hashes;
|
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)
|
for (const auto &h: arg.m_block_ids)
|
||||||
{
|
{
|
||||||
if (!hashes.insert(h).second)
|
if (!hashes.insert(h).second)
|
||||||
@ -2556,6 +2558,17 @@ skip:
|
|||||||
drop_connection(context, true, false);
|
drop_connection(context, true, false);
|
||||||
return 1;
|
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);
|
uint64_t n_use_blocks = m_core.prevalidate_block_hashes(arg.start_height, arg.m_block_ids, arg.m_block_weights);
|
||||||
|
@ -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