The block number caching is not robust to network failures. When a new block arrives, the block_archive corrects the block number cache in case of reorgs. However, since this correction makes queries, it may fail. In such cases, the cache will be in an inconsistent state.
The solution is making the update_latest_block routine never fail, and handle queries by block number in block_tree differently. We'll probably have to remove the cache and add a loop, walking back through the block_tree data structure until we find what we're looking for (or fall back to requesting it to the provider).