[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 core#20749 [8/17]
https://github.com/bitcoin/bitcoin/pull/20749/commits/d363d06bf7d6c3736140672ba8a7f82f4d6fb6ab
Depends on D11176