mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
Merge bitcoin/bitcoin#31533: fuzz: Add fuzz target for block index tree and related validation events
db2d39f642fuzz: add subtest for re-downloading a previously pruned block (Eugene Siegel)45f5b2dac3fuzz: Add fuzzer for block index (Martin Zumsande)c011e3aa54test: Wrap validation functions with TestChainstateManager (Martin Zumsande) Pull request description: This adds a fuzz target for the block index and various events in validation that interact with it. It can create arbitrary tree-like structure of block indexes, simulating (so far) the following events: - Adding a header - Receiving the full block (may be valid or not) - `ActivateBestChain()` - Reorging the chain to a new chain tip (possibly encountering invalid blocks on the way) - Pruning a block in the best chain - Receiving a previously pruned block again (`getblockfrompeer`) It might be interesting / possible to extend this to more events, such as dealing with more than one chainstate (assumeutxo). The test skips all actual validation of header/ block / transaction data by just simulating the outcome, and also doesn't interact with the data directory. The main goal is to ensure the integrity of the block index tree in all fuzzed constellations, by calling `CheckBlockIndex()` at the end of each iteration. Compared to #29158 this approach has a more limited scope (by skipping all actual validation), but it is fast - it doesn't do a full init sequence on each iteration, but "cleans up" after itself by resetting the global validation state after each iteration. ACKs for top commit: Crypt-iQ: reACKdb2d39f642maflcko: review ACKdb2d39f642🍶 sedited: Re-ACKdb2d39f642Tree-SHA512: 76cd5f8f4d7d7258620b46d7438bad4508c3bdc98825b48b60f694b5a9838e2b2cf4967c0ead181f86f66f4939ddfe552471851b9d18f84f584c03dd7e09fc43
This commit is contained in:
@@ -248,7 +248,6 @@ private:
|
||||
ChainstateManager& chainman);
|
||||
|
||||
RecursiveMutex cs_LastBlockFile;
|
||||
std::vector<CBlockFileInfo> m_blockfile_info;
|
||||
|
||||
//! Since assumedvalid chainstates may be syncing a range of the chain that is very
|
||||
//! far away from the normal/background validation process, we should segment blockfiles
|
||||
@@ -283,12 +282,6 @@ private:
|
||||
|
||||
const Obfuscation m_obfuscation;
|
||||
|
||||
/** Dirty block index entries. */
|
||||
std::set<CBlockIndex*> m_dirty_blockindex;
|
||||
|
||||
/** Dirty block file entries. */
|
||||
std::set<int> m_dirty_fileinfo;
|
||||
|
||||
/**
|
||||
* Map from external index name to oldest block that must not be pruned.
|
||||
*
|
||||
@@ -304,6 +297,15 @@ private:
|
||||
const FlatFileSeq m_block_file_seq;
|
||||
const FlatFileSeq m_undo_file_seq;
|
||||
|
||||
protected:
|
||||
std::vector<CBlockFileInfo> m_blockfile_info;
|
||||
|
||||
/** Dirty block index entries. */
|
||||
std::set<CBlockIndex*> m_dirty_blockindex;
|
||||
|
||||
/** Dirty block file entries. */
|
||||
std::set<int> m_dirty_fileinfo;
|
||||
|
||||
public:
|
||||
using Options = kernel::BlockManagerOpts;
|
||||
using ReadRawBlockResult = util::Expected<std::vector<std::byte>, ReadRawError>;
|
||||
|
||||
Reference in New Issue
Block a user