The function has several code and logic bugs, which prevent it from working at all:
vpindexToConnect.back()
is passed toCheckForkWarningConditionsOnNewFork
, which is the earliest connected block (least work block), not the new fork tipActivateBestChainStep
will never try to connect a block that descends from an invalid block, so the invalid fork will only ever be of height 1, never hitting the 7 block minimum condition
Instead of dragging the dead and wrong code around through every change in validation, remove it. In the future it could make sense to add a fork detection somewhere outside of the ActivateBestChainStep
logic (maybe net_processing).