Add compile time checking for cs_wallet runtime locking assertions.
This PR is a subset of #12665. The PR was broken up to make reviewing easier.
The intention is that literally all EXCLUSIVE_LOCKS_REQUIRED/LOCKS_EXCLUDED:s added in this PR should follow either directly or indirectly from AssertLockHeld(…)/AssertLockNotHeld(…):s already existing in the repo.
Consider the case where function A(…) contains AssertLockHeld(cs_foo) (without
first locking cs_foo in A), and that B(…) calls A(…) (without first locking cs_main):
- It directly follows that:
A(…)should have anEXCLUSIVE_LOCKS_REQUIRED(cs_foo)annotation. - It indirectly follows that:
B(…)should have anEXCLUSIVE_LOCKS_REQUIRED(cs_foo)annotation.