After AssumeUtxo background sync is completed in a ActivateBestChain() call, the GetRole() function called with BlockConnected() returns ChainstateRole::NORMAL instead of ChainstateRole::BACKGROUND for this chainstate.
This would make the wallet (which ignores BlockConnected notifications for the background chainstate) process it, change m_last_block_processed_height to the (ancient) snapshot height, and display an incorrect balance.
Fix this by caching the chainstate role before calling ActivateBestChainStep().
Also contains a test for this situation that fails on master.
Fixes #31546