perf(program): reduce PDA validation compute units#39
Merged
Conversation
Replace find_program_address in validate_pda with create_program_address since the bump is already provided in instruction data. Override validate_self in Escrow, Receipt, AllowedMint, and EscrowExtensions to use derive_address with the stored bump, avoiding the off-curve check that is unnecessary for accounts validated at creation. Also documents 2-step admin transfer as a future improvement.
b63b66f to
5b465d9
Compare
Restore canonical bump enforcement for instruction-provided PDA bumps while preserving a fast path for trusted stored bumps. Add integration regressions that verify noncanonical-but-valid PDA addresses are rejected for escrow, allowed mint, receipt, and extensions initialization flows.
amilz
previously approved these changes
Apr 9, 2026
amilz
reviewed
Apr 9, 2026
amilz
reviewed
Apr 9, 2026
No concrete type called this — all override `validate_self` with `Address::derive_address` directly. Default `validate_self` now falls back to `validate_pda` (canonical bump enforcement).
amilz
approved these changes
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
find_program_addressinvalidate_pdawithcreate_program_address— avoids re-searching for the canonical bump when it is already provided in instruction datavalidate_selfinEscrow,Receipt,AllowedMint, andEscrowExtensionsto usederive_addresswith the stored bump — skips the off-curve check that is unnecessary for accounts already validated at creationvalidate_extensions_pdafast path: uses stored bump +derive_addresswhen extensions account exists, falls back tofind_program_addressonly when account is uninitializeddocs/IMPROVEMENTS.md