---
# System prepended metadata

title: Untitled

---

Today:

LmdbGlobalState
    |
    \-> ScratchGlobalState
        |
        \-> Execution
            |
            \-> `put_stored_values(stored_values)`
                \-> ScratchTrieStore
                    \-> write -> cache
                \-> `write_root_to_lmdb`

               
Tomorrow (completely zero downtime):

Zero downtime:
    - DbGlobalState migration (background) to RocksDb & Working Set 
      - Done simultaneously - every time the RocksDb migration hits a leaf it writes it to the Working Set

DbGlobalState
- ScratchGlobalState
- Execution effects => `HashMap<Key, StoredValue>`
- Make a copy of `HashMap<Key, StoredValue>` and enqueue for Working Set (migration complete and queue is empty)
- Write `HashMap<Key, StoredValue>` to ScratchTrieStore => `HashMap<Digest, Trie<Key, StoredValue>>`
  - As we construct ScratchTrieStore we ultimately get a `(root, HashMap<Digest, Trie<Key, StoredValue>>)`
    - If RocksDb migration is complete and RocksDbTrieStore queue is empty, use RocksDbTrieStore otherwise use LMDB for ScratchTrieStore
    - Run in parallel
        - Enqueue copy of `(root, HashMap<Digest, Trie<Key, StoredValue>>)` for RocksdbTrieStore if we havent switched
        - Create block and send to LinearChain
        - write `HashMap<Digest, Trie<Key, StoredValue>>` to LmdbTrieStore
           

                
Tomorrow, but we keep migration pause at upgrade:
- If we are not at upgrade, use fast sync to create Working Set

- If we are at upgrade (8min upgrade)
  - Run the migration code we have, writing leaves to working set as we go

