Skip to content

Make account creation idempotent where necessary - #85

Open
fedgiac wants to merge 1 commit into
mainfrom
pda-creation-idempotent
Open

Make account creation idempotent where necessary#85
fedgiac wants to merge 1 commit into
mainfrom
pda-creation-idempotent

Conversation

@fedgiac

@fedgiac fedgiac commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Closes #37.

Introduce idempotent PDA creation so two parties racing to create the same canonical account don't step on each other's toes, especially when multiple PDAs are created in the same transaction. This happens during an auction when solvers concurrently create the same token buffer, or the same partially-fillable order from a signature.

With these changes, the loser of the race succeeds as a no-op instead of reverting with the system program's AccountAlreadyInUse.

All three creation sites that went through CanonicalPda::create now split into two methods over the same allocation:

  • create_idempotent: this is for order and buffer creation.
  • create_new: this is for state PDA creation.

How to test

New/updated tests in CI.

@fedgiac
fedgiac requested a review from a team as a code owner July 31, 2026 15:11
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.

Make PDA creation idempotent

1 participant