You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: fix graph copy stab/destab for multi-migration and dedup table (#5993)
The graph copy stabilization/destabilization algorithm basically does a
BFS walk to first serialize the heap to stable memory, then after an
upgrade a deserialization bringing back up the heap from stable memory.
This BFS was initially designed to just start the BFS walk out of the
stable actor record.
However, later additions to the enhanced OP incremental GC added 2
GC-only roots: the `blob deduplication table` and the `migration
functions list`. Without proper handling of the
serialization/deserialization, these objects would be lost and the new
actor version would work erroneously.
This PR modifies the BFS algorithm to add the two objects as roots in
the serialization/deserialization graph copy algorithm such that they
are first saved properly to stable memory and then restored correctly
into the heap. Other future GC roots can be treated similary.
To verify the functionality works correctly, two tests were modified to
trigger this behavior and check if the new upgraded actor works
correctly.
**Attention point:**
This PR also fixes a corner-case. For enhanced multi-migration, which
migration function (in the chain) is matched against the old actor type
is only determined at runtime (see `desugar.ml`), depending on which
migration function in the chain it's been brought at previously. The old
code in `compile_enhanced.ml` was performing compatibility checks
against the new actor `.pre`, which can be wrong for multi-migration in
case there might be multiple steps missing. Originally, the code made a
check against old actor and new actor `.pre` types early in the `start
destabilization` code path. This cannot work with the new migration.
The solution is to restore into `metadata` the old actor type from
stable memory and let the checks happen at `ICStableRead` time (via
`register_stable_type`, see `compile_enhanced.ml`). Previously, this
metadata was wiped and `ICStableRead` was not performing any checks,
just recovering the actor.
This way, the checks happen correctly at runtime for both enhanced
multi-migration and regular migration (or upgrade).
---------
Co-authored-by: Claudio Russo <claudio@dfinity.org>
0 commit comments