Introduce a constructor parameter for the StateDB called `keep`, which tells how many checkpoints to keep. When doing a new checkpoint, if the number of existing checkpoints exeeds `keep`, the oldest ones will be deleted.