Skip to content

Commit

Permalink
Merge pull request #3231 from onflow/bastian/expose-unreferenced-slab…
Browse files Browse the repository at this point in the history
…s-in-error
  • Loading branch information
turbolent authored Apr 9, 2024
2 parents 7982c28 + b6c976c commit 5d46b4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion migrations/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2747,6 +2747,6 @@ func TestDictionaryKeyConflict(t *testing.T) {
// Health check is expected to fail,
// as one of the arrays is still stored, but no longer referenced
err = storage.CheckHealth()
require.ErrorContains(t, err, "slabs not referenced from account Storage: [0x1.3]")
require.ErrorContains(t, err, "slabs not referenced: [0x1.3]")
})()
}
17 changes: 16 additions & 1 deletion runtime/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package runtime

import (
"fmt"
"runtime"
"sort"

Expand Down Expand Up @@ -347,8 +348,22 @@ func (s *Storage) CheckHealth() error {
return a.Compare(b) < 0
})

return errors.NewUnexpectedError("slabs not referenced from account Storage: %s", unreferencedRootSlabIDs)
return UnreferencedRootSlabsError{
UnreferencedRootSlabIDs: unreferencedRootSlabIDs,
}
}

return nil
}

type UnreferencedRootSlabsError struct {
UnreferencedRootSlabIDs []atree.StorageID
}

var _ errors.InternalError = UnreferencedRootSlabsError{}

func (UnreferencedRootSlabsError) IsInternalError() {}

func (e UnreferencedRootSlabsError) Error() string {
return fmt.Sprintf("slabs not referenced: %s", e.UnreferencedRootSlabIDs)
}

0 comments on commit 5d46b4d

Please sign in to comment.