Skip to content

chore: Force-sync all indices in sync_anchor_indices#3659

Merged
aterga merged 12 commits intomainfrom
arshavir/force-sync-all-indices
Mar 13, 2026
Merged

chore: Force-sync all indices in sync_anchor_indices#3659
aterga merged 12 commits intomainfrom
arshavir/force-sync-all-indices

Conversation

@aterga
Copy link
Collaborator

@aterga aterga commented Mar 10, 2026

Motivation

Indices computed based on pre-existing data cannot be synched for existing anchors simply by reading and then writing the anchor memory. Instead, the previous state of each index to be force-updated should be empty. In particular, this enables correctly populating the new lookup_anchor_with_passkey_pubkey_hash_memory index.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the anchor index migration logic so that indices can be (re)built for already-existing anchors by treating the “previous index state” as empty rather than relying on a read→write roundtrip.

Changes:

  • Add Storage::force_sync_all_indices() to rebuild all anchor-derived indices from the stored StorableAnchor using empty “previous” data.
  • Update sync_anchor_indices migration to call force_sync_all_indices instead of read+write.
  • Extend migration tests to simulate empty indices and verify passkey pubkey-hash indexing across single- and multi-batch runs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/internet_identity/src/storage.rs Introduces force_sync_all_indices() to rebuild indices for an existing StorableAnchor without rewriting the anchor.
src/internet_identity/src/migrations/sync_anchor_indices.rs Switches the migration to force-sync indices and adds assertions for the new passkey pubkey-hash index behavior in tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@sea-snake sea-snake left a comment

Choose a reason for hiding this comment

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

LGTM

@aterga aterga force-pushed the arshavir/force-sync-all-indices branch from e841c2b to 54e294d Compare March 12, 2026 17:04
@aterga aterga marked this pull request as ready for review March 13, 2026 11:12
@aterga aterga requested a review from Copilot March 13, 2026 14:02
@aterga aterga added this pull request to the merge queue Mar 13, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +712 to +716
/// Force-sync the passkey pubkey index for an anchor by reading its current `StorableAnchor`
/// and syncing indices with empty previous data. This is intended for data migrations
/// where the `StorableAnchor` already exists in `stable_anchor_memory` but the index
/// was not yet populated.
pub(crate) fn force_sync_all_indices(
Comment on lines +87 to +88
// force-sync its indices with empty previous data so that all current entries
// get added to the indices (even if the StorableAnchor already existed).
/// * version 1-8: no longer supported
/// * version 9: 4KB anchors, candid anchor record layout, persistent state in virtual memory,
/// with memory manager (from 2nd page on), archive entries buffer in stable memory
/// * version 10: passkey pubkey hash index key type changed from [u8; 32] to Principal
Merged via the queue into main with commit 1046bf8 Mar 13, 2026
68 checks passed
@aterga aterga deleted the arshavir/force-sync-all-indices branch March 13, 2026 14:22
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