Skip to content

Refactor PDA derivation for User account creation to avoid index-based collisions #1552

@juan-malbeclabs

Description

@juan-malbeclabs

Currently, when creating a User account, the PDA derivation still relies on an incremental index. This approach introduces a potential race condition when multiple users attempt to connect at the same time, since they may try to claim the same index.

Proposed Change

  • Update the PDA derivation method for User accounts so it no longer depends on the index.
  • Ensure uniqueness and determinism by using a combination of stable seeds (e.g., user pubkey, device identifier, or other unique attributes).
  • Validate that the new PDA derivation remains compatible with existing flows and does not break user discovery or account lookups.

Impact

  • Eliminates race conditions during concurrent user creation.
  • Improves reliability and scalability of the User account provisioning flow.
  • Reduces the risk of account conflicts or unintended overwrites.

Next Steps

  • Define the new PDA seed strategy.
  • Implement and update the relevant create_user instruction.
  • Adjust unit tests and e2e tests to cover concurrent account creation scenarios.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions