Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate principal and origin information in IndexedDB storage #2578

Merged
merged 4 commits into from
Aug 29, 2024

Conversation

frederikrothenberger
Copy link
Contributor

@frederikrothenberger frederikrothenberger commented Aug 29, 2024

This PR introduces the storage layout v4 which keeps separate digests for principals and origins. That way it will be possible in the future to determine whether a specific principal was last derived for a particular origin.

This PR introduces the storage layout v4 which keeps separate digests
for principals and origins. That way it will be possible in the future
to determine whether a specific principal was last derived for a particular
origin.
Copy link
Collaborator

@lmuntaner lmuntaner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just minor comments

src/frontend/src/storage/index.test.ts Outdated Show resolved Hide resolved
src/frontend/src/storage/index.test.ts Outdated Show resolved Hide resolved
expect(storageV4).toBeTypeOf("object");
expect(storageV4.anchors["10000"]).toBeDefined();
expect(storageV4.anchors["10001"]).toBeDefined();
expect(storageV4.anchors["10003"]).toBeDefined();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also check here that getAnchorByPrincipal works as expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, known principals are not migrated. They cant be migrated, because the digest scheme has changed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using getAnchorByPrincipal on 10003 won't work in this scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it will return undefined. But the VC flow is currently the only usage of that (and it will be restored after the next login) so the impact for users should be acceptable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, understood. Thanks for the explanation.

@frederikrothenberger frederikrothenberger added this pull request to the merge queue Aug 29, 2024
Merged via the queue into main with commit 4bae280 Aug 29, 2024
66 checks passed
@frederikrothenberger frederikrothenberger deleted the frederik/local-storage-info branch August 29, 2024 13:59
/**
* V4, indexeddb["ii-storage-v4"] = { anchors: { 20000: ... } }
* */
type StorageV4 = z.infer<typeof StorageV4>;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frederikrothenberger Why is there a V3 and a V4?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requirements have changed. The V3 (which was in use since December 2023) no longer stored enough information for the auto-selection for the most recently used principal.

Hence it was changed to V4, which stores the principal and origin digests separately. We still maintain compatibility with old storage layouts to prevent people losing their prepopulated identity numbers.

frederikrothenberger pushed a commit that referenced this pull request Sep 2, 2024
The errors in the comments were introduced in #2578.
github-merge-queue bot pushed a commit that referenced this pull request Sep 2, 2024
The errors in the comments were introduced in #2578.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants