Skip to content

Conversation

@aterga
Copy link
Contributor

@aterga aterga commented Dec 1, 2025

Motivation

This PR proposes a new storage model for anchors, extending the existing StorableAnchor type with fields to cover all data stored in StorableFixedAnchor. The idea is to eventually migrate all anchor data to StorableAnchor and obsolete StorableFixedAnchor, which limits the data per anchor to 4 KB.

Changes

  • Add optional fields to StableAnchor to represent data that is currently stored in StableFixedAnchor.
  • Extend From<Anchor> for (StableAnchor, StableFixedAnchor) to populate the new fields.

Tests

13 unit tests in from_conversion_tests module covering From<Anchor> for (StorableFixedAnchor, StorableAnchor) conversion:

Passkey Credentials

  • should_convert_passkey_credentials_with_authentication_purpose - Authentication passkeys → StorablePasskeyCredential with field mapping
  • should_convert_passkey_credentials_with_recovery_purpose - Recovery passkeys → added to passkey list at the end
  • should_convert_mixed_device_types - Mixed device types → proper ordering and separation

Recovery Keys

  • should_convert_recovery_keys_from_seed_phrase - Seed phrases → StorableRecoveryKey (excluded from passkey list)
  • should_convert_protected_recovery_key - Protected recovery keys → is_protected: Some(true)

Edge Cases

  • should_handle_empty_alias - Empty aliases → None instead of Some("")
  • should_use_default_origin_for_passkeys_without_origin - Missing origin → defaults to "https://identity.ic0.app"
  • should_handle_devices_without_credential_id - Devices without credential_id → excluded from both lists

Preservation

  • should_preserve_fixed_anchor_fields - StorableFixedAnchor → preserves devices, metadata, created_at
  • should_set_name_and_created_at_in_storable_anchor - StorableAnchor → name and created_at_ns set correctly
  • should_convert_openid_credentials - OpenID credentials → preserved during conversion

Empty State

  • should_handle_anchor_with_no_devices - Empty anchor → empty vectors

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 extends the StorableAnchor type to become a structural super-type of StorableFixedAnchor by adding fields that cover all anchor data. This is part of a migration strategy to eventually obsolete StorableFixedAnchor, which has a 4 KB data limit per anchor.

Key changes:

  • Added new structs StorablePasskeyCredential and StorableRecoveryKey to represent device credentials in the extended storage model
  • Extended StorableAnchor with new fields: created_at_ns, passkey_credentials, and recovery_phrases
  • Updated the From<Anchor> implementation to populate the new fields by converting device data into the new storage structures

Reviewed changes

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

File Description
src/internet_identity/src/storage/storable/anchor.rs Defines two new structs (StorablePasskeyCredential, StorableRecoveryKey) and adds three new fields to StorableAnchor
src/internet_identity/src/storage/anchor.rs Updates conversion logic to populate the new StorableAnchor fields from Anchor devices
src/internet_identity/src/storage.rs Fixes typo in error message from "StableAnchor" to "StorableAnchor"
src/internet_identity/src/main.rs Updates comment with a spelling correction

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

@aterga aterga requested a review from sea-snake December 1, 2025 15:01
@aterga aterga marked this pull request as ready for review December 1, 2025 22:11
…rsion

- Add 13 tests covering passkey credentials, recovery keys, and conversion edge cases
- Test authentication vs recovery purpose passkey handling
- Test protected/unprotected recovery key conversion
- Test empty alias and missing origin default values
- Test proper ordering (recovery passkeys appear at end of list)
- Test devices without credential_id exclusion
- Test OpenID credentials and fixed anchor field preservation
- Remove redundant AAGUID test per code review
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 8 out of 8 changed files in this pull request and generated 1 comment.


💡 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

As discussed, special edge case (purpose auth without credential id) will be handled differently in follow up PR.

@aterga aterga enabled auto-merge December 2, 2025 10:39
@aterga aterga added this pull request to the merge queue Dec 2, 2025
Merged via the queue into main with commit 6686b70 Dec 2, 2025
126 of 132 checks passed
@aterga aterga deleted the arshavir/anchor-migration branch December 2, 2025 10:50
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.

2 participants