SCORU/Node: GC for stores
Context
This MR implements an asynchronous garbage collection function in the stores modules (both for stores which consist of a simple index, and for stores which consist of a data file and an indexed, i.e. indexed files).
The GC is implemented following the same philosophy used in the L1 node. Each store is splitted in two (or more) internal stores: one "fresh" for new elements added to the store, and one (or multiple) "stale" for elements that were added before and that could be GCed.
flowchart LR
stale1 --- fresh
classDef default stroke:#333,stroke-width:2
style stale1 fill:#aabb88,color:white
style fresh fill:#22ff77
When a GC starts, a new fresh store is created and the previous fresh store becomes stale. This allows to continue to add elements to the store while the GC executes in the background. A temporary store is also created to perform the actual GC.
flowchart LR
stale1 --- stale2 --- new_fresh
tmp
classDef default stroke:#333,stroke-width:2
style stale1 fill:#aabb88,color:white
style new_fresh fill:#bbccaa,color:white
style stale2 fill:#22ff77
style new_fresh fill:#ff2277
style tmp fill:#ccccff
At the end of the GC, the temporary store becomes the new stale and the new fresh store remains.
flowchart LR
stale1 --- new_fresh
classDef default stroke:#333,stroke-width:2
style new_fresh fill:#ff2277,color:white
style stale1 fill:#ccccff
Manually testing the MR
dune exec src/lib_layer2_store/test/main.exe -- --file test_indexed_store.ml