mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Merge #21055: [Bundle 3/n] Prune remaining g_chainman usage in validation functions
e11b649650validation: CVerifyDB::VerifyDB: Use locking annotation (Carl Dong)03f75c42e1validation: Use existing chain member in CChainState::LoadGenesisBlock (Carl Dong)5e4af77380validation: Use existing chain member in CChainState::AcceptBlock (Carl Dong)fee73347c0validation: Pass in chain to FindBlockPos+SaveBlockToDisk (Carl Dong)a9d28bcd8dvalidation: Use *this in CChainState::ActivateBestChainStep (Carl Dong)4744efc9bavalidation: Pass in chainstate to CTxMemPool::check (Carl Dong)1fb7b2c595validation: Use *this in CChainState::InvalidateBlock (Carl Dong)8cdb2f7e58validation: Move LoadBlockIndexDB to CChainState (Carl Dong)8b99efbcc0validation: Move invalid block handling to CChainState (Carl Dong)2bdf37fe18validation: Pass in chainstate to CVerifyDB::VerifyDB (Carl Dong)31eac50c72validation: Remove global ::VersionBitsTip{State,SinceHeight,Statistics} (Carl Dong)63e4c7316avalidation: Pass in chainstate to ::PruneBlockFilesManual (Carl Dong)4bada76237validation: Pass in chainstate to UpdateTip (Carl Dong)a3ba08ba7dvalidation: Remove global ::{{Precious,Invalidate}Block,ResetBlockFailureFlags} (Carl Dong)4927c9e699validation: Remove global ::LoadGenesisBlock (Carl Dong)9da106be4dvalidation: Check chain tip is non-null in CheckFinalTx (Carl Dong) Pull request description: Overall PR: #20158 (tree-wide: De-globalize ChainstateManager) Based on: - [x] #20750 | [Bundle 2/n] Prune g_chainman usage in mempool-related validation functions Note to reviewers: 1. This bundle may _apparently_ introduce usage of `g_chainman` or `::Chain(state|)Active()` globals, but these are resolved later on in the overall PR. [Commits of overall PR](https://github.com/bitcoin/bitcoin/pull/20158/commits) 2. There may be seemingly obvious local references to `ChainstateManager` or other validation objects which are not being used in callers of the current function in question, this is done intentionally to **_keep each commit centered around one function/method_** to ease review and to make the overall change systematic. We don't assume anything about our callers. Rest assured that once we are considering that particular caller in later commits, we will use the obvious local references. [Commits of overall PR](https://github.com/bitcoin/bitcoin/pull/20158/commits) 3. When changing a function/method that has many callers (e.g. `LookupBlockIndex` with 55 callers), it is sometimes easier (and less error-prone) to use a scripted-diff. When doing so, there will be 3 commits in sequence so that every commit compiles like so: 1. Add `new_function`, make `old_function` a wrapper of `new_function`, divert all calls to `old_function` to `new_function` **in the local module only** 2. Scripted-diff to divert all calls to `old_function` to `new_function` **in the rest of the codebase** 3. Remove `old_function` Note to self: - [x] Address: https://github.com/bitcoin/bitcoin/pull/20750#discussion_r579400663 ACKs for top commit: laanwj: Code review ACKe11b649650Tree-SHA512: 205a451a741e32f17d5966de289f2f5a3f0817738c0087b70ff4755ddd217b53d01050ed396669bda2b1d216a88d927b9778777f9ff95ab1fe20e59c5f341776
This commit is contained in:
@@ -720,7 +720,7 @@ static void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImp
|
||||
fReindex = false;
|
||||
LogPrintf("Reindexing finished\n");
|
||||
// To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked):
|
||||
LoadGenesisBlock(chainparams);
|
||||
::ChainstateActive().LoadGenesisBlock(chainparams);
|
||||
}
|
||||
|
||||
// -loadblock=
|
||||
@@ -1636,7 +1636,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
|
||||
// If we're not mid-reindex (based on disk + args), add a genesis block on disk
|
||||
// (otherwise we use the one already on disk).
|
||||
// This is called again in ThreadImport after the reindex completes.
|
||||
if (!fReindex && !LoadGenesisBlock(chainparams)) {
|
||||
if (!fReindex && !::ChainstateActive().LoadGenesisBlock(chainparams)) {
|
||||
strLoadError = _("Error initializing block database");
|
||||
break;
|
||||
}
|
||||
@@ -1747,7 +1747,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
|
||||
// work when we allow VerifyDB to be parameterized by chainstate.
|
||||
if (&::ChainstateActive() == chainstate &&
|
||||
!CVerifyDB().VerifyDB(
|
||||
chainparams, &chainstate->CoinsDB(),
|
||||
chainparams, *chainstate, &chainstate->CoinsDB(),
|
||||
args.GetArg("-checklevel", DEFAULT_CHECKLEVEL),
|
||||
args.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) {
|
||||
strLoadError = _("Corrupted block database detected");
|
||||
|
||||
Reference in New Issue
Block a user