Properly lock cs_main in rest_block
Merge pull request #5301