Skip to content

feat: DLP v2 #132

@snawaz

Description

@snawaz

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions