HomePhabricator

protect g_chainman with cs_main

Description

protect g_chainman with cs_main

Summary:

I'd previously attempted to create a specialized lock for
ChainstateManager, but it turns out that because that lock would be
required for functions like ChainActive() and ChainstateActive(), it
created irreconcilable lock inversions since those functions are used so
broadly throughout the codebase.

Instead, I'm just using cs_main to protect the contents of g_chainman.

Completes backport (5/5) of core PR17737:
https://github.com/bitcoin/bitcoin/pull/17737/commits/c9017ce3bc27665594c9d80f395780d40755bb22

The lock change in wallet_tests.cpp is not needed due to out of order
backports.

Depends on D8540.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D8541

Details

Provenance
James O'Beirne <james.obeirne@pm.me>Authored on Jan 29 2020, 14:57
FabienCommitted on Nov 30 2020, 08:06
FabienPushed on Nov 30 2020, 08:07
Reviewer
Restricted Project
Differential Revision
D8541: protect g_chainman with cs_main
Parents
rABCfc121f25336b: test: add basic tests for ChainstateManager
Branches
Unknown
Tags
Unknown