Skip to content

Commit 5f44c5c

Browse files
committed
Merge bitcoin/bitcoin#24133: index: Improve robustness of coinstatsindex at restart
820c03a index: check muhash is in sync on coinstatsindex launch (Fabian Jahr) 38ed58b index: remove txindex references from base index (Fabian Jahr) Pull request description: This change lets the `coinstatsindex` fail loudly in case the internal `muhash` state differs from the last finalized output saved on disk, which would indicate that the `muhash` state somehow got out of sync. This should generally not happen since both are written to disk in a batch but #24076 seems to indicate that the might still be an issue. Since #24076 so far can not be reproduced reliably, the issue should not be closed yet. Further investigation and testing needs to be done. ACKs for top commit: Sjors: re-ACK 820c03a mzumsande: re-ACK 820c03a ryanofsky: Code review ACK 820c03a. Good to catch the error earlier Tree-SHA512: 3c985d7152698d25bad95d4ad512ff87dff13fabef790589c5a6cf93ca4251ad599e12feb7251a084503e2a213b022eaacfbaaa601464114ad372b029f64f204
2 parents ffcbaf5 + 820c03a commit 5f44c5c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/index/base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ class BaseIndex : public CValidationInterface
4040
DB(const fs::path& path, size_t n_cache_size,
4141
bool f_memory = false, bool f_wipe = false, bool f_obfuscate = false);
4242

43-
/// Read block locator of the chain that the txindex is in sync with.
43+
/// Read block locator of the chain that the index is in sync with.
4444
bool ReadBestBlock(CBlockLocator& locator) const;
4545

46-
/// Write block locator of the chain that the txindex is in sync with.
46+
/// Write block locator of the chain that the index is in sync with.
4747
void WriteBestBlock(CDBBatch& batch, const CBlockLocator& locator);
4848
};
4949

src/index/coinstatsindex.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,14 @@ bool CoinStatsIndex::Init()
363363
return error("%s: Cannot read current %s state; index may be corrupted",
364364
__func__, GetName());
365365
}
366+
367+
uint256 out;
368+
m_muhash.Finalize(out);
369+
if (entry.muhash != out) {
370+
return error("%s: Cannot read current %s state; index may be corrupted",
371+
__func__, GetName());
372+
}
373+
366374
m_transaction_output_count = entry.transaction_output_count;
367375
m_bogo_size = entry.bogo_size;
368376
m_total_amount = entry.total_amount;

0 commit comments

Comments
 (0)