This is a backport of [[https://github.com/bitcoin/bitcoin/pull/19438 | core#19438]]
https://github.com/bitcoin/bitcoin/pull/19438/commits/eccd736f3dc231ac0306ca763c3b72cf8247230a
GetNextBlockScriptFlags did not require to hold cs_main since D4100
Depends on D12218