Backports:
v31.1 still has the pre-fix LoadBlockIndex. It re-adds a pruned block to m_blocks_unlinked when its parent is header-only (#35050). When the next block connects, CheckBlockIndex fails with Assertion failed: (!foundInUnlinked). -checkblockindex is on by default only on regtest, so this crashes functional-test suites run against 31.x. With default settings, nodes on mainnet, testnet and signet do not run this check, so they do not crash.
Both commits are clean cherry-picks (-x). The only difference from master is context in test_runner.py. The new feature_prune_stale_fork.py fails on the v31.1 release binary with the assertion above. It passes on this branch, built from depends. Two runs each, on macOS arm64.
Made with my usual tools: a computer, the Internet and an LLM. The mistakes, as usual, are all mine.