In the first phase of DLP v2, implement the following ix:
delegate
commit
finalize
undelegate
call_handler
performance tips
-
validations:
- avoid
find_program_address; pass bumps.
- avoid
create_program_address if possible; consider using derive_address instead.
- minimize key comparisons.
- fail early, cheap checks first.
-
memory & data:
- avoid heap allocation; use zero-copy aggressively.
- avoid copies as well for bigger types (> 8 bytes).
- avoid wide arithmetic (u128 / U256) in hot path.
- prefer fixed-size account layouts.
- smaller binary: try to reuse code.
-
accounts:
- merge multiple accounts where possible.
- minimize total loaded account data size.
- avoid creating / reallocating accounts in commit/finalize.
- move cold data out of hot-path accounts.
-
PDAs & signers:
- avoid PDA signing unless strictly necessary.
- cache derived PDAs in state when reused.
-
instructions:
- minimize instruction count, especially on commit path.
- avoid CPI in commit/finalize.
- avoid ComputeBudget reliance.
- prefer one large ix instead of many smaller ix.
- commit/finalize must be infinitely boringly simple, even if setup is complex.
- single instruction only.
- no helper instructions.
- no multi-step commit flow.
- no retry logic inside the program.
-
logging:
- zero logs on success
- detailed logs on failure (including ix discriminator)
-
build strategy:
- feature-gate debug / validation logic
- avoid abstractions that prevent inlining in hot path
In the first phase of
DLP v2, implement the following ix:delegatecommitfinalizeundelegatecall_handlerperformance tips
validations:
find_program_address; pass bumps.create_program_addressif possible; consider usingderive_addressinstead.memory & data:
accounts:
PDAs & signers:
instructions:
logging:
build strategy: