[META] This commit should be followed up by removing the comments and assertions meant only to show that the change is correct.
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/20749 | core#20749]] [11/17]
https://github.com/bitcoin/bitcoin/pull/20749/commits/2a696472a1423e877bfa83f016f66c7e45be7369
Depends on D11182