onflow / atree

Atree provides scalable arrays and scalable ordered maps.
https://onflow.org
Apache License 2.0
39 stars 13 forks source link

Add feature to enable migrations to fix references to non-existent registers #387

Closed fxamacker closed 2 months ago

fxamacker commented 2 months ago

Updates #386

Problem

In testnet, broken references seem to have resulted from a bug that was fixed 2 years ago by https://github.com/onflow/cadence/pull/1565.

A broken reference is a StorageID referencing a non-existent register. So far, only 10 registers in testnet (none on mainnet) were found to contain broken references.

Solution

This PR adds a feature to enable migration programs in onflow/flow-go to fix broken references in maps.

FixLoadedBrokenReferences() traverses loaded slabs and replaces broken map (if any) with empty map having the same StorageID and also removes all slabs in the old map.

Limitations:

IMPORTANT: This should not be used to silently fix unknown problems. It should only be used by migration programs to fix known problems which were determined to be appropriate to fix in this manner.

TODO:

codecov-commenter commented 2 months ago

Codecov Report

Attention: Patch coverage is 75.15924% with 39 lines in your changes are missing coverage. Please review.

Project coverage is 66.48%. Comparing base (dc825c2) to head (d5cb164).

:exclamation: Current head d5cb164 differs from pull request most recent head a887780. Consider uploading reports for the commit a887780 to get more accurate results

Files Patch % Lines
storage.go 75.15% 27 Missing and 12 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## feature/stable-cadence #387 +/- ## ========================================================== + Coverage 66.09% 66.48% +0.38% ========================================================== Files 14 14 Lines 8233 8390 +157 ========================================================== + Hits 5442 5578 +136 - Misses 2113 2124 +11 - Partials 678 688 +10 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.