Files
bitcoin/src
MarcoFalke 1f45e85509 Merge #20972: locks: Annotate CTxMemPool::check to require cs_main
b396467053 locks: Annotate CTxMemPool::check to require cs_main (Carl Dong)

Pull request description:

  ```
  Currently, CTxMemPool::check locks CTxMemPool's own cs member, then
  calls GetSpendHeight which locks cs_main. This can potentially cause an
  undesirable lock invesion since CTxMemPool's cs is supposed to be locked
  after cs_main.

  This does not cause us any problems right now because all callers of
  CTxMemPool already lock cs_main before calling CTxMemPool::check, which
  means that the LOCK(cs_main) in GetSpendHeight becomes benign.

  However, it is currently possible for new code to be added which calls
  CTxMemPool::check without locking cs_main (which would be dangerous).
  Therefore we should make it explicit that cs_main needs to be held
  before calling CTxMemPool::check.

  NOTE: After all review-only assertions are removed in "#20158 |
        tree-wide: De-globalize ChainstateManager", and assuming that we
        keep the changes in "validation: Pass in spendheight to
        CTxMemPool::check", we can re-evaluate to see if this annotation
        is still necessary.
  ```
  -----

  Previous discussions:
  1. https://github.com/bitcoin/bitcoin/pull/20158#discussion_r520639845
  2. https://github.com/bitcoin/bitcoin/pull/20158#pullrequestreview-557117202
  3. https://github.com/bitcoin/bitcoin/pull/20749#discussion_r559425521

ACKs for top commit:
  jnewbery:
    Code review ACK b396467053
  MarcoFalke:
    ACK b396467053
  jonatack:
    ACK b396467053 review and debug built, verified that `cs_main` is held by callers of `CTxMemPool::check()` in `PeerManagerImpl::ProcessOrphanTx()`, `PeerManagerImpl::ProcessMessage()`, and `CChainState::ActivateBestChainStep()`

Tree-SHA512: 4635cddb4aa1af9532bb657b2f9c4deec4568d16ba28c574eae91bb77368cd40e23c3c720a9de11cec78e7ad678a44a5e25af67f13214b86b56e777e0c35a026
2021-01-21 16:45:45 +01:00
..
2020-12-08 19:26:30 +01:00
2021-01-07 18:07:09 +02:00
2020-11-19 15:48:24 +01:00
2021-01-18 22:09:05 +01:00
2020-12-31 09:45:41 +01:00
2020-12-31 09:45:41 +01:00
2020-12-31 09:45:41 +01:00
2020-12-31 09:45:41 +01:00
2020-08-27 20:07:27 -04:00
2020-11-10 14:33:37 -05:00
2020-12-31 09:45:41 +01:00
2021-01-04 12:31:31 +08:00
2021-01-04 12:31:31 +08:00
2020-12-31 09:45:41 +01:00
2021-01-04 12:23:16 +08:00
2020-12-31 09:45:41 +01:00
2020-11-23 21:02:54 +00:00
2021-01-04 12:23:16 +08:00
2021-01-07 18:07:09 +02:00
2021-01-07 18:07:09 +02:00
2021-01-04 12:31:31 +08:00
2020-12-31 09:45:41 +01:00
2020-12-31 09:45:41 +01:00
2020-12-31 09:45:41 +01:00
2020-12-31 09:45:41 +01:00
2020-06-21 06:02:59 -04:00
2020-06-21 06:02:59 -04:00
2020-12-10 20:46:29 +02:00
2020-07-01 14:44:24 -04:00
2020-10-12 12:14:53 -07:00