From 7308075b8a0e1002e0a76e5f712030fa4494be8d Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Fri, 6 Nov 2026 22:16:40 +0000 Subject: [PATCH] fix(compressed-account): make light-program-profiler optional for no_std (#2394) --- program-libs/compressed-account/Cargo.toml | 6 +++--- .../compressed-account/src/instruction_data/traits.rs | 5 +++-- .../src/instruction_data/zero_copy_set.rs | 9 +++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/program-libs/compressed-account/Cargo.toml b/program-libs/compressed-account/Cargo.toml index 71aea6164b..52551867be 100644 --- a/program-libs/compressed-account/Cargo.toml +++ b/program-libs/compressed-account/Cargo.toml @@ -17,8 +17,8 @@ idl-build = ["anchor-lang/idl-build", "anchor"] pinocchio = ["dep:pinocchio"] bytemuck-des = ["bytemuck"] new-unique = ["dep:solana-pubkey"] -profile-program = [] -profile-heap = ["dep:light-heap"] +profile-program = ["dep:light-program-profiler", "light-program-profiler/profile-program"] +profile-heap = ["dep:light-heap", "dep:light-program-profiler", "light-program-profiler/profile-heap"] poseidon = ["dep:light-poseidon", "light-hasher/poseidon"] keccak = ["light-hasher/keccak"] sha256 = ["light-hasher/sha256"] @@ -38,7 +38,7 @@ anchor-lang = { workspace = true, optional = true } bytemuck = { workspace = true, optional = true, features = ["derive"] } borsh = { workspace = true, default-features = false } solana-pubkey = { workspace = true, optional = true } -light-program-profiler = { workspace = true } +light-program-profiler = { workspace = true, optional = true } light-heap = { workspace = true, optional = true } tinyvec = { workspace = true } diff --git a/program-libs/compressed-account/src/instruction_data/traits.rs b/program-libs/compressed-account/src/instruction_data/traits.rs index ab6e718554..f18854492c 100644 --- a/program-libs/compressed-account/src/instruction_data/traits.rs +++ b/program-libs/compressed-account/src/instruction_data/traits.rs @@ -5,6 +5,7 @@ use anchor_lang::AnchorSerialize; #[allow(unused_imports)] #[cfg(not(all(feature = "std", feature = "anchor")))] use borsh::BorshSerialize as AnchorSerialize; +#[cfg(feature = "profile-program")] use light_program_profiler::profile; use tinyvec::ArrayVec; use zerocopy::Ref; @@ -22,7 +23,7 @@ pub trait InstructionDiscriminator { pub trait LightInstructionData: InstructionDiscriminator + AnchorSerialize { #[cfg(feature = "alloc")] - #[profile] + #[cfg_attr(feature = "profile-program", profile)] #[inline(never)] fn data(&self) -> Result, CompressedAccountError> { let inputs = AnchorSerialize::try_to_vec(self) @@ -34,7 +35,7 @@ pub trait LightInstructionData: InstructionDiscriminator + AnchorSerialize { Ok(data) } - #[profile] + #[cfg_attr(feature = "profile-program", profile)] fn data_array(&self) -> Result, CompressedAccountError> { let mut data = ArrayVec::new(); // Add discriminator diff --git a/program-libs/compressed-account/src/instruction_data/zero_copy_set.rs b/program-libs/compressed-account/src/instruction_data/zero_copy_set.rs index 8f7ebc6ddc..99867c0621 100644 --- a/program-libs/compressed-account/src/instruction_data/zero_copy_set.rs +++ b/program-libs/compressed-account/src/instruction_data/zero_copy_set.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "profile-program")] use light_program_profiler::profile; use light_zero_copy::traits::ZeroCopyAt; use zerocopy::little_endian::U16; @@ -13,7 +14,7 @@ use crate::{ }; impl ZOutputCompressedAccountWithPackedContextMut<'_> { - #[profile] + #[cfg_attr(feature = "profile-program", profile)] #[inline] pub fn set( &mut self, @@ -49,7 +50,7 @@ impl ZOutputCompressedAccountWithPackedContextMut<'_> { impl ZInAccountMut<'_> { #[inline] - #[profile] + #[cfg_attr(feature = "profile-program", profile)] pub fn set_z( &mut self, discriminator: [u8; 8], @@ -83,7 +84,7 @@ impl ZInAccountMut<'_> { } #[inline] - #[profile] + #[cfg_attr(feature = "profile-program", profile)] pub fn set( &mut self, discriminator: [u8; 8], @@ -159,7 +160,7 @@ impl ZInstructionDataInvokeCpiWithReadOnlyMut<'_> { impl ZNewAddressParamsAssignedPackedMut<'_> { #[inline] - #[profile] + #[cfg_attr(feature = "profile-program", profile)] pub fn set( &mut self, seed: [u8; 32],