mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 18:52:29 +02:00
Merge bitcoin/bitcoin#29770: index: Check all necessary block data is available before starting to sync
fd06157d14test: Add coverage for restarted node without any block sync (Fabian Jahr)3d7ab7ecb7rpc, test: Address feedback from #29668 (Fabian Jahr)312919c9ddtest: Indices can not start based on block data without undo data (Fabian Jahr)a9a3b29dd6index: Check availability of undo data for indices (Fabian Jahr)881ab4fc82support multiple block status checks in CheckBlockDataAvailability (furszy) Pull request description: Currently, we check that `BLOCK_HAVE_DATA` is available for all blocks an index needs to sync during startup. However, for `coinstatsindex` and `blockfilterindex` we also need the undo data for these blocks. If that data is missing in the blocks, we are currently still starting to sync each of these indices and then crash later when we encounter the missing data. This PR adds explicit knowledge of which block data is needed for each index and then checks its availability during startup before initializing the sync process on them. This also addresses a few open comments from #29668 in the last commit. ACKs for top commit: achow101: ACKfd06157d14furszy: utACKfd06157d14sedited: Re-ACKfd06157d14Tree-SHA512: e2ed81c93372b02daa8ddf2819df4164f96d92de05b1d48855410ecac78d5fcd9612d7f0e63a9d57d7e75a0b46e1bea278e43ea87f2693af0220d1f9c600e416
This commit is contained in:
@@ -122,9 +122,6 @@ protected:
|
||||
|
||||
void ChainStateFlushed(const kernel::ChainstateRole& role, const CBlockLocator& locator) override;
|
||||
|
||||
/// Return custom notification options for index.
|
||||
[[nodiscard]] virtual interfaces::Chain::NotifyOptions CustomOptions() { return {}; }
|
||||
|
||||
/// Initialize internal state from the database and block index.
|
||||
[[nodiscard]] virtual bool CustomInit(const std::optional<interfaces::BlockRef>& block) { return true; }
|
||||
|
||||
@@ -151,6 +148,9 @@ public:
|
||||
/// Get the name of the index for display in logs.
|
||||
const std::string& GetName() const LIFETIMEBOUND { return m_name; }
|
||||
|
||||
/// Return custom notification options for index.
|
||||
[[nodiscard]] virtual interfaces::Chain::NotifyOptions CustomOptions() { return {}; }
|
||||
|
||||
/// Blocks the current thread until the index is caught up to the current
|
||||
/// state of the block chain. This only blocks if the index has gotten in
|
||||
/// sync once and only needs to process blocks in the ValidationInterface
|
||||
|
||||
@@ -63,8 +63,6 @@ private:
|
||||
std::optional<uint256> ReadFilterHeader(int height, const uint256& expected_block_hash);
|
||||
|
||||
protected:
|
||||
interfaces::Chain::NotifyOptions CustomOptions() override;
|
||||
|
||||
bool CustomInit(const std::optional<interfaces::BlockRef>& block) override;
|
||||
|
||||
bool CustomCommit(CDBBatch& batch) override;
|
||||
@@ -80,6 +78,8 @@ public:
|
||||
explicit BlockFilterIndex(std::unique_ptr<interfaces::Chain> chain, BlockFilterType filter_type,
|
||||
size_t n_cache_size, bool f_memory = false, bool f_wipe = false);
|
||||
|
||||
interfaces::Chain::NotifyOptions CustomOptions() override;
|
||||
|
||||
BlockFilterType GetFilterType() const { return m_filter_type; }
|
||||
|
||||
/** Get a single filter by block. */
|
||||
|
||||
@@ -52,8 +52,6 @@ private:
|
||||
bool AllowPrune() const override { return true; }
|
||||
|
||||
protected:
|
||||
interfaces::Chain::NotifyOptions CustomOptions() override;
|
||||
|
||||
bool CustomInit(const std::optional<interfaces::BlockRef>& block) override;
|
||||
|
||||
bool CustomCommit(CDBBatch& batch) override;
|
||||
@@ -68,6 +66,8 @@ public:
|
||||
// Constructs the index, which becomes available to be queried.
|
||||
explicit CoinStatsIndex(std::unique_ptr<interfaces::Chain> chain, size_t n_cache_size, bool f_memory = false, bool f_wipe = false);
|
||||
|
||||
interfaces::Chain::NotifyOptions CustomOptions() override;
|
||||
|
||||
// Look up stats for a specific block using CBlockIndex
|
||||
std::optional<kernel::CCoinsStats> LookUpStats(const CBlockIndex& block_index) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user