mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
Merge bitcoin/bitcoin#29412: p2p: Don't process mutated blocks
d8087adc7e[test] IsBlockMutated unit tests (dergoegge)1ed2c98297Add transaction_identifier::size to allow Span conversion (dergoegge)1ec6bbeb8d[validation] Cache merkle root and witness commitment checks (dergoegge)5bf4f5ba32[test] Add regression test for #27608 (dergoegge)49257c0304[net processing] Don't process mutated blocks (dergoegge)2d8495e080[validation] Merkle root malleation should be caught by IsBlockMutated (dergoegge)66abce1d98[validation] Introduce IsBlockMutated (dergoegge)e7669e1343[refactor] Cleanup merkle root checks (dergoegge)95bddb930a[validation] Isolate merkle root checks (dergoegge) Pull request description: This PR proposes to check for mutated blocks early as a defense-in-depth mitigation against attacks leveraging mutated blocks. We introduce `IsBlockMutated` which catches all known forms of block malleation and use it to do an early mutation check whenever we receive a `block` message. We have observed attacks that abused mutated blocks in the past, which could have been prevented by simply not processing mutated blocks (e.g. https://github.com/bitcoin/bitcoin/pull/27608 for which a regression test is included in this PR). ACKs for top commit: achow101: ACKd8087adc7emaflcko: ACKd8087adc7e🏄 fjahr: Code review ACKd8087adc7esr-gi: Code review ACKd8087adc7eTree-SHA512: 618ff4ea7f168e10f07504d3651290efbb1bb2ab3b838ffff3527c028caf6c52dedad18d04d3dbc627977479710930e200f2dfae18a08f627efe7e64a57e535f
This commit is contained in:
@@ -379,6 +379,9 @@ bool TestBlockValidity(BlockValidationState& state,
|
||||
/** Check with the proof of work on each blockheader matches the value in nBits */
|
||||
bool HasValidProofOfWork(const std::vector<CBlockHeader>& headers, const Consensus::Params& consensusParams);
|
||||
|
||||
/** Check if a block has been mutated (with respect to its merkle root and witness commitments). */
|
||||
bool IsBlockMutated(const CBlock& block, bool check_witness_root);
|
||||
|
||||
/** Return the sum of the work on a given set of headers */
|
||||
arith_uint256 CalculateHeadersWork(const std::vector<CBlockHeader>& headers);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user