diff --git a/program/rust/Cargo.toml b/program/rust/Cargo.toml index babf453bd..e823ffe91 100644 --- a/program/rust/Cargo.toml +++ b/program/rust/Cargo.toml @@ -13,5 +13,8 @@ solana-program = "=1.10.29" bytemuck = "1.11.0" thiserror = "1.0" +[features] +debug = [] + [lib] crate-type = ["cdylib", "lib"] diff --git a/program/rust/src/lib.rs b/program/rust/src/lib.rs index 17b9c8f5e..d8fbb3d5d 100644 --- a/program/rust/src/lib.rs +++ b/program/rust/src/lib.rs @@ -7,7 +7,6 @@ mod c_oracle_header; mod deserialize; mod error; -mod log; mod processor; mod rust_oracle; mod time_machine_types; @@ -16,13 +15,18 @@ mod utils; #[cfg(test)] mod tests; +#[cfg(feature = "debug")] +mod log; + use crate::c_oracle_header::SUCCESSFULLY_UPDATED_AGGREGATE; use crate::error::OracleError; +#[cfg(feature = "debug")] use crate::log::{ post_log, pre_log, }; + use processor::process_instruction; use solana_program::entrypoint::deserialize; @@ -51,6 +55,7 @@ use solana_program::{ pub extern "C" fn entrypoint(input: *mut u8) -> u64 { let (program_id, accounts, instruction_data) = unsafe { deserialize(input) }; + #[cfg(feature = "debug")] if let Err(error) = pre_log(&accounts, instruction_data) { return error.into(); } @@ -60,6 +65,7 @@ pub extern "C" fn entrypoint(input: *mut u8) -> u64 { Ok(success_status) => success_status, }; + #[cfg(feature = "debug")] if let Err(error) = post_log(c_ret_val, &accounts) { return error.into(); } diff --git a/program/rust/src/log.rs b/program/rust/src/log.rs index 3128419f8..7ca8e3fed 100644 --- a/program/rust/src/log.rs +++ b/program/rust/src/log.rs @@ -98,7 +98,6 @@ pub fn pre_log(accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResu Ok(()) } - pub fn post_log(c_ret_val: u64, accounts: &[AccountInfo]) -> ProgramResult { if c_ret_val == SUCCESSFULLY_UPDATED_AGGREGATE { // We trust that the C oracle has properly checked account 1, we can only get here through