mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
Merge bitcoin/bitcoin#33252: p2p: add DifferenceFormatter fuzz target and invariant check
65a10fc3c5p2p: add assertion for BlockTransactionsRequest indexes (frankomosh)58be359f6bfuzz: add a target for DifferenceFormatter Class (frankomosh) Pull request description: Adds a fuzz test for the [`DifferenceFormatter`](e3f416dbf7/src/blockencodings.h (L22-L42)) (used in [`BlockTransactionsRequest`](https://github.com/bitcoin/bitcoin/blob/master/src/blockencodings.h#L44-L54), [BIP 152](https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki)). The DifferenceFormatter class implements differential encoding for compact block transactions (BIP 152). This PR ensures that its strictly-monotonic property is maintained. It complements the tests in [`blocktransactionsrequest_deserialize`](9703b7e6d5/src/test/fuzz/deserialize.cpp (L314)). Additionally, there's an added invariant check after GETBLOCKTXN deserialization in `net_processing.cpp`. ACKs for top commit: Crypt-iQ: tACK65a10fc3c5achow101: ACK65a10fc3c5dergoegge: Code review ACK65a10fc3c5Tree-SHA512: 70659cf045e99bb5f753763c7ddac094cb2883c202c899276cbe616889afa053b2d5e831f99d6386d4d1e4118cd35fa0b14b54667853fe067f6efe2eb77b4097
This commit is contained in:
@@ -4118,6 +4118,11 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
if (msg_type == NetMsgType::GETBLOCKTXN) {
|
||||
BlockTransactionsRequest req;
|
||||
vRecv >> req;
|
||||
// Verify differential encoding invariant: indexes must be strictly increasing
|
||||
// DifferenceFormatter should guarantee this property during deserialization
|
||||
for (size_t i = 1; i < req.indexes.size(); ++i) {
|
||||
Assume(req.indexes[i] > req.indexes[i-1]);
|
||||
}
|
||||
|
||||
std::shared_ptr<const CBlock> recent_block;
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user