Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 13 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ pub mod v1 {
pub mod v3 {
solana_pubkey::declare_id!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Man, it's too bad we didn't get Memo3 for this one 😁

}

/// Symbols from Memo version 4
pub mod v4 {
solana_pubkey::declare_id!("Memo4c2pN8afCj432Lb7RMVKi9PbQnnW7ewFFaV3oAH");
}
6 changes: 3 additions & 3 deletions pinocchio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ publish = false
crate-type = ["cdylib"]

[package.metadata.solana]
program-id = "PMemo11111111111111111111111111111111111111"
program-id = "Memo4c2pN8afCj432Lb7RMVKi9PbQnnW7ewFFaV3oAH"

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ['cfg(target_os, values("solana"))']

[dependencies]
pinocchio = "0.11"
solana-program-log = "1.1"
pinocchio = { version = "0.11", default-features = false }
solana-program-log = "1.2"

[dev-dependencies]
mollusk-svm = "0.12"
Expand Down
16 changes: 8 additions & 8 deletions pinocchio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ A `pinocchio`-based Memo program.

## Overview

`p-memo` is a reimplementation of the SPL Memo program using [`pinocchio`](https://github.com/anza-xyz/pinocchio). The program uses at most `~4%` of the compute units used by the current Memo program when signers are present; even when there are no signers, it needs only `~15%` of the current Memo program compute units. This efficiency is achieved by a combination of:
`p-memo` is a reimplementation of the SPL Memo program using [`pinocchio`](https://github.com/anza-xyz/pinocchio). The program uses at most `~4%` of the compute units used by the current Memo program when signers are present; even when there are no signers, it needs only `~14%` of the current Memo program compute units. This efficiency is achieved by a combination of:
1. `pinocchio` "lazy" entrypoint
2. `sol_log_pubkey` syscall to log pubkey values
3. [`solana-program-log`](https://crates.io/crates/solana-program-log) to format the memo message

Since it uses the syscall to log pubkeys, the output of the program is slightly different while loging the same information:
```
1: Program PMemo11111111111111111111111111111111111111 invoke [1]
1: Program Memo4c2pN8afCj432Lb7RMVKi9PbQnnW7ewFFaV3oAH invoke [1]
2: Program log: Signed by:
3: Program log: 1111111QLbz7JHiBTspS962RLKV8GndWFwiEaqKM
4: Program log: Memo (len 60):
5: Program log: why does spl memo use 36000 cus to print len 60 msg of ascii
6: Program PMemo11111111111111111111111111111111111111 consumed 537 of 1400000 compute units
7: Program PMemo11111111111111111111111111111111111111 success
6: Program Memo4c2pN8afCj432Lb7RMVKi9PbQnnW7ewFFaV3oAH consumed 537 of 1400000 compute units
7: Program Memo4c2pN8afCj432Lb7RMVKi9PbQnnW7ewFFaV3oAH success
```

Logging begins with entry into the program (`line 1`). Then there is a separate log to start the signers section (`line 2`); this is only present if there are signer accounts. After that there will be one line for each signer account (`line 3`), followed by the memo length and UTF-8 text (`line 4-5`). The program ends with the status of the instruction (`lines 6-7`).
Expand All @@ -28,10 +28,10 @@ CU comsumption:

| \# signers | p-memo | SPL Memo |
| ---------- | ----------- | --------- |
| 0 | 313 (`15%`) | 2,022 |
| 1 | 537 (`4%`) | 13,525 |
| 2 | 654 (`3%`) | 25,111 |
| 3 | 771 (`2%`) | 36,406 |
| 0 | 287 (`14%`) | 2,022 |
| 1 | 513 (`4%`) | 13,525 |
| 2 | 628 (`3%`) | 25,111 |
| 3 | 743 (`2%`) | 36,406 |

> [!NOTE]
> Using Solana CLI `v2.2.15`.
Expand Down
12 changes: 7 additions & 5 deletions pinocchio/src/entrypoint.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use pinocchio::{
entrypoint::{InstructionContext, MaybeAccount},
error::ProgramError,
ProgramResult,
use {
pinocchio::{
entrypoint::{InstructionContext, MaybeAccount},
error::ProgramError,
ProgramResult,
},
solana_program_log::log,
};
use solana_program_log::log;

/// Process a memo instruction.
///
Expand Down
9 changes: 5 additions & 4 deletions pinocchio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@

#![no_std]

mod entrypoint;

use pinocchio::{lazy_program_entrypoint, no_allocator, nostd_panic_handler};
use {
crate::entrypoint::process_instruction,
pinocchio::{lazy_program_entrypoint, no_allocator, nostd_panic_handler},
};

use crate::entrypoint::process_instruction;
mod entrypoint;

// Process the input lazily.
lazy_program_entrypoint!(process_instruction);
Expand Down
2 changes: 1 addition & 1 deletion pinocchio/tests/memo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use solana_program_error::ProgramError;
use solana_pubkey::Pubkey;

/// Program ID for the p-memo program.
const PROGRAM_ID: Pubkey = Pubkey::from_str_const("PMemo11111111111111111111111111111111111111");
const PROGRAM_ID: Pubkey = Pubkey::from_str_const("Memo4c2pN8afCj432Lb7RMVKi9PbQnnW7ewFFaV3oAH");

/// The memo to be printed.
const MEMO: &str = "why does spl memo use 36000 cus to print len 60 msg of ascii";
Expand Down
Loading