Skip to content

perf(program): reduce PDA validation compute units#39

Merged
dev-jodee merged 4 commits intomainfrom
perf/optimize-pda-validation-cu
Apr 10, 2026
Merged

perf(program): reduce PDA validation compute units#39
dev-jodee merged 4 commits intomainfrom
perf/optimize-pda-validation-cu

Conversation

@dev-jodee
Copy link
Copy Markdown
Collaborator

Summary

  • Replace find_program_address in validate_pda with create_program_address — avoids re-searching for the canonical bump when it is already provided in instruction data
  • Override validate_self in Escrow, Receipt, AllowedMint, and EscrowExtensions to use derive_address with the stored bump — skips the off-curve check that is unnecessary for accounts already validated at creation
  • Optimize validate_extensions_pda fast path: uses stored bump + derive_address when extensions account exists, falls back to find_program_address only when account is uninitialized
  • Add 2-step admin transfer as item fix: replace dangerous txtx install instructions with official docs #6 in docs/IMPROVEMENTS.md

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.
@dev-jodee dev-jodee force-pushed the perf/optimize-pda-validation-cu branch from b63b66f to 5b465d9 Compare April 7, 2026 17:19
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.
@dev-jodee dev-jodee requested a review from amilz April 7, 2026 17:46
amilz
amilz previously approved these changes 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).
@dev-jodee dev-jodee merged commit 924eb69 into main Apr 10, 2026
6 checks passed
@dev-jodee dev-jodee deleted the perf/optimize-pda-validation-cu branch April 10, 2026 16:41
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