diff options
author | MarcoFalke <falke.marco@gmail.com> | 2022-01-12 10:51:36 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2022-01-12 10:51:40 +0100 |
commit | 1f7acfdcca3525edf3eba23535240d23ff0c4fc9 (patch) | |
tree | 3035a031578bd248215c2449f88af5562a483d09 | |
parent | db1f04fa8cdc6795f9e57b28724f694fb4466dde (diff) | |
parent | ce95fb36af7db6582216adc64f2a66aaa06b55b3 (diff) |
Merge bitcoin/bitcoin#24024: Remove cs_main lock annotation from ChainstateManager.m_blockman
ce95fb36af7db6582216adc64f2a66aaa06b55b3 Remove cs_main lock annotation from ChainstateManager.m_blockman (Ryan Ofsky)
Pull request description:
`BlockManager` is a large data structure, and `cs_main` is not required to take its address or access every part of it. Individual `BlockManager` fields and methods which do require `cs_main` like `m_block_index` and `LookupBlockIndex` are already annotated separately, and these other annotations describe locking requirements more accurately and do a better job enforcing thread safety.
Since `cs_main` is not needed to access the address of the m_block object, this commit drops `cs_main` LOCK calls which were added pointlessly to satisfy this annotation in the past.
Code changes were made by dongcarl, I just wrote the commit description
ACKs for top commit:
MarcoFalke:
cr ACK ce95fb36af7db6582216adc64f2a66aaa06b55b3
dongcarl:
crACK ce95fb36af7db6582216adc64f2a66aaa06b55b3
jonatack:
ACK ce95fb36af7db6582216adc64f2a66aaa06b55b3 per `git range-diff db1f04f 5a1c413 ce95fb3` change since last push is rebase and dropping braces on the member initialization
Tree-SHA512: b18a6ebcc70bea750485f04d4feb7bb28450fea2176e513be9cc242e9f63b24254c5659e74eb6d6045c706a3aaeb94688937b25b7ca7653f8aa3cf8c18845d5a
-rw-r--r-- | src/test/fuzz/coins_view.cpp | 2 | ||||
-rw-r--r-- | src/validation.cpp | 2 | ||||
-rw-r--r-- | src/validation.h | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/src/test/fuzz/coins_view.cpp b/src/test/fuzz/coins_view.cpp index 5b85ccff83..994b4b9e49 100644 --- a/src/test/fuzz/coins_view.cpp +++ b/src/test/fuzz/coins_view.cpp @@ -273,7 +273,7 @@ FUZZ_TARGET_INIT(coins_view, initialize_coins_view) CCoinsStats stats{CoinStatsHashType::HASH_SERIALIZED}; bool expected_code_path = false; try { - (void)GetUTXOStats(&coins_view_cache, WITH_LOCK(::cs_main, return std::ref(g_setup->m_node.chainman->m_blockman)), stats); + (void)GetUTXOStats(&coins_view_cache, g_setup->m_node.chainman->m_blockman, stats); } catch (const std::logic_error&) { expected_code_path = true; } diff --git a/src/validation.cpp b/src/validation.cpp index 47b931a920..5deb44699a 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4873,7 +4873,7 @@ bool ChainstateManager::PopulateAndValidateSnapshot( // about the snapshot_chainstate. CCoinsViewDB* snapshot_coinsdb = WITH_LOCK(::cs_main, return &snapshot_chainstate.CoinsDB()); - if (!GetUTXOStats(snapshot_coinsdb, WITH_LOCK(::cs_main, return std::ref(m_blockman)), stats, breakpoint_fnc)) { + if (!GetUTXOStats(snapshot_coinsdb, m_blockman, stats, breakpoint_fnc)) { LogPrintf("[snapshot] failed to generate coins stats\n"); return false; } diff --git a/src/validation.h b/src/validation.h index fdc4e73b0a..edbd68f783 100644 --- a/src/validation.h +++ b/src/validation.h @@ -828,7 +828,7 @@ public: std::thread m_load_block; //! A single BlockManager instance is shared across each constructed //! chainstate to avoid duplicating block metadata. - node::BlockManager m_blockman GUARDED_BY(::cs_main); + node::BlockManager m_blockman; /** * In order to efficiently track invalidity of headers, we keep the set of |