Skip to content

Conversation

@raushan728
Copy link

Overview

This PR optimizes the pinocchio implementation of the Memo program, reducing the base execution cost to 283 CU while enhancing memory safety and aligning behavior with the standard SPL Memo program.

Performance & Optimization

  • CU Reduction: Optimized the base case (0 signers) from 313 CU to 283 CU (~9.6% reduction).
  • Syscall Efficiency: Replaced pinocchio_log::log! with direct sol_log_ syscalls and removed redundant length logging to minimize compute unit consumption.

Safety & Correctness

  • Safe Data Access: Replaced instruction_data_unchecked() with instruction_data()? to ensure all accounts are consumed before accessing data.
  • Error Alignment: Added explicit UTF-8 validation to return InvalidInstructionData, ensuring consistent error semantics with the standard SPL Memo implementation.
  • Edge Case Handling: Verified and tested support for zero-length memos and maximum MTU-sized (1232-byte) memos.

Developer Experience

  • Added missing pnpm scripts (build, test, lint) to package.json to match project documentation.

Verification

  • Tests: 10/10 functional tests passing in pinocchio/tests/memo.rs.
  • Metrics:
    • Base: 283 CU
    • Empty Memo: 139 CU
    • Max Size (1232b): 1985 CU
  • Lints: cargo clippy is clean with zero warnings.

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.

1 participant