This adds snapshot and restore methods to state and uses the snapshot
one to save a copy of the state when shutting down. Right now, this is
not used for anything else.
Some lines performing a migration, but this is only an idea of how it could
work.
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>