From 38e5a7e4841effa4233bde2fd5e59f1ef98f1434 Mon Sep 17 00:00:00 2001 From: febo Date: Sat, 13 Sep 2025 15:06:50 +0100 Subject: [PATCH 1/2] Bump pinocchio version --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aaf232da..db8e89d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3037,9 +3037,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pinocchio" -version = "0.9.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5123fe61ac87a327d434d530eaddaaf65069a37e33e5c9f798feaed29e4974c8" +checksum = "5b971851087bc3699b001954ad02389d50c41405ece3548cbcafc88b3e20017a" [[package]] name = "pinocchio-log" diff --git a/Cargo.toml b/Cargo.toml index bff59acb..d8145b0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ consolidate-commits = false mollusk-svm = "0.4.0" mollusk-svm-fuzz-fixture = "0.4.0" num-traits = "0.2" -pinocchio = "0.9" +pinocchio = "0.9.2" solana-instruction = "2.3.0" solana-program-error = "2.2.2" solana-program-option = "2.2.1" From 6877bf159760cf208bb93c65cb433407709e91b4 Mon Sep 17 00:00:00 2001 From: febo Date: Sat, 13 Sep 2025 15:09:51 +0100 Subject: [PATCH 2/2] Use compiler hints from pinocchio --- p-interface/src/lib.rs | 32 ------------------------ p-interface/src/state/account.rs | 3 +-- p-token/src/processor/mod.rs | 3 +-- p-token/src/processor/shared/transfer.rs | 5 ++-- 4 files changed, 5 insertions(+), 38 deletions(-) diff --git a/p-interface/src/lib.rs b/p-interface/src/lib.rs index ab8c3ecb..f07b0df5 100644 --- a/p-interface/src/lib.rs +++ b/p-interface/src/lib.rs @@ -8,35 +8,3 @@ pub mod state; pub mod program { pinocchio_pubkey::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"); } - -/// A "dummy" function with a hint to the compiler that it is unlikely to be -/// called. -/// -/// This function is used as a hint to the compiler to optimize other code paths -/// instead of the one where the function is used. -#[cold] -pub const fn cold_path() {} - -/// Return the given `bool` value with a hint to the compiler that `true` is the -/// likely case. -#[inline(always)] -pub const fn likely(b: bool) -> bool { - if b { - true - } else { - cold_path(); - false - } -} - -/// Return a given `bool` value with a hint to the compiler that `false` is the -/// likely case. -#[inline(always)] -pub const fn unlikely(b: bool) -> bool { - if b { - cold_path(); - true - } else { - false - } -} diff --git a/p-interface/src/state/account.rs b/p-interface/src/state/account.rs index a9ade92a..6647d25c 100644 --- a/p-interface/src/state/account.rs +++ b/p-interface/src/state/account.rs @@ -1,7 +1,6 @@ use { super::{account_state::AccountState, COption, Initializable, Transmutable}, - crate::likely, - pinocchio::{program_error::ProgramError, pubkey::Pubkey}, + pinocchio::{hint::likely, program_error::ProgramError, pubkey::Pubkey}, }; /// Incinerator address. diff --git a/p-token/src/processor/mod.rs b/p-token/src/processor/mod.rs index 155e329f..7e8ea476 100644 --- a/p-token/src/processor/mod.rs +++ b/p-token/src/processor/mod.rs @@ -1,7 +1,7 @@ use { core::{slice::from_raw_parts, str::from_utf8_unchecked}, pinocchio::{ - account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey, + account_info::AccountInfo, hint::unlikely, program_error::ProgramError, pubkey::Pubkey, syscalls::sol_memcpy_, ProgramResult, }, pinocchio_token_interface::{ @@ -12,7 +12,6 @@ use { multisig::{Multisig, MAX_SIGNERS}, Transmutable, }, - unlikely, }, }; diff --git a/p-token/src/processor/shared/transfer.rs b/p-token/src/processor/shared/transfer.rs index 13351e06..c637989a 100644 --- a/p-token/src/processor/shared/transfer.rs +++ b/p-token/src/processor/shared/transfer.rs @@ -1,10 +1,11 @@ use { crate::processor::{check_account_owner, validate_owner}, - pinocchio::{account_info::AccountInfo, program_error::ProgramError, ProgramResult}, + pinocchio::{ + account_info::AccountInfo, hint::unlikely, program_error::ProgramError, ProgramResult, + }, pinocchio_token_interface::{ error::TokenError, state::{account::Account, load, load_mut, load_mut_unchecked, mint::Mint}, - unlikely, }, };